Skip to content

feat(spec-specs, tests): EIP-8037 tx created contracts destroyed in same tx#2828

Merged
spencer-tb merged 2 commits into
ethereum:devnets/bal/7from
spencer-tb:feat/eip-8037-create-tx-selfdestruct-intrinsic-refund
May 10, 2026
Merged

feat(spec-specs, tests): EIP-8037 tx created contracts destroyed in same tx#2828
spencer-tb merged 2 commits into
ethereum:devnets/bal/7from
spencer-tb:feat/eip-8037-create-tx-selfdestruct-intrinsic-refund

Conversation

@spencer-tb
Copy link
Copy Markdown
Contributor

@spencer-tb spencer-tb commented May 8, 2026

🗒️ Description

A create tx charges STATE_BYTES_PER_NEW_ACCOUNT * COST_PER_STATE_BYTE of instrinsic state gas at the start of tx processing for contract creation. If the contract is then destroyed in the same tx via a selfdestruct, the existing refund mechanism clamps to the state gas used which does not include the intrinsic state gas charge from the start of tx processing. This means the intrinsic state gas charge for account creating stays billed even though no contract persists at end of the tx. TLDR; the user pays for state that was never written.

This PR aims to fix the inconsistency by routing the destroyed contract state gas charge by refunding then moment when the destroyed account is the create tx target.

@benaadams and Iván (ethrex) flagged this scenario class during the Soldogn interop on bal-devnet-6. The specific case Iván mentioned: "creation tx, initcode selfdestructs to an empty beneficiary with value > 0" was already correctly accounted for by accident. There was however a bug from many other scenarios:

value beneficiary net new state before fix after fix
0 self 0 over-bills 1 NEW_ACCOUNT 0 ✓
0 existing 0 over-bills 1 NEW_ACCOUNT 0 ✓
0 empty 0 over-bills 1 NEW_ACCOUNT 0 ✓
>0 self 0 (balance burned) over-bills 1 NEW_ACCOUNT 0 ✓
>0 existing 0 over-bills 1 NEW_ACCOUNT 0 ✓
>0 empty +1 (new beneficiary) 1 NEW_ACCOUNT 1 NEW_ACCOUNT ✓

✅ Checklist

  • All: Ran fast static checks to avoid unnecessary CI fails, see also Code Standards and Enabling Pre-commit Checks:
    just static
  • All: PR title adheres to the repo standard - it will be used as the squash commit message and should start type(scope):.
  • All: Considered updating the online docs in the ./docs/ directory.
  • All: Set appropriate labels for the changes (only maintainers can apply labels).

@codecov
Copy link
Copy Markdown

codecov Bot commented May 8, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (devnets/bal/7@5416cbb). Learn more about missing BASE report.

Additional details and impacted files
@@               Coverage Diff                @@
##             devnets/bal/7    #2828   +/-   ##
================================================
  Coverage                 ?   87.64%           
================================================
  Files                    ?      531           
  Lines                    ?    32378           
  Branches                 ?     3127           
================================================
  Hits                     ?    28378           
  Misses                   ?     3515           
  Partials                 ?      485           
Flag Coverage Δ
unittests 87.64% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 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 force-pushed the feat/eip-8037-create-tx-selfdestruct-intrinsic-refund branch from 0601713 to df8d6c1 Compare May 10, 2026 22:30
@spencer-tb spencer-tb changed the title feat(spec-specs, tests): EIP-8037 refund intrinsic NEW_ACCOUNT for tx-created contracts destroyed in same tx feat(spec-specs, tests): EIP-8037 tx created contracts destroyed in same tx May 10, 2026
@spencer-tb spencer-tb force-pushed the feat/eip-8037-create-tx-selfdestruct-intrinsic-refund branch from df8d6c1 to 6544240 Compare May 10, 2026 22:36
@spencer-tb spencer-tb merged commit 676afaf into ethereum:devnets/bal/7 May 10, 2026
8 of 9 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.

1 participant