{"eip":8189,"title":"snap/2 - BAL-Based State Healing","description":"Replaces trie node healing with block access list based state catch-up in the snap protocol","authors":["Toni Wahrstätter (@nerolation)","Gary Rong (@rjl493456442)"],"status":"Last Call","type":"Standards Track","category":"Networking","created":"2026-03-06","requires":[7928],"discussionsTo":"https://ethereum-magicians.org/t/eip-8189-snap-2-bal-based-state-healing/27953","repo":"EIPs","label":"EIP-8189","officialUrl":"https://eips.ethereum.org/EIPS/eip-8189","sourceUrl":"https://github.com/ethereum/EIPs/blob/master/EIPS/eip-8189.md","url":"https://eips.huatuo.xyz/eip-8189/","tldr":{"en":"Upgrades the snap sync protocol to snap/2, replacing slow trie-node \"healing\" with downloading block access lists and replaying their state diffs, so new nodes catch up to the chain head in fewer round trips.","ja":"snap sync プロトコルを snap/2 に更新し、遅いトライノードの「ヒーリング」を、ブロックアクセスリストのダウンロードとその状態差分のリプレイに置き換える。新しいノードが少ない往復でチェーンの先頭に追いつける。","ko":"snap sync 프로토콜을 snap/2로 업그레이드해, 느린 트라이 노드 \"힐링\"을 블록 액세스 리스트 다운로드와 그 상태 차이 재생으로 대체한다. 새 노드가 더 적은 왕복으로 체인 헤드를 따라잡는다.","zh":"把 snap 同步协议升级为 snap/2：用下载区块访问列表并重放其状态差异，取代缓慢的 trie 节点“修复”，让新节点用更少的往返追上链头。"},"tags":["networking","sync","snap","devp2p","bal"],"explainers":{"en":{"lang":"en","tldr":"Upgrades the snap sync protocol to snap/2, replacing slow trie-node \"healing\" with downloading block access lists and replaying their state diffs, so new nodes catch up to the chain head in fewer round trips.","tags":["networking","sync","snap","devp2p","bal"],"related":[7928],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-8189/","markdown":"## What problem does it solve?\n\nSnap sync lets a new node download Ethereum state in large ranges instead of walking the trie node by node. But the chain keeps moving while the download runs, so the copied state ends up a patchwork of different blocks. snap/1 fixes this in a **healing** phase: the node repeatedly asks peers for individual trie nodes (`GetTrieNodes`) until the state root matches. This can take many round trips, because the node only discovers what is missing as it goes.\n\n[EIP-7928](/eip-7928/) adds block-level access lists (BALs): a per-block record of every state change, committed in the block header. With BALs, a syncing node already knows exactly which blocks it fell behind on and can simply replay their diffs.\n\n## How it works\n\n**Protocol changes (snap/1 → snap/2):**\n\n| Message | ID | Change |\n| --- | --- | --- |\n| `GetTrieNodes` / `TrieNodes` | 0x06 / 0x07 | Removed |\n| `GetBlockAccessLists` | 0x08 | New: `[request-id, [blockhash...], bytes]` |\n| `BlockAccessLists` | 0x09 | New: `[request-id, [bal...]]` |\n| Account, storage and bytecode range messages | 0x00 to 0x05 | Unchanged |\n\n- Responses keep request order. A missing BAL is returned as the RLP empty string `0x80`. A peer may truncate from the tail to respect the `bytes` limit, with a recommended 2 MiB soft cap.\n- Every BAL must be checked: `keccak256(rlp(bal))` must equal the header's `block-access-list-hash`.\n\n**Sync algorithm:**\n\n1. Pick a pivot block P a little behind the head (for example HEAD-64).\n2. Bulk-download the state at P with the range messages.\n3. When the pivot moves to P+K, fetch BALs for blocks P+1 through P+K, verify each one, apply the diffs in order, and continue from P+K.\n4. Repeat as the chain advances, then verify the final state root.\n\nIf a reorg goes past the pivot, the node uses BALs from the old fork (back to the common ancestor) to find and re-fetch the entries that fork touched. Nodes are therefore asked to keep BALs for orphaned blocks within the retention period too.\n\n## Sample code\n\nWire messages and the verification step, in pseudocode:\n\n```python\n# request\nGetBlockAccessLists = [request_id, [h1, h2, h3], 2 * 1024 * 1024]\n\n# response: positional, 0x80 where unavailable\nBlockAccessLists = [request_id, [bal1, bal2, b\"\\x80\"]]\n\ndef apply_catch_up(state, headers, bals):\n    for header, bal in zip(headers, bals):          # strict block order\n        if bal == b\"\\x80\":\n            raise Retry(\"ask another peer\")\n        assert keccak256(rlp.encode(bal)) == header.block_access_list_hash\n        state.apply_diff(bal)\n    return state\n```\n\n## Things to know\n\n- **Status: Last Call** (deadline 2026-11-01 in the spec). Final wording may still change.\n- snap/2 only works for blocks after EIP-7928 activates (the spec refers to post-Amsterdam blocks), since earlier headers have no BAL hash. Older clients keep using snap/1.\n- A syncing node should pick snap/1 or snap/2 for a sync, not run both at once; afterwards it can serve both.\n- BAL requests can return much more data than they ask for, so serving nodes should rate-limit. Peers that return empty entries for blocks they should have can be deprioritized.\n- BAL exchange lives in `snap` rather than `eth`, following the idea that sync primitives belong in satellite protocols.\n"},"ja":{"lang":"ja","tldr":"snap sync プロトコルを snap/2 に更新し、遅いトライノードの「ヒーリング」を、ブロックアクセスリストのダウンロードとその状態差分のリプレイに置き換える。新しいノードが少ない往復でチェーンの先頭に追いつける。","tags":["networking","sync","snap","devp2p","bal"],"related":[7928],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-8189/","markdown":"## 何を解決するのか\n\nsnap sync では、新しいノードがトライをノード単位でたどる代わりに、Ethereum のステートを大きな範囲で一括ダウンロードできます。しかし、ダウンロードの間もチェーンは進み続けるため、コピーされたステートは異なるブロックのつぎはぎになります。snap/1 は、これを**ヒーリング**フェーズで解決します。ステートルートが一致するまで、ノードはピアに個々のトライノード（`GetTrieNodes`）を繰り返し要求します。ノードは進めながら足りないものを発見していくだけなので、多くの往復が必要になることがあります。\n\n[EIP-7928](/eip-7928/) はブロックレベルのアクセスリスト（BAL）を追加します。これは、すべての状態変更をブロックごとに記録したもので、ブロックヘッダーにコミットされます。BAL があれば、同期中のノードはどのブロックで遅れたのかを正確に把握しており、その差分を単純にリプレイできます。\n\n## 仕組み\n\n**プロトコルの変更（snap/1 → snap/2）:**\n\n| メッセージ | ID | 変更 |\n| --- | --- | --- |\n| `GetTrieNodes` / `TrieNodes` | 0x06 / 0x07 | 削除 |\n| `GetBlockAccessLists` | 0x08 | 新規: `[request-id, [blockhash...], bytes]` |\n| `BlockAccessLists` | 0x09 | 新規: `[request-id, [bal...]]` |\n| アカウント、ストレージ、バイトコードの範囲メッセージ | 0x00 〜 0x05 | 変更なし |\n\n- レスポンスはリクエストの順序を保ちます。存在しない BAL は RLP の空文字列 `0x80` として返されます。ピアは `bytes` の上限を守るため、末尾から切り詰めてもかまいません。推奨されるソフトキャップは 2 MiB です。\n- すべての BAL を検証しなければなりません。`keccak256(rlp(bal))` がヘッダーの `block-access-list-hash` と等しくなければなりません。\n\n**同期アルゴリズム:**\n\n1. 先頭より少し手前のピボットブロック P を選びます（たとえば HEAD-64）。\n2. 範囲メッセージで P 時点のステートを一括ダウンロードします。\n3. ピボットが P+K に進んだら、ブロック P+1 から P+K までの BAL を取得し、それぞれを検証し、差分を順に適用して、P+K から続けます。\n4. チェーンが進むたびに繰り返し、最後に最終的なステートルートを検証します。\n\nリオーグがピボットを越えた場合、ノードは旧フォーク（共通の祖先まで遡る）の BAL を使って、そのフォークが触れたエントリを見つけて再取得します。そのため、ノードには、孤立したブロックの BAL も保持期間内は保存しておくことが求められます。\n\n## サンプルコード\n\nワイヤーメッセージと検証ステップを疑似コードで示します。\n\n```python\n# request\nGetBlockAccessLists = [request_id, [h1, h2, h3], 2 * 1024 * 1024]\n\n# response: positional, 0x80 where unavailable\nBlockAccessLists = [request_id, [bal1, bal2, b\"\\x80\"]]\n\ndef apply_catch_up(state, headers, bals):\n    for header, bal in zip(headers, bals):          # strict block order\n        if bal == b\"\\x80\":\n            raise Retry(\"ask another peer\")\n        assert keccak256(rlp.encode(bal)) == header.block_access_list_hash\n        state.apply_diff(bal)\n    return state\n```\n\n## 知っておくべきこと\n\n- **ステータス: Last Call**（仕様上の締め切りは 2026-11-01）。最終的な文言はまだ変わる可能性があります。\n- snap/2 が使えるのは EIP-7928 が有効化された後のブロックだけです（仕様は Amsterdam 以降のブロックに言及しています）。それ以前のヘッダーには BAL ハッシュがないためです。古いクライアントは引き続き snap/1 を使います。\n- 同期中のノードは、1 回の同期で snap/1 か snap/2 のどちらかを選ぶべきで、両方を同時に動かしてはいけません。同期後は両方を提供できます。\n- BAL のリクエストは、要求した以上に多くのデータを返すことがあるため、提供側のノードはレート制限をかけるべきです。持っているはずのブロックに対して空のエントリを返すピアは、優先度を下げられます。\n- BAL の交換が `eth` ではなく `snap` に置かれているのは、同期のプリミティブはサテライトプロトコルに属するという考え方に従ったものです。\n"},"ko":{"lang":"ko","tldr":"snap sync 프로토콜을 snap/2로 업그레이드해, 느린 트라이 노드 \"힐링\"을 블록 액세스 리스트 다운로드와 그 상태 차이 재생으로 대체한다. 새 노드가 더 적은 왕복으로 체인 헤드를 따라잡는다.","tags":["networking","sync","snap","devp2p","bal"],"related":[7928],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-8189/","markdown":"## 어떤 문제를 해결하나요?\n\nsnap sync는 새 노드가 트라이를 노드 단위로 훑는 대신 이더리움 상태를 큰 범위로 내려받게 해 줍니다. 하지만 다운로드하는 동안에도 체인은 계속 진행되므로, 복사된 상태는 서로 다른 블록의 조각보가 됩니다. snap/1은 이를 **힐링** 단계에서 해결합니다. 상태 루트가 일치할 때까지 노드가 피어에게 개별 트라이 노드(`GetTrieNodes`)를 반복해서 요청합니다. 노드는 진행하면서 무엇이 빠졌는지 알아낼 뿐이므로 왕복이 많이 필요할 수 있습니다.\n\n[EIP-7928](/eip-7928/)은 블록 수준 액세스 리스트(BAL)를 추가합니다. 블록마다 모든 상태 변경을 기록하고 블록 헤더에 커밋하는 것입니다. BAL이 있으면 동기화 중인 노드는 자신이 어떤 블록에서 뒤처졌는지 정확히 알고, 그 차이를 그대로 재생하면 됩니다.\n\n## 어떻게 동작하나요?\n\n**프로토콜 변경(snap/1 → snap/2):**\n\n| 메시지 | ID | 변경 |\n| --- | --- | --- |\n| `GetTrieNodes` / `TrieNodes` | 0x06 / 0x07 | 제거 |\n| `GetBlockAccessLists` | 0x08 | 신규: `[request-id, [blockhash...], bytes]` |\n| `BlockAccessLists` | 0x09 | 신규: `[request-id, [bal...]]` |\n| 계정, 스토리지, 바이트코드 범위 메시지 | 0x00 ~ 0x05 | 변경 없음 |\n\n- 응답은 요청 순서를 유지합니다. 없는 BAL은 RLP 빈 문자열 `0x80`으로 반환됩니다. 피어는 `bytes` 한도를 지키기 위해 끝에서부터 잘라낼 수 있으며, 권장 소프트 상한은 2 MiB입니다.\n- 모든 BAL을 검증해야 합니다. `keccak256(rlp(bal))`이 헤더의 `block-access-list-hash`와 같아야 합니다.\n\n**동기화 알고리즘:**\n\n1. 헤드보다 조금 뒤에 있는 피벗 블록 P를 고릅니다(예를 들어 HEAD-64).\n2. 범위 메시지로 P 시점의 상태를 일괄 다운로드합니다.\n3. 피벗이 P+K로 옮겨가면 블록 P+1부터 P+K까지의 BAL을 가져와 각각 검증하고, 차이를 순서대로 적용한 뒤 P+K부터 이어갑니다.\n4. 체인이 진행됨에 따라 반복하고, 마지막에 최종 상태 루트를 검증합니다.\n\n리오그가 피벗을 넘어가면, 노드는 옛 포크(공통 조상까지 거슬러 올라감)의 BAL을 사용해 그 포크가 건드린 항목을 찾아 다시 가져옵니다. 따라서 노드는 고아 블록의 BAL도 보존 기간 동안 유지하도록 요구받습니다.\n\n## 샘플 코드\n\n와이어 메시지와 검증 단계를 의사 코드로 나타냈습니다.\n\n```python\n# request\nGetBlockAccessLists = [request_id, [h1, h2, h3], 2 * 1024 * 1024]\n\n# response: positional, 0x80 where unavailable\nBlockAccessLists = [request_id, [bal1, bal2, b\"\\x80\"]]\n\ndef apply_catch_up(state, headers, bals):\n    for header, bal in zip(headers, bals):          # strict block order\n        if bal == b\"\\x80\":\n            raise Retry(\"ask another peer\")\n        assert keccak256(rlp.encode(bal)) == header.block_access_list_hash\n        state.apply_diff(bal)\n    return state\n```\n\n## 알아둘 점\n\n- **상태: Last Call**(명세상 마감일은 2026-11-01). 최종 문구는 아직 바뀔 수 있습니다.\n- snap/2는 EIP-7928이 활성화된 이후의 블록에서만 동작합니다(명세는 Amsterdam 이후 블록을 언급합니다). 이전 헤더에는 BAL 해시가 없기 때문입니다. 오래된 클라이언트는 계속 snap/1을 사용합니다.\n- 동기화 중인 노드는 한 번의 동기화에서 snap/1과 snap/2 중 하나를 골라야 하며 둘을 동시에 돌려서는 안 됩니다. 이후에는 둘 다 제공할 수 있습니다.\n- BAL 요청은 요청한 것보다 훨씬 많은 데이터를 반환할 수 있으므로 제공하는 노드는 속도를 제한해야 합니다. 가지고 있어야 할 블록에 대해 빈 항목을 반환하는 피어는 우선순위를 낮출 수 있습니다.\n- BAL 교환이 `eth`가 아니라 `snap`에 있는 것은 동기화 프리미티브는 위성 프로토콜에 속한다는 생각을 따른 것입니다.\n"},"zh":{"lang":"zh","tldr":"把 snap 同步协议升级为 snap/2：用下载区块访问列表并重放其状态差异，取代缓慢的 trie 节点“修复”，让新节点用更少的往返追上链头。","tags":["networking","sync","snap","devp2p","bal"],"related":[7928],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-8189/","markdown":"## 它解决什么问题？\n\nsnap 同步让新节点可以成批范围地下载以太坊状态，而不必逐个节点遍历 trie。但下载期间链仍在前进，所以复制下来的状态最终是由不同区块拼凑而成的。snap/1 在**修复（healing）**阶段解决这个问题：节点反复向对等节点请求单个 trie 节点（`GetTrieNodes`），直到状态根匹配为止。这可能需要很多次往返，因为节点只能边走边发现缺了什么。\n\n[EIP-7928](/eip-7928/) 增加了区块级访问列表（BAL）：对每个区块中所有状态变更的记录，并承诺在区块头中。有了 BAL，正在同步的节点就能确切知道自己落后了哪些区块，只需重放它们的差异即可。\n\n## 它如何运作\n\n**协议变更（snap/1 → snap/2）：**\n\n| 消息 | ID | 变更 |\n| --- | --- | --- |\n| `GetTrieNodes` / `TrieNodes` | 0x06 / 0x07 | 移除 |\n| `GetBlockAccessLists` | 0x08 | 新增：`[request-id, [blockhash...], bytes]` |\n| `BlockAccessLists` | 0x09 | 新增：`[request-id, [bal...]]` |\n| 账户、存储和字节码的范围消息 | 0x00 至 0x05 | 不变 |\n\n- 响应保持请求的顺序。缺失的 BAL 以 RLP 空字符串 `0x80` 返回。对等节点可以从末尾截断以遵守 `bytes` 限制，建议的软上限为 2 MiB。\n- 每个 BAL 都必须校验：`keccak256(rlp(bal))` 必须等于区块头中的 `block-access-list-hash`。\n\n**同步算法：**\n\n1. 选取一个比链头稍早的枢轴区块 P（例如 HEAD-64）。\n2. 用范围消息批量下载 P 处的状态。\n3. 当枢轴前移到 P+K 时，获取区块 P+1 到 P+K 的 BAL，逐个校验，按顺序应用差异，然后从 P+K 继续。\n4. 随着链的推进重复这一过程，最后校验最终的状态根。\n\n如果发生的重组越过了枢轴，节点会使用旧分叉（一直回溯到共同祖先）的 BAL，找出并重新获取该分叉触及的条目。因此也要求节点在保留期内保存孤块的 BAL。\n\n## 示例代码\n\n线上传输的消息和校验步骤，用伪代码表示：\n\n```python\n# request\nGetBlockAccessLists = [request_id, [h1, h2, h3], 2 * 1024 * 1024]\n\n# response: positional, 0x80 where unavailable\nBlockAccessLists = [request_id, [bal1, bal2, b\"\\x80\"]]\n\ndef apply_catch_up(state, headers, bals):\n    for header, bal in zip(headers, bals):          # strict block order\n        if bal == b\"\\x80\":\n            raise Retry(\"ask another peer\")\n        assert keccak256(rlp.encode(bal)) == header.block_access_list_hash\n        state.apply_diff(bal)\n    return state\n```\n\n## 需要注意\n\n- **状态：Last Call**（规范中的截止日期为 2026-11-01）。最终措辞仍可能变化。\n- snap/2 只适用于 EIP-7928 激活之后的区块（规范指的是 Amsterdam 之后的区块），因为更早的区块头没有 BAL 哈希。旧客户端继续使用 snap/1。\n- 正在同步的节点应当在一次同步中选择 snap/1 或 snap/2，而不是同时运行两者；同步完成后可以同时提供两者的服务。\n- BAL 请求返回的数据量可能远多于所请求的，因此提供服务的节点应当限速。对本应拥有的区块返回空条目的对等节点可以被降低优先级。\n- BAL 的交换放在 `snap` 而不是 `eth` 中，遵循同步原语应归属于附属协议的思路。\n"}}}
