EIPs Explained

EIP-2681 · Final · Core · 2020-04-25

EIP-2681: Limit account nonce to 2^64-1

Caps every account nonce at 2^64-1, retroactively from genesis, so clients, proofs and transaction formats can treat nonces as fixed 64-bit integers.

What problem does it solve?

The Yellow Paper originally allowed an account nonce to be an arbitrarily large unsigned integer. In practice no account comes anywhere near even 64 bits, and clients like go-ethereum already stored it as a 64-bit number. But "arbitrary length" is awkward for state proofs and witnesses, for new transaction formats, and for client code that otherwise has to handle 256-bit nonces just in case.

EIP-2681 makes the practical limit official: a nonce is always between 0 and 2^64-1.

How it works

Two rules, applied retroactively from genesis (no fork block needed, because no existing account violates them):

  1. A transaction whose nonce is >= 2^64-1 is invalid. Equal-to is included because executing it would push the sender's nonce past the limit.
  2. If CREATE or CREATE2 runs from an account whose nonce is already 2^64-1, it fails: 0 is pushed on the stack and no initcode gas is deducted.

Reaching the limit by sending transactions would cost at least 21000 × (2^64-1) gas, so the cap is unreachable in practice. Older replay-protection tricks such as Morden's large starting nonce are no longer needed since EIP-155 introduced chain IDs.

Sample code

Validation as a client might implement it:

MAX_NONCE = 2**64 - 1

def validate_tx_nonce(tx, sender_account):
    if tx.nonce >= MAX_NONCE:
        raise InvalidTransaction("nonce too high (EIP-2681)")
    if tx.nonce != sender_account.nonce:
        raise InvalidTransaction("nonce mismatch")

def op_create(evm):
    if evm.current_account.nonce == MAX_NONCE:
        evm.stack.push(0)       # creation fails, no initcode executed
        return
    # ... normal CREATE logic

Fixed-size nonce in Solidity tooling (e.g. a struct mirroring account state):

struct AccountState {
    uint64 nonce;      // fits by EIP-2681
    uint256 balance;
}

Things to know

  • Status is Final. Because it is retroactive and no account was affected, it did not need to be tied to a specific network upgrade.
  • Nothing changes for normal users. The limit matters for client developers, proof systems and transaction-format designers.
  • Later proposals rely on it: for example EIP-7702 authorizations require the nonce to be below 2^64-1.

#nonce #core #transactions #consensus

Details

Authors
Alex Beregszaszi (@axic)
Status
Final
Type
Standards Track / Core
Created
2020-04-25
Required by

Machine-readable: Markdown · JSON