chore: impl evm env provider for noop (#13342)

This commit is contained in:
Matthias Seitz
2024-12-12 13:20:42 +01:00
committed by GitHub
parent 92fae83c0d
commit 3b08b659aa
4 changed files with 24 additions and 55 deletions

View File

@ -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"
]

View File

@ -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 {