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

refactor: use EvmEnv when setting up Evm #13800

Merged
merged 4 commits into from
Jan 15, 2025
Merged

refactor: use EvmEnv when setting up Evm #13800

merged 4 commits into from
Jan 15, 2025

Conversation

klkvr
Copy link
Collaborator

@klkvr klkvr commented Jan 15, 2025

We've introduced EvmEnv to encapsulate Evm configuration not related to transaction, however most of the logic still operates on it directly to convert into revm::Env. This makes abstracting over EvmEnv and TxEnv not feasible

This PR changes logic to operate directly on EvmEnv as much as possible, only converting it to revm::Env when Evm is actually being created

This allows us to

  1. Make parts of the logic generic over TxEnv because it is now always passed separately
  2. Makes future abstraction over EvmEnv easier because it is now also properly separated

@klkvr klkvr changed the title feat: use EvmEnv when setting up Evm refactor: use EvmEnv when setting up Evm Jan 15, 2025
Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, this is a lot cleaner because this further separates evm(env) from the tx, because we really need this to be two different things

Comment on lines -151 to -152
cfg_env_with_handler_cfg,
block_env,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah this is a lot better

Comment on lines 55 to 57
/// including the spec id.
///
/// This will preserve any handler modifications
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we update the docs here that this configures the evm for the block and tx

Self {
cfg_env_with_handler_cfg: CfgEnvWithHandlerCfg {
cfg_env: Default::default(),
handler_cfg: Default::default(),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add a sanity doc here that handler_cfg::default will configure optimism if revm's optimism feature is enabled?

Comment on lines +328 to +329
let tx_env = RpcNodeCore::evm_config(&this).tx_env(tx, *signer);
let (res, _) = this.transact(&mut db, evm_env.clone(), tx_env)?;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great, incrementally better

@klkvr klkvr enabled auto-merge January 15, 2025 15:44
@klkvr klkvr added this pull request to the merge queue Jan 15, 2025
Merged via the queue into main with commit d5978a7 Jan 15, 2025
43 checks passed
@klkvr klkvr deleted the klkvr/use-evm-env branch January 15, 2025 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants