Skip to content

feat(tests): port TouchToEmptyAccountRevert legacy tests#2388

Draft
chfast wants to merge 1 commit intoethereum:forks/amsterdamfrom
chfast:eip161-touch-empty
Draft

feat(tests): port TouchToEmptyAccountRevert legacy tests#2388
chfast wants to merge 1 commit intoethereum:forks/amsterdamfrom
chfast:eip161-touch-empty

Conversation

@chfast
Copy link
Copy Markdown
Member

@chfast chfast commented Mar 3, 2026

🗒️ Description

  • Port 6 legacy TouchToEmptyAccountRevert static tests for EIP-161 empty account cleanup
  • 3 test functions × 2 parametrized target balance variants (empty/funded):
    • test_touch_empty_account_call_chain: zero-value CALL through a call chain
    • test_touch_empty_account_call_then_oog: direct CALL + OOG sub-call
    • test_touch_empty_account_selfdestruct_then_oog: SELFDESTRUCT touch + OOG sub-call
  • Valid from Istanbul to London (EIP-161 applies, pre-EIP-1559)

🔗 Related Issues or PRs

Closes #2174

✅ Checklist

  • All: Ran fast tox checks to avoid unnecessary CI fails, see also Code Standards and Enabling Pre-commit Checks:
    uvx tox -e 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).
  • Tests: Ran mkdocs serve locally and verified the auto-generated docs for new tests in the Test Case Reference are correctly formatted.
  • Tests: For PRs implementing a missed test case, update the post-mortem document to add an entry the list.
  • Ported Tests: All converted JSON/YML tests from ethereum/tests or tests/static have been assigned @ported_from marker.

Cute Animal Picture

🪱

@chfast chfast marked this pull request as draft March 3, 2026 08:09
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.73%. Comparing base (446eabf) to head (97b54c0).
⚠️ Report is 1 commits behind head on forks/amsterdam.

Additional details and impacted files
@@               Coverage Diff                @@
##           forks/amsterdam    #2388   +/-   ##
================================================
  Coverage            85.73%   85.73%           
================================================
  Files                  599      599           
  Lines                36916    36916           
  Branches              3771     3771           
================================================
  Hits                 31650    31650           
  Misses                4604     4604           
  Partials               662      662           
Flag Coverage Δ
unittests 85.73% <ø> (ø)

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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@felix314159
Copy link
Copy Markdown
Contributor

Ready for review or still in draft?

@chfast chfast force-pushed the eip161-touch-empty branch 3 times, most recently from ec18c9d to a58ef7e Compare March 5, 2026 15:35
@chfast chfast marked this pull request as ready for review March 5, 2026 18:51
@chfast
Copy link
Copy Markdown
Member Author

chfast commented Mar 5, 2026

Ready for review or still in draft?

Ready now.

Copy link
Copy Markdown
Member

@marioevz marioevz left a comment

Choose a reason for hiding this comment

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

Some comments, thanks!

An empty target is deleted; a funded target survives.
"""
storage = Storage()
target = pre.empty_account()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm now thinking that this empty_account name could be misleading. We are not placing an account with all fields set to zero in the pre-state, as one might expect an empty account to be, rather the returned address is an address that is nowhere in the pre-state.

Perhaps pre.nonexistent_address() is a better name.

I don't think we currently can put an actual empty account in the pre-state, but after looking at the original static tests, it doesn't try to put an empty account either, so it might be ok?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It looks I moved too fast with these tests, sorry. The main point I need precise this scenario which is not covered in evmone by EEST: there is an empty account in the pre-state, it is touched during execution, then this touch is reverted and the account is not deleted in the end.

I identified only this legacy test (from legacytests repo) coverts it. Now I understand why: this test is filled for Paris+ only in EEST.

Can I create completely empty account in the pre-state pre-Paris?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

So, afaik:

  • The test framework has a check to disallow empty accounts in the pre-allocation (but we can workaround this depending on the next point)
  • I'm not sure if the same check exists on the EELS side in one or multiple forks, perhaps @SamWilsn or @gurukamath know
  • If not possible, this might be one reason why we would not be able to delete legacy-tests, cc @danceratopz

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I will investigate this.

target = pre.empty_account()

if target_balance > 0:
pre[target] = Account(balance=target_balance)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Need to add pytest.mark.pre_alloc_mutable due to this line.

@marioevz
Copy link
Copy Markdown
Member

marioevz commented Mar 6, 2026

Another comment is that these files should be deleted in this PR:

tests/static/state_tests/stRevertTest/TouchToEmptyAccountRevert2_ParisFiller.json
tests/static/state_tests/stRevertTest/TouchToEmptyAccountRevert3_ParisFiller.json
tests/static/state_tests/stRevertTest/TouchToEmptyAccountRevert_ParisFiller.json

@marioevz marioevz self-assigned this Mar 6, 2026
@chfast chfast force-pushed the eip161-touch-empty branch 3 times, most recently from 2bd4c6a to d557a11 Compare March 6, 2026 16:13
@chfast chfast marked this pull request as draft March 6, 2026 16:14
@chfast chfast force-pushed the eip161-touch-empty branch from d557a11 to 4da5eea Compare March 6, 2026 16:20
@chfast chfast force-pushed the eip161-touch-empty branch from 4da5eea to 97b54c0 Compare March 6, 2026 16:22
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.

Add tests for "reverted touch of empty account"

3 participants