Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
rakita committed Dec 26, 2024
1 parent bf35974 commit eb09c36
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
2 changes: 1 addition & 1 deletion crates/context/interface/src/transaction/access_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use primitives::{Address, B256};
///
/// Number of account and storage slots is used to calculate initial tx gas cost.
#[auto_impl(&, Box, Arc, Rc)]
pub trait AccessListTrait: Clone {
pub trait AccessListTrait {
/// Iterate over access list.
fn iter(&self) -> impl Iterator<Item = (Address, impl Iterator<Item = B256>)>;

Expand Down
16 changes: 16 additions & 0 deletions crates/context/interface/src/transaction/transaction_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,19 @@ pub enum TransactionType {
/// Custom type means that transaction trait was extend and have custom types
Custom,
}

impl TransactionType {
pub fn from_u8(ty: Option<u8>) -> Option<Self> {
let Some(ty) = ty else {
return Some(Self::Legacy);
};
let ty = match ty {
1 => Self::Eip2930,
2 => Self::Eip1559,
3 => Self::Eip4844,
4 => Self::Eip7702,
_ => return None,
};
Some(ty)
}
}
2 changes: 1 addition & 1 deletion crates/handler/src/post_execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ where
let caller_account = context.journal().load_account(caller)?;

let reimbursed =
effective_gas_price.saturating_add((gas.remaining() + gas.refunded() as u64) as u128);
effective_gas_price.saturating_mul((gas.remaining() + gas.refunded() as u64) as u128);
caller_account.data.info.balance = caller_account
.data
.info
Expand Down
7 changes: 4 additions & 3 deletions crates/handler/src/pre_execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use context_interface::{
Block, BlockGetter, Cfg, CfgGetter, JournalDBError, JournalGetter, TransactionGetter,
};
use handler_interface::PreExecutionHandler;
use primitives::{Address, BLOCKHASH_STORAGE_ADDRESS, U256};
use primitives::{Address, B256, BLOCKHASH_STORAGE_ADDRESS, U256};
use specification::{eip7702, hardfork::SpecId};
use std::{boxed::Box, vec::Vec};

Expand Down Expand Up @@ -60,8 +60,9 @@ where
}

// Load access list
if let Some(access_list) = context.tx().access_list().cloned() {
for access_list in access_list.iter() {
if let Some(access_list) = context.tx().access_list() {
let access_list = access_list.iter().collect::<Vec<(Address, Vec<B256>)>>();
for access_list in access_list {
context.journal().warm_account_and_storage(
access_list.0,
access_list.1.map(|i| U256::from_be_bytes(i.0)),
Expand Down

0 comments on commit eb09c36

Please sign in to comment.