---
eip: 8247
label: EIP-8247
title: Ancestor-Indexed BALs
status: Draft
type: Standards Track
category: Core
created: 2026-05-03
requires: 7928
official: https://eips.ethereum.org/EIPS/eip-8247
source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-8247.md
canonical: https://eips.huatuo.xyz/zh/eip-8247/
lang: zh
tldr: 缩小 EIP-7928 的区块级访问列表：让地址和存储键可以指回最近八个区块的列表之一，而不是重复完整的 20 字节或 32 字节的值。
tags: [bal, compression, core, state, access-list]
---

# EIP-8247: Ancestor-Indexed BALs

> Compact references to recent block access lists for repeated addresses and storage slots

**TL;DR:** 缩小 EIP-7928 的区块级访问列表：让地址和存储键可以指回最近八个区块的列表之一，而不是重复完整的 20 字节或 32 字节的值。

## 它解决什么问题？

[EIP-7928](/eip-7928/) 为每个区块添加一个区块访问列表（Block Access List，BAL）：列出该区块触及的每个账户和存储槽，以及交易后的变更。BAL 支持并行执行和验证，但会消耗带宽，而且其体积的大部分是原始标识符：20 字节的地址和 32 字节的存储键。

热门合约和存储槽（主要代币、DEX 池、预言机）在一个又一个区块中被触及，因此相同的标识符反复出现。指向某个值在最近区块中已出现的位置，比把它完整写出来要短得多。作者估计可缩小 30–50 % 的体积，具体取决于区块之间的复用程度。

## 它如何运作

新增两种引用类型，都是 RLP 列表：

```text
AccountRef = [ancestor_offset: uint8, account_index: uint32]
SlotRef    = [ancestor_offset: uint8, account_index: uint32, slot_index: uint32]
```

- `ancestor_offset` 取值 0–7：0 是父区块，7 是第八代祖先。
- `account_index` 是该账户在那个祖先 BAL 中的位置（按 EIP-7928，已按地址排序）。
- `slot_index` 是在该账户的**槽字典**中的位置：它被修改过和被读取过的存储键的并集，经排序并去重。

在 EIP-7928 中出现 `Address` 或 `StorageKey` 的地方，现在都可以出现引用。两者通过 RLP 类型区分：字面值是字节串，引用是列表。

引用总是针对完全*展开*的祖先 BAL（所有引用都已被替换为字面值）来解析，而不是针对编码后的 BAL，因此不会出现引用链。

编码是**规范的**：如果某个值存在任何有效引用，就禁止使用字面值，并且必须使用按 `(ancestor_offset, account_index, slot_index)` 排序最小的那个引用。这使得编码后的 BAL 成为区块及其祖先的确定性函数，构建者无法对其进行填充。

## 示例代码

解析和选择引用的伪代码：

```python
def resolve(ref, block_number, expanded_ancestors):
    off = ref[0]
    assert 0 <= off <= 7
    anc = expanded_ancestors[block_number - off - 1]   # must be post-activation
    acct = anc.accounts[ref[1]]                         # IndexError -> invalid block
    if len(ref) == 2:
        return acct.address
    return acct.slot_dictionary[ref[2]]                 # sorted union of reads+writes

def encode_address(addr, block_number, expanded_ancestors):
    for off in range(8):                                # smallest offset first
        anc = expanded_ancestors.get(block_number - off - 1)
        if anc and addr in anc.account_index:
            return [off, anc.account_index[addr]]
    return addr                                         # literal only if no ref exists
```

每项节省的大小：

```text
Address    20 bytes -> AccountRef ~5 bytes
StorageKey 32 bytes -> SlotRef    ~9 bytes
```

## 需要注意

- **状态：Draft。** 测试用例仍待定。
- 这是一项硬分叉变更。对激活前区块的引用是无效的，激活前的 BAL 保持字面值形式。
- 客户端必须保留（或能够重建）最近八个规范区块的展开 BAL 和槽字典。查找是有界的数组访问，因此 DoS 风险有限。
- EIP-7928 的 `bal_items` 大小限制作用于展开后的 BAL，所以压缩不会让区块容纳更多条目。
- 与任何绑定到其祖先的数据一样，重组可能使那些引用在新链上无法解析的区块失效。
- 网络上的 BAL 交换由 [EIP-8159](/eip-8159/) 单独涵盖。


---

This is an unofficial plain-language summary. Read the full specification: https://eips.ethereum.org/EIPS/eip-8247
