Skip to content

feat(spec-spec, tests): Implement eip-8246 and testing scenario#2842

Open
LouisTsai-Csie wants to merge 6 commits into
ethereum:eips/amsterdam/eip-8246from
LouisTsai-Csie:implement-eip-8246
Open

feat(spec-spec, tests): Implement eip-8246 and testing scenario#2842
LouisTsai-Csie wants to merge 6 commits into
ethereum:eips/amsterdam/eip-8246from
LouisTsai-Csie:implement-eip-8246

Conversation

@LouisTsai-Csie
Copy link
Copy Markdown
Collaborator

@LouisTsai-Csie LouisTsai-Csie commented May 12, 2026

🗒️ Description

Implement EIP-8246: https://forkcast.org/eips/8246

🔗 Related Issues or PRs

issue #2821

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

Put a link to a cute animal picture inside the parenthesis-->

@codecov
Copy link
Copy Markdown

codecov Bot commented May 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.01%. Comparing base (87c52b4) to head (b510ef9).

Additional details and impacted files
@@                   Coverage Diff                    @@
##           eips/amsterdam/eip-8246    #2842   +/-   ##
========================================================
  Coverage                    90.01%   90.01%           
========================================================
  Files                          539      539           
  Lines                        32618    32623    +5     
  Branches                      3030     3030           
========================================================
+ Hits                         29361    29366    +5     
  Misses                        2699     2699           
  Partials                       558      558           
Flag Coverage Δ
unittests 90.01% <100.00%> (+<0.01%) ⬆️

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 requested a review from gurukamath May 13, 2026 21:52
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.

Looks good overall. I think we need to take care of failing tests in ./tests/cancun/eip6780_selfdestruct before eventually merging into forks/amsterdam (if this gets included in a devnet).

Comment thread tests/amsterdam/eip8246_selfdestruct_no_burn/test_selfdestruct_no_burn.py Outdated
Comment thread tests/amsterdam/eip8246_selfdestruct_no_burn/test_selfdestruct_no_burn.py Outdated
Comment thread src/ethereum/forks/amsterdam/state_tracker.py Outdated
@LouisTsai-Csie LouisTsai-Csie marked this pull request as ready for review May 14, 2026 16:08
Comment thread src/ethereum/forks/amsterdam/state_tracker.py Outdated
Comment thread src/ethereum/forks/amsterdam/state_tracker.py Outdated
Comment thread src/ethereum/forks/amsterdam/state_tracker.py Outdated
Comment thread src/ethereum/forks/amsterdam/fork.py Outdated
for address in tx_output.accounts_to_delete:
destroy_account(tx_state, address)
destroy_storage(tx_state, address)
modify_state(tx_state, address, preserve_account_balance)
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.

If modify_state ends up calling destroy_account (zero-balance case), destroy_storage runs twice. Not a huge issue but something to be kept in mind

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I will keep it as is, but let me know if you have any suggestion!

Copy link
Copy Markdown
Contributor

@gurukamath gurukamath May 20, 2026

Choose a reason for hiding this comment

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

Why not just call destroy_storage in convert_to_balance_only_account like destroy_account currently does? That way, the diff in fork.py looks cleaner as well. Otherwise, this looks good to me.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Great idea, i will add a new commit.

@marioevz
Copy link
Copy Markdown
Member

Checking the list of failing tests for the current fill in Amsterdam, they all look like expected failures because of the behavior change.

I recommend we track these in the EIP tracking issue #2821, tackle them in separate PRs to merge to eips/amsterdam/eip-8246, and merge this PR as is after addressing the spec comments.

@LouisTsai-Csie LouisTsai-Csie marked this pull request as draft May 19, 2026 09:02
Comment thread tests/cancun/eip6780_selfdestruct/test_selfdestruct.py Outdated
@LouisTsai-Csie LouisTsai-Csie marked this pull request as ready for review May 20, 2026 14:24
@LouisTsai-Csie
Copy link
Copy Markdown
Collaborator Author

LouisTsai-Csie commented May 20, 2026

@marioevz @gurukamath I've updated according to the comment. Now the PR contains spec & test for eip-8246 and refactor the failing legacy tests. Please take a look!

I will stop adding new tests here, and wait for the PR to merge first.

Copy link
Copy Markdown
Contributor

@SamWilsn SamWilsn left a comment

Choose a reason for hiding this comment

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

A quick review of only the spec related changes.

Comment on lines +434 to +436
Invoked by ``modify_state`` (and the coinbase fee-credit path) to
clean up an account that has become empty (zero nonce, empty
code, and zero balance) so it does not appear in the post-state.
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.

There's something funky about this. I've opened #2908.

set_account(tx_state, address, None)


def convert_to_balance_only_account(account: Account) -> None:
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.

This function name needs work. The word "convert" implies that something is changing about the kind of account, not about its contents. For example, you "convert a gas-powered car to electric", but you don't "convert a dirty car to clean" when you go through a car wash.

convert_to_balance_only_account implies that the account is changing "kinds" from a regular account to one that can only have a balance. As far as I am aware, there's nothing special about a balance only account. It's equivalent to an account that has received ether but has not sent any transactions.

Some ideas:

  • reset_account (pairs nicely with destroy_account, but also might be confusing)
  • make_account_deployable (this is more semantically meaningful I think, but a mouthful)
  • clear_account_nonce_and_code_hash (says what it does, but not what it intends; might make future refactors more difficult)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I applied Guru's feedback by moving destroy_storage into the convert_to_balance_only_account function, and your suggestion here. Now the refactored function becomes:

def convert_to_balance_only_account(
    tx_state: TransactionState, address: Address
) -> None:
    def clear_account(account: Account) -> None:
        account.nonce = Uint(0)
        account.code_hash = EMPTY_CODE_HASH
    destroy_storage(tx_state, address)
    modify_state(tx_state, address, clear_account)

Since it now clears storage, nonce, and code hash, the name clear_account_nonce_and_code_hash no longer fits, while reset_accounts is a bit confusing?

I would support make_account_deployable compared to other two suggestions, i also come up with:

  • nullify_account_code_storage_nonce
  • strip_to_balance_only

What do you think?

set_account(tx_state, address, None)


def convert_to_balance_only_account(account: Account) -> None:
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.

The pattern for other functions in this file is to create a function that operates on a frozen account, that defines an nested function to apply the transformation. Is there a reason this function breaks from that pattern?

If not, I'd suggest something like:

def convert_to_balance_only_account(tx_state: TransactionState, ​​address: Address) -> None:
    def clear_account(account: Account) -> None:
        account.nonce = Uint(0)
        account.code_hash = EMPTY_CODE_HASH

    modify_state(tx_state, address, clear_account)

Copy link
Copy Markdown
Contributor

@Carsons-Eels Carsons-Eels left a comment

Choose a reason for hiding this comment

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

I don't see anything wrong with the spec code that hasn't been commented on, will review the tests tomorrow. 🚀

Comment thread src/ethereum/forks/amsterdam/fork.py Outdated
Comment on lines +1093 to +1094
destroy_storage(tx_state, address)
modify_state(tx_state, address, convert_to_balance_only_account)
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.

Might be worth a comment here noting that the explicit destroy_storage exists for EIP-7928 block-access-list completeness...

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I dont fully understand, could you expand more on this?

I applied Guru and Sam's feedback on the refactor, would this break anything?

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.

5 participants