{"eip":3102,"title":"Binary trie structure","description":"Change the storage structure from hexary to binary, merge the account and storage tries, and use blake2b.","authors":["Guillaume Ballet (@gballet)","Vitalik Buterin (@vbuterin)"],"status":"Stagnant","type":"Standards Track","category":"Core","created":"2020-09-01","discussionsTo":"https://ethresear.ch/t/binary-trie-format/7621","repo":"EIPs","label":"EIP-3102","officialUrl":"https://eips.ethereum.org/EIPS/eip-3102","sourceUrl":"https://github.com/ethereum/EIPs/blob/master/EIPS/eip-3102.md","url":"https://eips.huatuo.xyz/eip-3102/","tldr":{"en":"Proposed replacing Ethereum's hexary Merkle Patricia Trie with a single binary trie, merging account and storage data, dropping RLP and hashing with blake2b, to shrink stateless proofs.","ja":"Ethereum の 16 分木 Merkle Patricia Trie を単一のバイナリトライに置き換え、アカウントとストレージのデータを統合し、RLP をやめて blake2b でハッシュすることで、ステートレスなプルーフを小さくする提案。","ko":"이더리움의 16진 Merkle Patricia Trie를 단일 이진 트라이로 대체하고, 계정과 스토리지 데이터를 합치며, RLP를 없애고 blake2b로 해시해 스테이트리스 증명을 줄이자고 제안했다.","zh":"提议用单一的二叉树取代以太坊的十六叉 Merkle Patricia Trie，合并账户与存储数据，弃用 RLP 并改用 blake2b 哈希，以缩小无状态证明的体积。"},"tags":["state","trie","statelessness","merkle","core"],"explainers":{"en":{"lang":"en","tldr":"Proposed replacing Ethereum's hexary Merkle Patricia Trie with a single binary trie, merging account and storage data, dropping RLP and hashing with blake2b, to shrink stateless proofs.","tags":["state","trie","statelessness","merkle","core"],"related":[2926,2584,6800,7864],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-3102/","markdown":"## What problem does it solve?\n\nEthereum's state lives in a **hexary** Merkle Patricia Trie (16 children per node), with a separate storage trie per contract. That made sense when the bottleneck was database reads, but it produces large proofs: each level of a Merkle proof must include all sibling hashes, and with 16 children that is 15 hashes per level.\n\nFor a **stateless** Ethereum, where blocks ship with proofs (witnesses) of the state they touch, proof size is what matters. The spec's back-of-envelope table for 2²⁴ elements gives about 768 bytes per branch for a binary tree versus 2,880 bytes for a hexary one. Clients had also moved to flat key/value databases, so the hexary layout no longer bought much on disk.\n\n## How it works\n\n- **One trie.** Account and storage tries are merged into a single binary trie; keys are 32 to 64 bytes.\n- **Account layout.** For address `a`, take `hash(a)` minus its last two bits and append a 2-bit tag:\n  - `00` balance, `01` nonce, `10` code, `11` storage root\n  - storage slot `k` lives at `… ++ 0b11 ++ hash(k)`\n  - with code merkleization ([EIP-2926](/eip-2926/)), code chunk `c` lives under the `10` branch.\n- **Simpler encoding.** No RLP, no hex-prefix leaf marker (a leaf is just a node with no children), and every node is hashed regardless of size.\n- **Hash function.** blake2b replaces keccak256 for speed, to offset the roughly 4× increase in node count.\n\nMerkleization rule:\n\n```\ninternal_hash = hash(left_child_hash || right_child_hash)\nleaf_hash     = hash(hash(key) || hash(leaf_value))\n# nodes with a prefix (extension) additionally commit to path length:\nprefixed_hash = hash(u256(path_length - 1) || \u003chash above\u003e)\n```\n\nCommitting to the full path length from the root (not just the prefix) means deleting a leaf does not force rehashing its sibling.\n\n## Sample code\n\nComputing the key for an account field and a storage slot (Python, using blake2b):\n\n```python\nfrom hashlib import blake2b\n\ndef h(x: bytes) -\u003e bytes:\n    return blake2b(x, digest_size=32).digest()\n\ndef account_key(address: bytes, tag: int) -\u003e int:\n    \"\"\"Return the 256-bit key: first 254 bits of h(address) ++ 2-bit tag.\"\"\"\n    stem = int.from_bytes(h(address), \"big\") \u003e\u003e 2\n    return (stem \u003c\u003c 2) | tag\n\nBALANCE, NONCE, CODE, STORAGE = 0b00, 0b01, 0b10, 0b11\n\ndef storage_key(address: bytes, slot: int) -\u003e bytes:\n    prefix = account_key(address, STORAGE).to_bytes(32, \"big\")\n    return prefix + h(slot.to_bytes(32, \"big\"))   # 64-byte key\n```\n\n## Things to know\n\n- **Status: Stagnant.** It was not adopted, and a switch would require a hard fork plus a full state conversion. The spec points to [EIP-2584](/eip-2584/) for a transition approach.\n- Later stateless-state designs took a different shape: [EIP-6800](/eip-6800/) proposed a unified verkle tree, and [EIP-7864](/eip-7864/) returns to a unified binary tree with a different key layout.\n- The rationale for blake2b over BLAKE3 was the lack of an official Go BLAKE3 release at the time.\n- The spec mentions a 32-byte code chunk size from an older version of EIP-2926; that EIP now uses 31 bytes.\n"},"ja":{"lang":"ja","tldr":"Ethereum の 16 分木 Merkle Patricia Trie を単一のバイナリトライに置き換え、アカウントとストレージのデータを統合し、RLP をやめて blake2b でハッシュすることで、ステートレスなプルーフを小さくする提案。","tags":["state","trie","statelessness","merkle","core"],"related":[2926,2584,6800,7864],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-3102/","markdown":"## 何を解決するのか\n\nEthereum のステートは、**16 分木**（ノードあたり 16 の子）の Merkle Patricia Trie に置かれ、コントラクトごとに別のストレージトライがあります。ボトルネックがデータベース読み取りだった頃は理にかなっていましたが、プルーフが大きくなります。Merkle プルーフの各レベルには兄弟ハッシュをすべて含める必要があり、子が 16 個なら 1 レベルにつき 15 個のハッシュです。\n\nブロックが触れるステートのプルーフ（ウィットネス）を同梱する**ステートレス** Ethereum では、重要なのはプルーフのサイズです。仕様の概算表（2²⁴ 要素の場合）では、1 ブランチあたりバイナリツリーで約 768 バイト、16 分木で 2,880 バイトとされています。クライアントもフラットなキー/バリュー DB に移行しており、16 分木のレイアウトはディスク上ではあまり利点がなくなっていました。\n\n## 仕組み\n\n- **トライは 1 つ。** アカウントトライとストレージトライを単一のバイナリトライに統合します。キーは 32〜64 バイトです。\n- **アカウントのレイアウト。** アドレス `a` について、`hash(a)` から末尾 2 ビットを除いたものに、2 ビットのタグを付けます。\n  - `00` 残高、`01` nonce、`10` コード、`11` ストレージルート\n  - ストレージスロット `k` は `… ++ 0b11 ++ hash(k)` に置かれます\n  - コードのマークル化（[EIP-2926](/eip-2926/)）を使う場合、コードチャンク `c` は `10` ブランチの下に置かれます。\n- **よりシンプルなエンコーディング。** RLP も hex-prefix のリーフマーカー（リーフは子を持たないノードというだけ）もなく、すべてのノードはサイズに関係なくハッシュされます。\n- **ハッシュ関数。** ノード数が約 4 倍になるのを相殺するため、速度重視で keccak256 の代わりに blake2b を使います。\n\nマークル化の規則:\n\n```\ninternal_hash = hash(left_child_hash || right_child_hash)\nleaf_hash     = hash(hash(key) || hash(leaf_value))\n# nodes with a prefix (extension) additionally commit to path length:\nprefixed_hash = hash(u256(path_length - 1) || \u003chash above\u003e)\n```\n\nルートからのパス全長にコミットする（プレフィックスだけではなく）ことで、リーフを削除しても兄弟の再ハッシュが不要になります。\n\n## サンプルコード\n\nアカウントのフィールドとストレージスロットのキーの計算（Python、blake2b を使用）:\n\n```python\nfrom hashlib import blake2b\n\ndef h(x: bytes) -\u003e bytes:\n    return blake2b(x, digest_size=32).digest()\n\ndef account_key(address: bytes, tag: int) -\u003e int:\n    \"\"\"Return the 256-bit key: first 254 bits of h(address) ++ 2-bit tag.\"\"\"\n    stem = int.from_bytes(h(address), \"big\") \u003e\u003e 2\n    return (stem \u003c\u003c 2) | tag\n\nBALANCE, NONCE, CODE, STORAGE = 0b00, 0b01, 0b10, 0b11\n\ndef storage_key(address: bytes, slot: int) -\u003e bytes:\n    prefix = account_key(address, STORAGE).to_bytes(32, \"big\")\n    return prefix + h(slot.to_bytes(32, \"big\"))   # 64-byte key\n```\n\n## 知っておくべきこと\n\n- **ステータス: Stagnant。** 採用されず、切り替えにはハードフォークとステートの完全な変換が必要になります。仕様は移行方法として [EIP-2584](/eip-2584/) を挙げています。\n- その後のステートレス向けステート設計は別の形を取りました。[EIP-6800](/eip-6800/) は統合 Verkle ツリーを提案し、[EIP-7864](/eip-7864/) は異なるキーレイアウトの統合バイナリツリーに戻っています。\n- BLAKE3 ではなく blake2b を選んだ理由は、当時 Go の公式 BLAKE3 リリースがなかったことでした。\n- 仕様は、EIP-2926 の古いバージョンにあった 32 バイトのコードチャンクサイズに言及していますが、その EIP は現在 31 バイトを使っています。\n"},"ko":{"lang":"ko","tldr":"이더리움의 16진 Merkle Patricia Trie를 단일 이진 트라이로 대체하고, 계정과 스토리지 데이터를 합치며, RLP를 없애고 blake2b로 해시해 스테이트리스 증명을 줄이자고 제안했다.","tags":["state","trie","statelessness","merkle","core"],"related":[2926,2584,6800,7864],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-3102/","markdown":"## 어떤 문제를 해결하나요?\n\n이더리움의 상태는 **16진(hexary)** Merkle Patricia Trie(노드당 자식 16개)에 있고, 컨트랙트마다 별도의 스토리지 트라이가 있습니다. 병목이 데이터베이스 읽기이던 시절에는 합리적이었지만 증명이 커집니다. Merkle 증명의 각 레벨에는 형제 해시를 모두 포함해야 하고, 자식이 16개이면 레벨당 해시가 15개입니다.\n\n블록이 건드리는 상태의 증명(witness)을 함께 싣는 **스테이트리스(stateless)** 이더리움에서는 증명 크기가 중요합니다. 사양의 대략적인 계산표(2²⁴개 요소 기준)는 브랜치당 이진 트리가 약 768바이트, 16진 트리가 2,880바이트라고 보여 줍니다. 클라이언트도 이미 평면적인 키/값 데이터베이스로 옮겨 갔기 때문에, 16진 구조는 디스크에서 더는 큰 이점이 없었습니다.\n\n## 어떻게 동작하나요?\n\n- **트라이 하나.** 계정 트라이와 스토리지 트라이를 단일 이진 트라이로 합칩니다. 키는 32~64바이트입니다.\n- **계정 레이아웃.** 주소 `a`에 대해 `hash(a)`에서 마지막 두 비트를 뺀 값에 2비트 태그를 붙입니다.\n  - `00` 잔액, `01` nonce, `10` 코드, `11` 스토리지 루트\n  - 스토리지 슬롯 `k`는 `… ++ 0b11 ++ hash(k)`에 위치합니다\n  - 코드 머클화([EIP-2926](/eip-2926/))를 쓰면 코드 청크 `c`는 `10` 브랜치 아래에 위치합니다.\n- **더 단순한 인코딩.** RLP도, hex-prefix 리프 표시도 없고(리프는 자식이 없는 노드일 뿐입니다), 모든 노드는 크기와 상관없이 해시됩니다.\n- **해시 함수.** 노드 수가 약 4배 늘어나는 것을 상쇄하기 위해 속도를 위해 keccak256 대신 blake2b를 씁니다.\n\n머클화 규칙:\n\n```\ninternal_hash = hash(left_child_hash || right_child_hash)\nleaf_hash     = hash(hash(key) || hash(leaf_value))\n# nodes with a prefix (extension) additionally commit to path length:\nprefixed_hash = hash(u256(path_length - 1) || \u003chash above\u003e)\n```\n\n(접두사만이 아니라) 루트부터의 전체 경로 길이를 커밋하면, 리프를 삭제해도 형제를 다시 해시할 필요가 없습니다.\n\n## 샘플 코드\n\n계정 필드와 스토리지 슬롯의 키 계산(Python, blake2b 사용):\n\n```python\nfrom hashlib import blake2b\n\ndef h(x: bytes) -\u003e bytes:\n    return blake2b(x, digest_size=32).digest()\n\ndef account_key(address: bytes, tag: int) -\u003e int:\n    \"\"\"Return the 256-bit key: first 254 bits of h(address) ++ 2-bit tag.\"\"\"\n    stem = int.from_bytes(h(address), \"big\") \u003e\u003e 2\n    return (stem \u003c\u003c 2) | tag\n\nBALANCE, NONCE, CODE, STORAGE = 0b00, 0b01, 0b10, 0b11\n\ndef storage_key(address: bytes, slot: int) -\u003e bytes:\n    prefix = account_key(address, STORAGE).to_bytes(32, \"big\")\n    return prefix + h(slot.to_bytes(32, \"big\"))   # 64-byte key\n```\n\n## 알아둘 점\n\n- **상태: Stagnant.** 채택되지 않았으며, 전환하려면 하드 포크와 전체 상태 변환이 필요합니다. 사양은 전환 방식으로 [EIP-2584](/eip-2584/)를 가리킵니다.\n- 이후의 스테이트리스 상태 설계는 다른 형태를 띠었습니다. [EIP-6800](/eip-6800/)은 통합 verkle 트리를 제안했고, [EIP-7864](/eip-7864/)는 다른 키 레이아웃의 통합 이진 트리로 돌아갑니다.\n- BLAKE3 대신 blake2b를 고른 근거는 당시 공식 Go BLAKE3 릴리스가 없었다는 점이었습니다.\n- 사양은 EIP-2926의 이전 버전에 있던 32바이트 코드 청크 크기를 언급하는데, 해당 EIP는 지금 31바이트를 사용합니다.\n"},"zh":{"lang":"zh","tldr":"提议用单一的二叉树取代以太坊的十六叉 Merkle Patricia Trie，合并账户与存储数据，弃用 RLP 并改用 blake2b 哈希，以缩小无状态证明的体积。","tags":["state","trie","statelessness","merkle","core"],"related":[2926,2584,6800,7864],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-3102/","markdown":"## 它解决什么问题？\n\n以太坊的状态存放在**十六叉** Merkle Patricia Trie 中（每个节点 16 个子节点），每个合约还有单独的存储树。当瓶颈在数据库读取时这样做是合理的，但它会产生很大的证明：Merkle 证明的每一层都必须包含所有兄弟哈希，16 个子节点意味着每层 15 个哈希。\n\n对于**无状态**以太坊，区块会附带其所触及状态的证明（witness），重要的是证明的大小。规范中对 2²⁴ 个元素的粗略估算表显示，二叉树每个分支约 768 字节，而十六叉树为 2,880 字节。客户端也已经转向扁平的键值数据库，所以十六叉布局在磁盘上不再带来多少好处。\n\n## 它如何运作\n\n- **只有一棵树。** 账户树和存储树合并为单一的二叉树；键长为 32 到 64 字节。\n- **账户布局。** 对于地址 `a`，取 `hash(a)` 去掉最后两位，再附加一个 2 位标签：\n  - `00` 余额，`01` nonce，`10` 代码，`11` 存储根\n  - 存储槽 `k` 位于 `… ++ 0b11 ++ hash(k)`\n  - 采用代码默克尔化（[EIP-2926](/eip-2926/)）时，代码块 `c` 位于 `10` 分支之下。\n- **更简单的编码。** 没有 RLP，没有 hex-prefix 叶子标记（叶子就是没有子节点的节点），每个节点无论大小都会被哈希。\n- **哈希函数。** 为了速度，用 blake2b 取代 keccak256，以抵消节点数量约 4 倍的增长。\n\n默克尔化规则：\n\n```\ninternal_hash = hash(left_child_hash || right_child_hash)\nleaf_hash     = hash(hash(key) || hash(leaf_value))\n# nodes with a prefix (extension) additionally commit to path length:\nprefixed_hash = hash(u256(path_length - 1) || \u003chash above\u003e)\n```\n\n承诺从根开始的完整路径长度（而不仅是前缀），意味着删除一个叶子不会迫使重新哈希它的兄弟节点。\n\n## 示例代码\n\n计算账户字段和存储槽的键（Python，使用 blake2b）：\n\n```python\nfrom hashlib import blake2b\n\ndef h(x: bytes) -\u003e bytes:\n    return blake2b(x, digest_size=32).digest()\n\ndef account_key(address: bytes, tag: int) -\u003e int:\n    \"\"\"Return the 256-bit key: first 254 bits of h(address) ++ 2-bit tag.\"\"\"\n    stem = int.from_bytes(h(address), \"big\") \u003e\u003e 2\n    return (stem \u003c\u003c 2) | tag\n\nBALANCE, NONCE, CODE, STORAGE = 0b00, 0b01, 0b10, 0b11\n\ndef storage_key(address: bytes, slot: int) -\u003e bytes:\n    prefix = account_key(address, STORAGE).to_bytes(32, \"big\")\n    return prefix + h(slot.to_bytes(32, \"big\"))   # 64-byte key\n```\n\n## 需要注意\n\n- **状态：Stagnant。** 它没有被采纳，而切换需要一次硬分叉外加完整的状态转换。规范指向 [EIP-2584](/eip-2584/) 作为过渡方案。\n- 后来的无状态状态设计采取了不同的形态：[EIP-6800](/eip-6800/) 提议统一的 verkle 树，[EIP-7864](/eip-7864/) 则回到统一的二叉树，只是键布局不同。\n- 选择 blake2b 而不是 BLAKE3，理由是当时没有官方的 Go 版 BLAKE3 发布。\n- 规范提到了 EIP-2926 旧版本中的 32 字节代码块大小；该 EIP 现在使用 31 字节。\n"}}}
