Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update EIP-6780: Add clarifications to EIP-6780 #7308

Merged
merged 9 commits into from
Sep 10, 2023
33 changes: 21 additions & 12 deletions EIPS/eip-6780.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,37 +27,46 @@ The behaviour of `SELFDESTRUCT` is changed in the following way:

1. When `SELFDESTRUCT` is executed in a transaction that is not the same as the contract calling `SELFDESTRUCT` was created:

- `SELFDESTRUCT` does not delete any storage keys or code
- `SELFDESTRUCT` transfers the entire account balance to the target.
- No refund is given, as per [EIP-3529](./eip-3529.md).
- [EIP-2929](./eip-2929.md)'s rules regarding `SELFDESTRUCT` remain unchanged.
- The current execution frame halts.
- `SELFDESTRUCT` does not delete any data (including storage keys, code, or the account itself).
- `SELFDESTRUCT` transfers the entire account balance to the target.
- Note that no refund is given since [EIP-3529](./eip-3529.md).
- Note that the rules of [EIP-2929](./eip-2929.md) regarding `SELFDESTRUCT` remain unchanged.

2. When `SELFDESTRUCT` is executed in the same transaction as the contract was created:

- `SELFDESTRUCT` continues to behave as originally, i.e. deletes all storage keys and the account itself.
- Subsequently, the account will behave like exactly like an empty account, both in the same transaction and in all later ones
- Transfer the account balance to the target **and** set account balance to `0.`
- Note that no refund is given since [EIP-3529](./eip-3529.md).
- Note that the rules of [EIP-2929](./eip-2929.md) regarding `SELFDESTRUCT` remain unchanged.
- Note that when verkle tries are implemented on Ethereum, the cleared storage will be marked as having been written before but empty. This leads to no observable differences in EVM execution, but a contract having been created and deleted will lead to different state roots compared to the action not happening.
- `SELFDESTRUCT` continues to behave as originally, i.e. deletes all storage keys and the account itself, and execution halts.
- Subsequently, the account will behave exactly like an empty account, both in the same transaction and in all later ones.
- Transfer the account balance to the target **and** set account balance to `0`.
shemnon marked this conversation as resolved.
Show resolved Hide resolved
- Note that no refund is given since [EIP-3529](./eip-3529.md).
- Note that the rules of [EIP-2929](./eip-2929.md) regarding `SELFDESTRUCT` remain unchanged.
- Note that when verkle tries are implemented on Ethereum, the cleared storage will be marked as having been written before but empty. This leads to no observable differences in EVM execution, but a contract having been created and deleted will lead to different state roots compared to the action not happening.

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 `SELFDESTRUCT` opcode remains deprecated as specified in [EIP-6049](./eip-6049.md). 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.

## Rationale

Getting rid of the `SELFDESTRUCT` opcode 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 of `SELFDESTRUCT` working, while reducing the complexity of the change on EVM implementations that would come from contract versioning. A further option that was considered was to just remove storage clearing from `SELFDESTRUCT` in [EIP-6046](./eip-6046.md) while preserving removal of contracts, however this is not safe because existing contracts rely on storage being empty when they are deployed.

Removing "hollow" accounts at addresses that are not externally owned and that only held a balance prior to contract creation provides a better user experience than leaving an account with a non-zero nonce, possible storage, and no code to access that storage.
shemnon marked this conversation as resolved.
Show resolved Hide resolved

## Backwards Compatibility

This EIP requires a hard fork, since it modifies consensus rules.

The only breaking change occurs when a contract is re-created at the same address using `CREATE2` (after a `SELFDESTRUCT`), where the `SELFDESTRUCT` is executed in a transaction that's different from the one that originally creates the contract.
Contracts that depended on re-deploying contracts at the same address using `CREATE2` (after a `SELFDESTRUCT`) will no longer function properly if the created contract does not call `SELFDESTRUCT` within the current transaction.
shemnon marked this conversation as resolved.
Show resolved Hide resolved

Previously it was possible to burn ether by calling `SELFDESTRUCT` targeting 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.
shemnon marked this conversation as resolved.
Show resolved Hide resolved
shemnon marked this conversation as resolved.
Show resolved Hide resolved

## Security Considerations

The following applications of `SELFDESTRUCT` will be broken and applications that use it in this way are not safe anymore:

2. Where `CREATE2` is used to redeploy a contract in the same place in order to make a contract upgradable. This is not supported anymore and [ERC-2535](./eip-2535.md) or other types of proxy contracts should be used instead.
1. Where `CREATE2` is used to redeploy a contract in the same place in order to make a contract upgradable. This is not supported anymore and [ERC-2535](./eip-2535.md) or other types of proxy contracts should be used instead.

2. Where a contract depended on burning ether via a `SELFDESTRUCT` with the contract as beneficiary, in a contract not created within the transaction.
shemnon marked this conversation as resolved.
Show resolved Hide resolved

## Copyright

Expand Down