feat(tests, spec-specs): add full cost per state byte pricing function for EIP-8037#2687
Merged
spencer-tb merged 7 commits intoethereum:eips/amsterdam/eip-8037from Apr 21, 2026
Conversation
marioevz
reviewed
Apr 15, 2026
Member
marioevz
left a comment
There was a problem hiding this comment.
Just two preliminary comments, which I think we could even apply directly to forks/amsterdam.
4 tasks
Member
|
@spencer-tb created #2690 to address the comment I made, it's not a pretty PR but it does the job, and I did an ad-hoc (not in the PR) verification in the |
9755dba to
3e1d7c4
Compare
1c27d22 to
6048561
Compare
3e1d7c4 to
44b47cc
Compare
6048561 to
4c80029
Compare
cc2cd47 to
44c4c15
Compare
4c80029 to
0208778
Compare
44c4c15 to
de5bf67
Compare
0b39285 to
200cc05
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## eips/amsterdam/eip-8037 #2687 +/- ##
==========================================================
Coverage ? 86.28%
==========================================================
Files ? 599
Lines ? 37164
Branches ? 3804
==========================================================
Hits ? 32066
Misses ? 4530
Partials ? 568
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
fselmo
reviewed
Apr 20, 2026
c07a313 to
f609e81
Compare
f609e81 to
7f41819
Compare
ba05246 to
a98b09e
Compare
a98b09e to
a3cbac3
Compare
Contributor
Author
de71eca
into
ethereum:eips/amsterdam/eip-8037
23 checks passed
spencer-tb
added a commit
to spencer-tb/execution-specs
that referenced
this pull request
Apr 21, 2026
…n for EIP-8037 (ethereum#2687) Co-authored-by: marioevz <marioevz@gmail.com>
spencer-tb
added a commit
that referenced
this pull request
Apr 21, 2026
…n for EIP-8037 (#2687) Co-authored-by: marioevz <marioevz@gmail.com>
fselmo
pushed a commit
that referenced
this pull request
May 5, 2026
…n for EIP-8037 (#2687) Co-authored-by: marioevz <marioevz@gmail.com>
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
Summary
cost_per_state_bytepricing function in both the spec and testing framework to compute the EIP-8037 quantized value from the block gas limitBaseFork._env_gas_limitclass variable, synced automatically by theforkfixture fromEnvironment.gas_limit(default 120M, or--block-gas-limit)gas_costs(),sstore_state_gas(), etc.) respond to the actual block gas limit — no parameter threading neededEnvironment(gas_limit=X)or use--block-gas-limitget the correspondingcost_per_state_byteautomaticallyGas Limit Flow
EnvironmentDefaults.gas_limit(default 120M, or--block-gas-limit) via theenv_gas_limitfixtureforkfixture, creates a per-test fork variant viafork.with_env_gas_limit(env_gas_limit)and monkey-patchesEnvironmentso anyEnvironment(gas_limit=X)syncsXback to the variant's_env_gas_limitfork.gas_costs(),fork.sstore_state_gas(), etc. which readcls._env_gas_limitto compute cpsbstate.py/blockchain.pysetfork._env_gas_limit = env.gas_limitper-block before t8n executionstate_gas_per_byte(gas_limit)receives the block gas limit from the environment and computes cpsb dynamicallyFork Calculator Split
On top of this, Mario's refactor splits the previously combined opcode-gas surface on
BaseForkinto three separate per-dimension maps:opcode_state_map— state gas cost per opcode (cpsb multiplier or callable)opcode_refund_map— regular gas refund per opcodeopcode_state_refund_map— state gas refund per opcodeTests can now query each dimension independently instead of pulling a mixed regular+state value. Paired with the dynamic cpsb, opcode state-gas/refund calculations scale with the block gas limit automatically.
Remaining Fixes
A separate follow-up commit (
feat(tests): remaining fixes) addresses pre-existing tests that assumed the previously-hardcoded cpsb=1174 and broke under the new dynamic computation:test_state_gas_reservoir.py: pinfork._env_gas_limitin four tests so every cpsb-dependent value read matches what the block uses at execution timetest_bls12_variable_length_input_contracts.py: apply the default env gas limit variant in the discount-table splitter so collection-time cpsb matches runtimePorted Static Test Fixes
A separate commit (
fix(tests): drop inflated env gas_limit in ported_static) removes thegas_limit=<value>line fromEnvironment(...)calls in 576 ported_static test files. These values were inherited as boilerplate from the original static JSON fillers (ranging from 1M to max-i64) with no functional purpose, under the old hardcoded cpsb=1174 they didn't matter, but under dynamic cpsb they caused:Storage/Account.balanceassertionsRemoving the override lets
Environmentdefault toEnvironmentDefaults.gas_limit = 120M, which yields the canonical cpsb=1174 these tests were always implicitly designed against. All 576 files verified to have a singleTransactionwithtx.gas_limit <= 14Mand no references toenv.gas_limitin test logic, so the change preserves test semantics.🔗 Related Issues or PRs
N/A.
✅ Checklist
just statictype(scope):.