Skip to content

Conversation

@dvush
Copy link
Contributor

@dvush dvush commented Dec 4, 2025

📝 Summary

Uses revm utilities for evm context creating for historical blocks instead of manual context creation.

This change simplifies code and fixes a bug where certain field is not set in the context after fusaka.

💡 Motivation and Context


✅ I have completed the following steps:

  • Run make lint
  • Run make test
  • Added tests (if applicable)

Copilot AI review requested due to automatic review settings December 4, 2025 16:57
@dvush dvush requested a review from ZanCorDX as a code owner December 4, 2025 16:57
Copilot finished reviewing on behalf of dvush December 4, 2025 17:01
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the from_onchain_block method to use EthEvmConfig for creating the EVM environment, replacing manual BlockEnv construction. This aligns the implementation with the standard configuration approach used elsewhere in the codebase.

Key Changes

  • Replaced manual BlockEnv and CfgEnv construction with EthEvmConfig::evm_env() call
  • Removed dependency on default_cfg_env, BlockEnv, and BlobExcessGasAndPrice
  • Simplified blob excess gas handling by delegating to the standard config

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

let mut evm_env = eth_evm_config
.evm_env(&onchain_block.header)
.expect("evm env config");
evm_env.block_env.beneficiary = beneficiary;
Copy link

Copilot AI Dec 4, 2025

Choose a reason for hiding this comment

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

Missing evm_env.cfg_env.tx_chain_id_check = true; configuration that exists in the from_attributes method (line 177). This inconsistency could lead to different EVM behavior for chain ID validation between blocks created from attributes vs onchain blocks. Consider adding this configuration after modifying the beneficiary to ensure consistent behavior.

Suggested change
evm_env.block_env.beneficiary = beneficiary;
evm_env.block_env.beneficiary = beneficiary;
evm_env.cfg_env.tx_chain_id_check = true;

Copilot uses AI. Check for mistakes.
.evm_env(&onchain_block.header)
.expect("evm env config");
evm_env.block_env.beneficiary = beneficiary;
assert_eq!(evm_env.block_env.number, U256::from(block_number));
Copy link

Copilot AI Dec 4, 2025

Choose a reason for hiding this comment

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

This assertion verifies that evm_env.block_env.number matches the expected block number, which is good for catching configuration issues early. However, consider whether a runtime assertion is appropriate here or if this should be a debug assertion (debug_assert_eq!) for production builds, given that from_attributes doesn't perform similar verification.

Suggested change
assert_eq!(evm_env.block_env.number, U256::from(block_number));
debug_assert_eq!(evm_env.block_env.number, U256::from(block_number));

Copilot uses AI. Check for mistakes.
Comment on lines +254 to +256
let mut evm_env = eth_evm_config
.evm_env(&onchain_block.header)
.expect("evm env config");
Copy link

Copilot AI Dec 4, 2025

Choose a reason for hiding this comment

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

The error handling here is inconsistent with from_attributes. In from_attributes (line 176), a similar call to next_evm_env uses .ok()? to gracefully return None on error, but here .expect() will panic. Consider changing the return type to Option<BlockBuildingContext> and using .ok()? instead, or provide a more descriptive error message explaining what conditions could cause this to fail.

Copilot uses AI. Check for mistakes.
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