Conversation
zzzckck
previously approved these changes
Jan 17, 2024
zzzckck
approved these changes
Jan 17, 2024
This was referenced Apr 8, 2024
This was referenced May 9, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
BEP-344: Implement EIP-6780: SELFDESTRUCT only in same transaction
1. Summary
As part of Cancun upgrade, Implement EIP-6780: SELFDESTRUCT only in same transaction is required to be implemented to BSC.
2. Abstract
This EIP changes the functionality of the
SELFDESTRUCTopcode. The new functionality will be only to send all Ether in the account to the target, except that the current behaviour is preserved whenSELFDESTRUCTis called in the same transaction a contract was created.3. Motivation
The
SELFDESTRUCTopcode requires large changes to the state of an account, in particular removing all code and storage. This will not be possible in the future with Verkle trees: Each account will be stored in many different account keys, which will not be obviously connected to the root account.This EIP implements this change. Applications that only use
SELFDESTRUCTto retrieve funds will still work. Applications that only useSELFDESTRUCTin the same transaction as they created a contract will also continue to work without any changes.4. Specification
The behaviour of
SELFDESTRUCTis changed in the following way:When
SELFDESTRUCTis executed in a transaction that is not the same as the contract callingSELFDESTRUCTwas created:SELFDESTRUCTdoes not delete any data (including storage keys, code, or the account itself).SELFDESTRUCTtransfers the entire account balance to the target.SELFDESTRUCTthere is no net change in balances. Unlike the prior specification, Ether will not be burnt in this case.SELFDESTRUCTremain unchanged.When
SELFDESTRUCTis executed in the same transaction as the contract was created:SELFDESTRUCTcontinues to behave as it did prior to this EIP, this includes the following actionsSELFDESTRUCTdeletes data as previously specified.SELFDESTRUCTtransfers the entire account balance to the targetSELFDESTRUCTis set to0.SELFDESTRUCTthat Ether will be burnt.SELFDESTRUCTremain unchanged.A contract is considered created at the beginning of a create transaction or when a CREATE series operation begins execution (CREATE, CREATE2, and other operations that deploy contracts in the future). If a balance exists at the contract's new address it is still considered to be a contract creation.
The
SELFDESTRUCTopcode remains deprecated as specified in EIP-6049. Any use in newly deployed contracts is strongly discouraged even if this new behaviour is taken into account, and future changes to the EVM might further reduce the functionality of the opcode.5. Rationale
Getting rid of the
SELFDESTRUCTopcode has been considered in the past, and there are currently no strong reasons to use it. This EIP implements a behavior that will attempt to leave some common uses ofSELFDESTRUCTworking, while reducing the complexity of the change on EVM implementations that would come from contract versioning.Handling the account creation and contract creation as two distinct and possibly separate events is needed for use cases such as counterfactual accounts. By allowing the
SELFDESTRUCTto delete the account at contract creation time it will not result in stubs of counterfactually instantiated contracts that never had any on-chain state other than a balance prior to the contract creation. These accounts would never have any storage and thus the trie updates to delete the account would be limited to the account node, which is the same impact a regular transfer of ether would have.6. Backwards Compatibility
This EIP requires a hard fork, since it modifies consensus rules.
Contracts that depended on re-deploying contracts at the same address using
CREATE2(after aSELFDESTRUCT) will no longer function properly if the created contract does not callSELFDESTRUCTwithin the same transaction.Previously it was possible to burn ether by calling
SELFDESTRUCTtargeting the executing contract as the beneficiary. If the contract existed prior to the transaction the ether will not be burned. If the contract was newly created in the transaction the ether will be burned, as before.7. Security Considerations
The following applications of
SELFDESTRUCTwill be broken and applications that use it in this way are not safe anymore:Where
CREATE2is used to redeploy a contract in the same place in order to make a contract upgradable. This is not supported anymore and ERC-2535 or other types of proxy contracts should be used instead.Where a contract depended on burning Ether via a
SELFDESTRUCTwith the contract as beneficiary, in a contract not created within the same transaction.8. License
The content is licensed under CC0.
9. Reference
Guillaume Ballet (@gballet), Vitalik Buterin (@vbuterin), Dankrad Feist (@dankrad), "EIP-6780: SELFDESTRUCT only in same transaction [DRAFT]," Ethereum Improvement Proposals, no. 6780, March 2023. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-6780.