Skip to content

Commit

Permalink
revm adjustments part 2
Browse files Browse the repository at this point in the history
  • Loading branch information
onbjerg committed Jul 5, 2024
1 parent 0de610a commit 9a1865b
Showing 1 changed file with 19 additions and 31 deletions.
50 changes: 19 additions & 31 deletions crates/primitives/src/transaction/compat.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{Address, Transaction, TransactionSigned, TxKind, U256};
use revm_primitives::TxEnv;
use revm_primitives::{AuthorizationList, TxEnv};

/// Implements behaviour to fill a [`TxEnv`] from another transaction.
pub trait FillTxEnv {
Expand Down Expand Up @@ -40,16 +40,7 @@ impl FillTxEnv for TransactionSigned {
tx_env.data = tx.input.clone();
tx_env.chain_id = Some(tx.chain_id);
tx_env.nonce = Some(tx.nonce);
tx_env.access_list = tx
.access_list
.iter()
.map(|l| {
(
l.address,
l.storage_keys.iter().map(|k| U256::from_be_bytes(k.0)).collect(),
)
})
.collect();
tx_env.access_list = tx.access_list.0.clone();
tx_env.blob_hashes.clear();
tx_env.max_fee_per_blob_gas.take();
}
Expand All @@ -62,16 +53,7 @@ impl FillTxEnv for TransactionSigned {
tx_env.data = tx.input.clone();
tx_env.chain_id = Some(tx.chain_id);
tx_env.nonce = Some(tx.nonce);
tx_env.access_list = tx
.access_list
.iter()
.map(|l| {
(
l.address,
l.storage_keys.iter().map(|k| U256::from_be_bytes(k.0)).collect(),
)
})
.collect();
tx_env.access_list = tx.access_list.0.clone();
tx_env.blob_hashes.clear();
tx_env.max_fee_per_blob_gas.take();
}
Expand All @@ -84,19 +66,25 @@ impl FillTxEnv for TransactionSigned {
tx_env.data = tx.input.clone();
tx_env.chain_id = Some(tx.chain_id);
tx_env.nonce = Some(tx.nonce);
tx_env.access_list = tx
.access_list
.iter()
.map(|l| {
(
l.address,
l.storage_keys.iter().map(|k| U256::from_be_bytes(k.0)).collect(),
)
})
.collect();
tx_env.access_list = tx.access_list.0.clone();
tx_env.blob_hashes.clone_from(&tx.blob_versioned_hashes);
tx_env.max_fee_per_blob_gas = Some(U256::from(tx.max_fee_per_blob_gas));
}
Transaction::Eip7702(tx) => {
tx_env.gas_limit = tx.gas_limit;
tx_env.gas_price = U256::from(tx.max_fee_per_gas);
tx_env.gas_priority_fee = Some(U256::from(tx.max_priority_fee_per_gas));
tx_env.transact_to = tx.to;
tx_env.value = tx.value;
tx_env.data = tx.input.clone();
tx_env.chain_id = Some(tx.chain_id);
tx_env.nonce = Some(tx.nonce);
tx_env.access_list = tx.access_list.0.clone();
tx_env.blob_hashes.clear();
tx_env.max_fee_per_blob_gas.take();
tx_env.authorization_list =
Some(AuthorizationList::Signed(tx.authorization_list.clone()));
}
#[cfg(feature = "optimism")]
Transaction::Deposit(tx) => {
tx_env.access_list.clear();
Expand Down

0 comments on commit 9a1865b

Please sign in to comment.