reth_evm/provider.rs
1//! Provider trait for populating the EVM environment.
2
3use crate::ConfigureEvmEnv;
4use alloy_consensus::Header;
5use reth_storage_errors::provider::ProviderResult;
6use revm::primitives::{BlockEnv, CfgEnvWithHandlerCfg};
7
8/// A provider type that knows chain specific information required to configure a
9/// [`CfgEnvWithHandlerCfg`].
10///
11/// This type is mainly used to provide required data to configure the EVM environment that is
12/// not part of the block and stored separately (on disk), for example the total difficulty.
13#[auto_impl::auto_impl(&, Arc)]
14pub trait EvmEnvProvider<H = Header>: Send + Sync {
15 /// Fills the default [`CfgEnvWithHandlerCfg`] and [BlockEnv] fields with values specific to the
16 /// given block header.
17 fn env_with_header<EvmConfig>(
18 &self,
19 header: &H,
20 evm_config: EvmConfig,
21 ) -> ProviderResult<(CfgEnvWithHandlerCfg, BlockEnv)>
22 where
23 EvmConfig: ConfigureEvmEnv<Header = H>;
24}