EIPs Explained

EIP-2029 · Stagnant · Core · 2019-05-15

EIP-2029: State Rent A - State counters contract

Part of the abandoned State Rent roadmap: deploy a tiny contract at the same address on every network whose storage the protocol would later fill with counters such as the total number of transactions.

What problem does it solve?

In 2019 Alexey Akhunov's "State Rent" roadmap aimed to curb unbounded growth of Ethereum's state by charging accounts for the storage they occupy and evicting those that do not pay. Several steps in that plan needed global counters, such as the total number of transactions ever executed, and Ethereum had no place in its state to keep them.

The key use was replay protection after eviction. If an evicted account is recreated by someone sending it ether, its nonce would restart at zero, letting old signed transactions be replayed. Seeding a new account's nonce from a global transaction counter avoids that.

How it works

This EIP, "change A" of the roadmap, only creates the storage location:

  1. Before a chosen block, a contract is deployed with CREATE2 so that it has the same address on every network. Anyone can submit the deployment transaction, and it needs no hard fork.

  2. Its code simply returns the storage slot named by its 32-byte argument:

    0x60 0x20 0x60 0x00 0x80 0x80 0x35 0x54 0x90 0x52 0xF3
    PUSH1 32 PUSH1 0 DUP1 DUP1 CALLDATALOAD SLOAD SWAP1 MSTORE RETURN
    
  3. Later rent changes, such as EIP-2031 (net transaction counter), would have the protocol itself write counter values into this contract's storage.

The spec weighed two alternatives. Adding fields to the state structure would change how the state root is built and break existing Merkle-proof tooling. An EIP-2014-style oracle would return values that are not explicitly part of the Merkle state. Keeping the counters in ordinary contract storage keeps them Merkle-ized and provable.

Sample code

Reading counter slot 0 from such a contract (ethers v6). The address is a placeholder because the contract was never deployed by the protocol:

import { JsonRpcProvider, zeroPadValue, toBigInt } from "ethers";

const provider = new JsonRpcProvider(process.env.RPC_URL);
const COUNTERS = process.env.COUNTERS_ADDRESS!; // hypothetical CREATE2 address

const slot = zeroPadValue("0x00", 32);          // which counter to read
const raw = await provider.call({ to: COUNTERS, data: slot }); // calldata is just the slot
console.log("counter value:", toBigInt(raw));

The contract's whole behaviour in Solidity terms:

fallback(bytes calldata input) external returns (bytes memory) {
    bytes32 slot = abi.decode(input, (bytes32));
    bytes32 value;
    assembly { value := sload(slot) }
    return abi.encode(value);
}

Things to know

  • Status is Stagnant. The State Rent roadmap was abandoned, and Ethereum has not introduced rent or account eviction.
  • No deployment address or activation block is specified. Any address you see attributed to this EIP is not part of the spec.
  • Sibling proposals from the same roadmap include EIP-2026 (fixed prepayment for accounts), EIP-2027 (net contract size accounting) and EIP-2031. All are Stagnant.
  • Ethereum has since pursued other approaches to state growth, such as stateless-client research, rather than rent.

#state-rent #system-contract #counters #state #core

Details

Authors
Alexey Akhunov (@AlexeyAkhunov)
Status
Stagnant
Type
Standards Track / Core
Created
2019-05-15
Required by

Machine-readable: Markdown · JSON