Skip to content

feat(tests): Add 2D block gas validity EIP-8037 test for multi-tx state-heavy blocks#2581

Merged
spencer-tb merged 1 commit into
ethereum:devnets/bal/3from
qu0b:qu0b/test/2d-gas-block-validity
Mar 28, 2026
Merged

feat(tests): Add 2D block gas validity EIP-8037 test for multi-tx state-heavy blocks#2581
spencer-tb merged 1 commit into
ethereum:devnets/bal/3from
qu0b:qu0b/test/2d-gas-block-validity

Conversation

@qu0b

@qu0b qu0b commented Mar 27, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds test_block_2d_gas_valid_when_cumulative_exceeds_limit to the EIP-8037 reservoir test suite
  • Tests that a block with 5 SSTORE zero-to-nonzero transactions is valid under 2D gas accounting (max(regular, state) <= gas_limit) even when the receipt cumulative_gas_used exceeds gas_limit
  • Block header gas_used = 187,840 (state dimension bottleneck) vs gas_limit = 252,855, while sum(tx_gas_used) = 317,870

Motivation

EIP-8037 specifies block validity as:

gas_used = max(block_output.block_regular_gas_used, block_output.block_state_gas_used)
assert gas_used <= block.gas_limit

Multiple clients retain a pre-8037 invariant (sum(tx_gas_used) <= gas_limit) in their gasPool / block processing code, which incorrectly rejects valid blocks when state gas dominates. This test surfaces that bug.

Currently fails against:

  • go-ethereum (bal-devnet-3): SubGas returns ErrGasLimitReached
  • nimbus-eth1 (bal-devnet-3): commitOrRollbackDependingOnGasUsed rejects with "block header gasLimit reached"

Fills successfully against the EELS reference implementation.

Test plan

  • uv run fill passes (blockchain_test + blockchain_test_engine)
  • ruff check passes
  • mypy passes
  • header_verify confirms gas_used = 5 * sstore_state_gas
  • Confirmed INVALID on geth and nimbus via hive consume-engine-local

🤖 Generated with Claude Code

Add test_block_2d_gas_valid_when_cumulative_exceeds_limit to verify
that blocks are valid under EIP-8037's 2D gas accounting even when
the receipt cumulative_gas_used exceeds the block gas limit.

EIP-8037 defines block validity as max(block_regular_gas_used,
block_state_gas_used) <= gas_limit. The receipt cumulative_gas_used
sums both dimensions per-tx and can legitimately exceed gas_limit.
This test catches clients that incorrectly use a 1D cumulative
check for block validation.

Currently fails on geth (bal-devnet-3) and nimbus-eth1 (bal-devnet-3)
due to a residual pre-8037 gasPool invariant.

Ref: ethereum#2578

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@spencer-tb spencer-tb merged commit ec92b86 into ethereum:devnets/bal/3 Mar 28, 2026
11 of 12 checks passed
@danceratopz danceratopz changed the title test(eip8037): 2D block gas validity for multi-tx state-heavy blocks feat(tests): Add 2D block gas validity EIP-8037 test for multi-tx state-heavy blocks Mar 30, 2026
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