EIPs Explained

EIP-6800 · Stagnant · Core · 2023-03-17

EIP-6800: Ethereum state using a unified verkle tree

Proposed moving Ethereum's state into a single Verkle tree with 32-byte keys, shrinking state proofs enough to make stateless clients practical.

What problem does it solve?

Ethereum's state lives in a hexary Merkle Patricia Tree (MPT). To prove a piece of state (an account, a storage slot) to a node that does not store the state, you need a witness: all sibling hashes on the path to the root. In the MPT that is close to 3 kB per account access on average and several times more in the worst case. The spec estimates a worst-case block witness of about 18 MB, too large to broadcast within a 12-second slot.

Small witnesses are the precondition for stateless clients: nodes that verify blocks using the witness instead of a local copy of the state. EIP-6800 proposed switching to a Verkle tree, whose vector commitments bring witnesses down to roughly 200 bytes per account on average.

How it works

One flat tree. Instead of an account trie with per-contract storage tries, all state goes into a single key-value tree with 32-byte keys and 32-byte values. Each key is a 31-byte stem plus a 1-byte suffix; the 256 values sharing a stem are committed together.

Commitments. Internal nodes have 256 children and commit to them with Pedersen vector commitments over the Bandersnatch curve. A zero value is distinguished from an empty slot.

Embedding of state. Keys come from a Pedersen hash of (address, tree_index) plus a suffix:

  • Suffix 0 (BASIC_DATA_LEAF_KEY): version, code size, nonce and balance packed into one value.
  • Suffix 1: code hash.
  • Suffixes 64–127: the first 64 storage slots, stored next to the account header.
  • From 128: contract code, split into 31-byte chunks, each prefixed with one byte saying how many leading bytes are PUSHDATA.
  • Other storage slots start at 256**31 and are grouped 256 per stem.

Transition. The new tree starts empty. After the fork, all writes and copies of accessed state go into the Verkle tree while the MPT is frozen; migration details are in EIP-7612. Gas changes for witness access are in EIP-4762.

Sample code

Key derivation for an account's basic data and a storage slot, from the spec's pseudocode:

BASIC_DATA_LEAF_KEY   = 0
HEADER_STORAGE_OFFSET = 64
CODE_OFFSET           = 128
VERKLE_NODE_WIDTH     = 256
MAIN_STORAGE_OFFSET   = 256**31

def get_tree_key(address32: bytes, tree_index: int, sub_index: int) -> bytes:
    stem = pedersen_hash(address32 + tree_index.to_bytes(32, "little"))[:31]
    return stem + bytes([sub_index])

def basic_data_key(address32):
    return get_tree_key(address32, 0, BASIC_DATA_LEAF_KEY)

def storage_key(address32, slot: int):
    if slot < CODE_OFFSET - HEADER_STORAGE_OFFSET:   # slots 0..63
        pos = HEADER_STORAGE_OFFSET + slot
    else:
        pos = MAIN_STORAGE_OFFSET + slot
    return get_tree_key(address32, pos // VERKLE_NODE_WIDTH, pos % VERKLE_NODE_WIDTH)

Things to know

  • Status: Stagnant. It has not been scheduled for any upgrade. A binary-tree alternative for the same goal is proposed in EIP-7864.
  • Grouping storage means accessing nearby slots, or slots 0–63, becomes cheaper, while code access is charged per 31-byte chunk. The spec estimates the code-chunk cost could raise average gas use by about 6–12%, partly offset by cheaper storage.
  • In-EVM proofs of historical state that assume the MPT format would stop working after such a change.
  • It requires EIP-6780, which restricts SELFDESTRUCT so contracts can no longer wipe their whole storage in one step.

#state #verkle #stateless #core #trie

Details

Authors
Vitalik Buterin (@vbuterin), Dankrad Feist (@dankrad), Kevaundray Wedderburn (@kevaundray), Guillaume Ballet (@gballet), Piper Merriam (@pipermerriam), Gottfried Herold (@GottfriedHerold), Ignacio Hagopian (@jsign), Tanishq Jasoria (@tanishqjasoria), Gajinder Singh (@g11tech), Danno Ferrin (@shemnon)
Status
Stagnant
Type
Standards Track / Core
Created
2023-03-17
Requires
Required by

Machine-readable: Markdown · JSON