feat(tests): sweep the refund merge over every call and create opcode - #3506
Merged
spencer-tb merged 1 commit intoSep 2, 2026
Merged
Conversation
Add two tests pinning where a merged state gas refund lands, swept over `with_all_call_opcodes` and `with_all_create_opcodes`. A holder contract owns the cleared slot, so a create's initcode reaches it the same way a call's child does, and the parent's spill comes from setting the slot through the holder. Each test measures a clearing window against a no-op window of identical code, so neither needs gas arithmetic. Today the refund stays in the reservoir: the two windows cost the same at a call, and at a create the second window's account creation charge draws on the parked refund, so the clearing window costs one slot's state gas more. With the `src/` change of ethereum#3478 applied, every arm flips to minus one slot's state cost. Before this, `CREATE` and `CREATE2` never merged a refunding child into a parent holding a spill: a repayment applied only at `generic_call` passed the whole suite. `CALL`, `CALLCODE` and depth 2 did reach the path, in `test_state_gas_sstore` and `test_state_gas_set_code`, but nothing there discriminates. Both tests reach the holder through an intermediate frame, so the sweep pins depth 2 as well. `STATICCALL` is excluded: a static child cannot write, so it can never refund. `test_cross_frame_refund_parks_in_reservoir` builds the same probe, so move that shape into `clearing_probe_code` and take the setting code as a parameter. Its fixtures are unchanged. Follow-up to ethereum#3490 and ethereum#3499. Coverage for ethereum/EIPs#12265 and ethereum#3478.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## forks/amsterdam #3506 +/- ##
================================================
Coverage 93.90% 93.90%
================================================
Files 624 624
Lines 36905 36905
Branches 3326 3326
================================================
Hits 34655 34655
Misses 1569 1569
Partials 681 681
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:
|
spencer-tb
approved these changes
Sep 2, 2026
spencer-tb
left a comment
Contributor
There was a problem hiding this comment.
Awesome thanks! LGTM no issues from my end :)
This was referenced Sep 2, 2026
Merged
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
Add two tests pinning where a merged state gas refund lands, swept over
with_all_call_opcodesandwith_all_create_opcodes. A holder contract owns the cleared slot, so a create's initcode reaches it the same way a call's child does, and the parent's spill comes from setting the slot through the holder.Each test measures a clearing window against a no-op window of identical code, so neither needs gas arithmetic. Today the refund stays in the reservoir: the two windows cost the same at a call, and at a create the second window's account creation charge draws on the parked refund, so the clearing window costs one slot's state gas more. With the
src/change of #3478 applied, every arm flips to minus one slot's state cost.Before this,
CREATEandCREATE2never merged a refunding child into a parent holding a spill: a repayment applied only atgeneric_callpassed the whole suite.CALL,CALLCODEand depth 2 did reach the path, intest_state_gas_sstoreandtest_state_gas_set_code, but nothing there discriminates. Both tests reach the holder through an intermediate frame, so the sweep pins depth 2 as well.STATICCALLis excluded: a static child cannot write, so it can never refund.Related Issues or PRs
Follow-up to #3490 and #3499. Coverage for ethereum/EIPs#12265 and #3478.
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.