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

Change evm_env_cache to header cache #12902

Closed
mattsse opened this issue Nov 27, 2024 · 2 comments · Fixed by #13017
Closed

Change evm_env_cache to header cache #12902

mattsse opened this issue Nov 27, 2024 · 2 comments · Fixed by #13017
Assignees
Labels
A-rpc Related to the RPC implementation C-enhancement New feature or request D-good-first-issue Nice and easy! A great choice to get started

Comments

@mattsse
Copy link
Collaborator

mattsse commented Nov 27, 2024

Describe the feature

This currently bakes in the revm environments into caching:

/// The LRU cache for revm environments
evm_env_cache: EnvLruCache<LimitEnvs>,

this will no longer with with upcoming revm changes where these settings will be generic, or if we want to support something that is not revm, like a different kind of execution.

The environment settings are derived from the 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>,
{

so what we can do here is:
first change the cache from caching env objects to Header and convert the environments on demand

this is only called here:

.get_evm_env(block_hash)

so as a first step we can do is change the cache to Header,
and move this step:

let mut cfg = CfgEnvWithHandlerCfg::new_with_spec_id(
CfgEnv::default(),
SpecId::LATEST,
);
let mut block_env = BlockEnv::default();
let res = provider
.fill_env_at(
&mut cfg,
&mut block_env,
block_hash.into(),
evm_config,
)
.map(|_| (cfg, block_env));

Additional context

No response

@mattsse mattsse added C-enhancement New feature or request S-needs-triage This issue needs to be labelled labels Nov 27, 2024
@mattsse mattsse added D-good-first-issue Nice and easy! A great choice to get started A-rpc Related to the RPC implementation and removed S-needs-triage This issue needs to be labelled labels Nov 27, 2024
@lakshya-sky
Copy link
Contributor

@mattsse I would like to work on this?

@mattsse
Copy link
Collaborator Author

mattsse commented Nov 27, 2024

cool, assigned

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rpc Related to the RPC implementation C-enhancement New feature or request D-good-first-issue Nice and easy! A great choice to get started
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants