Skip to content

Commit d21656a

Browse files
authored
Add EIP: Revert creation in case of non-empty storage
Merged by EIP-Bot.
1 parent 33dc682 commit d21656a

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

EIPS/eip-7610.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
eip: 7610
3+
title: Revert creation in case of non-empty storage
4+
description: Revert contract creation if address already has the non-empty storage
5+
author: Gary Rong (@rjl493456442), Martin Holst Swende (@holiman)
6+
discussions-to: https://ethereum-magicians.org/t/eip-revert-creation-in-case-of-non-empty-storage/18452
7+
status: Draft
8+
type: Standards Track
9+
category: Core
10+
created: 2024-02-02
11+
---
12+
13+
## Abstract
14+
15+
This EIP causes contract creation to throw an error when attempted at an address with pre-existing storage.
16+
17+
## Specification
18+
19+
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119 and RFC 8174.
20+
21+
If a contract creation is attempted due to a creation transaction, the `CREATE` opcode, the `CREATE2` opcode, or any other reason, and the destination address already has either a nonzero nonce, a nonzero code length, or non-empty storage, then the creation MUST throw as if the first byte in the init code were an invalid opcode. This change MUST apply retroactively for all existing blocks.
22+
23+
This EIP amends [EIP-684](./eip-684.md) with one extra condition, requiring empty storage for contract deployment.
24+
25+
## Rationale
26+
27+
EIP-684 defines two conditions for contract deployment: the destination address must have zero nonce and zero code length. Unfortunately, this is not sufficient. Before [EIP-158](./eip-158.md) was applied, the nonce of a newly deployed contract remained set to zero. Therefore, it was entirely possible to create a contract with a zero nonce and zero code length but with non-empty storage, if slots were set in the constructor. There exists 28 such contracts on Ethereum mainnet at this time.
28+
29+
As one of the core tenets of smart contracts is that its code will not change, even if the code is zero length. The contract creation must be rejected in such instanace.
30+
31+
## Backwards Compatibility
32+
33+
This is an execution layer upgrade, and so it requires a hard fork.
34+
35+
## Test Cases
36+
37+
There exists quite a number of tests in the ethereum tests repo as well as in the execution spec tests, which test the scenario of deployment to targets with non-empty storage. These tests have been considered problematic in the past; Reth and EELS both intentionally implement a version of the account reset solely to pass the tests. Py-evm declared the situation impossible and never implemented account reset.
38+
39+
Refilling the existing tests will provide sufficient coverage for this EIP.
40+
41+
## Security Considerations
42+
43+
This EIP is a security upgrade: it enforces the imutability of deployed code.
44+
45+
## Copyright
46+
47+
Copyright and related rights waived via [CC0](../LICENSE.md).

0 commit comments

Comments
 (0)