Skip to content

feat(tests): EIP-8037 - CALL with value to selfdestructed account#2646

Merged
spencer-tb merged 2 commits into
ethereum:eips/amsterdam/eip-8037from
kclowes:feat/8037-call-with-value-to-self-destruct
Apr 19, 2026
Merged

feat(tests): EIP-8037 - CALL with value to selfdestructed account#2646
spencer-tb merged 2 commits into
ethereum:eips/amsterdam/eip-8037from
kclowes:feat/8037-call-with-value-to-self-destruct

Conversation

@kclowes

@kclowes kclowes commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

🗒️ Description

Adds test coverage for CALL with value to an account that was selfdestructed (per EIP-6780), both the same transaction case and the pre existing case. No spec change: EIP-8037 and EIP-6780 together already produce the correct behavior, and this PR documents it with strict header_verify discriminators.

Related EIP spec clarification: ethereum/EIPs#11532 (point 5).

Behavior under test

When an account is created and then selfdestructed in the same transaction, EIP-6780 defers deletion to the end of the transaction. During the transaction the account still has nonce = 1 from the CREATE, so it is neither empty nor nonexistent and the new account creation gate does not fire on a subsequent CALL with value, no GAS_NEW_ACCOUNT state gas is charged. End of the transaction destruction still removes the account regardless of any value received after SELFDESTRUCT, so value transferred by the CALL is burned along with the destroyed account. Combined with the same transaction SELFDESTRUCT state gas refund (#2707), the net state gas across the CREATE + SELFDESTRUCT + CALL(value) lifecycle is zero.

For a pre existing contract that runs SELFDESTRUCT, EIP-6780 does not queue it for destruction, so a subsequent CALL sees an existing, code carrying account and the new account creation gate does not fire either.

Tests

All in tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_call.py. The init_code_at_high_bytes helper is moved to spec.py for reuse with the related PR #2707.

  • test_call_value_to_self_destructed_same_tx_account, smoke test parametrized create_opcode=[CREATE, CREATE2]. Confirms the happy path runs to completion. Strict discrimination lives in test_call_value_to_self_destructed_header_gas_used.
  • test_call_value_to_self_destructed_header_gas_used, strict header_verify discriminator parametrized create_opcode=[CREATE, CREATE2] × selfdestruct_beneficiary=[self, external]. Block header gas_used equals exactly one GAS_NEW_ACCOUNT (only the CREATE's state charge), proving no second charge from the CALL.
  • test_call_value_to_self_destructed_burns_value, strict header_verify parametrized create_opcode=[CREATE, CREATE2] × call_value=[1 wei, 1 ether]. Block header gas used equals one GAS_NEW_ACCOUNT. Post state asserts the created address is NONEXISTENT and the orchestrator balance is zero, proving the value is burned when end of the transaction destruction runs.
  • test_call_zero_value_to_self_destructed_same_tx_account, strict header_verify parametrized create_opcode=[CREATE, CREATE2]. Value transfer gates the new account charge, so a zero value CALL never triggers it. Block header equals one GAS_NEW_ACCOUNT.
  • test_call_value_to_pre_existing_selfdestructed_account, strict header_verify parametrized beneficiary_type=[eoa, contract]. Pre deployed contract runs SELFDESTRUCT, then the orchestrator does a value bearing CALL and a sequence of cold SSTORE probes that make block state gas dominate. Block header gas used equals num_probes * sstore_state_gas exactly. A spurious new account charge on the value bearing CALL would push the header up by that charge.

🔗 Related Issues or PRs

✅ 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).

@kclowes kclowes changed the title Add tests for CALL with value to self-destructed acct 8037: Add tests for CALL with value to self-destructed acct Apr 9, 2026
@kclowes kclowes force-pushed the feat/8037-call-with-value-to-self-destruct branch from 58a639c to d2a6c58 Compare April 9, 2026 17:09
@codecov

codecov Bot commented Apr 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (eips/amsterdam/eip-8037@e723e7d). Learn more about missing BASE report.

Additional details and impacted files
@@                    Coverage Diff                     @@
##             eips/amsterdam/eip-8037    #2646   +/-   ##
==========================================================
  Coverage                           ?   88.18%           
==========================================================
  Files                              ?      524           
  Lines                              ?    31120           
  Branches                           ?     3036           
==========================================================
  Hits                               ?    27444           
  Misses                             ?     3161           
  Partials                           ?      515           
Flag Coverage Δ
unittests 88.18% <ø> (?)

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.

@marioevz marioevz force-pushed the eips/amsterdam/eip-8037 branch from b9f0afa to 23a638d Compare April 9, 2026 18:18
@kclowes kclowes force-pushed the feat/8037-call-with-value-to-self-destruct branch from d2a6c58 to e42ab1f Compare April 9, 2026 20:05
@kclowes kclowes changed the title 8037: Add tests for CALL with value to self-destructed acct feat(tests): EIP 8037 - Add tests for CALL with value to self-destructed acct Apr 9, 2026
@kclowes kclowes added C-feat Category: an improvement or new feature C-eip Category: tracking implementation of an EIP A-test-tests Area: tests for packages/testing labels Apr 9, 2026
@kclowes kclowes force-pushed the feat/8037-call-with-value-to-self-destruct branch from e42ab1f to ef6a264 Compare April 9, 2026 22:27
@kclowes kclowes marked this pull request as ready for review April 9, 2026 22:28
@kclowes kclowes requested a review from spencer-tb April 9, 2026 22:38
@marioevz marioevz force-pushed the eips/amsterdam/eip-8037 branch from 629b34b to 9755dba Compare April 10, 2026 22:19
@kclowes kclowes force-pushed the feat/8037-call-with-value-to-self-destruct branch from ef6a264 to d4ffd74 Compare April 15, 2026 17:23
@felix314159 felix314159 force-pushed the eips/amsterdam/eip-8037 branch from 9755dba to 3e1d7c4 Compare April 16, 2026 10:34
@spencer-tb spencer-tb force-pushed the feat/8037-call-with-value-to-self-destruct branch 2 times, most recently from ba78c62 to 7286786 Compare April 17, 2026 15:07
@spencer-tb spencer-tb changed the title feat(tests): EIP 8037 - Add tests for CALL with value to self-destructed acct feat(tests): EIP-8037 - CALL with value to selfdestructed account Apr 17, 2026
@spencer-tb spencer-tb force-pushed the eips/amsterdam/eip-8037 branch from 3e1d7c4 to 44b47cc Compare April 17, 2026 16:01
@spencer-tb spencer-tb force-pushed the feat/8037-call-with-value-to-self-destruct branch from 7286786 to 5cf982e Compare April 19, 2026 12:31

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

LGTM!

@spencer-tb spencer-tb merged commit ddfdb0d into ethereum:eips/amsterdam/eip-8037 Apr 19, 2026
12 of 15 checks passed
spencer-tb added a commit to spencer-tb/execution-specs that referenced this pull request Apr 19, 2026
…efund

EIP-11532 (merged as PR ethereum#2707) refunds the CREATE's
`GAS_NEW_ACCOUNT` at end-of-tx when the created account is also
destroyed in the same transaction. This broke three tests in
`test_state_gas_call.py` (added by PR ethereum#2646 before ethereum#2707 merged)
that asserted `header.gas_used == new_account_state_gas`; after
the refund `block_state_gas_used` is zero and the header reports
`block_regular` instead.

Affected tests (20 variants):
  test_call_value_to_self_destructed_header_gas_used
  test_call_value_to_self_destructed_burns_value
  test_call_zero_value_to_self_destructed_same_tx_account

The original discriminator intent (no spurious GAS_NEW_ACCOUNT
charge on the CALL) still holds: a buggy extra charge would push
`state_gas_used` to 131,488 and bump the header above
`new_account_state_gas`. Pin the expected `header.gas_used` to
the empirical `block_regular` per variant, with a build-time
`assert expected < new_account_state_gas` so the
spurious-charge discriminator stays sharp.
spencer-tb added a commit to spencer-tb/execution-specs that referenced this pull request Apr 20, 2026
…efund

EIP-11532 (merged as PR ethereum#2707) refunds the CREATE's
`GAS_NEW_ACCOUNT` at end-of-tx when the created account is also
destroyed in the same transaction. This broke three tests in
`test_state_gas_call.py` (added by PR ethereum#2646 before ethereum#2707 merged)
that asserted `header.gas_used == new_account_state_gas`; after
the refund `block_state_gas_used` is zero and the header reports
`block_regular` instead.

Affected tests (20 variants):
  test_call_value_to_self_destructed_header_gas_used
  test_call_value_to_self_destructed_burns_value
  test_call_zero_value_to_self_destructed_same_tx_account

The original discriminator intent (no spurious GAS_NEW_ACCOUNT
charge on the CALL) still holds: a buggy extra charge would push
`state_gas_used` to 131,488 and bump the header above
`new_account_state_gas`. Pin the expected `header.gas_used` to
the empirical `block_regular` per variant, with a build-time
`assert expected < new_account_state_gas` so the
spurious-charge discriminator stays sharp.
spencer-tb added a commit to spencer-tb/execution-specs that referenced this pull request Apr 20, 2026
EIP-11532 (merged as ethereum#2707) refunds the CREATE's `GAS_NEW_ACCOUNT`
at end-of-tx when the created account is also destroyed in the same
transaction. Three tests in `test_state_gas_call.py` (added by ethereum#2646
before ethereum#2707 merged) asserted `header.gas_used == new_account_state_gas`;
after the refund `block_state_gas_used` is zero, so the header reports
`block_regular` instead and those assertions fail.

Drop the brittle `header_verify` from the three tests. Remaining
post-state checks still validate the semantics each test cares about.

Affected (20 variants across `blockchain_test` and `blockchain_test_engine`):
  test_call_value_to_self_destructed_header_gas_used
  test_call_value_to_self_destructed_burns_value
  test_call_zero_value_to_self_destructed_same_tx_account
marioevz pushed a commit that referenced this pull request Apr 20, 2026
)

Co-authored-by: spencer-tb <spencer.tb@ethereum.org>
spencer-tb added a commit that referenced this pull request Apr 20, 2026
)

Co-authored-by: spencer-tb <spencer.tb@ethereum.org>
spencer-tb added a commit to spencer-tb/execution-specs that referenced this pull request Apr 21, 2026
spencer-tb added a commit to spencer-tb/execution-specs that referenced this pull request Apr 21, 2026
spencer-tb added a commit that referenced this pull request Apr 21, 2026
)

Co-authored-by: spencer-tb <spencer.tb@ethereum.org>
@jangko jangko mentioned this pull request Apr 21, 2026
9 tasks
@kclowes kclowes deleted the feat/8037-call-with-value-to-self-destruct branch April 29, 2026 03:19
fselmo pushed a commit that referenced this pull request May 5, 2026
)

Co-authored-by: spencer-tb <spencer.tb@ethereum.org>
spencer-tb added a commit to spencer-tb/execution-specs that referenced this pull request May 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-test-tests Area: tests for packages/testing C-eip Category: tracking implementation of an EIP C-feat Category: an improvement or new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants