Skip to content

feat(tests): cover ModExp gas before EIP-2565 - #3237

Draft
chfast wants to merge 1 commit into
ethereum:forks/amsterdamfrom
chfast:modexp-eip198-gas
Draft

feat(tests): cover ModExp gas before EIP-2565#3237
chfast wants to merge 1 commit into
ethereum:forks/amsterdamfrom
chfast:modexp-eip198-gas

Conversation

@chfast

@chfast chfast commented Jul 26, 2026

Copy link
Copy Markdown
Member

Description

The gas measurement harness lived in the EIP-7883 directory and every test using it started at Berlin, so the EIP-198 schedule that prices the precompile from Byzantium until Berlin had no coverage: the only ModExp tests reaching those forks call with all the gas available.

Move the harness down to the EIP-198 directory, which already owns ModExpInput and is imported by the later repricing EIPs, and select the gas formula through a modexp_spec fixture that a repricing directory overrides. The formulas move with it: Spec198 is new, Spec2565 is the former Spec body, and EIP-7883 keeps overriding it.

Two fixes were needed to reach Byzantium. The harness subtracted gas_costs().WARM_ACCESS as the cost of the call, but that field holds the EIP-2929 value on every fork, so before Berlin it under-counted the flat EIP-150 charge by 600 gas. And get_exponent_head() left-padded an exponent whose input is truncated, while reading past the end of the input yields zeros on the right; the EIP-2565 minimum of 200 gas had hidden the difference, which is observable under EIP-198 where a call can be free.

With that in place, the legacy vectors and the exact-gas boundary test now run from Byzantium, and a new test pins each branch of the EIP-198 multiplication complexity formula at its exact cost and one gas less.

Related Issues or PRs

N/A.

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.

The gas measurement harness lived in the EIP-7883 directory and every
test using it started at Berlin, so the EIP-198 schedule that prices the
precompile from Byzantium until Berlin had no coverage: the only ModExp
tests reaching those forks call with all the gas available.

Move the harness down to the EIP-198 directory, which already owns
`ModExpInput` and is imported by the later repricing EIPs, and select
the gas formula through a `modexp_spec` fixture that a repricing
directory overrides. The formulas move with it: `Spec198` is new,
`Spec2565` is the former `Spec` body, and EIP-7883 keeps overriding it.

Two fixes were needed to reach Byzantium. The harness subtracted
`gas_costs().WARM_ACCESS` as the cost of the call, but that field holds
the EIP-2929 value on every fork, so before Berlin it under-counted the
flat EIP-150 charge by 600 gas. And `get_exponent_head()` left-padded an
exponent whose input is truncated, while reading past the end of the
input yields zeros on the right; the EIP-2565 minimum of 200 gas had
hidden the difference, which is observable under EIP-198 where a call
can be free.

With that in place, the legacy vectors and the exact-gas boundary test
now run from Byzantium, and a new test pins each branch of the EIP-198
multiplication complexity formula at its exact cost and one gas less.

Claude-Session: https://claude.ai/code/session_019YyttTB1mqHzWa77K3sEoT
@codecov

codecov Bot commented Jul 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.41%. Comparing base (1646cf5) to head (8000c1d).
⚠️ Report is 7 commits behind head on forks/amsterdam.

Additional details and impacted files
@@               Coverage Diff                @@
##           forks/amsterdam    #3237   +/-   ##
================================================
  Coverage            93.41%   93.41%           
================================================
  Files                  624      624           
  Lines                37014    37014           
  Branches              3386     3386           
================================================
  Hits                 34576    34576           
  Misses                1668     1668           
  Partials               770      770           
Flag Coverage Δ
unittests 93.41% <ø> (ø)

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.

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.

1 participant