Skip to content

Conversation

@RomarQ
Copy link
Collaborator

@RomarQ RomarQ commented Jul 22, 2025

What does it do?

Adds a test to ensure that when a contract is created with CREATE2 and Self Destructed in the same transaction, it can be created again.

The behaviour of SELFDESTRUCT was changed in Cancun hard-fork, where it will recover all funds to the target but not delete the account, except when called in the same transaction as creation.

References:
https://eips.ethereum.org/EIPS/eip-6780

@RomarQ RomarQ marked this pull request as ready for review July 22, 2025 11:30
@RomarQ RomarQ requested a review from sorpaas as a code owner July 22, 2025 11:30
T::AccountProvider::remove_account(&account_id);
}
let account_id = T::AddressMapping::into_account_id(*address);
T::AccountProvider::remove_account(&account_id);
Copy link
Member

Choose a reason for hiding this comment

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

What's the reason to remove the if branch?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

When we destroy the contract inside the constructor, the AccountCode is not yet set.

@sorpaas
Copy link
Member

sorpaas commented Jul 24, 2025

Is EIP-6780 implemented at this moment? From my look, it doesn't seem so yet:

for address in &state.substate.deletes {

@RomarQ
Copy link
Collaborator Author

RomarQ commented Jul 24, 2025

Is EIP-6780 implemented at this moment? From my look, it doesn't seem so yet:

for address in &state.substate.deletes {

It was added in this PR: #1588

Copy link
Member

@sorpaas sorpaas left a comment

Choose a reason for hiding this comment

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

In #1588 there's one scenario I'm not sure if it's considered -- a contract that is being created can still write a large number of storage values, and upon self-destruct, clear_suffix will still need to delete a lot of values from the changeset.

But I think this is safe as this is purely a in-memory operation with no merkle involved.

@sorpaas sorpaas merged commit f1ae726 into master Jul 28, 2025
4 checks passed
@sorpaas sorpaas deleted the rq/fix-remove_account branch July 28, 2025 00:30
l0r1s pushed a commit to opentensor/frontier that referenced this pull request Aug 6, 2025
* test: self-destruct functionality after cancun upgrade

* fix self-destruct logic
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.

3 participants