feat: alloy-evm and new revm integration (#14021)

Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
Co-authored-by: rakita <rakita@users.noreply.github.com>
This commit is contained in:
Arsenii Kulikov
2025-02-17 23:59:23 +04:00
committed by GitHub
parent bb6dec7ceb
commit 336c3d1fac
142 changed files with 1841 additions and 1929 deletions

View File

@ -18,14 +18,14 @@ reth-primitives-traits.workspace = true
reth-zstd-compressors = { workspace = true, optional = true }
# ethereum
alloy-eips.workspace = true
alloy-eips = { workspace = true, features = ["k256"] }
alloy-primitives.workspace = true
alloy-network = { workspace = true, optional = true }
alloy-consensus = { workspace = true, features = ["serde"] }
alloy-serde = { workspace = true, optional = true }
alloy-rlp.workspace = true
alloy-rpc-types-eth = { workspace = true, optional = true }
revm-primitives.workspace = true
revm-context.workspace = true
# misc
arbitrary = { workspace = true, optional = true, features = ["derive"] }
@ -65,9 +65,9 @@ std = [
"alloy-eips/std",
"derive_more/std",
"secp256k1?/std",
"revm-primitives/std",
"alloy-serde?/std",
"alloy-rpc-types-eth?/std",
"revm-context/std",
]
reth-codec = [
"std",
@ -84,7 +84,6 @@ arbitrary = [
"reth-codecs?/arbitrary",
"reth-primitives-traits/arbitrary",
"alloy-eips/arbitrary",
"revm-primitives/arbitrary",
"alloy-serde?/arbitrary",
"alloy-rpc-types-eth?/arbitrary",
]

View File

@ -21,7 +21,7 @@ use reth_primitives_traits::{
transaction::{error::TransactionConversionError, signed::RecoveryError},
FillTxEnv, InMemorySize, SignedTransaction,
};
use revm_primitives::{AuthorizationList, TxEnv};
use revm_context::TxEnv;
use serde::{Deserialize, Serialize};
macro_rules! delegate {
@ -750,81 +750,89 @@ impl reth_codecs::Compact for TransactionSigned {
}
}
impl FillTxEnv for TransactionSigned {
impl FillTxEnv<TxEnv> for TransactionSigned {
fn fill_tx_env(&self, tx_env: &mut TxEnv, sender: Address) {
tx_env.caller = sender;
match self.as_ref() {
Transaction::Legacy(tx) => {
tx_env.gas_limit = tx.gas_limit;
tx_env.gas_price = U256::from(tx.gas_price);
tx_env.gas_priority_fee = None;
tx_env.transact_to = tx.to;
tx_env.value = tx.value;
tx_env.data = tx.input.clone();
tx_env.chain_id = tx.chain_id;
tx_env.nonce = Some(tx.nonce);
tx_env.access_list.clear();
tx_env.blob_hashes.clear();
tx_env.max_fee_per_blob_gas.take();
tx_env.authorization_list = None;
}
Transaction::Eip2930(tx) => {
tx_env.gas_limit = tx.gas_limit;
tx_env.gas_price = U256::from(tx.gas_price);
tx_env.gas_priority_fee = None;
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.clone_from(&tx.access_list.0);
tx_env.blob_hashes.clear();
tx_env.max_fee_per_blob_gas.take();
tx_env.authorization_list = None;
}
Transaction::Eip1559(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.clone_from(&tx.access_list.0);
tx_env.blob_hashes.clear();
tx_env.max_fee_per_blob_gas.take();
tx_env.authorization_list = None;
}
Transaction::Eip4844(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 = TxKind::Call(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.clone_from(&tx.access_list.0);
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));
tx_env.authorization_list = None;
}
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.into();
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.clone_from(&tx.access_list.0);
tx_env.blob_hashes.clear();
tx_env.max_fee_per_blob_gas.take();
tx_env.authorization_list =
Some(AuthorizationList::Signed(tx.authorization_list.clone()));
}
*tx_env = match self.as_ref() {
Transaction::Legacy(tx) => TxEnv {
gas_limit: tx.gas_limit,
gas_price: tx.gas_price,
gas_priority_fee: None,
kind: tx.to,
value: tx.value,
data: tx.input.clone(),
chain_id: tx.chain_id,
nonce: tx.nonce,
access_list: Default::default(),
blob_hashes: Default::default(),
max_fee_per_blob_gas: Default::default(),
authorization_list: Default::default(),
tx_type: 0,
caller: sender,
},
Transaction::Eip2930(tx) => TxEnv {
gas_limit: tx.gas_limit,
gas_price: tx.gas_price,
gas_priority_fee: None,
kind: tx.to,
value: tx.value,
data: tx.input.clone(),
chain_id: Some(tx.chain_id),
nonce: tx.nonce,
access_list: tx.access_list.clone(),
blob_hashes: Default::default(),
max_fee_per_blob_gas: Default::default(),
authorization_list: Default::default(),
tx_type: 1,
caller: sender,
},
Transaction::Eip1559(tx) => TxEnv {
gas_limit: tx.gas_limit,
gas_price: tx.max_fee_per_gas,
gas_priority_fee: Some(tx.max_priority_fee_per_gas),
kind: tx.to,
value: tx.value,
data: tx.input.clone(),
chain_id: Some(tx.chain_id),
nonce: tx.nonce,
access_list: tx.access_list.clone(),
blob_hashes: Default::default(),
max_fee_per_blob_gas: Default::default(),
authorization_list: Default::default(),
tx_type: 2,
caller: sender,
},
Transaction::Eip4844(tx) => TxEnv {
gas_limit: tx.gas_limit,
gas_price: tx.max_fee_per_gas,
gas_priority_fee: Some(tx.max_priority_fee_per_gas),
kind: TxKind::Call(tx.to),
value: tx.value,
data: tx.input.clone(),
chain_id: Some(tx.chain_id),
nonce: tx.nonce,
access_list: tx.access_list.clone(),
blob_hashes: tx.blob_versioned_hashes.clone(),
max_fee_per_blob_gas: tx.max_fee_per_blob_gas,
authorization_list: Default::default(),
tx_type: 3,
caller: sender,
},
Transaction::Eip7702(tx) => TxEnv {
gas_limit: tx.gas_limit,
gas_price: tx.max_fee_per_gas,
gas_priority_fee: Some(tx.max_priority_fee_per_gas),
kind: TxKind::Call(tx.to),
value: tx.value,
data: tx.input.clone(),
chain_id: Some(tx.chain_id),
nonce: tx.nonce,
access_list: tx.access_list.clone(),
blob_hashes: Default::default(),
max_fee_per_blob_gas: Default::default(),
authorization_list: tx.authorization_list.clone(),
tx_type: 4,
caller: sender,
},
}
}
}