Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generic data primitives EvmEnvProvider #12943

Open
Tracked by #12358
emhane opened this issue Nov 28, 2024 · 0 comments · May be fixed by #12981
Open
Tracked by #12358

Generic data primitives EvmEnvProvider #12943

emhane opened this issue Nov 28, 2024 · 0 comments · May be fixed by #12981
Labels
A-execution Related to the Execution and EVM A-sdk Related to reth's use as a library C-debt Refactor of code section that is hard to understand or maintain

Comments

@emhane
Copy link
Member

emhane commented Nov 28, 2024

Describe the feature

Make EvmEnvProvider generic over data primitives

/// A provider type that knows chain specific information required to configure a
/// [`CfgEnvWithHandlerCfg`].
///
/// This type is mainly used to provide required data to configure the EVM environment that is
/// usually stored on disk.
#[auto_impl::auto_impl(&, Arc)]
pub trait EvmEnvProvider: Send + Sync {
/// Fills the [`CfgEnvWithHandlerCfg`] and [BlockEnv] fields with values specific to the given
/// [BlockHashOrNumber].
fn fill_env_at<EvmConfig>(
&self,
cfg: &mut CfgEnvWithHandlerCfg,
block_env: &mut BlockEnv,
at: BlockHashOrNumber,
evm_config: EvmConfig,
) -> ProviderResult<()>
where
EvmConfig: ConfigureEvmEnv<Header = Header>;
/// Fills the default [`CfgEnvWithHandlerCfg`] and [BlockEnv] fields with values specific to the
/// given [Header].
fn env_with_header<EvmConfig>(
&self,
header: &Header,
evm_config: EvmConfig,
) -> ProviderResult<(CfgEnvWithHandlerCfg, BlockEnv)>
where
EvmConfig: ConfigureEvmEnv<Header = Header>,
{
let mut cfg = CfgEnvWithHandlerCfg::new_with_spec_id(CfgEnv::default(), SpecId::LATEST);
let mut block_env = BlockEnv::default();
self.fill_env_with_header(&mut cfg, &mut block_env, header, evm_config)?;
Ok((cfg, block_env))
}
/// Fills the [`CfgEnvWithHandlerCfg`] and [BlockEnv] fields with values specific to the given
/// [Header].
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>;
/// Fills the [`CfgEnvWithHandlerCfg`] fields with values specific to the given
/// [BlockHashOrNumber].
fn fill_cfg_env_at<EvmConfig>(
&self,
cfg: &mut CfgEnvWithHandlerCfg,
at: BlockHashOrNumber,
evm_config: EvmConfig,
) -> ProviderResult<()>
where
EvmConfig: ConfigureEvmEnv<Header = Header>;
/// Fills the [`CfgEnvWithHandlerCfg`] fields with values specific to the given [Header].
fn fill_cfg_env_with_header<EvmConfig>(
&self,
cfg: &mut CfgEnvWithHandlerCfg,
header: &Header,
evm_config: EvmConfig,
) -> ProviderResult<()>
where
EvmConfig: ConfigureEvmEnv<Header = Header>;
}

Additional context

No response

@emhane emhane added A-execution Related to the Execution and EVM A-sdk Related to reth's use as a library C-debt Refactor of code section that is hard to understand or maintain labels Nov 28, 2024
@htiennv htiennv linked a pull request Nov 28, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-execution Related to the Execution and EVM A-sdk Related to reth's use as a library C-debt Refactor of code section that is hard to understand or maintain
Projects
Status: Todo
Development

Successfully merging a pull request may close this issue.

1 participant