diff --git a/Cargo.lock b/Cargo.lock index e191b69ebf53..cc0d04f62f9f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7678,6 +7678,7 @@ dependencies = [ "reth-primitives-traits", "reth-prune-types", "reth-revm", + "reth-storage-api", "reth-storage-errors", "revm", "revm-primitives", diff --git a/crates/evm/Cargo.toml b/crates/evm/Cargo.toml index fe5505b52bd0..39add9396cd2 100644 --- a/crates/evm/Cargo.toml +++ b/crates/evm/Cargo.toml @@ -24,6 +24,8 @@ reth-prune-types.workspace = true reth-revm.workspace = true reth-storage-errors.workspace = true +reth-storage-api = { workspace = true, optional = true } + revm.workspace = true revm-primitives.workspace = true @@ -66,6 +68,7 @@ test-utils = [ "reth-primitives/test-utils", "reth-primitives-traits/test-utils", "reth-revm/test-utils", + "dep:reth-storage-api", "revm/test-utils", "reth-prune-types/test-utils" ] diff --git a/crates/evm/src/test_utils.rs b/crates/evm/src/test_utils.rs index 22ba4a316e2e..65c2a75fac16 100644 --- a/crates/evm/src/test_utils.rs +++ b/crates/evm/src/test_utils.rs @@ -5,20 +5,37 @@ use crate::{ BasicBatchExecutor, BasicBlockExecutor, BatchExecutor, BlockExecutionInput, BlockExecutionOutput, BlockExecutionStrategy, BlockExecutorProvider, Executor, }, + provider::EvmEnvProvider, system_calls::OnStateHook, + ConfigureEvmEnv, }; use alloy_eips::eip7685::Requests; -use alloy_primitives::BlockNumber; +use alloy_primitives::{BlockNumber, U256}; use parking_lot::Mutex; use reth_execution_errors::BlockExecutionError; use reth_execution_types::ExecutionOutcome; use reth_primitives::{BlockWithSenders, EthPrimitives, NodePrimitives, Receipt, Receipts}; use reth_prune_types::PruneModes; -use reth_storage_errors::provider::ProviderError; +use reth_storage_errors::provider::{ProviderError, ProviderResult}; use revm::State; -use revm_primitives::db::Database; +use revm_primitives::{db::Database, BlockEnv, CfgEnvWithHandlerCfg}; use std::{fmt::Display, sync::Arc}; +impl EvmEnvProvider + for reth_storage_api::noop::NoopProvider +{ + fn env_with_header( + &self, + header: &N::BlockHeader, + evm_config: EvmConfig, + ) -> ProviderResult<(CfgEnvWithHandlerCfg, BlockEnv)> + where + EvmConfig: ConfigureEvmEnv
, + { + Ok(evm_config.cfg_and_block_env(header, U256::MAX)) + } +} + /// A [`BlockExecutorProvider`] that returns mocked execution results. #[derive(Clone, Debug, Default)] pub struct MockExecutorProvider { diff --git a/crates/storage/storage-api/src/noop.rs b/crates/storage/storage-api/src/noop.rs index 153da578e350..fe481d581ad4 100644 --- a/crates/storage/storage-api/src/noop.rs +++ b/crates/storage/storage-api/src/noop.rs @@ -526,58 +526,6 @@ impl StateProviderFactory for NoopP } } -// impl EvmEnvProvider for NoopProvider { -// fn fill_env_at( -// &self, -// _cfg: &mut CfgEnvWithHandlerCfg, -// _block_env: &mut BlockEnv, -// _at: BlockHashOrNumber, -// _evm_config: EvmConfig, -// ) -> ProviderResult<()> -// where -// EvmConfig: ConfigureEvmEnv
, -// { -// Ok(()) -// } -// -// fn fill_env_with_header( -// &self, -// _cfg: &mut CfgEnvWithHandlerCfg, -// _block_env: &mut BlockEnv, -// _header: &Header, -// _evm_config: EvmConfig, -// ) -> ProviderResult<()> -// where -// EvmConfig: ConfigureEvmEnv
, -// { -// Ok(()) -// } -// -// fn fill_cfg_env_at( -// &self, -// _cfg: &mut CfgEnvWithHandlerCfg, -// _at: BlockHashOrNumber, -// _evm_config: EvmConfig, -// ) -> ProviderResult<()> -// where -// EvmConfig: ConfigureEvmEnv
, -// { -// Ok(()) -// } -// -// fn fill_cfg_env_with_header( -// &self, -// _cfg: &mut CfgEnvWithHandlerCfg, -// _header: &Header, -// _evm_config: EvmConfig, -// ) -> ProviderResult<()> -// where -// EvmConfig: ConfigureEvmEnv
, -// { -// Ok(()) -// } -// } - impl StageCheckpointReader for NoopProvider { fn get_stage_checkpoint(&self, _id: StageId) -> ProviderResult> { Ok(None)