{"eip":2584,"title":"Trie format transition with overlay trees","description":"This EIP proposes a method to convert the state trie format from hexary to binary: new values are directly stored in a binary trie “laid over” the hexary trie. Meanwhile, the hexary trie is converted to a binary trie in the background. When the process is finished, both layers are merged.","authors":["Guillaume Ballet (@gballet)"],"status":"Stagnant","type":"Standards Track","category":"Core","created":"2020-04-03","discussionsTo":"https://ethresear.ch/t/overlay-method-for-hex-bin-tree-conversion/7104","repo":"EIPs","label":"EIP-2584","officialUrl":"https://eips.ethereum.org/EIPS/eip-2584","sourceUrl":"https://github.com/ethereum/EIPs/blob/master/EIPS/eip-2584.md","url":"https://eips.huatuo.xyz/eip-2584/","tldr":{"en":"A stagnant plan to switch Ethereum's state from a hexary to a binary trie without halting the chain, by writing new state to an overlay trie while the old one is converted in the background.","ja":"チェーンを止めずに Ethereum のステートを 16 分木（hexary）から二分木（binary）トライへ切り替える、停滞（Stagnant）中の計画。古いトライをバックグラウンドで変換する間、新しいステートはオーバーレイトライに書き込む。","ko":"체인을 멈추지 않고 이더리움 상태를 16진(hexary) 트라이에서 이진(binary) 트라이로 바꾸는 정체(Stagnant) 상태의 계획. 옛 트라이를 백그라운드에서 변환하는 동안 새 상태는 오버레이 트라이에 기록한다.","zh":"一项处于停滞（Stagnant）状态的计划：在不停止链的情况下，把以太坊状态从十六叉 trie 切换为二叉 trie，做法是在旧 trie 于后台转换期间，把新状态写入覆盖层（overlay）trie。"},"tags":["state","trie","binary","migration","core","stagnant"],"explainers":{"en":{"lang":"en","tldr":"A stagnant plan to switch Ethereum's state from a hexary to a binary trie without halting the chain, by writing new state to an overlay trie while the old one is converted in the background.","tags":["state","trie","binary","migration","core","stagnant"],"related":[6800,7612,7748,7864],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-2584/","markdown":"## What problem does it solve?\n\nEthereum stores its state in a hexary Merkle Patricia Trie: each branch node has 16 children. A binary trie (2 children per branch) gives much smaller Merkle proofs, which matters for stateless clients and light clients.\n\nThe hard part is the migration. The full state is far too large to convert within one block time, so you cannot just flip a switch at a fork block. Earlier ideas were \"stop the world\" (halt the chain during conversion) or \"copy on write\" (convert branches only when touched, which may never finish). EIP-2584 proposes a method that keeps the chain running and still completes in predictable time.\n\n## How it works\n\nThree phases (the abstract calls it four, but the text describes three):\n\n1. **Phase 1 — overlay.** From block `h₁`, all state *writes* go to a new, initially empty binary **overlay trie**, whose root is a new block-header field. The old hexary **base trie** is frozen; reads check the overlay first, then fall back to the base. Deleted accounts are marked in the overlay with the empty hash. Meanwhile every node converts the frozen hexary trie to binary in the background.\n2. **Phase 2 — merge.** At block `h₂`, the state root switches to the converted binary base root. The overlay becomes read/delete only; writes go to the base trie. Before each block, the first `N` accounts (in key order) are moved out of the overlay into the base trie.\n3. **Phase 3 — done.** Once the overlay is empty, its root field is removed from the header.\n\n`h₂` must be far enough after `h₁` for miners to finish converting; the author reports a prototype converting in roughly 30 minutes on a fast machine.\n\n## Sample code\n\nPseudocode for state access during phase 1:\n\n```python\nEMPTY = keccak(b\"\")\n\ndef read_account(addr):\n    v = overlay.get(addr)\n    if v == EMPTY:            # deleted during the transition\n        return None\n    if v is not None:\n        return v\n    return base_hex.get(addr) # frozen hexary trie\n\ndef write_account(addr, value):\n    overlay.put(addr, value)  # base trie is never touched in phase 1\n\ndef delete_account(addr):\n    overlay.put(addr, EMPTY)\n```\n\nAnd the per-block merge step in phase 2:\n\n```python\nfor addr, v in overlay.first_n_sorted(N):\n    if v == EMPTY:\n        base_bin.delete(addr)\n    else:\n        base_bin.put(addr, v)\n    overlay.delete(addr)\n```\n\n## Things to know\n\n- Status is **Stagnant**. It is a hard fork that changes block format and hashes, and was never scheduled.\n- Security notes in the spec: an attacker could bloat the overlay to prolong phase 2 (possibly mitigated by pricier `SSTORE` in phase 1), and if `h₂` comes too soon, miners might not compute the converted root in time.\n- The overlay idea lived on in later state-migration work: [EIP-7612](/eip-7612/) (overlay transition to Verkle) and [EIP-7748](/eip-7748/) (state conversion). The target tree has since shifted from Verkle ([EIP-6800](/eip-6800/)) to a unified binary tree ([EIP-7864](/eip-7864/)), both still drafts or stagnant.\n"},"ja":{"lang":"ja","tldr":"チェーンを止めずに Ethereum のステートを 16 分木（hexary）から二分木（binary）トライへ切り替える、停滞（Stagnant）中の計画。古いトライをバックグラウンドで変換する間、新しいステートはオーバーレイトライに書き込む。","tags":["state","trie","binary","migration","core","stagnant"],"related":[6800,7612,7748,7864],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-2584/","markdown":"## 何を解決するのか\n\nEthereum はステートを 16 分木の Merkle Patricia Trie に保存しており、各ブランチノードは 16 個の子を持ちます。二分木トライ（ブランチあたり子が 2 個）にすると Merkle 証明がはるかに小さくなり、ステートレスクライアントやライトクライアントにとって重要です。\n\n難しいのは移行です。ステート全体は 1 ブロック時間の間に変換するには大きすぎるため、フォークブロックでスイッチを切り替えるだけというわけにはいきません。これまでのアイデアは「stop the world」（変換中はチェーンを止める）か「copy on write」（触れたブランチだけ変換する。永遠に終わらないかもしれない）でした。EIP-2584 は、チェーンを動かし続けながら、予測可能な時間で完了する方法を提案します。\n\n## 仕組み\n\n3 つのフェーズがあります（abstract では 4 つとされていますが、本文が説明しているのは 3 つです）。\n\n1. **フェーズ 1 — オーバーレイ。** ブロック `h₁` から、すべてのステートの*書き込み*は、新しく最初は空の二分木の**オーバーレイトライ**に向かいます。そのルートはブロックヘッダーの新しいフィールドになります。古い 16 分木の**ベーストライ**は凍結され、読み取りはまずオーバーレイを確認し、なければベースにフォールバックします。削除されたアカウントは、オーバーレイ内で空ハッシュによってマークされます。その間、すべてのノードがバックグラウンドで、凍結された 16 分木のトライを二分木に変換します。\n2. **フェーズ 2 — マージ。** ブロック `h₂` で、ステートルートが変換済みの二分木のベースルートに切り替わります。オーバーレイは読み取りと削除のみになり、書き込みはベーストライに向かいます。各ブロックの前に、最初の `N` 個のアカウント（キー順）がオーバーレイからベーストライに移されます。\n3. **フェーズ 3 — 完了。** オーバーレイが空になったら、そのルートのフィールドはヘッダーから削除されます。\n\n`h₂` は、マイナーが変換を終えられるよう `h₁` から十分に離れていなければなりません。著者は、高速なマシンでプロトタイプの変換にかかった時間を約 30 分と報告しています。\n\n## サンプルコード\n\nフェーズ 1 でのステートアクセスの疑似コード:\n\n```python\nEMPTY = keccak(b\"\")\n\ndef read_account(addr):\n    v = overlay.get(addr)\n    if v == EMPTY:            # deleted during the transition\n        return None\n    if v is not None:\n        return v\n    return base_hex.get(addr) # frozen hexary trie\n\ndef write_account(addr, value):\n    overlay.put(addr, value)  # base trie is never touched in phase 1\n\ndef delete_account(addr):\n    overlay.put(addr, EMPTY)\n```\n\nそして、フェーズ 2 でのブロックごとのマージ処理:\n\n```python\nfor addr, v in overlay.first_n_sorted(N):\n    if v == EMPTY:\n        base_bin.delete(addr)\n    else:\n        base_bin.put(addr, v)\n    overlay.delete(addr)\n```\n\n## 知っておくべきこと\n\n- ステータスは **Stagnant** です。ブロックフォーマットとハッシュを変えるハードフォークであり、実施が予定されたことはありません。\n- 仕様のセキュリティに関する注記: 攻撃者がオーバーレイを肥大化させてフェーズ 2 を長引かせる可能性があり（フェーズ 1 で `SSTORE` を高くすれば緩和できるかもしれません）、`h₂` が早すぎるとマイナーが変換後のルートを間に合うように計算できないかもしれません。\n- オーバーレイのアイデアは、その後のステート移行の取り組みに受け継がれました。[EIP-7612](/eip-7612/)（Verkle へのオーバーレイ移行）と [EIP-7748](/eip-7748/)（ステート変換）です。移行先のツリーは、Verkle（[EIP-6800](/eip-6800/)）から統一二分木（[EIP-7864](/eip-7864/)）へと移りましたが、どちらもまだドラフトか停滞中です。\n"},"ko":{"lang":"ko","tldr":"체인을 멈추지 않고 이더리움 상태를 16진(hexary) 트라이에서 이진(binary) 트라이로 바꾸는 정체(Stagnant) 상태의 계획. 옛 트라이를 백그라운드에서 변환하는 동안 새 상태는 오버레이 트라이에 기록한다.","tags":["state","trie","binary","migration","core","stagnant"],"related":[6800,7612,7748,7864],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-2584/","markdown":"## 어떤 문제를 해결하나요?\n\n이더리움은 상태를 16진 Merkle Patricia Trie에 저장하며, 각 브랜치 노드는 자식이 16개입니다. 이진 트라이(브랜치당 자식 2개)는 Merkle 증명이 훨씬 작아져서 스테이트리스 클라이언트와 라이트 클라이언트에 중요합니다.\n\n어려운 점은 마이그레이션입니다. 전체 상태는 한 블록 시간 안에 변환하기에는 너무 커서, 포크 블록에서 스위치를 넘기듯 바꿀 수 없습니다. 이전의 아이디어는 \"stop the world\"(변환하는 동안 체인을 멈춤)나 \"copy on write\"(건드린 브랜치만 변환하므로 영영 끝나지 않을 수 있음)였습니다. EIP-2584는 체인을 계속 돌리면서도 예측 가능한 시간 안에 끝나는 방법을 제안합니다.\n\n## 어떻게 동작하나요?\n\n세 단계가 있습니다(abstract에서는 네 단계라고 하지만 본문이 설명하는 것은 세 단계입니다).\n\n1. **1단계 — 오버레이.** 블록 `h₁`부터 모든 상태 *쓰기*는 새로 만든, 처음에는 비어 있는 이진 **오버레이 트라이**로 갑니다. 그 루트는 블록 헤더의 새 필드가 됩니다. 옛 16진 **베이스 트라이**는 동결되고, 읽기는 오버레이를 먼저 확인한 뒤 베이스로 폴백합니다. 삭제된 계정은 오버레이에서 빈 해시로 표시합니다. 그동안 모든 노드는 백그라운드에서 동결된 16진 트라이를 이진으로 변환합니다.\n2. **2단계 — 병합.** 블록 `h₂`에서 상태 루트가 변환된 이진 베이스 루트로 바뀝니다. 오버레이는 읽기/삭제만 가능해지고 쓰기는 베이스 트라이로 갑니다. 매 블록 전에 (키 순서대로) 처음 `N`개 계정이 오버레이에서 베이스 트라이로 옮겨집니다.\n3. **3단계 — 완료.** 오버레이가 비면 그 루트 필드는 헤더에서 제거됩니다.\n\n`h₂`는 채굴자가 변환을 마칠 수 있도록 `h₁`보다 충분히 뒤여야 합니다. 작성자는 프로토타입이 빠른 머신에서 약 30분 만에 변환했다고 보고합니다.\n\n## 샘플 코드\n\n1단계의 상태 접근 의사 코드:\n\n```python\nEMPTY = keccak(b\"\")\n\ndef read_account(addr):\n    v = overlay.get(addr)\n    if v == EMPTY:            # deleted during the transition\n        return None\n    if v is not None:\n        return v\n    return base_hex.get(addr) # frozen hexary trie\n\ndef write_account(addr, value):\n    overlay.put(addr, value)  # base trie is never touched in phase 1\n\ndef delete_account(addr):\n    overlay.put(addr, EMPTY)\n```\n\n그리고 2단계의 블록별 병합 단계:\n\n```python\nfor addr, v in overlay.first_n_sorted(N):\n    if v == EMPTY:\n        base_bin.delete(addr)\n    else:\n        base_bin.put(addr, v)\n    overlay.delete(addr)\n```\n\n## 알아둘 점\n\n- 상태는 **Stagnant**입니다. 블록 형식과 해시를 바꾸는 하드포크이며, 일정이 잡힌 적은 없습니다.\n- 명세의 보안 관련 메모: 공격자가 오버레이를 부풀려 2단계를 길어지게 할 수 있고(1단계에서 `SSTORE`를 더 비싸게 해 완화할 수도 있습니다), `h₂`가 너무 이르면 채굴자가 변환된 루트를 제때 계산하지 못할 수 있습니다.\n- 오버레이 아이디어는 이후의 상태 마이그레이션 작업으로 이어졌습니다. [EIP-7612](/eip-7612/)(Verkle로의 오버레이 전환)와 [EIP-7748](/eip-7748/)(상태 변환)입니다. 목표 트리는 Verkle([EIP-6800](/eip-6800/))에서 통합 이진 트리([EIP-7864](/eip-7864/))로 옮겨 갔으며, 둘 다 아직 초안이거나 정체 상태입니다.\n"},"zh":{"lang":"zh","tldr":"一项处于停滞（Stagnant）状态的计划：在不停止链的情况下，把以太坊状态从十六叉 trie 切换为二叉 trie，做法是在旧 trie 于后台转换期间，把新状态写入覆盖层（overlay）trie。","tags":["state","trie","binary","migration","core","stagnant"],"related":[6800,7612,7748,7864],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-2584/","markdown":"## 它解决什么问题？\n\n以太坊把状态存放在十六叉 Merkle Patricia Trie 中：每个分支节点有 16 个子节点。二叉 trie（每个分支 2 个子节点）能让 Merkle 证明小得多，这对无状态客户端和轻客户端很重要。\n\n难点在于迁移。完整状态太大，不可能在一个出块时间内转换完，所以不能在分叉区块简单地一键切换。早先的想法是“stop the world”（转换期间暂停整条链）或“copy on write”（只在被触及时才转换分支，可能永远转换不完）。EIP-2584 提出了一种方法，既让链持续运行，又能在可预测的时间内完成。\n\n## 它如何运作\n\n分三个阶段（摘要里说是四个，但正文描述的是三个）：\n\n1. **阶段 1：覆盖层。** 从区块 `h₁` 开始，所有状态*写入*都进入一个新的、最初为空的二叉**覆盖层 trie**，其根是区块头中的一个新字段。旧的十六叉**基础 trie** 被冻结；读取先查覆盖层，未命中再回退到基础 trie。被删除的账户在覆盖层中用空哈希标记。与此同时，每个节点在后台把冻结的十六叉 trie 转换为二叉。\n2. **阶段 2：合并。** 在区块 `h₂`，状态根切换为转换好的二叉基础根。覆盖层变为只读/只能删除；写入进入基础 trie。每个区块之前，覆盖层中前 `N` 个账户（按键顺序）被移入基础 trie。\n3. **阶段 3：完成。** 覆盖层清空之后，其根字段会从区块头中移除。\n\n`h₂` 必须与 `h₁` 相隔足够远，让矿工能完成转换；作者报告称，原型在一台高速机器上大约 30 分钟即可完成转换。\n\n## 示例代码\n\n阶段 1 中状态访问的伪代码：\n\n```python\nEMPTY = keccak(b\"\")\n\ndef read_account(addr):\n    v = overlay.get(addr)\n    if v == EMPTY:            # deleted during the transition\n        return None\n    if v is not None:\n        return v\n    return base_hex.get(addr) # frozen hexary trie\n\ndef write_account(addr, value):\n    overlay.put(addr, value)  # base trie is never touched in phase 1\n\ndef delete_account(addr):\n    overlay.put(addr, EMPTY)\n```\n\n以及阶段 2 中每个区块的合并步骤：\n\n```python\nfor addr, v in overlay.first_n_sorted(N):\n    if v == EMPTY:\n        base_bin.delete(addr)\n    else:\n        base_bin.put(addr, v)\n    overlay.delete(addr)\n```\n\n## 需要注意\n\n- 状态为 **Stagnant**。这是一次会改变区块格式和哈希的硬分叉，从未被排入计划。\n- 规范中的安全说明：攻击者可能撑大覆盖层以拖延阶段 2（也许可以通过在阶段 1 提高 `SSTORE` 的价格来缓解）；如果 `h₂` 来得太早，矿工可能来不及算出转换后的根。\n- 覆盖层的想法延续到了后来的状态迁移工作中：[EIP-7612](/eip-7612/)（向 Verkle 的覆盖层过渡）和 [EIP-7748](/eip-7748/)（状态转换）。目标树此后已从 Verkle（[EIP-6800](/eip-6800/)）转向统一二叉树（[EIP-7864](/eip-7864/)），两者仍然是草案或停滞状态。\n"}}}
