Skip to content

refactor(test-tests): migrate frontier to shanghai gas costs to bytecode.gas_cost(fork)#2188

Merged
marioevz merged 6 commits intoethereum:forks/amsterdamfrom
spencer-tb:chore/migrate-gas-costs-remaining
Feb 11, 2026
Merged

refactor(test-tests): migrate frontier to shanghai gas costs to bytecode.gas_cost(fork)#2188
marioevz merged 6 commits intoethereum:forks/amsterdamfrom
spencer-tb:chore/migrate-gas-costs-remaining

Conversation

@spencer-tb
Copy link
Contributor

@spencer-tb spencer-tb commented Feb 11, 2026

🗒️ Description

Migrate remaining Frontier, Berlin, TangerineWhistle, and Shanghai test files from manual fork.gas_costs() calculations to bytecode.gas_cost(fork).

This is a pure refactor with no functional change, all exact gas-boundary test fixtures produce identical output (verified via fixture hash comparison).

The benefit is maintainability: tests now declare intent via opcode metadata (e.g., address_warm=False, value_transfer=True) and delegate gas calculation to the framework's opcode_gas_map(), so future gas schedule changes only need updating in one place.

Files migrated:

  • tests/frontier/opcodes/test_call.py
  • tests/frontier/opcodes/test_call_and_callcode_gas_calculation.py
  • tests/berlin/eip2929_gas_cost_increases/test_precompile_warming.py
  • tests/berlin/eip2930_access_list/test_acl.py
  • tests/tangerine_whistle/eip150_operation_gas_costs/test_eip150_selfdestruct.py
  • tests/shanghai/eip3651_warm_coinbase/test_warm_coinbase.py
  • tests/shanghai/eip3860_initcode/test_initcode.py

Pre-Berlin hardcoded values (700 for Byzantium-Berlin CALL, 40 for Homestead CALL) are kept where the framework's opcode_gas_map doesn't model pre-EIP-2929 costs. The remaining fork.gas_costs().G_CALL_STIPEND reference is intentional, it's a threshold check, not a gas cost. Per-word costs (G_INITCODE_WORD, G_KECCAK_256_WORD) are kept as-is since they aren't expressible via bytecode.gas_cost.

🔗 Related Issues or PRs

Partially fixes #2049.

✅ 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).

Cute Animal Picture

arcanine

…s_cost(fork)`

Migrate Frontier, Berlin, TangerineWhistle, and Shanghai test files from
`fork.gas_costs()` / hardcoded constants to `bytecode.gas_cost(fork)` API.

Files migrated:
- tests/frontier/opcodes/test_call.py
- tests/frontier/opcodes/test_call_and_callcode_gas_calculation.py
- tests/berlin/eip2929_gas_cost_increases/test_precompile_warming.py
- tests/berlin/eip2930_access_list/test_acl.py
- tests/tangerine_whistle/eip150_operation_gas_costs/test_eip150_selfdestruct.py
- tests/shanghai/eip3651_warm_coinbase/test_warm_coinbase.py
- tests/shanghai/eip3860_initcode/test_initcode.py
@spencer-tb spencer-tb force-pushed the chore/migrate-gas-costs-remaining branch from 49550c8 to 5bc2716 Compare February 11, 2026 14:48
@spencer-tb spencer-tb added C-refactor Category: refactor A-test-tests Area: tests for packages/testing labels Feb 11, 2026
@spencer-tb spencer-tb changed the title refactor(test-tests): migrate remaining gas costs to bytecode.gas_cost(fork) refactor(test-tests): migrate frontier to shanghai gas costs to bytecode.gas_cost(fork) Feb 11, 2026
@codecov
Copy link

codecov bot commented Feb 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.07%. Comparing base (a82b1f6) to head (eca664f).
⚠️ Report is 1 commits behind head on forks/amsterdam.

Additional details and impacted files
@@               Coverage Diff                @@
##           forks/amsterdam    #2188   +/-   ##
================================================
  Coverage            86.07%   86.07%           
================================================
  Files                  599      599           
  Lines                39472    39472           
  Branches              3780     3780           
================================================
  Hits                 33977    33977           
  Misses                4862     4862           
  Partials               633      633           
Flag Coverage Δ
unittests 86.07% <ø> (ø)

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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

@marioevz marioevz left a comment

Choose a reason for hiding this comment

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

Awesome change, thanks! The comments are just to remove the wrapping of Bytecode since you can directly do Op.SSTORE(...).gas_cost(fork) for example.

@marioevz marioevz merged commit 353c388 into ethereum:forks/amsterdam Feb 11, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-test-tests Area: tests for packages/testing C-refactor Category: refactor P-medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chore(test-tests): migrate tests from fork.gas_costs to bytecode.gas_cost(fork)

2 participants