Skip to content

fix(anvil): track Amsterdam block gas accounting#14759

Open
Perico-perica46 wants to merge 1 commit into
foundry-rs:masterfrom
Perico-perica46:fix-anvil-amsterdam-block-gas
Open

fix(anvil): track Amsterdam block gas accounting#14759
Perico-perica46 wants to merge 1 commit into
foundry-rs:masterfrom
Perico-perica46:fix-anvil-amsterdam-block-gas

Conversation

@Perico-perica46
Copy link
Copy Markdown
Contributor

Motivation

AnvilBlockExecutor still accumulated tx_gas_used() as both the receipt cumulative gas and the block gas total. After Amsterdam/EIP-8037, revm splits regular gas and state gas, and the block header should use the maximum of the block regular gas and block state gas while receipts keep cumulative transaction gas.

Anvil's node setup also set the hardfork directly on a default CfgEnv, which left spec-dependent gas params and the Amsterdam EIP-8037 flag stale for explicit and auto-detected hardforks.

Solution

Initialize and update Anvil's CfgEnv through revm's spec-aware gas parameter APIs. Track receipt cumulative gas separately from regular/state block gas in AnvilBlockExecutor. Use the Amsterdam-aware gas accumulator for block availability and final BlockExecutionResult::gas_used, and return GasOutput::with_state_gas so downstream executor consumers preserve both gas components.

Add an Amsterdam integration test that mines a contract creation transaction and checks the block header gas uses split block gas accounting instead of receipt cumulative gas.

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant