EIPs Explained

EIP-6188 · Stagnant · Core · 2022-12-20

EIP-6188: Nonce Cap

A stagnant core proposal that caps account nonces at 2^64-2, reserving the value 2^64-1 so other EIPs can use it to mark special contracts.

What problem does it solve?

Every Ethereum account has a nonce. For externally owned accounts it counts transactions sent; for contracts it counts contracts created via CREATE / CREATE2. The nonce is a 64-bit value, but no account realistically gets anywhere near the top of that range.

EIP-6188 carves out the very top value as a reserved marker. Its author is explicit that the EIP is "not terribly useful on its own": it only adds a small check. The point is to give other proposals a guaranteed-unused nonce value they can assign to accounts with unusual behaviour (the spec mentions "alias or other special contracts"). It was written alongside EIP-6190, a Verkle-compatible redesign of SELFDESTRUCT, and shares its discussion thread.

How it works

Two consensus rule changes:

  1. Transactions from EOAs. A transaction whose nonce is 2^64-1 or 2^64-2 is invalid. In practice, an EOA can therefore send transactions only with nonces below 2^64-2.
  2. CREATE and CREATE2. If creating a contract would increment the creator's nonce to 2^64-1, it is set to 2^64-2 instead.

Result: no normal account can ever reach nonce 2^64-1. Any account found with that nonce must have been put there deliberately by some other protocol rule, so the value can safely act as a flag.

2^64 - 1 = 0xFFFFFFFFFFFFFFFF  -> reserved marker
2^64 - 2 = 0xFFFFFFFFFFFFFFFE  -> ceiling for ordinary accounts

Sample code

Client-side validity checks, in pseudocode:

NONCE_RESERVED = 2**64 - 1
NONCE_CAP      = 2**64 - 2

def validate_tx_nonce(tx, sender_account):
    if tx.nonce >= NONCE_CAP:          # 2^64-2 and 2^64-1 are both rejected
        raise InvalidTransaction("nonce above cap")
    if tx.nonce != sender_account.nonce:
        raise InvalidTransaction("nonce mismatch")

def bump_nonce_on_create(creator_account):
    new_nonce = creator_account.nonce + 1
    if new_nonce == NONCE_RESERVED:
        new_nonce = NONCE_CAP          # never step onto the reserved value
    creator_account.nonce = new_nonce

Both rules are cheap comparisons; the cost is purely in coordinating a consensus change across clients.

Things to know

  • Status is Stagnant: it has not been scheduled for any network upgrade and nothing on mainnet relies on it.
  • Changing which transactions are valid is a consensus change, so it would require a hard fork if ever adopted.
  • The spec argues there is no practical impact on users, because reaching nonce 2^64-2 through normal activity is infeasible.
  • Read it together with EIP-6190 (also Stagnant), which motivated reserving a special nonce value.

#core #nonce #consensus #accounts #stagnant

Details

Authors
Gavin John (@Pandapip1)
Status
Stagnant
Type
Standards Track / Core
Created
2022-12-20
Requires
Required by

Machine-readable: Markdown · JSON