EIP-2029 State Rent A: State Counter Contract (State Rent A - State counters contract)
No call decision · Scaling & data · EIP status Stagnant · created 2019-05-15
Deploy a special contract at the same address on every network to store a state counter such as the total transaction count, and use it as the nonce for evicted accounts when they are revived, to prevent replay attacks.
Why it is needed
Ethereum state has no dedicated space to record values such as the total transaction count or the total account count. This becomes a problem under the State Rent roadmap. Once State Rent is introduced, accounts that have gone unused for a long time will be evicted from state, and if someone later sends ether to that address, the account is recreated starting from nonce 0. In that case, a replay attack becomes possible, in which transactions previously sent by that account are resent. To prevent this, the nonce of the newly created account must be filled not with 0 but with a value such as the total number of transactions that have occurred network-wide up to that point. To do that, a place to record such a counter is needed first.
What changes
Today
- Ethereum state has no dedicated space to record counters such as the total transaction count or the total account count.
- An account that was evicted under State Rent and later revived by receiving ether has its nonce start from 0, which risks replaying its past transactions.
After EIP-2029
- A counter contract is deployed at the same address on every network using CREATE2.
- The Ethereum protocol writes counter values such as the total transaction count into this contract's storage.
- The nonce of newly created non-contract accounts is filled with this counter value to prevent replay attacks.
Who is affected
- Client teams: Logic must be implemented to maintain the counter value and to give protocol-level special treatment to the contract at this specific address.
- Validators/nodes: The way the state root is constructed does not change, but updating the counter is added to the state transition rules.
- Wallet & app developers: Once State Rent and the account eviction/revival scheme are introduced, the way nonces are handled may change.
- Ordinary users: This proposal by itself produces no immediately noticeable change; it is groundwork for the larger State Rent roadmap.
In depth
Contract code and behavior
The bytecode of the deployed contract is 0x60 0x20 0x60 0x00 0x80 0x80 0x35 0x54 0x90 0x52 0xF3, which in assembly is PUSH1 32 PUSH1 0 DUP1 DUP1 CALLDATALOAD SLOAD SWAP1 MSTORE RETURN. It is a simple lookup contract that takes a single 32-byte argument x, looks up the value of slot x in its own storage, and returns it as is.
Same address on every network via CREATE2
This contract is deployed before block A using the CREATE2 opcode, so that it has the same address on any network. The implementation assumes a transaction that anyone can send from an arbitrary Ethereum address, which triggers the deployment of this contract.
Purpose: nonce-based replay protection
The most important counter to be used is the total number of transactions that have occurred so far. This value is used to fill the nonce of newly created non-contract accounts. This way, even an account that was once evicted and later revived by receiving ether will not have its nonce reset to 0, preventing replay of its past transactions.
Option A of the State Rent roadmap
This proposal is part of the State Rent v3 proposal, corresponding to option "A" among the alternatives. The motivation is that Ethereum state currently has no dedicated space to record state counters such as the transaction count or account count.
Alternatives considered
Two alternatives were considered. The first is to extend the Ethereum state structure itself by adding a field, which has the downside of affecting existing software tied to the construction of the state root, particularly software that handles Merkle proofs. The second is the Extended State Oracle (EIP-2014), in which a precompiled contract with a standardized interface returns the counter value, but this has the problem that the returned data does not explicitly exist in state or get Merkleized, so snapshot syncing must implicitly include the counters separately.
Can be deployed without a hard fork
This change is backwards compatible and can be activated without a hard fork. The implementation is assumed to take the form of a single transaction, sendable from an arbitrary Ethereum address, that triggers deployment of the counter contract.
Current status of the proposal
This EIP is a Standards Track (Core) proposal created on May 15, 2019, and its current status is Stagnant. The call records and discussion materials contain no separate fork-inclusion decision or recent discussion related to this proposal.