---
eip: 7862
label: EIP-7862
title: Delayed State Root
status: Draft
type: Standards Track
category: Core
created: 2024-12-23
official: https://eips.ethereum.org/EIPS/eip-7862
source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-7862.md
canonical: https://eips.huatuo.xyz/zh/eip-7862/
lang: zh
tldr: 让每个区块头携带上一个区块的状态根而不是自身的状态根，把昂贵的状态根计算从构建者和见证者的关键路径上移除。
tags: [consensus, state-root, performance, scaling, core]
---

# EIP-7862: Delayed State Root

> Separate state root computation from block validation

**TL;DR:** 让每个区块头携带上一个区块的状态根而不是自身的状态根，把昂贵的状态根计算从构建者和见证者的关键路径上移除。

## 它解决什么问题？

每个以太坊区块头都包含 `state_root`，即区块执行后所有账户的 Merkle-Patricia 根。计算它需要对每条被触及的 trie 路径做哈希，这是生成和验证区块时最慢的步骤之一。

这项成本落在了最糟糕的位置：

- **构建者**要为 MEV 拍卖期间尝试的每一个候选区块重新计算根，每个 slot 可能多达数千次。
- **验证者**在重新计算并检查区块的根之前，无法证明该区块有效。

随着 gas 上限提高、ePBS（[EIP-7732](/eip-7732/)）使时间更加紧张，这会成为瓶颈。[EIP-7928](/eip-7928/) 的区块级访问列表有助于并行化执行，但对正在构建的当前区块的根没有帮助。

## 它如何运作

EIP-7862 把根移位一个区块。不新增区块头字段；只改变 `state_root` 的含义：

- 区块 `n` 的区块头包含**区块 `n-1` 的执行后状态根**，也就是区块 `n` 的执行前状态。
- 客户端维护一个 `last_computed_state_root`。区块头验证会检查 `header.state_root == last_computed_state_root`。
- 执行完区块 `n` 之后，客户端计算其执行后状态根并存储起来，以便与区块 `n+1` 进行核对。
- 在分叉区块 `F` 处，区块头携带 `F-1` 的执行后状态根；从 `F+1` 起，每个区块携带其父区块的状态根。

效果：

1. 构建者每个 slot 只需计算一个状态根（针对上一个区块），而不是每个候选区块一个。
2. 验证者执行完区块后就可以见证，无需等待其状态根。
3. 区块 `n` 的状态根计算在区块到达时即可开始，借助区块 `n` 的访问列表实现并行，并在区块 `n+1` 到来之前完成。

## 示例代码

以 execution-spec 风格的伪代码表示的核心改动：

```python
def validate_header(chain, header):
    # Delayed: this header commits to the PARENT's post-state.
    if header.state_root != chain.last_computed_state_root:
        raise InvalidBlock
    # ... other checks unchanged

def state_transition(chain, block):
    validate_header(chain, block.header)
    out = apply_body(block_env, block.transactions, block.withdrawals)
    if out.block_gas_used != block.header.gas_used:
        raise InvalidBlock
    # receipts, logs bloom, requests ... still validated as before

    # Computed off the critical path; checked by the NEXT block.
    chain.last_computed_state_root = state_root(block_env.state)
    chain.blocks.append(block)
```

## 需要注意

- 状态：**Draft**。它需要一次硬分叉；未升级的客户端会拒绝新区块。
- 轻客户端以及任何验证状态证明的人会多出一个 slot 的延迟：关于区块 `n` 结果的证明需要区块 `n+1` 的区块头。
- 客户端必须保留区块 `n` 的执行前状态，直到其根被包含进下一个区块，并且在重组期间要沿着新链重新计算 `last_computed_state_root`。
- ePBS 载荷信封中的共识层状态根不受影响；只有执行区块头发生变化。
- [EIP-7886](/eip-7886/)（Delayed execution）探索了一个相关的想法，即把区块验证与执行分离。


---

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