diff --git a/crates/ethereum/evm/src/execute.rs b/crates/ethereum/evm/src/execute.rs index db361f35d54c..c80e476bcbda 100644 --- a/crates/ethereum/evm/src/execute.rs +++ b/crates/ethereum/evm/src/execute.rs @@ -10,7 +10,7 @@ use reth_evm::{ BatchBlockExecutionOutput, BatchExecutor, BlockExecutionInput, BlockExecutionOutput, BlockExecutorProvider, Executor, }, - ConfigureEvm, ConfigureEvmEnv, + ConfigureEvm, }; use reth_interfaces::{ executor::{BlockExecutionError, BlockValidationError}, @@ -62,7 +62,6 @@ impl EthExecutorProvider { impl EthExecutorProvider where EvmConfig: ConfigureEvm, - EvmConfig: ConfigureEvmEnv, { fn eth_executor(&self, db: DB) -> EthBlockExecutor where @@ -79,7 +78,6 @@ where impl BlockExecutorProvider for EthExecutorProvider where EvmConfig: ConfigureEvm, - EvmConfig: ConfigureEvmEnv, { type Executor> = EthBlockExecutor; @@ -117,7 +115,6 @@ struct EthEvmExecutor { impl EthEvmExecutor where EvmConfig: ConfigureEvm, - EvmConfig: ConfigureEvmEnv, { /// Executes the transactions in the block and returns the receipts. /// @@ -158,7 +155,7 @@ where .into()) } - EvmConfig::fill_tx_env(evm.tx_mut(), transaction, *sender, ()); + EvmConfig::fill_tx_env(evm.tx_mut(), transaction, *sender); // Execute transaction. let ResultAndState { result, state } = evm.transact().map_err(move |err| { @@ -238,8 +235,6 @@ impl EthBlockExecutor { impl EthBlockExecutor where EvmConfig: ConfigureEvm, - // TODO(mattsse): get rid of this - EvmConfig: ConfigureEvmEnv, DB: Database, { /// Configures a new evm configuration and block environment for the given block. @@ -353,7 +348,6 @@ where impl Executor for EthBlockExecutor where EvmConfig: ConfigureEvm, - EvmConfig: ConfigureEvmEnv, DB: Database, { type Input<'a> = BlockExecutionInput<'a, BlockWithSenders>; @@ -403,8 +397,6 @@ impl EthBatchExecutor { impl BatchExecutor for EthBatchExecutor where EvmConfig: ConfigureEvm, - // TODO(mattsse): get rid of this - EvmConfig: ConfigureEvmEnv, DB: Database, { type Input<'a> = BlockExecutionInput<'a, BlockWithSenders>; diff --git a/crates/ethereum/evm/src/lib.rs b/crates/ethereum/evm/src/lib.rs index 0c8506ff7cda..7799cf4107ee 100644 --- a/crates/ethereum/evm/src/lib.rs +++ b/crates/ethereum/evm/src/lib.rs @@ -12,7 +12,7 @@ use reth_evm::{ConfigureEvm, ConfigureEvmEnv}; use reth_primitives::{ revm::{config::revm_spec, env::fill_tx_env}, revm_primitives::{AnalysisKind, CfgEnvWithHandlerCfg, TxEnv}, - Address, ChainSpec, Head, Header, Transaction, U256, + Address, ChainSpec, Head, Header, TransactionSigned, U256, }; use reth_revm::{Database, EvmBuilder}; pub mod execute; @@ -27,12 +27,7 @@ pub mod dao_fork; pub struct EthEvmConfig; impl ConfigureEvmEnv for EthEvmConfig { - type TxMeta = (); - - fn fill_tx_env(tx_env: &mut TxEnv, transaction: T, sender: Address, _meta: ()) - where - T: AsRef, - { + fn fill_tx_env(tx_env: &mut TxEnv, transaction: &TransactionSigned, sender: Address) { fill_tx_env(tx_env, transaction, sender) } diff --git a/crates/evm/src/lib.rs b/crates/evm/src/lib.rs index c69e33d652a6..94cac8bccd4e 100644 --- a/crates/evm/src/lib.rs +++ b/crates/evm/src/lib.rs @@ -8,7 +8,9 @@ #![cfg_attr(not(test), warn(unused_crate_dependencies))] #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] -use reth_primitives::{revm::env::fill_block_env, Address, ChainSpec, Header, Transaction, U256}; +use reth_primitives::{ + revm::env::fill_block_env, Address, ChainSpec, Header, TransactionSigned, U256, +}; use revm::{inspector_handle_register, Database, Evm, EvmBuilder, GetInspector}; use revm_primitives::{BlockEnv, CfgEnvWithHandlerCfg, EnvWithHandlerCfg, SpecId, TxEnv}; @@ -92,17 +94,8 @@ pub trait ConfigureEvm: ConfigureEvmEnv { /// This represents the set of methods used to configure the EVM's environment before block /// execution. pub trait ConfigureEvmEnv: Send + Sync + Unpin + Clone + 'static { - /// The type of the transaction metadata that should be used to fill fields in the transaction - /// environment. - /// - /// On ethereum mainnet, this is `()`, and on optimism these are the L1 fee fields and - /// additional L1 block info. - type TxMeta; - - /// Fill transaction environment from a [Transaction] and the given sender address. - fn fill_tx_env(tx_env: &mut TxEnv, transaction: T, sender: Address, meta: Self::TxMeta) - where - T: AsRef; + /// Fill transaction environment from a [TransactionSigned] and the given sender address. + fn fill_tx_env(tx_env: &mut TxEnv, transaction: &TransactionSigned, sender: Address); /// Fill [CfgEnvWithHandlerCfg] fields according to the chain spec and given header fn fill_cfg_env( diff --git a/crates/optimism/evm/src/execute.rs b/crates/optimism/evm/src/execute.rs index c6bb5c7cf233..f729ceda1c74 100644 --- a/crates/optimism/evm/src/execute.rs +++ b/crates/optimism/evm/src/execute.rs @@ -9,15 +9,15 @@ use reth_evm::{ BatchBlockExecutionOutput, BatchExecutor, BlockExecutionInput, BlockExecutionOutput, BlockExecutorProvider, Executor, }, - ConfigureEvm, ConfigureEvmEnv, + ConfigureEvm, }; use reth_interfaces::{ executor::{BlockExecutionError, BlockValidationError}, provider::ProviderError, }; use reth_primitives::{ - BlockNumber, BlockWithSenders, Bytes, ChainSpec, GotExpected, Hardfork, Header, PruneModes, - Receipt, Receipts, TxType, Withdrawals, U256, + BlockNumber, BlockWithSenders, ChainSpec, GotExpected, Hardfork, Header, PruneModes, Receipt, + Receipts, TxType, Withdrawals, U256, }; use reth_revm::{ batch::{BlockBatchRecord, BlockExecutorStats}, @@ -56,7 +56,6 @@ impl OpExecutorProvider { impl OpExecutorProvider where EvmConfig: ConfigureEvm, - EvmConfig: ConfigureEvmEnv, { fn op_executor(&self, db: DB) -> OpBlockExecutor where @@ -73,7 +72,6 @@ where impl BlockExecutorProvider for OpExecutorProvider where EvmConfig: ConfigureEvm, - EvmConfig: ConfigureEvmEnv, { type Executor> = OpBlockExecutor; @@ -110,7 +108,6 @@ struct OpEvmExecutor { impl OpEvmExecutor where EvmConfig: ConfigureEvm, - EvmConfig: ConfigureEvmEnv, { /// Executes the transactions in the block and returns the receipts. /// @@ -182,9 +179,7 @@ where .transpose() .map_err(|_| OptimismBlockExecutionError::AccountLoadFailed(*sender))?; - let mut buf = Vec::with_capacity(transaction.length_without_header()); - transaction.encode_enveloped(&mut buf); - EvmConfig::fill_tx_env(evm.tx_mut(), transaction, *sender, buf.into()); + EvmConfig::fill_tx_env(evm.tx_mut(), transaction, *sender); // Execute transaction. let ResultAndState { result, state } = evm.transact().map_err(move |err| { @@ -274,8 +269,6 @@ impl OpBlockExecutor { impl OpBlockExecutor where EvmConfig: ConfigureEvm, - // TODO(mattsse): get rid of this - EvmConfig: ConfigureEvmEnv, DB: Database, { /// Configures a new evm configuration and block environment for the given block. @@ -375,7 +368,6 @@ where impl Executor for OpBlockExecutor where EvmConfig: ConfigureEvm, - EvmConfig: ConfigureEvmEnv, DB: Database, { type Input<'a> = BlockExecutionInput<'a, BlockWithSenders>; @@ -428,8 +420,6 @@ impl OpBatchExecutor { impl BatchExecutor for OpBatchExecutor where EvmConfig: ConfigureEvm, - // TODO: get rid of this - EvmConfig: ConfigureEvmEnv, DB: Database, { type Input<'a> = BlockExecutionInput<'a, BlockWithSenders>; diff --git a/crates/optimism/evm/src/lib.rs b/crates/optimism/evm/src/lib.rs index 748eeab7b372..31d39fcb6ac4 100644 --- a/crates/optimism/evm/src/lib.rs +++ b/crates/optimism/evm/src/lib.rs @@ -13,7 +13,7 @@ use reth_evm::{ConfigureEvm, ConfigureEvmEnv}; use reth_primitives::{ revm::{config::revm_spec, env::fill_op_tx_env}, revm_primitives::{AnalysisKind, CfgEnvWithHandlerCfg, TxEnv}, - Address, Bytes, ChainSpec, Head, Header, Transaction, U256, + Address, ChainSpec, Head, Header, TransactionSigned, U256, }; use reth_revm::{inspector_handle_register, Database, Evm, EvmBuilder, GetInspector}; @@ -32,13 +32,10 @@ pub use error::OptimismBlockExecutionError; pub struct OptimismEvmConfig; impl ConfigureEvmEnv for OptimismEvmConfig { - type TxMeta = Bytes; - - fn fill_tx_env(tx_env: &mut TxEnv, transaction: T, sender: Address, meta: Bytes) - where - T: AsRef, - { - fill_op_tx_env(tx_env, transaction, sender, meta); + fn fill_tx_env(tx_env: &mut TxEnv, transaction: &TransactionSigned, sender: Address) { + let mut buf = Vec::with_capacity(transaction.length_without_header()); + transaction.encode_enveloped(&mut buf); + fill_op_tx_env(tx_env, transaction, sender, buf.into()); } fn fill_cfg_env( diff --git a/crates/revm/src/test_utils.rs b/crates/revm/src/test_utils.rs index 73df4ea4b4dc..48e6e7c4d01e 100644 --- a/crates/revm/src/test_utils.rs +++ b/crates/revm/src/test_utils.rs @@ -2,7 +2,7 @@ use reth_evm::{ConfigureEvm, ConfigureEvmEnv}; use reth_interfaces::provider::ProviderResult; use reth_primitives::{ keccak256, revm::config::revm_spec, trie::AccountProof, Account, Address, BlockNumber, - Bytecode, Bytes, ChainSpec, Head, Header, StorageKey, Transaction, B256, U256, + Bytecode, Bytes, ChainSpec, Head, Header, StorageKey, TransactionSigned, B256, U256, }; #[cfg(not(feature = "optimism"))] @@ -114,20 +114,17 @@ impl StateProvider for StateProviderTest { pub struct TestEvmConfig; impl ConfigureEvmEnv for TestEvmConfig { - #[cfg(not(feature = "optimism"))] - type TxMeta = (); - #[cfg(feature = "optimism")] - type TxMeta = Bytes; - #[allow(unused_variables)] - fn fill_tx_env(tx_env: &mut TxEnv, transaction: T, sender: Address, meta: Self::TxMeta) - where - T: AsRef, - { + fn fill_tx_env(tx_env: &mut TxEnv, transaction: &TransactionSigned, sender: Address) { #[cfg(not(feature = "optimism"))] fill_tx_env(tx_env, transaction, sender); + #[cfg(feature = "optimism")] - fill_op_tx_env(tx_env, transaction, sender, meta); + { + let mut buf = Vec::with_capacity(transaction.length_without_header()); + transaction.encode_enveloped(&mut buf); + fill_op_tx_env(tx_env, transaction, sender, buf.into()); + } } fn fill_cfg_env( diff --git a/examples/custom-evm/src/main.rs b/examples/custom-evm/src/main.rs index d2c016add2f6..9572e38be73f 100644 --- a/examples/custom-evm/src/main.rs +++ b/examples/custom-evm/src/main.rs @@ -20,7 +20,7 @@ use reth::{ use reth_node_api::{ConfigureEvm, ConfigureEvmEnv, FullNodeTypes}; use reth_node_core::{args::RpcServerArgs, node_config::NodeConfig}; use reth_node_ethereum::{EthEvmConfig, EthExecutorProvider, EthereumNode}; -use reth_primitives::{Chain, ChainSpec, Genesis, Header, Transaction}; +use reth_primitives::{Chain, ChainSpec, Genesis, Header, TransactionSigned}; use reth_tracing::{RethTracer, Tracer}; use std::sync::Arc; @@ -61,13 +61,8 @@ impl MyEvmConfig { } impl ConfigureEvmEnv for MyEvmConfig { - type TxMeta = (); - - fn fill_tx_env(tx_env: &mut TxEnv, transaction: T, sender: Address, meta: Self::TxMeta) - where - T: AsRef, - { - EthEvmConfig::fill_tx_env(tx_env, transaction, sender, meta) + fn fill_tx_env(tx_env: &mut TxEnv, transaction: &TransactionSigned, sender: Address) { + EthEvmConfig::fill_tx_env(tx_env, transaction, sender) } fn fill_cfg_env(