Skip to content

feat(tests): sweep the refund merge over every call and create opcode - #3506

Merged
spencer-tb merged 1 commit into
ethereum:forks/amsterdamfrom
chfast:eip8037-refund-merge-site-sweep
Sep 2, 2026
Merged

spencer-tb merged 1 commit into
ethereum:forks/amsterdamfrom
chfast:eip8037-refund-merge-site-sweep

Conversation

@chfast

@chfast chfast commented Sep 2, 2026

Copy link
Copy Markdown
Member

Description

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 #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.

Related Issues or PRs

Follow-up to #3490 and #3499. Coverage for ethereum/EIPs#12265 and #3478.

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.

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

codecov Bot commented Sep 2, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.90%. Comparing base (76910d3) to head (1200b9d).

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           
Flag Coverage Δ
unittests 93.90% <ø> (ø)

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.

@spencer-tb spencer-tb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome thanks! LGTM no issues from my end :)

@spencer-tb
spencer-tb merged commit ad19524 into ethereum:forks/amsterdam Sep 2, 2026
17 checks passed
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.

2 participants