refactor(tests): Remove fork.gas_costs() reconstruction from Amsterdam EIP-8037/8038 tests#3169
refactor(tests): Remove fork.gas_costs() reconstruction from Amsterdam EIP-8037/8038 tests#3169marioevz wants to merge 5 commits into
fork.gas_costs() reconstruction from Amsterdam EIP-8037/8038 tests#3169Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## forks/amsterdam #3169 +/- ##
================================================
Coverage 93.39% 93.39%
================================================
Files 624 624
Lines 37014 37014
Branches 3386 3386
================================================
Hits 34570 34570
Misses 1671 1671
Partials 773 773
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:
|
c14495c to
e410c89
Compare
|
Updated |
|
Finish eip-8037 review except I will leave my review comment later |
LouisTsai-Csie
left a comment
There was a problem hiding this comment.
EIP-8037: Two small issues
- Missing coverage:
test_create_refund_credited_against_child_spillstill usesgas_costs.NEW_ACCOUNTand isn't covered in this refactor. - Redundant state-gas definition: In
test_exact_coinbase_fee_simple_sstore, we definesstore_state_gas = Op.SSTORE(new_value=1).state_cost(fork), then definesstore_code = Op.SSTORE(sstore_storage.store_next(1), 1), and referencesstore_state_gas. We could simplify by usingsstore_code.state_cost(fork)directly instead. No changes needed, pure suggestion
EIP-8038: I need additional review time since I'm uncertain why some assertions were completely removed.
04be158 to
2743747
Compare
|
@LouisTsai-Csie applied your comments and repurposed the test that was no longer correct (It checked an account creation refund when we don't charge for it in the first place anymore). |
Description
Motivation
Many Amsterdam gas tests re-derived expected gas by hand-summing
fork.gas_costs()constants (NEW_ACCOUNT,CALL_VALUE,COLD_STORAGE_WRITE,VERY_LOW, …). This duplicates the framework's own gas calculation and makes the tests brittle: any future fork that reprices or restructures the schedule silently diverges from these hand-built expectations.This PR replaces that reconstruction with framework constructs that track the live schedule, and fixes the one place the framework couldn't express a cost.
Scope: the
eip8037_state_creation_gas_cost_increaseandeip8038_state_access_gas_cost_increasesuites (24 test files) plus a small testing-framework change.Types of change
Framework (
packages/testing)CALL/CALLCODEnew-account gas into the EIP-8037 two-dimensional model: theirNEW_ACCOUNTcharge now lands on the state dimension (opcode_state_map+ a regular-cost override) instead of being stuck in regular gas, so.state_cost(fork)/.regular_cost(fork)are correct for value-to-new-account calls. Total.gas_cost(fork)is unchanged.call_value_stipend()fork accessor for the value-call stipend, which has no opcode/bytecode representation.Tests — replace hand-reconstructed gas with framework constructs
.gas_cost/.regular_cost/.state_cost/.refund) on the actual fragments under test, driven by opcode metadata (account_new,value_transfer,address_warm, storage-slot state, …).transaction_intrinsic_cost_calculator,transaction_top_frame_state_gas, andtransaction_data_floor_cost_calculator.fork.fork_at(...)), not raw constants.call_value_stipend()accessor.Tests — drop redundant self-checks
fork.gas_costs()decomposition of the same fork (framework-vs-framework). They add no coverage over the runtime behavior each test already exercises and only break on repricing.Bug fix
NEW_ACCOUNTfrom the transaction intrinsic; under EIP-2780 the intrinsic is regular-only, so the subtraction went negative (masked previously because the state dimension dominated the headergas_used).Deliberately retained
fork.gas_costs()use remains in the transient-storage regression test, where the declaredOPCODE_TLOAD/OPCODE_TSTOREschedule value is the subject under test (measured at runtime viaCodeGasMeasure).Testing
Related Issues or PRs
Fixes #3042
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.Cute Animal Picture