feat(tests): cover ModExp gas before EIP-2565 - #3237
Draft
chfast wants to merge 1 commit into
Draft
Conversation
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 Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
ModExpInputand is imported by the later repricing EIPs, and select the gas formula through amodexp_specfixture that a repricing directory overrides. The formulas move with it:Spec198is new,Spec2565is the formerSpecbody, and EIP-7883 keeps overriding it.Two fixes were needed to reach Byzantium. The harness subtracted
gas_costs().WARM_ACCESSas 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. Andget_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
just static<type>(<area>): <title>, where<type>and<area>come from an appropriateC-<type>, respectivelyA-<area>, label. The title should match the target squash commit message.