Skip to content

refactor(test-tests): migrate precompile gas costs to fork.gas_costs()#2192

Merged
marioevz merged 2 commits intoethereum:forks/amsterdamfrom
spencer-tb:chore/migrate-precompile-gas-costs
Feb 12, 2026
Merged

refactor(test-tests): migrate precompile gas costs to fork.gas_costs()#2192
marioevz merged 2 commits intoethereum:forks/amsterdamfrom
spencer-tb:chore/migrate-precompile-gas-costs

Conversation

@spencer-tb
Copy link
Contributor

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

🗒️ Description

Migrate precompile gas costs from hardcoded Spec.* constants in test files to dynamic fork.gas_costs().G_PRECOMPILE_* lookups.

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

The benefit is maintainability: when EIP-7904 reprices precompiles (e.g., ECADD 150 to 314, BLS12_G1ADD 375 to 643, POINT_EVALUATION 50000 to 89363), only gas_costs.py and forks.py need updating instead of every test file.

GasCosts dataclass additions

New constants added with default=0, set per-fork:

Constant Fork Value
G_PRECOMPILE_ECRECOVER Frontier 3000
G_PRECOMPILE_SHA256_BASE Frontier 60
G_PRECOMPILE_SHA256_WORD Frontier 12
G_PRECOMPILE_RIPEMD160_BASE Frontier 600
G_PRECOMPILE_RIPEMD160_WORD Frontier 120
G_PRECOMPILE_IDENTITY_BASE Frontier 15
G_PRECOMPILE_IDENTITY_WORD Frontier 3
G_PRECOMPILE_BLAKE2F_PER_ROUND Istanbul 1
G_PRECOMPILE_POINT_EVALUATION Cancun 50000
G_PRECOMPILE_BLS_G1ADD Prague 375
G_PRECOMPILE_BLS_G1MUL Prague 12000
G_PRECOMPILE_BLS_G1MAP Prague 5500
G_PRECOMPILE_BLS_G2ADD Prague 600
G_PRECOMPILE_BLS_G2MUL Prague 22500
G_PRECOMPILE_BLS_G2MAP Prague 23800
G_PRECOMPILE_BLS_PAIRING_BASE Prague 37700
G_PRECOMPILE_BLS_PAIRING_PER_PAIR Prague 32600
G_PRECOMPILE_P256VERIFY Osaka 6900

Files migrated

  • tests/cancun/eip4844_blobs/test_point_evaluation_precompile.py
  • tests/cancun/eip4844_blobs/test_point_evaluation_precompile_gas.py
  • tests/prague/eip2537_bls_12_381_precompiles/conftest.py + spec.py
  • tests/osaka/eip7951_p256verify_precompiles/conftest.py + test_p256verify.py

Spec.* references in @pytest.mark.parametrize decorators are kept since fork is unavailable at module-load time. Beacon roots (Spec.BEACON_ROOTS_CALL_GAS) is skipped — it's a system contract, not a precompile.

🔗 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

beedrill

@spencer-tb spencer-tb added P-medium C-refactor Category: refactor A-test-tests Area: tests for packages/testing labels Feb 11, 2026
@spencer-tb spencer-tb force-pushed the chore/migrate-precompile-gas-costs branch 3 times, most recently from 1a11b10 to 0b3d925 Compare February 11, 2026 17:27
…s()`

Add precompile gas cost constants to the GasCosts dataclass and set
values per-fork so tests use dynamic gas costs instead of hardcoded
Spec.* constants. This enables EIP-7904 repricing with a single-file
change.
@spencer-tb spencer-tb force-pushed the chore/migrate-precompile-gas-costs branch from 0b3d925 to 4dc9b25 Compare February 11, 2026 17:29
@spencer-tb
Copy link
Contributor Author

I'm thinking of creating a similiar abstraction here called: precompile.gas_cost(fork, input_data)

@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 (7581447).
⚠️ Report is 6 commits behind head on forks/amsterdam.

Additional details and impacted files
@@               Coverage Diff                @@
##           forks/amsterdam    #2192   +/-   ##
================================================
  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.

@marioevz marioevz self-requested a review February 11, 2026 19:30
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.

LGTM, thanks!

@marioevz marioevz merged commit 0c1cdc4 into ethereum:forks/amsterdam Feb 12, 2026
18 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