Skip to content

Commit

Permalink
chore: impl evm env provider for noop (#13342)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse authored Dec 12, 2024
1 parent 92fae83 commit 3b08b65
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 55 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions crates/evm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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"
]
23 changes: 20 additions & 3 deletions crates/evm/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<C: Send + Sync, N: NodePrimitives> EvmEnvProvider<N::BlockHeader>
for reth_storage_api::noop::NoopProvider<C, N>
{
fn env_with_header<EvmConfig>(
&self,
header: &N::BlockHeader,
evm_config: EvmConfig,
) -> ProviderResult<(CfgEnvWithHandlerCfg, BlockEnv)>
where
EvmConfig: ConfigureEvmEnv<Header = N::BlockHeader>,
{
Ok(evm_config.cfg_and_block_env(header, U256::MAX))
}
}

/// A [`BlockExecutorProvider`] that returns mocked execution results.
#[derive(Clone, Debug, Default)]
pub struct MockExecutorProvider {
Expand Down
52 changes: 0 additions & 52 deletions crates/storage/storage-api/src/noop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -526,58 +526,6 @@ impl<C: Send + Sync + 'static, N: NodePrimitives> StateProviderFactory for NoopP
}
}

// impl EvmEnvProvider for NoopProvider {
// fn fill_env_at<EvmConfig>(
// &self,
// _cfg: &mut CfgEnvWithHandlerCfg,
// _block_env: &mut BlockEnv,
// _at: BlockHashOrNumber,
// _evm_config: EvmConfig,
// ) -> ProviderResult<()>
// where
// EvmConfig: ConfigureEvmEnv<Header = Header>,
// {
// Ok(())
// }
//
// fn fill_env_with_header<EvmConfig>(
// &self,
// _cfg: &mut CfgEnvWithHandlerCfg,
// _block_env: &mut BlockEnv,
// _header: &Header,
// _evm_config: EvmConfig,
// ) -> ProviderResult<()>
// where
// EvmConfig: ConfigureEvmEnv<Header = Header>,
// {
// Ok(())
// }
//
// fn fill_cfg_env_at<EvmConfig>(
// &self,
// _cfg: &mut CfgEnvWithHandlerCfg,
// _at: BlockHashOrNumber,
// _evm_config: EvmConfig,
// ) -> ProviderResult<()>
// where
// EvmConfig: ConfigureEvmEnv<Header = Header>,
// {
// Ok(())
// }
//
// fn fill_cfg_env_with_header<EvmConfig>(
// &self,
// _cfg: &mut CfgEnvWithHandlerCfg,
// _header: &Header,
// _evm_config: EvmConfig,
// ) -> ProviderResult<()>
// where
// EvmConfig: ConfigureEvmEnv<Header = Header>,
// {
// Ok(())
// }
// }

impl<C: Send + Sync, N: NodePrimitives> StageCheckpointReader for NoopProvider<C, N> {
fn get_stage_checkpoint(&self, _id: StageId) -> ProviderResult<Option<StageCheckpoint>> {
Ok(None)
Expand Down

0 comments on commit 3b08b65

Please sign in to comment.