---
eip: 7916
label: EIP-7916
title: SSZ ProgressiveList
status: Review
type: Standards Track
category: Core
created: 2025-03-24
official: https://eips.ethereum.org/EIPS/eip-7916
source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-7916.md
canonical: https://eips.huatuo.xyz/zh/eip-7916/
lang: zh
tldr: 为 SSZ 增加 ProgressiveList 和 ProgressiveBitlist：没有固定容量的列表，其 Merkle 树分阶段增长，因此短列表的哈希成本很低，并且每个元素的广义索引永远保持稳定。
tags: [ssz, consensus, merkle, serialization, core]
---

# EIP-7916: SSZ ProgressiveList

> SSZ types for efficiently hashing short lists

**TL;DR:** 为 SSZ 增加 ProgressiveList 和 ProgressiveBitlist：没有固定容量的列表，其 Merkle 树分阶段增长，因此短列表的哈希成本很低，并且每个元素的广义索引永远保持稳定。

## 它解决什么问题？

以太坊共识层使用 SSZ 对数据进行序列化和哈希。目前每个 SSZ 列表都声明为带有最大容量 `N` 的 `List[type, N]`，其 Merkle 树始终按 `N` 来确定大小。这会带来三个问题：

- **浪费哈希计算**：按 1,024 项声明的列表即使只存了 3 项，也要为充满零填充的深层树付出代价，而嵌套列表会让这一成本成倍增加。
- **随意的上限**：`N` 往往只是一个猜测值，"以防万一"地设得很大。
- **不稳定的证明**：如果某次分叉改变了 `N`，树的深度就会变化，每个元素的广义索引（gindex）都会移动，验证证明的轻客户端或合约就会失效。

## 它如何运作

EIP-7916 定义了一种新的树形，即 `merkleize_progressive`。根节点不再是一棵平衡树，而是由一串每次扩大 4 倍的子树组成的链：

```
root
 ├─ subtree of 1 chunk      (chunk 0)
 └─ ┬─ subtree of 4 chunks  (chunks 1..4)
    └─ ┬─ subtree of 16 chunks (chunks 5..20)
       └─ ┬─ subtree of 64 ...
          └─ 0
```

只会构建所需数量的层级，因此短列表的哈希成本很低。由于每个子树的大小是固定的，无论列表增长到多长，第 `i` 个数据块始终位于相同的 gindex。

有两种新的 SSZ 类型使用这种树形：

- `ProgressiveList[type]`：**不声明上限**的变长列表。
- `ProgressiveBitlist`：对应的比特列表。
- `ProgressiveByteList` 是 `ProgressiveList[byte]` 的别名。

序列化和 JSON 映射与 `List[type, N]` 和 `Bitlist[N]` 完全一致；只有哈希树根不同。根为 `mix_in_length(merkleize_progressive(...), len(value))`。初始叶子数（1）和增长系数（4）是固定的，不是参数。

## 示例代码

按照规范编写的 Python 参考 merkleization：

```python
def merkleize_progressive(chunks, num_leaves=1):
    if len(chunks) == 0:
        return Bytes32()                       # zero terminator
    a = merkleize(chunks[:num_leaves], num_leaves)          # balanced subtree
    b = merkleize_progressive(chunks[num_leaves:], num_leaves * 4)
    return hash(a + b)

def hash_tree_root_progressive_list(values, is_basic):
    if is_basic:
        chunks = pack(values)
    else:
        chunks = [hash_tree_root(v) for v in values]
    return mix_in_length(merkleize_progressive(chunks), len(values))
```

在共识规范风格的容器中声明类型：

```python
class Example(Container):
    validators: ProgressiveList[ValidatorIndex]   # no N needed
    flags: ProgressiveBitlist
    data: ProgressiveByteList
```

## 需要注意

- **状态：Review。** 它尚未纳入任何已排期的分叉。
- 由于没有声明上限，实现应当强制执行与具体场景相关的边界。SSZ 的 `uint32` 偏移量意味着在其他类型内部大约有 4 GB 的上限，而网络层面的限制要低得多。
- 大列表深处元素的证明会稍长一些，不过仍然只是对数级增长。
- SSZ 相关的工作还包括 [EIP-7495](/eip-7495/)（progressive container）和 SSZ 交易格式 [EIP-6404](/eip-6404/)。


---

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