{"eip":8347,"title":"Offline State Migration to the PBT","description":"Convert state to the PBT off the consensus-critical path, distribute a verifiable snapshot, and swap the commitment at a single fork","authors":["Carlos Perez (@CPerezz)","Maria Silva (@misilva73)","Kevaundray Wedderburn (@kevaundray)"],"status":"Draft","type":"Standards Track","category":"Core","created":"2026-07-23","requires":[7523,7928,8159,8297],"discussionsTo":"https://ethereum-magicians.org/t/eip-8347-offline-state-migration-to-the-pbt/29089","repo":"EIPs","label":"EIP-8347","officialUrl":"https://eips.ethereum.org/EIPS/eip-8347","sourceUrl":"https://github.com/ethereum/EIPs/blob/master/EIPS/eip-8347.md","url":"https://eips.huatuo.xyz/eip-8347/","tldr":{"en":"A plan to move Ethereum's state from the Merkle Patricia Trie to the Partitioned Binary Tree by converting it off-chain into a verifiable snapshot, catching up with block access lists, and switching the state root at a single fork.","ja":"Ethereum のステートを Merkle Patricia Trie から Partitioned Binary Tree へ移行する計画。オフチェーンで検証可能なスナップショットに変換し、ブロックアクセスリストで追いつき、1 回のフォークでステートルートを切り替える。","ko":"이더리움의 상태를 Merkle Patricia Trie에서 Partitioned Binary Tree로 옮기는 계획. 오프체인에서 검증 가능한 스냅샷으로 변환하고, 블록 액세스 리스트로 따라잡은 뒤, 한 번의 포크에서 상태 루트를 전환한다.","zh":"一项把以太坊状态从 Merkle Patricia Trie 迁移到 Partitioned Binary Tree 的方案：先在链下将其转换为可验证的快照，再借助区块访问列表追赶，并在单个分叉处切换状态根。"},"tags":["state","binary-tree","migration","statelessness","core"],"explainers":{"en":{"lang":"en","tldr":"A plan to move Ethereum's state from the Merkle Patricia Trie to the Partitioned Binary Tree by converting it off-chain into a verifiable snapshot, catching up with block access lists, and switching the state root at a single fork.","tags":["state","binary-tree","migration","statelessness","core"],"related":[8297,7928,7748,7523],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-8347/","markdown":"## What problem does it solve?\n\n[EIP-8297](/eip-8297/) proposes replacing Ethereum's hexary Merkle Patricia Trie (MPT) with a **Partitioned Binary Tree (PBT)**, which is friendlier to stateless clients and zk provers. The hard part is moving hundreds of gigabytes of live mainnet state to the new commitment without splitting the chain.\n\nOne family of proposals ([EIP-7748](/eip-7748/) and similar) converts state *online*: a few accounts per block, inside consensus, with an overlay tree in between. EIP-8347 takes the other path: convert **offline**, outside consensus, then switch everything at once. The benefits it claims:\n\n- The fork changes only how `stateRoot` is computed. No conversion cursor lives in state and no MPT walk order becomes consensus-critical.\n- The state root always commits to the whole state (MPT before, PBT after), so no hybrid proofs are needed.\n- zkEVM provers never have to prove a conversion step.\n\nThe costs: nodes hold both trees for a while (roughly double state storage), apply every block's writes to both, and consensus cannot see conversion progress directly.\n\n## How it works\n\n1. **Conversion (off-chain).** A finalized `ANCHOR_BLOCK` is picked. Producers build a *preimage file* (raw addresses and slot keys behind the MPT's hashed paths) and a byte-canonical **PBT snapshot** containing only leaves. Both are pure functions of the anchor state, so independent producers must emit identical bytes.\n2. **Distribution and dual-check.** Anyone may distribute the artifacts (P2P, era-style files, CDNs, torrents). Every node verifies them twice: rebuild the PBT and match the claimed root, *and* re-hash the same leaves under the MPT schema and match the anchor block's header `stateRoot`. The second check ties the snapshot to consensus, so the source need not be trusted.\n3. **Catch-up via BAL-replay.** The node applies each later block's writes from its [EIP-7928](/eip-7928/) block access list straight to the PBT, without re-executing. Late joiners use re-anchored snapshots, roughly weekly (`REANCHOR_CADENCE = 50400` blocks).\n4. **Shadow commitment.** Attesters should publish signed PBT roots of each block, so the network can see agreement before the switch. This is for observability only.\n5. **Swap.** At `PBT_ACTIVATION_FORK` the header's `stateRoot` starts holding the PBT root. No header field is added or retyped, and the beacon chain treats the root as opaque bytes.\n\n## Sample code\n\nRecord layout of the preimage file (byte-canonical, sorted by hashed key):\n\n```text\nrecord = address[20] | slotCount[4, big-endian] | slotKey[32] * slotCount\n  - records sorted ascending by keccak256(address)\n  - slot keys within a record sorted ascending by keccak256(slotKey)\n```\n\nSnapshot layout and the dual-check, as pseudocode:\n\n```python\n# snapshot = record* | 0x07 | pbtRoot[32]\n# tags: 0x00-0x02 account header, 0x03 code group, 0x04-0x06 storage\ndef verify_snapshot(snapshot, preimages, anchor_header):\n    leaves, claimed_root = parse_snapshot(snapshot)\n    assert build_pbt(leaves).root == claimed_root                  # internal consistency\n    assert mpt_root_from(leaves, preimages) == anchor_header.state_root  # consensus anchoring\n```\n\n## Things to know\n\n- **Status: Draft.** `ANCHOR_BLOCK` is TBD and the activation fork is not scheduled; that is left to a future hard-fork meta EIP.\n- It depends on the PBT design in EIP-8297 (itself a Draft), on BALs from EIP-7928, and on empty accounts being gone ([EIP-7523](/eip-7523/)), so empty accounts are excluded from the snapshot.\n- Recovering all key preimages is the expensive part, because Keccak cannot be inverted. They come from clients that retained them, from BALs, or from replaying the chain.\n- Expect more disk and write load during the transition window, until the activation block is finalized.\n- Reorgs must be handled on the PBT too: nodes should keep the last finalized PBT as a base and treat newer blocks as discardable layers.\n"},"ja":{"lang":"ja","tldr":"Ethereum のステートを Merkle Patricia Trie から Partitioned Binary Tree へ移行する計画。オフチェーンで検証可能なスナップショットに変換し、ブロックアクセスリストで追いつき、1 回のフォークでステートルートを切り替える。","tags":["state","binary-tree","migration","statelessness","core"],"related":[8297,7928,7748,7523],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-8347/","markdown":"## 何を解決するのか\n\n[EIP-8297](/eip-8297/) は、Ethereum の 16 分木 Merkle Patricia Trie（MPT）を、ステートレスクライアントと zk プルーバーにとって扱いやすい **Partitioned Binary Tree（PBT）** に置き換えることを提案しています。難しいのは、数百ギガバイトのメインネットのライブステートを、チェーンを分裂させずに新しいコミットメントへ移すことです。\n\n提案の一群（[EIP-7748](/eip-7748/) など）は、ステートを*オンライン*で変換します。コンセンサス内で 1 ブロックあたり数アカウントずつ、間にオーバーレイツリーを挟みます。EIP-8347 は別の道を取ります。コンセンサスの外で**オフライン**に変換し、その後すべてを一度に切り替えます。主張されている利点:\n\n- フォークが変えるのは `stateRoot` の計算方法だけです。変換カーソルがステートに存在せず、MPT の走査順序がコンセンサスにとって重要になることもありません。\n- ステートルートは常にステート全体にコミットするため（以前は MPT、以後は PBT）、ハイブリッドな証明は不要です。\n- zkEVM プルーバーが変換ステップを証明する必要は一切ありません。\n\nコスト: ノードはしばらくの間、両方のツリーを保持し（ステートストレージはおよそ 2 倍）、すべてのブロックの書き込みを両方に適用し、コンセンサスは変換の進行状況を直接見ることができません。\n\n## 仕組み\n\n1. **変換（オフチェーン）。** ファイナライズ済みの `ANCHOR_BLOCK` が選ばれます。プロデューサーは、*プリイメージファイル*（MPT のハッシュ化されたパスの元になる生のアドレスとスロットキー）と、リーフのみを含むバイト正準な **PBT スナップショット** を構築します。どちらもアンカーのステートの純粋関数なので、独立したプロデューサーは同一のバイト列を出力しなければなりません。\n2. **配布とダブルチェック。** 誰でも成果物を配布できます（P2P、era 形式のファイル、CDN、トレント）。すべてのノードはそれを 2 回検証します。PBT を再構築して主張されたルートと一致させること、*そして*同じリーフを MPT スキーマでハッシュし直してアンカーブロックのヘッダーの `stateRoot` と一致させることです。2 つ目のチェックがスナップショットをコンセンサスに結びつけるため、配布元を信頼する必要はありません。\n3. **BAL リプレイによる追いつき。** ノードは、後続の各ブロックの書き込みを、再実行せずに、[EIP-7928](/eip-7928/) のブロックアクセスリストから直接 PBT に適用します。遅れて参加するノードは、およそ週 1 回（`REANCHOR_CADENCE = 50400` ブロック）の再アンカーされたスナップショットを使います。\n4. **シャドウコミットメント。** アテスターは各ブロックの署名付き PBT ルートを公開すべきで、これによりネットワークは切り替え前に合意を確認できます。これは可観測性のためだけのものです。\n5. **切り替え。** `PBT_ACTIVATION_FORK` で、ヘッダーの `stateRoot` が PBT ルートを保持し始めます。ヘッダーフィールドの追加や型の変更はなく、ビーコンチェーンはそのルートを不透明なバイト列として扱います。\n\n## サンプルコード\n\nプリイメージファイルのレコードレイアウト（バイト正準、ハッシュ化されたキーでソート）:\n\n```text\nrecord = address[20] | slotCount[4, big-endian] | slotKey[32] * slotCount\n  - records sorted ascending by keccak256(address)\n  - slot keys within a record sorted ascending by keccak256(slotKey)\n```\n\nスナップショットのレイアウトとダブルチェック（擬似コード）:\n\n```python\n# snapshot = record* | 0x07 | pbtRoot[32]\n# tags: 0x00-0x02 account header, 0x03 code group, 0x04-0x06 storage\ndef verify_snapshot(snapshot, preimages, anchor_header):\n    leaves, claimed_root = parse_snapshot(snapshot)\n    assert build_pbt(leaves).root == claimed_root                  # internal consistency\n    assert mpt_root_from(leaves, preimages) == anchor_header.state_root  # consensus anchoring\n```\n\n## 知っておくべきこと\n\n- **ステータス: Draft。** `ANCHOR_BLOCK` は TBD で、有効化フォークはスケジュールされていません。それは将来のハードフォークのメタ EIP に委ねられています。\n- EIP-8297 の PBT 設計（それ自体が Draft）、EIP-7928 の BAL、そして空アカウントがなくなっていること（[EIP-7523](/eip-7523/)）に依存しているため、空アカウントはスナップショットから除外されます。\n- すべてのキーのプリイメージを復元するのは、Keccak を逆算できないため、コストの高い部分です。プリイメージは、それを保持していたクライアント、BAL、またはチェーンのリプレイから得られます。\n- 切り替えの期間中、有効化ブロックがファイナライズされるまで、ディスクと書き込みの負荷が増えることを想定してください。\n- リオルグは PBT 側でも処理しなければなりません。ノードは最後にファイナライズされた PBT をベースとして保持し、それより新しいブロックは破棄可能なレイヤーとして扱うべきです。\n"},"ko":{"lang":"ko","tldr":"이더리움의 상태를 Merkle Patricia Trie에서 Partitioned Binary Tree로 옮기는 계획. 오프체인에서 검증 가능한 스냅샷으로 변환하고, 블록 액세스 리스트로 따라잡은 뒤, 한 번의 포크에서 상태 루트를 전환한다.","tags":["state","binary-tree","migration","statelessness","core"],"related":[8297,7928,7748,7523],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-8347/","markdown":"## 어떤 문제를 해결하나요?\n\n[EIP-8297](/eip-8297/)은 이더리움의 16진 Merkle Patricia Trie(MPT)를 스테이트리스 클라이언트와 zk 증명기에 더 친화적인 **Partitioned Binary Tree(PBT)**로 대체할 것을 제안합니다. 어려운 점은 수백 GB의 메인넷 라이브 상태를 체인을 분열시키지 않고 새 커밋먼트로 옮기는 것입니다.\n\n제안의 한 계열([EIP-7748](/eip-7748/) 등)은 상태를 *온라인*으로 변환합니다. 합의 안에서 블록당 몇 개의 계정씩, 중간에 오버레이 트리를 두고 변환합니다. EIP-8347은 다른 길을 택합니다. 합의 바깥에서 **오프라인**으로 변환한 뒤 한꺼번에 전환합니다. 주장하는 이점은 다음과 같습니다.\n\n- 포크는 `stateRoot`가 계산되는 방식만 바꿉니다. 상태 안에 변환 커서가 없고, MPT 순회 순서가 합의에 결정적인 요소가 되지도 않습니다.\n- 상태 루트는 항상 전체 상태에 커밋합니다(이전에는 MPT, 이후에는 PBT). 따라서 하이브리드 증명이 필요 없습니다.\n- zkEVM 증명기는 변환 단계를 증명할 필요가 전혀 없습니다.\n\n비용은 다음과 같습니다. 노드는 한동안 두 트리를 모두 보유하고(상태 스토리지가 대략 두 배), 모든 블록의 쓰기를 둘 다에 적용하며, 합의는 변환 진행 상황을 직접 볼 수 없습니다.\n\n## 어떻게 동작하나요?\n\n1. **변환(오프체인).** 파이널라이즈된 `ANCHOR_BLOCK`이 선택됩니다. 생산자는 *프리이미지 파일*(MPT의 해시된 경로 뒤에 있는 원시 주소와 슬롯 키)과, 리프만 담은 바이트 정규 **PBT 스냅샷**을 만듭니다. 둘 다 앵커 상태의 순수 함수이므로 독립적인 생산자들이 동일한 바이트를 내놓아야 합니다.\n2. **배포와 이중 검증.** 누구나 산출물을 배포할 수 있습니다(P2P, era 방식 파일, CDN, 토렌트). 모든 노드는 이를 두 번 검증합니다. PBT를 다시 만들어 주장된 루트와 맞추고, *그리고* 같은 리프를 MPT 스키마로 다시 해시해 앵커 블록 헤더의 `stateRoot`와 맞춥니다. 두 번째 검증이 스냅샷을 합의에 묶어 주므로 출처를 신뢰할 필요가 없습니다.\n3. **BAL 재생으로 따라잡기.** 노드는 이후 각 블록의 쓰기를 다시 실행하지 않고 [EIP-7928](/eip-7928/) 블록 액세스 리스트에서 곧바로 PBT에 적용합니다. 늦게 합류하는 노드는 대략 주 1회(`REANCHOR_CADENCE = 50400` 블록) 다시 앵커링된 스냅샷을 사용합니다.\n4. **섀도 커밋먼트.** 어테스터는 각 블록의 서명된 PBT 루트를 게시해야 하며, 그러면 네트워크가 전환 전에 합의 여부를 볼 수 있습니다. 이는 관측 용도일 뿐입니다.\n5. **교체.** `PBT_ACTIVATION_FORK`에서 헤더의 `stateRoot`가 PBT 루트를 담기 시작합니다. 헤더 필드가 추가되거나 타입이 바뀌지 않으며, 비콘 체인은 그 루트를 불투명한 바이트로 취급합니다.\n\n## 샘플 코드\n\n프리이미지 파일의 레코드 레이아웃(바이트 정규, 해시된 키 기준 정렬):\n\n```text\nrecord = address[20] | slotCount[4, big-endian] | slotKey[32] * slotCount\n  - records sorted ascending by keccak256(address)\n  - slot keys within a record sorted ascending by keccak256(slotKey)\n```\n\n스냅샷 레이아웃과 이중 검증(의사 코드):\n\n```python\n# snapshot = record* | 0x07 | pbtRoot[32]\n# tags: 0x00-0x02 account header, 0x03 code group, 0x04-0x06 storage\ndef verify_snapshot(snapshot, preimages, anchor_header):\n    leaves, claimed_root = parse_snapshot(snapshot)\n    assert build_pbt(leaves).root == claimed_root                  # internal consistency\n    assert mpt_root_from(leaves, preimages) == anchor_header.state_root  # consensus anchoring\n```\n\n## 알아둘 점\n\n- **상태: Draft.** `ANCHOR_BLOCK`은 TBD이고 활성화 포크는 일정이 잡히지 않았습니다. 이는 향후 하드 포크 메타 EIP에 맡겨져 있습니다.\n- EIP-8297의 PBT 설계(그 자체도 Draft), EIP-7928의 BAL, 그리고 빈 계정이 사라졌다는 점([EIP-7523](/eip-7523/))에 의존하므로, 빈 계정은 스냅샷에서 제외됩니다.\n- 모든 키 프리이미지를 복원하는 것이 비용이 많이 드는 부분인데, Keccak은 역산할 수 없기 때문입니다. 프리이미지는 이를 보관해 온 클라이언트, BAL, 또는 체인 재생에서 얻습니다.\n- 전환 기간 동안, 활성화 블록이 파이널라이즈될 때까지 디스크와 쓰기 부하가 늘어날 것으로 예상하세요.\n- 리오그는 PBT에서도 처리해야 합니다. 노드는 마지막으로 파이널라이즈된 PBT를 기반으로 유지하고 더 최근 블록은 버릴 수 있는 레이어로 취급해야 합니다.\n"},"zh":{"lang":"zh","tldr":"一项把以太坊状态从 Merkle Patricia Trie 迁移到 Partitioned Binary Tree 的方案：先在链下将其转换为可验证的快照，再借助区块访问列表追赶，并在单个分叉处切换状态根。","tags":["state","binary-tree","migration","statelessness","core"],"related":[8297,7928,7748,7523],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-8347/","markdown":"## 它解决什么问题？\n\n[EIP-8297](/eip-8297/) 提议用 **Partitioned Binary Tree（PBT）** 取代以太坊的十六叉 Merkle Patricia Trie（MPT），PBT 对无状态客户端和 zk 证明器更友好。难点在于，如何在不分裂链的前提下，把数百 GB 的主网实时状态迁移到新的承诺上。\n\n一类方案（[EIP-7748](/eip-7748/) 及类似方案）*在线*转换状态：在共识内每个区块转换几个账户，中间使用一棵叠加树。EIP-8347 走另一条路：在共识之外**离线**转换，然后一次性全部切换。它宣称的好处：\n\n- 分叉只改变 `stateRoot` 的计算方式。状态中没有转换游标，MPT 的遍历顺序也不会成为共识关键。\n- 状态根始终承诺整个状态（之前是 MPT，之后是 PBT），因此不需要混合证明。\n- zkEVM 证明器永远不必证明转换步骤。\n\n代价是：节点在一段时间内要同时持有两棵树（状态存储大约翻倍），把每个区块的写入同时应用到两棵树，而且共识无法直接看到转换进度。\n\n## 它如何运作\n\n1. **转换（链下）。** 选定一个已最终确定的 `ANCHOR_BLOCK`。生产者构建一个*原像文件*（MPT 哈希路径背后的原始地址和存储槽键），以及一个字节规范化、只含叶子的 **PBT 快照**。两者都是锚点状态的纯函数，因此独立的生产者必须输出完全相同的字节。\n2. **分发与双重检查。** 任何人都可以分发这些产物（P2P、era 风格文件、CDN、种子）。每个节点都会验证两次：重建 PBT 并匹配所声称的根，*并且*按 MPT 模式对相同的叶子重新哈希，匹配锚点区块头中的 `stateRoot`。第二次检查把快照与共识绑定在一起，因此无需信任来源。\n3. **通过 BAL 重放追赶。** 节点把之后每个区块的写入，直接从其 [EIP-7928](/eip-7928/) 区块访问列表应用到 PBT，而无需重新执行。后加入的节点使用重新锚定的快照，大约每周一次（`REANCHOR_CADENCE = 50400` 个区块）。\n4. **影子承诺。** 见证者应当发布每个区块的签名 PBT 根，让网络在切换前能看到共识是否一致。这仅用于可观测性。\n5. **切换。** 在 `PBT_ACTIVATION_FORK`，区块头的 `stateRoot` 开始存放 PBT 根。不新增区块头字段，也不改变其类型，信标链把该根视为不透明的字节。\n\n## 示例代码\n\n原像文件的记录布局（字节规范化，按哈希后的键排序）：\n\n```text\nrecord = address[20] | slotCount[4, big-endian] | slotKey[32] * slotCount\n  - records sorted ascending by keccak256(address)\n  - slot keys within a record sorted ascending by keccak256(slotKey)\n```\n\n快照布局和双重检查，以伪代码表示：\n\n```python\n# snapshot = record* | 0x07 | pbtRoot[32]\n# tags: 0x00-0x02 account header, 0x03 code group, 0x04-0x06 storage\ndef verify_snapshot(snapshot, preimages, anchor_header):\n    leaves, claimed_root = parse_snapshot(snapshot)\n    assert build_pbt(leaves).root == claimed_root                  # internal consistency\n    assert mpt_root_from(leaves, preimages) == anchor_header.state_root  # consensus anchoring\n```\n\n## 需要注意\n\n- **状态：Draft。** `ANCHOR_BLOCK` 尚待确定，激活分叉也未排期；这留给未来的硬分叉元 EIP。\n- 它依赖 EIP-8297 中的 PBT 设计（其本身也是 Draft）、EIP-7928 的 BAL，以及空账户已被清除（[EIP-7523](/eip-7523/)），因此快照中不包含空账户。\n- 恢复所有键的原像是代价高昂的部分，因为 Keccak 无法求逆。它们来自保留了原像的客户端、BAL，或重放链。\n- 在过渡窗口期间，直到激活区块被最终确定之前，预计磁盘和写入负载会增加。\n- 重组在 PBT 上也必须处理：节点应保留最近一个已最终确定的 PBT 作为基础，并把更新的区块当作可丢弃的层。\n"}}}
