Skip to content

feat(tests): EIP-8037 additional state gas coverage#2718

Merged
spencer-tb merged 11 commits intoethereum:eips/amsterdam/eip-8037from
spencer-tb:eips/amsterdam/eip-8037-test-additions-fixes-devnet-4
Apr 20, 2026
Merged

feat(tests): EIP-8037 additional state gas coverage#2718
spencer-tb merged 11 commits intoethereum:eips/amsterdam/eip-8037from
spencer-tb:eips/amsterdam/eip-8037-test-additions-fixes-devnet-4

Conversation

@spencer-tb
Copy link
Copy Markdown
Contributor

@spencer-tb spencer-tb commented Apr 19, 2026

🗒️ Description

Revives the state gas test coverage from the closed PR #2639 and closes gaps surfaced by the evmone mutation testing report on that same PR from @chfast.

Most of the tests originated during bal-devnet-3 client testing, Maria's state gas accounting review, and spec reviews. They live on feat/eip-8037-tests-devnet3 and feat/eip-8037-additional-tests and were bundled into #2639 but never landed. The seven spec PRs that did merge since (#2689, #2698, #2703, #2704, #2707, #2711, plus PR #2646 and PR #2725) invalidated some of the originals (inverted premises, duplicates) and left a coverage gap for the rest, which this PR closes.

Devnet-3 client bug regressions

Two client bugs were discovered during bal-devnet-3 testing. Regression tests:

  • Besu: reservoir consumed on top level halt after child spill restore (Besu fix f4c8b36, cc @daniellehrner @jochem-brouwer). When a child frame spilled state gas into gas_left, then failed, then the parent hit an exception halt at the top level, Besu was incorrectly consuming the restored reservoir instead of refunding it to the sender. test_top_level_halt_preserves_restored_reservoir ports the regression with child_termination * reservoir_delta parametrization.
  • Geth: nested CREATE refund applied too eagerly (cc @MariusVanDerWijden). The closed PR's original test_inner_create_state_gas_persists_on_failure asserted the parents GAS_NEW_ACCOUNT charge for an inner CREATE must NOT be refunded on child failure. PR feat(spec-specs, tests): EIP-8037 - CREATE failure refunds state gas to reservoir #2704 subsequently changed the spec to do exactly what geth was doing (refund on failure), inverting the original test's premise. PR feat(spec-specs, tests): EIP-8037 - CREATE failure refunds state gas to reservoir #2704's own refund tests cover the non-creation-factory case, test_inner_create_fail_refunds_in_creation_tx fills the creation tx gap.

Access list gas classification

  • test_access_list_gas_is_regular_not_state (EIP-2930 access list intrinsic must stay on the regular dimension, parametrized over list size and keys per entry), and test_access_list_warm_savings_stay_regular (warm-access savings must stay on regular, catches clients crediting the cold to warm delta to state gas). cc @MariusVanDerWijden

Block 2D gas accounting edge cases

  • test_tx_rejected_when_regular_gas_exceeds_block_limit_small (tight boundary case complementing PR feat(spec-specs, tests): EIP-8037 - per-dimension block gas limit check at tx inclusion #2703 tests, cc @kclowes), test_block_2d_gas_tx_gas_limit_exceeds_regular_remaining (the inclusion check uses min(TX_MAX_GAS_LIMIT, tx.gas - intrinsic.state) not the raw tx.gas_limit, cc @jwasinger), test_receipt_cumulative_differs_from_header_gas_used (2D header.gas_used can diverge from 1D receipt cumulative_gas_used when state dominates), test_failed_create_tx_state_gas_dominates (creation tx with tight gas and REVERT/halt initcode where state dominates the header).

Initcode size validation ordering

Ports the initcode size before state gas ordering regression. cc @chfast

  • test_oversized_initcode_tx_no_state_gas (creation tx path)
  • test_oversized_initcode_opcode_no_state_gas (CREATE/CREATE2 opcode path)

Reservoir preservation and CALLCODE edge cases

  • test_top_level_halt_preserves_restored_reservoir (the Besu bug regression above), test_callcode_value_no_new_account_state_gas (CALLCODE transfers value to self, never creates a new account), test_create_oog_during_state_gas_charge (inner CREATE OOGs on the state gas charge itself; parent reservoir is restored and subsequent SSTORE still succeeds).

Creation-tx compositions

  • test_selfdestruct_in_create_tx_initcode (creation-tx initcode SELFDESTRUCTs to a new beneficiary; the same-tx refund cancels its GAS_NEW_ACCOUNT charge), test_inner_create_succeeds_code_deposit_state_gas (creation tx with an inner CREATE that succeeds and deploys code; parametrized over outer_outcome × create_opcode).

Nested CREATE fail and deep-recursion

  • test_nested_create_fail_parent_revert_state_gas (two-layer refund: caller to factory to inner CREATE failure to factory REVERTs or STOPs, parametrized over child_failure * parent_reverts * create_opcode), test_create_stack_depth_state_gas_consumed (deep-recursion robustness; CALLs self until gas exhausts, EIP-150 63/64 caps effective depth well below the stack limit; outermost SSTORE probe verifies the reservoir threaded through), test_inner_create_fail_refunds_in_creation_tx (geth bug regression, rewritten for the post PR feat(spec-specs, tests): EIP-8037 - CREATE failure refunds state gas to reservoir #2704 spec change).

Mutation testing regression tests

Four from @chfast's evmone mutation testing report on the closed PR, plus one from a local mutation scan against the current spec:

  • test_call_new_account_no_regular_account_creation_cost (pre-Amsterdam 25_000 regular ACCOUNT_CREATION_COST removal for CALL-to-new-account)
  • test_selfdestruct_new_beneficiary_no_regular_account_creation_cost (same 25k regular charge removal, SELFDESTRUCT variant)
  • test_child_failure_refunds_state_gas_to_reservoir_not_gas_left (incorporate_child_on_error restores to state_gas_left, not gas_left)
  • test_create_collision_burned_gas_counted_in_block_regular (collision-burned create_message_gas must count toward block_regular_gas_used)
  • test_create_selfdestruct_code_deposit_refund_header_check (same-tx CREATE+SELFDESTRUCT refund includes the code-length term; the existing test only asserts the account is gone, not that the refund landed at the block level)

Each was validated by injecting the target mutation into the spec and confirming the test fails under the bug.

Closed PR tests not ported and why

Six tests from the closed PRs original set are intentionally dropped:

Test Why dropped
test_failed_create_opcode_state_gas_dominates Duplicated by PR #2704's test_create_child_{revert,halt}_refunds_state_gas + test_create_code_deposit_oog_refunds_state_gas. Premise also inverted by PR #2704's refund.
test_inner_create_state_gas_persists_on_failure Premise inverted by PR #2704 (see Geth bug section above). The spec now refunds on child failure; the original test asserted the opposite. Rewritten as test_inner_create_fail_refunds_in_creation_tx.
test_create_nonce_overflow_state_gas_consumed Duplicated by PR #2704's test_create_silent_failure_refunds_state_gas[nonce_overflow]. Premise also inverted.
test_create2_collision_state_gas_block_accounting Duplicated by PR #2704's test_create_collision_refunds_state_gas. Premise inverted.
test_create_selfdestruct_same_tx_no_state_gas_refund Premise fully inverted by PR #2707.
test_call_value_to_selfdestructed_same_tx_account (test_state_gas_selfdestruct.py variant) Duplicated by PR #2646's three tests already on upstream (and separately updated by PR #2725).

🔗 Related Issues or PRs

Closed PR whose test set that this PR revives: #2639.

✅ Checklist

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

@marioevz marioevz force-pushed the eips/amsterdam/eip-8037 branch from cc2cd47 to 44c4c15 Compare April 20, 2026 07:53
@spencer-tb spencer-tb force-pushed the eips/amsterdam/eip-8037-test-additions-fixes-devnet-4 branch 2 times, most recently from 9d29dcf to 25e2a3e Compare April 20, 2026 07:58
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 20, 2026

Codecov Report

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

Additional details and impacted files
@@                    Coverage Diff                     @@
##             eips/amsterdam/eip-8037    #2718   +/-   ##
==========================================================
  Coverage                           ?   86.27%           
==========================================================
  Files                              ?      599           
  Lines                              ?    37156           
  Branches                           ?     3803           
==========================================================
  Hits                               ?    32058           
  Misses                             ?     4530           
  Partials                           ?      568           
Flag Coverage Δ
unittests 86.27% <ø> (?)

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 changed the title feat(tests): EIP-8037 additional state gas coverage + regression fix from devnet-4 merges feat(tests): EIP-8037 additional state gas coverage Apr 20, 2026
@spencer-tb spencer-tb added this to the Devnet-4 milestone Apr 20, 2026
@spencer-tb spencer-tb force-pushed the eips/amsterdam/eip-8037 branch from 44c4c15 to de5bf67 Compare April 20, 2026 15:29
@spencer-tb spencer-tb force-pushed the eips/amsterdam/eip-8037-test-additions-fixes-devnet-4 branch from 656ca32 to b9b80f8 Compare April 20, 2026 16:36
Copy link
Copy Markdown
Contributor

@kclowes kclowes left a comment

Choose a reason for hiding this comment

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

This LGTM! :shipit: There are a few related edge cases that I will put up in another PR, but nothing major or that should be blocking at all. Nice work!

Copy link
Copy Markdown
Contributor

@fselmo fselmo left a comment

Choose a reason for hiding this comment

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

lgtm. Just minor readability nit we can always clean up later. 🚢

Comment thread tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_create.py Outdated
@spencer-tb spencer-tb force-pushed the eips/amsterdam/eip-8037-test-additions-fixes-devnet-4 branch from 82374fe to 4dca651 Compare April 20, 2026 20:05
@spencer-tb spencer-tb merged commit f5da8ef into ethereum:eips/amsterdam/eip-8037 Apr 20, 2026
17 checks passed
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
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.

3 participants