diff --git a/crates/ethereum/evm/src/lib.rs b/crates/ethereum/evm/src/lib.rs index 2aaa063d745b..50907223a1a2 100644 --- a/crates/ethereum/evm/src/lib.rs +++ b/crates/ethereum/evm/src/lib.rs @@ -26,6 +26,7 @@ use reth_chainspec::ChainSpec; use reth_evm::{env::EvmEnv, ConfigureEvm, ConfigureEvmEnv, NextBlockEnvAttributes}; use reth_primitives::TransactionSigned; use reth_primitives_traits::transaction::execute::FillTxEnv; +use reth_revm::{inspector_handle_register, EvmBuilder}; use revm_primitives::{ AnalysisKind, BlobExcessGasAndPrice, BlockEnv, CfgEnv, CfgEnvWithHandlerCfg, Env, SpecId, TxEnv, }; @@ -182,24 +183,57 @@ impl ConfigureEvmEnv for EthEvmConfig { } } -impl ConfigureEvm for EthEvmConfig {} +impl ConfigureEvm for EthEvmConfig { + fn evm_with_env( + &self, + db: DB, + evm_env: EvmEnv, + tx: TxEnv, + ) -> reth_revm::Evm<'_, (), DB> { + EvmBuilder::default() + .with_db(db) + .with_cfg_env_with_handler_cfg(evm_env.cfg_env_with_handler_cfg) + .with_block_env(evm_env.block_env) + .with_tx_env(tx) + .build() + } + + fn evm_with_env_and_inspector( + &self, + db: DB, + evm_env: EvmEnv, + tx: TxEnv, + inspector: I, + ) -> reth_revm::Evm<'_, I, DB> + where + DB: reth_revm::Database, + I: reth_revm::GetInspector, + { + EvmBuilder::default() + .with_db(db) + .with_external_context(inspector) + .with_cfg_env_with_handler_cfg(evm_env.cfg_env_with_handler_cfg) + .with_block_env(evm_env.block_env) + .with_tx_env(tx) + .append_handler_register(inspector_handle_register) + .build() + } +} #[cfg(test)] mod tests { use super::*; - use alloy_consensus::{constants::KECCAK_EMPTY, Header}; + use alloy_consensus::Header; use alloy_genesis::Genesis; - use alloy_primitives::{B256, U256}; + use alloy_primitives::U256; use reth_chainspec::{Chain, ChainSpec, MAINNET}; use reth_evm::{env::EvmEnv, execute::ProviderError}; use reth_revm::{ db::{CacheDB, EmptyDBTyped}, inspectors::NoOpInspector, primitives::{BlockEnv, CfgEnv, SpecId}, - JournaledState, }; use revm_primitives::HandlerCfg; - use std::collections::HashSet; #[test] fn test_fill_cfg_and_block_env() { @@ -226,45 +260,6 @@ mod tests { assert_eq!(cfg_env_with_handler_cfg.chain_id, chain_spec.chain().id()); } - #[test] - #[allow(clippy::needless_update)] - fn test_evm_configure() { - // Create a default `EthEvmConfig` - let evm_config = EthEvmConfig::new(MAINNET.clone()); - - // Initialize an empty database wrapped in CacheDB - let db = CacheDB::>::default(); - - // Create an EVM instance using the configuration and the database - let evm = evm_config.evm(db); - - // Check that the EVM environment is initialized with default values - assert_eq!(evm.context.evm.inner.env, Box::default()); - - // Latest spec ID and no warm preloaded addresses - assert_eq!( - evm.context.evm.inner.journaled_state, - JournaledState::new(SpecId::LATEST, HashSet::default()) - ); - - // Ensure that the accounts database is empty - assert!(evm.context.evm.inner.db.accounts.is_empty()); - - // Ensure that the block hashes database is empty - assert!(evm.context.evm.inner.db.block_hashes.is_empty()); - - // Verify that there are two default contracts in the contracts database - assert_eq!(evm.context.evm.inner.db.contracts.len(), 2); - assert!(evm.context.evm.inner.db.contracts.contains_key(&KECCAK_EMPTY)); - assert!(evm.context.evm.inner.db.contracts.contains_key(&B256::ZERO)); - - // Ensure that the logs database is empty - assert!(evm.context.evm.inner.db.logs.is_empty()); - - // No Optimism - assert_eq!(evm.handler.cfg, HandlerCfg { spec_id: SpecId::LATEST, ..Default::default() }); - } - #[test] #[allow(clippy::needless_update)] fn test_evm_with_env_default_spec() { @@ -374,57 +369,15 @@ mod tests { let evm = evm_config.evm_with_env(db, evm_env, Default::default()); // Check that the spec ID is setup properly - assert_eq!(evm.handler.spec_id(), SpecId::CONSTANTINOPLE); + assert_eq!(evm.handler.spec_id(), SpecId::PETERSBURG); // No Optimism assert_eq!( evm.handler.cfg, - HandlerCfg { spec_id: SpecId::CONSTANTINOPLE, ..Default::default() } + HandlerCfg { spec_id: SpecId::PETERSBURG, ..Default::default() } ); } - #[test] - #[allow(clippy::needless_update)] - fn test_evm_with_inspector() { - let evm_config = EthEvmConfig::new(MAINNET.clone()); - - let db = CacheDB::>::default(); - - // No operation inspector - let noop = NoOpInspector; - - let evm = evm_config.evm_with_inspector(db, noop); - - // Check that the inspector is set correctly - assert_eq!(evm.context.external, noop); - - // Check that the EVM environment is initialized with default values - assert_eq!(evm.context.evm.inner.env, Box::default()); - - // Latest spec ID and no warm preloaded addresses - assert_eq!( - evm.context.evm.inner.journaled_state, - JournaledState::new(SpecId::LATEST, HashSet::default()) - ); - - // Ensure that the accounts database is empty - assert!(evm.context.evm.inner.db.accounts.is_empty()); - - // Ensure that the block hashes database is empty - assert!(evm.context.evm.inner.db.block_hashes.is_empty()); - - // Verify that there are two default contracts in the contracts database - assert_eq!(evm.context.evm.inner.db.contracts.len(), 2); - assert!(evm.context.evm.inner.db.contracts.contains_key(&KECCAK_EMPTY)); - assert!(evm.context.evm.inner.db.contracts.contains_key(&B256::ZERO)); - - // Ensure that the logs database is empty - assert!(evm.context.evm.inner.db.logs.is_empty()); - - // No Optimism - assert_eq!(evm.handler.cfg, HandlerCfg { spec_id: SpecId::LATEST, ..Default::default() }); - } - #[test] #[allow(clippy::needless_update)] fn test_evm_with_env_and_default_inspector() { @@ -530,7 +483,7 @@ mod tests { ); // Check that the spec ID is set properly - assert_eq!(evm.handler.spec_id(), SpecId::CONSTANTINOPLE); + assert_eq!(evm.handler.spec_id(), SpecId::PETERSBURG); assert_eq!(evm.context.evm.env.block, evm_env.block_env); assert_eq!(evm.context.evm.env.cfg, evm_env.cfg_env_with_handler_cfg.cfg_env); assert_eq!(evm.context.evm.env.tx, Default::default()); @@ -539,7 +492,7 @@ mod tests { // No Optimism assert_eq!( evm.handler.cfg, - HandlerCfg { spec_id: SpecId::CONSTANTINOPLE, ..Default::default() } + HandlerCfg { spec_id: SpecId::PETERSBURG, ..Default::default() } ); } } diff --git a/crates/evm/src/builder.rs b/crates/evm/src/builder.rs deleted file mode 100644 index 94531dd0ff01..000000000000 --- a/crates/evm/src/builder.rs +++ /dev/null @@ -1,141 +0,0 @@ -//! Builder for creating an EVM with a database and environment. - -use alloc::boxed::Box; -use revm::{inspector_handle_register, Database, Evm, EvmBuilder, GetInspector}; -use revm_primitives::EnvWithHandlerCfg; - -/// Builder for creating an EVM with a database and environment. -/// -/// Wrapper around [`EvmBuilder`] that allows for setting the database and environment for the EVM. -/// -/// This is useful for creating an EVM with a custom database and environment without having to -/// necessarily rely on Revm inspector. -#[derive(Debug)] -pub struct RethEvmBuilder { - /// The database to use for the EVM. - db: DB, - /// The environment to use for the EVM. - env: Option>, - /// The external context for the EVM. - external_context: EXT, -} - -impl RethEvmBuilder { - /// Create a new EVM builder with the given database. - pub const fn new(db: DB) -> Self { - Self { db, env: None, external_context: () } - } -} - -impl RethEvmBuilder -where - DB: Database, -{ - /// Set the environment for the EVM. - pub fn with_env(mut self, env: Box) -> Self { - self.env = Some(env); - self - } - - /// Set the external context for the EVM. - pub fn with_external_context(self, external_context: EXT1) -> RethEvmBuilder { - RethEvmBuilder { db: self.db, env: self.env, external_context } - } - - /// Build the EVM with the given database and environment. - pub fn build<'a>(self) -> Evm<'a, EXT, DB> { - let mut builder = - EvmBuilder::default().with_db(self.db).with_external_context(self.external_context); - if let Some(env) = self.env { - builder = builder.with_spec_id(env.spec_id()); - builder = builder.with_env(env.env); - } - - builder.build() - } - - /// Build the EVM with the given database and environment, using the given inspector. - pub fn build_with_inspector<'a, I>(self, inspector: I) -> Evm<'a, I, DB> - where - I: GetInspector, - EXT: 'a, - { - let mut builder = - EvmBuilder::default().with_db(self.db).with_external_context(self.external_context); - if let Some(env) = self.env { - builder = builder.with_spec_id(env.spec_id()); - builder = builder.with_env(env.env); - } - builder - .with_external_context(inspector) - .append_handler_register(inspector_handle_register) - .build() - } -} - -/// Trait for configuring an EVM builder. -pub trait ConfigureEvmBuilder { - /// The type of EVM builder that this trait can configure. - type Builder<'a, DB: Database>: EvmFactory; -} - -/// Trait for configuring the EVM for executing full blocks. -pub trait EvmFactory { - /// Returns new EVM with the given database - /// - /// This does not automatically configure the EVM with [`crate::ConfigureEvmEnv`] methods. It is - /// up to the caller to call an appropriate method to fill the transaction and block - /// environment before executing any transactions using the provided EVM. - fn evm(self, db: DB) -> Evm<'static, (), DB> - where - Self: Sized, - { - RethEvmBuilder::new(db).build() - } - - /// Returns a new EVM with the given database configured with the given environment settings, - /// including the spec id. - /// - /// This will preserve any handler modifications - fn evm_with_env<'a, DB: Database + 'a>( - &self, - db: DB, - env: EnvWithHandlerCfg, - ) -> Evm<'a, (), DB> { - RethEvmBuilder::new(db).with_env(env.into()).build() - } - - /// Returns a new EVM with the given database configured with the given environment settings, - /// including the spec id. - /// - /// This will use the given external inspector as the EVM external context. - /// - /// This will preserve any handler modifications - fn evm_with_env_and_inspector( - &self, - db: DB, - env: EnvWithHandlerCfg, - inspector: I, - ) -> Evm<'_, I, DB> - where - DB: Database, - I: GetInspector, - { - RethEvmBuilder::new(db).with_env(env.into()).build_with_inspector(inspector) - } - - /// Returns a new EVM with the given inspector. - /// - /// Caution: This does not automatically configure the EVM with [`crate::ConfigureEvmEnv`] - /// methods. It is up to the caller to call an appropriate method to fill the transaction - /// and block environment before executing any transactions using the provided EVM. - fn evm_with_inspector(&self, db: DB, inspector: I) -> Evm<'_, I, DB> - where - DB: Database, - I: GetInspector, - { - RethEvmBuilder::new(db).build_with_inspector(inspector) - } -} - -impl EvmFactory for RethEvmBuilder {} diff --git a/crates/evm/src/lib.rs b/crates/evm/src/lib.rs index 2b5c98adcbb3..1271bb14b77b 100644 --- a/crates/evm/src/lib.rs +++ b/crates/evm/src/lib.rs @@ -17,14 +17,12 @@ extern crate alloc; -use crate::builder::RethEvmBuilder; use alloy_consensus::BlockHeader as _; use alloy_primitives::{Address, Bytes, B256, U256}; use reth_primitives_traits::{BlockHeader, SignedTransaction}; use revm::{Database, Evm, GetInspector}; use revm_primitives::{BlockEnv, CfgEnvWithHandlerCfg, Env, SpecId, TxEnv}; -pub mod builder; pub mod either; /// EVM environment configuration. pub mod env; @@ -42,26 +40,11 @@ pub mod test_utils; /// Trait for configuring the EVM for executing full blocks. pub trait ConfigureEvm: ConfigureEvmEnv { - /// Returns new EVM with the given database - /// - /// This does not automatically configure the EVM with [`ConfigureEvmEnv`] methods. It is up to - /// the caller to call an appropriate method to fill the transaction and block environment - /// before executing any transactions using the provided EVM. - fn evm(&self, db: DB) -> Evm<'_, (), DB> { - RethEvmBuilder::new(db).build() - } - /// Returns a new EVM with the given database configured with the given environment settings, /// including the spec id and transaction environment. /// /// This will preserve any handler modifications - fn evm_with_env(&self, db: DB, evm_env: EvmEnv, tx: TxEnv) -> Evm<'_, (), DB> { - let mut evm = self.evm(db); - evm.modify_spec_id(evm_env.cfg_env_with_handler_cfg.handler_cfg.spec_id); - evm.context.evm.env = - Env::boxed(evm_env.cfg_env_with_handler_cfg.cfg_env, evm_env.block_env, tx); - evm - } + fn evm_with_env(&self, db: DB, evm_env: EvmEnv, tx: TxEnv) -> Evm<'_, (), DB>; /// Returns a new EVM with the given database configured with `cfg` and `block_env` /// configuration derived from the given header. Relies on @@ -90,27 +73,7 @@ pub trait ConfigureEvm: ConfigureEvmEnv { ) -> Evm<'_, I, DB> where DB: Database, - I: GetInspector, - { - let mut evm = self.evm_with_inspector(db, inspector); - evm.modify_spec_id(evm_env.cfg_env_with_handler_cfg.handler_cfg.spec_id); - evm.context.evm.env = - Env::boxed(evm_env.cfg_env_with_handler_cfg.cfg_env, evm_env.block_env, tx); - evm - } - - /// Returns a new EVM with the given inspector. - /// - /// Caution: This does not automatically configure the EVM with [`ConfigureEvmEnv`] methods. It - /// is up to the caller to call an appropriate method to fill the transaction and block - /// environment before executing any transactions using the provided EVM. - fn evm_with_inspector(&self, db: DB, inspector: I) -> Evm<'_, I, DB> - where - DB: Database, - I: GetInspector, - { - RethEvmBuilder::new(db).build_with_inspector(inspector) - } + I: GetInspector; } impl<'b, T> ConfigureEvm for &'b T @@ -118,10 +81,6 @@ where T: ConfigureEvm, &'b T: ConfigureEvmEnv
, { - fn evm(&self, db: DB) -> Evm<'_, (), DB> { - (*self).evm(db) - } - fn evm_for_block(&self, db: DB, header: &Self::Header) -> Evm<'_, (), DB> { (*self).evm_for_block(db, header) } @@ -143,14 +102,6 @@ where { (*self).evm_with_env_and_inspector(db, evm_env, tx_env, inspector) } - - fn evm_with_inspector(&self, db: DB, inspector: I) -> Evm<'_, I, DB> - where - DB: Database, - I: GetInspector, - { - (*self).evm_with_inspector(db, inspector) - } } /// This represents the set of methods used to configure the EVM's environment before block diff --git a/crates/optimism/evm/src/lib.rs b/crates/optimism/evm/src/lib.rs index dbadd23b0317..ad172c764411 100644 --- a/crates/optimism/evm/src/lib.rs +++ b/crates/optimism/evm/src/lib.rs @@ -168,19 +168,41 @@ impl ConfigureEvmEnv for OpEvmConfig { } impl ConfigureEvm for OpEvmConfig { - fn evm(&self, db: DB) -> Evm<'_, (), DB> { - EvmBuilder::default().with_db(db).optimism().build() + fn evm_with_env( + &self, + db: DB, + mut evm_env: EvmEnv, + tx: TxEnv, + ) -> Evm<'_, (), DB> { + evm_env.cfg_env_with_handler_cfg.handler_cfg.is_optimism = true; + + EvmBuilder::default() + .with_db(db) + .with_cfg_env_with_handler_cfg(evm_env.cfg_env_with_handler_cfg) + .with_block_env(evm_env.block_env) + .with_tx_env(tx) + .build() } - fn evm_with_inspector(&self, db: DB, inspector: I) -> Evm<'_, I, DB> + fn evm_with_env_and_inspector( + &self, + db: DB, + mut evm_env: EvmEnv, + tx: TxEnv, + inspector: I, + ) -> Evm<'_, I, DB> where DB: Database, I: GetInspector, { + evm_env.cfg_env_with_handler_cfg.handler_cfg.is_optimism = true; + EvmBuilder::default() .with_db(db) .with_external_context(inspector) - .optimism() + .with_cfg_env_with_handler_cfg(evm_env.cfg_env_with_handler_cfg) + .with_block_env(evm_env.block_env) + .with_tx_env(tx) .append_handler_register(inspector_handle_register) .build() } @@ -189,14 +211,10 @@ impl ConfigureEvm for OpEvmConfig { #[cfg(test)] mod tests { use super::*; - use alloy_consensus::{constants::KECCAK_EMPTY, Header, Receipt}; + use alloy_consensus::{Header, Receipt}; use alloy_eips::eip7685::Requests; use alloy_genesis::Genesis; - use alloy_primitives::{ - bytes, - map::{HashMap, HashSet}, - Address, LogData, B256, U256, - }; + use alloy_primitives::{bytes, map::HashMap, Address, LogData, B256, U256}; use reth_chainspec::ChainSpec; use reth_evm::execute::ProviderError; use reth_execution_types::{ @@ -209,7 +227,6 @@ mod tests { db::{BundleState, CacheDB, EmptyDBTyped}, inspectors::NoOpInspector, primitives::{AccountInfo, BlockEnv, CfgEnv, SpecId}, - JournaledState, }; use revm_primitives::HandlerCfg; use std::sync::Arc; @@ -244,47 +261,6 @@ mod tests { assert_eq!(cfg_env_with_handler_cfg.chain_id, chain_spec.chain().id()); } - #[test] - fn test_evm_configure() { - // Create a default `OpEvmConfig` - let evm_config = test_evm_config(); - - // Initialize an empty database wrapped in CacheDB - let db = CacheDB::>::default(); - - // Create an EVM instance using the configuration and the database - let evm = evm_config.evm(db); - - // Check that the EVM environment is initialized with default values - assert_eq!(evm.context.evm.inner.env, Box::default()); - - // Latest spec ID and no warm preloaded addresses - assert_eq!( - evm.context.evm.inner.journaled_state, - JournaledState::new(SpecId::LATEST, HashSet::default()) - ); - - // Ensure that the accounts database is empty - assert!(evm.context.evm.inner.db.accounts.is_empty()); - - // Ensure that the block hashes database is empty - assert!(evm.context.evm.inner.db.block_hashes.is_empty()); - - // Verify that there are two default contracts in the contracts database - assert_eq!(evm.context.evm.inner.db.contracts.len(), 2); - assert!(evm.context.evm.inner.db.contracts.contains_key(&KECCAK_EMPTY)); - assert!(evm.context.evm.inner.db.contracts.contains_key(&B256::ZERO)); - - // Ensure that the logs database is empty - assert!(evm.context.evm.inner.db.logs.is_empty()); - - // Optimism in handler - assert_eq!(evm.handler.cfg, HandlerCfg { spec_id: SpecId::LATEST, is_optimism: true }); - - // Default spec ID - assert_eq!(evm.handler.spec_id(), SpecId::LATEST); - } - #[test] fn test_evm_with_env_default_spec() { let evm_config = test_evm_config(); @@ -389,50 +365,6 @@ mod tests { assert_eq!(evm.handler.cfg, HandlerCfg { spec_id: SpecId::ECOTONE, is_optimism: true }); } - #[test] - fn test_evm_with_inspector() { - let evm_config = test_evm_config(); - - let db = CacheDB::>::default(); - - // No operation inspector - let noop = NoOpInspector; - - let evm = evm_config.evm_with_inspector(db, noop); - - // Check that the inspector is set correctly - assert_eq!(evm.context.external, noop); - - // Check that the EVM environment is initialized with default values - assert_eq!(evm.context.evm.inner.env, Box::default()); - - // Latest spec ID and no warm preloaded addresses - assert_eq!( - evm.context.evm.inner.journaled_state, - JournaledState::new(SpecId::LATEST, HashSet::default()) - ); - - // Ensure that the accounts database is empty - assert!(evm.context.evm.inner.db.accounts.is_empty()); - - // Ensure that the block hashes database is empty - assert!(evm.context.evm.inner.db.block_hashes.is_empty()); - - // Verify that there are two default contracts in the contracts database - assert_eq!(evm.context.evm.inner.db.contracts.len(), 2); - assert!(evm.context.evm.inner.db.contracts.contains_key(&KECCAK_EMPTY)); - assert!(evm.context.evm.inner.db.contracts.contains_key(&B256::ZERO)); - - // Ensure that the logs database is empty - assert!(evm.context.evm.inner.db.logs.is_empty()); - - // Default spec ID - assert_eq!(evm.handler.spec_id(), SpecId::LATEST); - - // Optimism in handler - assert_eq!(evm.handler.cfg, HandlerCfg { spec_id: SpecId::LATEST, is_optimism: true }); - } - #[test] fn test_evm_with_env_and_default_inspector() { let evm_config = test_evm_config(); diff --git a/examples/custom-evm/src/main.rs b/examples/custom-evm/src/main.rs index 3490914b67bc..ac534d43c677 100644 --- a/examples/custom-evm/src/main.rs +++ b/examples/custom-evm/src/main.rs @@ -55,8 +55,8 @@ impl MyEvmConfig { impl MyEvmConfig { /// Sets the precompiles to the EVM handler /// - /// This will be invoked when the EVM is created via [ConfigureEvm::evm] or - /// [ConfigureEvm::evm_with_inspector] + /// This will be invoked when the EVM is created via [ConfigureEvm::evm_with_env] or + /// [ConfigureEvm::evm_with_env_and_inspector] /// /// This will use the default mainnet precompiles and add additional precompiles. pub fn set_precompiles(handler: &mut EvmHandler) @@ -117,15 +117,24 @@ impl ConfigureEvmEnv for MyEvmConfig { } impl ConfigureEvm for MyEvmConfig { - fn evm(&self, db: DB) -> Evm<'_, (), DB> { + fn evm_with_env(&self, db: DB, evm_env: EvmEnv, tx: TxEnv) -> Evm<'_, (), DB> { EvmBuilder::default() .with_db(db) + .with_cfg_env_with_handler_cfg(evm_env.cfg_env_with_handler_cfg) + .with_block_env(evm_env.block_env) + .with_tx_env(tx) // add additional precompiles .append_handler_register(MyEvmConfig::set_precompiles) .build() } - fn evm_with_inspector(&self, db: DB, inspector: I) -> Evm<'_, I, DB> + fn evm_with_env_and_inspector( + &self, + db: DB, + evm_env: EvmEnv, + tx: TxEnv, + inspector: I, + ) -> Evm<'_, I, DB> where DB: Database, I: GetInspector, @@ -133,6 +142,9 @@ impl ConfigureEvm for MyEvmConfig { EvmBuilder::default() .with_db(db) .with_external_context(inspector) + .with_cfg_env_with_handler_cfg(evm_env.cfg_env_with_handler_cfg) + .with_block_env(evm_env.block_env) + .with_tx_env(tx) // add additional precompiles .append_handler_register(MyEvmConfig::set_precompiles) .append_handler_register(inspector_handle_register) diff --git a/examples/stateful-precompile/src/main.rs b/examples/stateful-precompile/src/main.rs index 1fb4dbefb3a9..2cdebfe5602c 100644 --- a/examples/stateful-precompile/src/main.rs +++ b/examples/stateful-precompile/src/main.rs @@ -68,8 +68,8 @@ impl MyEvmConfig { /// Sets the precompiles to the EVM handler /// - /// This will be invoked when the EVM is created via [ConfigureEvm::evm] or - /// [ConfigureEvm::evm_with_inspector] + /// This will be invoked when the EVM is created via [ConfigureEvm::evm_with_env] or + /// [ConfigureEvm::evm_with_env_and_inspector] /// /// This will use the default mainnet precompiles and wrap them with a cache. pub fn set_precompiles( @@ -179,10 +179,13 @@ impl ConfigureEvmEnv for MyEvmConfig { } impl ConfigureEvm for MyEvmConfig { - fn evm(&self, db: DB) -> Evm<'_, (), DB> { + fn evm_with_env(&self, db: DB, evm_env: EvmEnv, tx: TxEnv) -> Evm<'_, (), DB> { let new_cache = self.precompile_cache.clone(); EvmBuilder::default() .with_db(db) + .with_cfg_env_with_handler_cfg(evm_env.cfg_env_with_handler_cfg) + .with_block_env(evm_env.block_env) + .with_tx_env(tx) // add additional precompiles .append_handler_register_box(Box::new(move |handler| { MyEvmConfig::set_precompiles(handler, new_cache.clone()) @@ -190,7 +193,13 @@ impl ConfigureEvm for MyEvmConfig { .build() } - fn evm_with_inspector(&self, db: DB, inspector: I) -> Evm<'_, I, DB> + fn evm_with_env_and_inspector( + &self, + db: DB, + evm_env: EvmEnv, + tx: TxEnv, + inspector: I, + ) -> Evm<'_, I, DB> where DB: Database, I: GetInspector, @@ -199,6 +208,9 @@ impl ConfigureEvm for MyEvmConfig { EvmBuilder::default() .with_db(db) .with_external_context(inspector) + .with_cfg_env_with_handler_cfg(evm_env.cfg_env_with_handler_cfg) + .with_block_env(evm_env.block_env) + .with_tx_env(tx) // add additional precompiles .append_handler_register_box(Box::new(move |handler| { MyEvmConfig::set_precompiles(handler, new_cache.clone())