Skip to content

feat(tests): block-level 2D gas accounting tests for EIP-8037#2610

Merged
spencer-tb merged 2 commits into
ethereum:eips/amsterdam/eip-8037from
qu0b:qu0b/test/block-2d-gas-accounting
Apr 1, 2026
Merged

feat(tests): block-level 2D gas accounting tests for EIP-8037#2610
spencer-tb merged 2 commits into
ethereum:eips/amsterdam/eip-8037from
qu0b:qu0b/test/block-2d-gas-accounting

Conversation

@qu0b

@qu0b qu0b commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

🗒️ Description

  • Add 9 blockchain tests (28 parametrized items) for block-level two-dimensional gas accounting under EIP-8037
  • Tests target inter-client disagreements observed on BAL devnet-3 where EL clients diverged on block.gas_used due to incorrect 2D gas metering.

Test Coverage

Test What it catches
test_block_gas_used_state_dominates (4 variants) Clients ignoring state gas dimension, summing instead of max, or conflating spillover with regular gas
test_block_gas_used_regular_dominates Multi-tx block accumulation when state gas is zero
test_block_gas_used_mixed_txs (2 variants) Non-contiguous state gas contributions across interleaved STOP/SSTORE txs
test_block_gas_refund_eip7778_no_block_reduction EIP-7778 interaction: refunds must not reduce block-level gas accounting
test_block_2d_gas_boundary_exact_fit (3 variants) Block validity when max(regular, state) == gas_limit exactly — catches clients that sum dimensions
test_block_gas_used_call_new_account GAS_NEW_ACCOUNT state gas from CALL creating accounts reflected in block gas
test_block_gas_used_create_tx CREATE tx intrinsic state gas in block-level 2D accounting
test_multi_block_dimension_flip Independent per-block 2D max when dominant dimension flips between blocks

Motivation

On BAL devnet-3, multiple EL clients (erigon, reth, ethrex, nimbus) produced incorrect block.gas_used values because they either:

  1. Had no 2D gas metering at all (reth, nimbus)
  2. Only tracked regular gas at the block level, allowing state gas to grow unbounded (erigon)
  3. Disagreed on reservoir spillover accounting

These tests reproduce the exact failure modes observed in production devnet testing.

🔗 Related Issues or PRs

N/A.

✅ Checklist

  • All: Ran fast tox checks to avoid unnecessary CI fails, see also Code Standards and Enabling Pre-commit Checks:
    uvx tox -e static
  • All: PR title adheres to the repo standard - it will be used as the squash commit message and should start type(scope):.
  • All: Considered updating the online docs in the ./docs/ directory.
  • All: Set appropriate labels for the changes (only maintainers can apply labels).

@spencer-tb spencer-tb added C-feat Category: an improvement or new feature A-tests Area: Consensus tests. labels Apr 1, 2026
spencer-tb added a commit to spencer-tb/execution-specs that referenced this pull request Apr 1, 2026
Covered by test_block_gas_used_create_tx in ethereum#2610.
spencer-tb added a commit to spencer-tb/execution-specs that referenced this pull request Apr 1, 2026
Covered by test_block_gas_used_call_new_account in ethereum#2610.
Add 9 blockchain tests (28 parametrized items) targeting inter-client
disagreements observed on BAL devnet-3 where EL clients diverged on
block.gas_used due to incorrect 2D gas metering.

Tests cover:
- State-dominant blocks (SSTORE state gas > regular gas)
- Regular-dominant blocks (STOP txs, zero state gas)
- Mixed tx blocks (grouped and interleaved ordering)
- EIP-7778 interaction (refunds excluded from block gas)
- Boundary: block valid when max(regular, state) == gas_limit
- CALL creating new account (GAS_NEW_ACCOUNT state gas)
- CREATE tx intrinsic state gas
- Multi-block dimension flip (regular→state dominance)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@spencer-tb spencer-tb force-pushed the qu0b/test/block-2d-gas-accounting branch 2 times, most recently from 5aab56a to 34d5e5d Compare April 1, 2026 21:55
Use fork methods for all gas computation: Op.SSTORE.gas_cost(fork),
Op.SSTORE.with_metadata() for warm slot dynamics, fork.sstore_state_gas(),
fork.transaction_intrinsic_cost_calculator(). No manual gas constants.

Rename helpers: drop _ prefix (sstore_tx_gas, sstore_txs, stop_txs).
Add return type annotations. Remove _stop_tx_gas wrapper. Use
stop_txs() helper consistently. Replace hardcoded 0xDEAD0001 with
pre.fund_eoa(amount=0). Replace hardcoded +1000 padding with
fork-derived value. Remove unused Bytecode import and explicit fee
params. Clean up docstrings and test ids.
@spencer-tb spencer-tb force-pushed the qu0b/test/block-2d-gas-accounting branch from 34d5e5d to d634142 Compare April 1, 2026 22:04
@codecov

codecov Bot commented Apr 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (eips/amsterdam/eip-8037@5e7832a). Learn more about missing BASE report.

Additional details and impacted files
@@                    Coverage Diff                     @@
##             eips/amsterdam/eip-8037    #2610   +/-   ##
==========================================================
  Coverage                           ?   88.17%           
==========================================================
  Files                              ?      524           
  Lines                              ?    31088           
  Branches                           ?     3036           
==========================================================
  Hits                               ?    27412           
  Misses                             ?     3161           
  Partials                           ?      515           
Flag Coverage Δ
unittests 88.17% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@spencer-tb spencer-tb requested review from kclowes April 1, 2026 22:28

@spencer-tb spencer-tb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM! I just made some refactoring changes.

@spencer-tb spencer-tb merged commit 468e5b2 into ethereum:eips/amsterdam/eip-8037 Apr 1, 2026
17 of 18 checks passed
spencer-tb added a commit to spencer-tb/execution-specs that referenced this pull request Apr 1, 2026
marioevz pushed a commit that referenced this pull request Apr 9, 2026
Co-authored-by: spencer-tb <spencer.tb@ethereum.org>
marioevz pushed a commit that referenced this pull request Apr 10, 2026
Co-authored-by: spencer-tb <spencer.tb@ethereum.org>
felix314159 pushed a commit to felix314159/execution-specs that referenced this pull request Apr 14, 2026
felix314159 pushed a commit that referenced this pull request Apr 16, 2026
Co-authored-by: spencer-tb <spencer.tb@ethereum.org>
spencer-tb added a commit that referenced this pull request Apr 17, 2026
Co-authored-by: spencer-tb <spencer.tb@ethereum.org>
marioevz pushed a commit that referenced this pull request Apr 20, 2026
Co-authored-by: spencer-tb <spencer.tb@ethereum.org>
spencer-tb added a commit that referenced this pull request Apr 20, 2026
Co-authored-by: spencer-tb <spencer.tb@ethereum.org>
spencer-tb added a commit to spencer-tb/execution-specs that referenced this pull request Apr 21, 2026
spencer-tb added a commit to spencer-tb/execution-specs that referenced this pull request Apr 21, 2026
spencer-tb added a commit that referenced this pull request Apr 21, 2026
Co-authored-by: spencer-tb <spencer.tb@ethereum.org>
fselmo pushed a commit that referenced this pull request May 5, 2026
Co-authored-by: spencer-tb <spencer.tb@ethereum.org>
spencer-tb added a commit to spencer-tb/execution-specs that referenced this pull request May 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-tests Area: Consensus tests. C-feat Category: an improvement or new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants