EIPs Explained

EIP-7864 · Draft · Core · 2025-01-20

EIP-7864: Ethereum state using a unified binary tree

Proposes replacing Ethereum's hexary Merkle-Patricia tries with one binary tree holding accounts, code and storage, giving smaller proofs and a structure suited to zero-knowledge proving of blocks.

What problem does it solve?

Ethereum's state today lives in a Merkle-Patricia Trie (MPT): a hexary (16-way) tree of accounts, where each contract has its own separate storage trie. This design is hard to prove efficiently:

  • Proofs are large. Each level of a hexary tree needs up to 15 sibling hashes, so proving even small pieces of state is expensive. Contract code is not part of the tree, so proving one byte of code can mean shipping the whole contract.
  • It uses RLP encoding and Keccak, and it is a "tree of trees", all costly inside ZK circuits.

The long-term goal is for blocks to be verified with validity proofs and for nodes to run statelessly. EIP-7864 proposes a state tree designed for that, replacing the earlier unified Verkle tree plan (EIP-6800).

How it works

  • One tree, one key space. Account headers, code and storage all live in a single binary tree whose keys map to 32-byte values. No separate storage tries, no RLP.
  • Stems of 256 leaves. A key is made of a type prefix byte, a stem, and a final subindex byte. Keys sharing a stem sit together under one StemNode with 256 leaf slots, so data that is accessed together is proved together.
  • Grouped by type. The first key byte separates headers, code and storage into their own subtrees, so each can be synced or handled differently.
  • Account header leaf. Version, code size, nonce and balance are packed into one 32-byte BASIC_DATA leaf; the code hash sits in a neighbouring leaf. The first code chunks and storage slots share the account's stem.
  • Chunked code. Bytecode is split into 31-byte chunks, each prefixed by one byte saying how many leading bytes are PUSH data, so a chunk can be executed and proved on its own.
  • Simple hashing. Internal nodes hash left || right; stem nodes hash the stem plus the root of their 256 leaves; empty subtrees hash to 32 zero bytes. There are no extension nodes.

The new tree starts empty. New writes go to it while the MPT is frozen; moving the old data over is left to a later fork (EIP-7748). The transition is described in EIP-7612 and the gas changes for state access in EIP-4762.

Sample code

Packing an account's basic-data leaf, following the layout in the spec (Python):

def pack_basic_data(version: int, code_size: int, nonce: int, balance: int) -> bytes:
    leaf = bytearray(32)
    leaf[0] = version                                # byte 0
    # bytes 1..4 reserved
    leaf[5:8] = code_size.to_bytes(3, "big")        # bytes 5..7
    leaf[8:16] = nonce.to_bytes(8, "big")           # bytes 8..15
    leaf[16:32] = balance.to_bytes(16, "big")       # bytes 16..31
    return bytes(leaf)

def address32(addr20: bytes) -> bytes:
    return b"\x00" * 12 + addr20                     # addresses are widened to 32 bytes

# key = [HEADER_SUBTREE=0] + hash(address32) + [BASIC_DATA_LEAF_KEY=0]

Things to know

  • Status: Draft. Nothing here is scheduled for a network upgrade.
  • The hash function is not decided. Reference code uses BLAKE3 for experimentation only; Keccak and Poseidon2 are also candidates. Do not treat any root computed today as final.
  • Some constants in the draft (how many code chunks and storage slots live in the account stem) are stated inconsistently between the parameter table and the prose, so check the latest version before implementing.
  • Switching trees changes the root hash and the proof formats that light clients, bridges and eth_getProof users depend on.
  • It replaces the Verkle plan: the earlier Verkle EIPs (EIP-6800, EIP-7612, EIP-7748) still carry Verkle titles, while this EIP reuses their transition and gas mechanics.

#state #binary-tree #stateless #zk #core

Details

Authors
Vitalik Buterin (@vbuterin), Guillaume Ballet (@gballet), Dankrad Feist (@dankrad), Ignacio Hagopian (@jsign), Kevaundray Wedderburn (@kevaundray), Tanishq Jasoria (@tanishqjasoria), Gajinder Singh (@g11tech), Danno Ferrin (@shemnon), Piper Merriam (@pipermerriam), Gottfried Herold (@GottfriedHerold)
Status
Draft
Type
Standards Track / Core
Created
2025-01-20

Machine-readable: Markdown · JSON