Skip to content

Conversation

raxhvl
Copy link
Member

@raxhvl raxhvl commented Sep 16, 2025

🗒️ Description

Test case effects of SELFDESTRUCT on EIP-7928.

cc: @nerolation bal_changes for the self-destructing contract is captured too.

Additional changes

  • Validate not just ordering but duplicate entries in the BAL coming from EELS / t8n
  • Restrict extra keys in the models used for BALs so we fail on unexpected kwargs used

✅ Checklist

  • All: Ran fast tox checks to avoid unnecessary CI fails, see also Code Standards and Enabling Pre-commit Checks:
    uvx --with=tox-uv tox -e lint,typecheck,spellcheck,markdownlint
  • All: PR title adheres to the repo standard - it will be used as the squash commit message and should start type(scope):.
  • All: Set appropriate labels for the changes (only maintainers can apply labels).

@raxhvl raxhvl added scope:tests Scope: Changes EL client test cases in `./tests` type:test Type: Add/refactor fw unit tests; no fw or el client test case changes labels Sep 16, 2025
@raxhvl raxhvl requested a review from fselmo September 16, 2025 09:56
@raxhvl raxhvl marked this pull request as ready for review September 16, 2025 09:56
@raxhvl raxhvl self-assigned this Sep 17, 2025
@raxhvl raxhvl force-pushed the feat/eip-7928/test-self-destruct branch 2 times, most recently from 73e22e4 to 296091d Compare September 19, 2025 09:20
Copy link
Collaborator

@fselmo fselmo left a comment

Choose a reason for hiding this comment

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

Lgtm overall, thanks for getting this in 👌🏼. I left some comments to think about but also, I don't expect selfdestruct tests to grow too large. I don't think these deserve their own file for this reason, please correct me if I'm wrong though. Perhaps we should move these into the positive (err... non-invalid) test cases for now instead of their own file. Thoughts?

@fselmo fselmo force-pushed the feat/eip-7928/test-self-destruct branch from 296091d to a3c2f1f Compare September 22, 2025 16:33
@fselmo

This comment was marked as resolved.

@raxhvl
Copy link
Member Author

raxhvl commented Sep 22, 2025

re: creating a separate file for this test

This is purely done to avoid conflicts while I work on these PRs in parallel (I have done the same in other PRs too). Once all PRs are merged, we could group them. Let me know if you want me to move them now.

@fselmo
Copy link
Collaborator

fselmo commented Sep 22, 2025

This is purely done to avoid conflicts while I work on these PRs in parallel (I have done the same in other PRs too). Once all PRs are merged, we could group them. Let me know if you want me to move them now.

Oh I see. I wouldn't think it's difficult to rebase if these are standalone cases. It would be better to PR them to the appropriate place, but if that's messy I suppose that's fine. Don't let this be a blocker at all.

@raxhvl

This comment was marked as resolved.

@nerolation

This comment was marked as resolved.

@raxhvl

This comment was marked as resolved.

@nerolation

This comment was marked as resolved.

@raxhvl

This comment was marked as resolved.

@nerolation

This comment was marked as resolved.

@nerolation

This comment was marked as resolved.

@raxhvl

This comment was marked as resolved.

@raxhvl
Copy link
Member Author

raxhvl commented Sep 23, 2025

Just so you are in the loop @fselmo

Self destructs will now include an address with postNonce=0 and newCode=0x. The rationale is that setting post nonce to 0 is effectively an account reset operation, and no other operation except SELFDESTRUCT should be able to do it.

@fselmo
Copy link
Collaborator

fselmo commented Sep 23, 2025

@nerolation @raxhvl this should be updated in the EIP specifications, right? Anyone working on that?

@nerolation
Copy link
Contributor

Yeah on it!

Copy link
Collaborator

@fselmo fselmo left a comment

Choose a reason for hiding this comment

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

LGTM! We should move the test into test_block_access_lists.py before merging since self destruct cases shouldn't need a standalone file. I also updated the eels resolutions to point to the latest specs commit for Toni's changes that were merged in.

@raxhvl

This comment was marked as resolved.

@nerolation
Copy link
Contributor

Will fix it - thanks!

@fselmo fselmo force-pushed the feat/eip-7928/test-self-destruct branch from 88370ff to 59b2dc7 Compare September 23, 2025 17:54
fselmo and others added 16 commits September 28, 2025 18:05
Co-authored-by: felipe <[email protected]>
- Add a parametrized case for pre-funded selfdestruct account. In
  this case, the account was funded before the self-destruct, so
  we do record the balance post-state as being `0` since there is
  an actual balance change between pre-state and post-state.

- The case where a same-transaction selfdestruct account was not
  pre-funded, there is no net balance change between pre-state and
  post-state so we don't record any balance change in the BAL.
@fselmo fselmo force-pushed the feat/eip-7928/test-self-destruct branch from 7a01039 to 366e454 Compare September 29, 2025 00:07
@fselmo
Copy link
Collaborator

fselmo commented Sep 29, 2025

@raxhvl... @nerolation and I worked on self destruct back and forth some at the end of last week to get the specs ironed out and I added the specific case of the pre-funded self-destruct account where we want to record the balance change as 0 in the end. I cherry picked this here.

I also pointed to the latest commit in the spec for the resolver. All the tests are currently filling here now.

I think this is good to go? Let me know if we're missing anything 👀

@raxhvl
Copy link
Member Author

raxhvl commented Sep 29, 2025

Thanks @fselmo I made the following changes

  1. parameterize pre_funded separately from self_destruct_in_same_tx to get better test coverage for both cases
  2. Extend the self destruct bytecode to include storage operation (read and write)

@nerolation Here is the impact on specs

  1. If the account has been prefunded before self destruct tx (sending ether to a create 2 tx before deploying it) then self destruct will include a balance_change -> 0

@raxhvl

This comment was marked as resolved.

* Add more complex selfdestruct tests

* Add tests for EIP-7928 around precompiles
@fselmo
Copy link
Collaborator

fselmo commented Sep 29, 2025

Depends on fselmo/execution-specs#13

I commented on the issue here, the tests here were not expecting the right things. This does fill appropriately now (fixed here. I think this PR is good to be merged.

@fselmo fselmo force-pushed the feat/eip-7928/test-self-destruct branch from dae8940 to 81fcca4 Compare September 29, 2025 17:47
@fselmo fselmo force-pushed the feat/eip-7928/test-self-destruct branch from 81fcca4 to ac1e471 Compare September 29, 2025 17:53
Copy link
Contributor

@spencer-tb spencer-tb left a comment

Choose a reason for hiding this comment

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

LGTM! Couple small comments. No blockers. Feel free to merge :D

@fselmo fselmo merged commit 20c1b63 into main Sep 29, 2025
16 checks passed
@fselmo fselmo deleted the feat/eip-7928/test-self-destruct branch September 29, 2025 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope:tests Scope: Changes EL client test cases in `./tests` type:test Type: Add/refactor fw unit tests; no fw or el client test case changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants