Skip to content

refactor(tests): Remove fork.gas_costs() reconstruction from Amsterdam EIP-8037/8038 tests#3169

Open
marioevz wants to merge 5 commits into
ethereum:forks/amsterdamfrom
marioevz:fix-eip-8037-8038-gas-checks
Open

refactor(tests): Remove fork.gas_costs() reconstruction from Amsterdam EIP-8037/8038 tests#3169
marioevz wants to merge 5 commits into
ethereum:forks/amsterdamfrom
marioevz:fix-eip-8037-8038-gas-checks

Conversation

@marioevz

@marioevz marioevz commented Jul 14, 2026

Copy link
Copy Markdown
Member

Description

Motivation

Many Amsterdam gas tests re-derived expected gas by hand-summing fork.gas_costs() constants (NEW_ACCOUNT, CALL_VALUE, COLD_STORAGE_WRITE, VERY_LOW, …). This duplicates the framework's own gas calculation and makes the tests brittle: any future fork that reprices or restructures the schedule silently diverges from these hand-built expectations.

This PR replaces that reconstruction with framework constructs that track the live schedule, and fixes the one place the framework couldn't express a cost.

Scope: the eip8037_state_creation_gas_cost_increase and eip8038_state_access_gas_cost_increase suites (24 test files) plus a small testing-framework change.

Types of change

Framework (packages/testing)
  • Wire CALL/CALLCODE new-account gas into the EIP-8037 two-dimensional model: their NEW_ACCOUNT charge now lands on the state dimension (opcode_state_map + a regular-cost override) instead of being stuck in regular gas, so .state_cost(fork) / .regular_cost(fork) are correct for value-to-new-account calls. Total .gas_cost(fork) is unchanged.
  • Add a call_value_stipend() fork accessor for the value-call stipend, which has no opcode/bytecode representation.
Tests — replace hand-reconstructed gas with framework constructs
  • Opcode/bytecode cost methods (.gas_cost / .regular_cost / .state_cost / .refund) on the actual fragments under test, driven by opcode metadata (account_new, value_transfer, address_warm, storage-slot state, …).
  • Transaction-level costs via transaction_intrinsic_cost_calculator, transaction_top_frame_state_gas, and transaction_data_floor_cost_calculator.
  • Fork-transition / cross-fork comparisons derived from the same bytecode/intrinsic evaluated at each fork (fork.fork_at(...)), not raw constants.
  • The value-call stipend sourced from the new call_value_stipend() accessor.
Tests — drop redundant self-checks
  • Removed assertions that compared a framework-computed value against a fork.gas_costs() decomposition of the same fork (framework-vs-framework). They add no coverage over the runtime behavior each test already exercises and only break on repricing.
Bug fix
  • Corrected several contract-creation tests that subtracted NEW_ACCOUNT from the transaction intrinsic; under EIP-2780 the intrinsic is regular-only, so the subtraction went negative (masked previously because the state dimension dominated the header gas_used).

Deliberately retained

  • One fork.gas_costs() use remains in the transient-storage regression test, where the declared OPCODE_TLOAD/OPCODE_TSTORE schedule value is the subject under test (measured at runtime via CodeGasMeasure).

Testing

  • Full Amsterdam fixture fill: 9285 passed, 9 skipped (unchanged from baseline — no regressions).
  • Framework opcode-gas unit tests pass.

Related Issues or PRs

Fixes #3042

Checklist

  • Ran fast static checks to avoid CI fails, see Code Standards & Verifying Changes: just static
  • PR title has the form <type>(<area>): <title>, where <type> and <area> come from an appropriate C-<type>, respectively A-<area>, label. The title should match the target squash commit message.

Cute Animal Picture

Put a link to a cute animal picture inside the parenthesis-->

@codecov

codecov Bot commented Jul 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.39%. Comparing base (5fa5938) to head (2743747).
⚠️ Report is 2 commits behind head on forks/amsterdam.

Additional details and impacted files
@@               Coverage Diff                @@
##           forks/amsterdam    #3169   +/-   ##
================================================
  Coverage            93.39%   93.39%           
================================================
  Files                  624      624           
  Lines                37014    37014           
  Branches              3386     3386           
================================================
  Hits                 34570    34570           
  Misses                1671     1671           
  Partials               773      773           
Flag Coverage Δ
unittests 93.39% <ø> (ø)

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

☔ View full report in Codecov by Harness.
📢 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.

@marioevz
marioevz force-pushed the fix-eip-8037-8038-gas-checks branch from c14495c to e410c89 Compare July 14, 2026 19:44
@marioevz
marioevz requested a review from spencer-tb July 16, 2026 11:42
@marioevz
marioevz marked this pull request as ready for review July 16, 2026 11:42
@marioevz

Copy link
Copy Markdown
Member Author

Updated write-test.md claude skill to set the new test expectations as directives.

@LouisTsai-Csie

LouisTsai-Csie commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Finish eip-8037 review except tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_selfdestruct.py

I will leave my review comment later

@LouisTsai-Csie LouisTsai-Csie 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.

EIP-8037: Two small issues

  • Missing coverage: test_create_refund_credited_against_child_spill still uses gas_costs.NEW_ACCOUNT and isn't covered in this refactor.
  • Redundant state-gas definition: In test_exact_coinbase_fee_simple_sstore, we define sstore_state_gas = Op.SSTORE(new_value=1).state_cost(fork), then define sstore_code = Op.SSTORE(sstore_storage.store_next(1), 1), and reference sstore_state_gas. We could simplify by using sstore_code.state_cost(fork) directly instead. No changes needed, pure suggestion

EIP-8038: I need additional review time since I'm uncertain why some assertions were completely removed.

@marioevz
marioevz force-pushed the fix-eip-8037-8038-gas-checks branch from 04be158 to 2743747 Compare July 22, 2026 08:48
@marioevz

Copy link
Copy Markdown
Member Author

@LouisTsai-Csie applied your comments and repurposed the test that was no longer correct (It checked an account creation refund when we don't charge for it in the first place anymore).

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.

Remove extensive and superflous gas checks in EIP-8038 tests

2 participants