---
eip: 7542
label: EIP-7542
title: eth/70 - available-blocks-extended protocol
status: Withdrawn
type: Standards Track
category: Networking
created: 2023-10-21
requires: 7642
official: https://eips.ethereum.org/EIPS/eip-7542
source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-7542.md
canonical: https://eips.huatuo.xyz/zh/eip-7542/
lang: zh
tldr: 一项已撤回的 eth/70 p2p 协议提案：节点公布自己能提供的区块范围，使对等节点不再去请求某个节点已经修剪掉的历史数据；这一想法后来改在 eth/69 中实现。
tags: [networking, devp2p, history-expiry, sync, withdrawn]
---

# EIP-7542: eth/70 - available-blocks-extended protocol

> Adds more info in the handshake about available block range and adds message types to request block ranges and the send them

**TL;DR:** 一项已撤回的 eth/70 p2p 协议提案：节点公布自己能提供的区块范围，使对等节点不再去请求某个节点已经修剪掉的历史数据；这一想法后来改在 eth/69 中实现。

## 它解决什么问题？

随着历史过期（[EIP-4444](/eip-4444/)）的实施，一些节点会继续提供旧区块，另一些则会将其修剪。如果没有任何信号，需要历史数据的节点只能先连接对等节点、请求具体区块，才知道对方有没有，既浪费带宽，也浪费时间。同步时也会遇到同样的问题：一个自己仍在同步的对等节点，可能没有你需要的区块，而你只有在收到空响应后才会知道。

EIP-7542 提议让每个节点公布自己能提供的区块范围，使对等节点可以选择向谁请求、与谁保持连接。

## 它如何运作

该提案定义了新的 `eth` 协议版本 `eth/70`，在被广泛采用之前与 `eth/69` 并行运行：

- `Status (0x00)` 握手在 `forkid` 之后新增一个 `blockRange` 字段，其中 `blockRange` 为 `[startBlock, endBlock]`。
- 两条新消息：
  - `RequestBlockRange (0x0b)`：向对等节点询问其当前范围。
  - `SendBlockRange (0x0c)`：以 `[startBlock, endBlock]` 作答。

由于范围会随着节点同步或修剪而变动，对等节点可以随时重新查询。

节点应当不论对方范围如何都保持连接；唯一的例外是，如果某个节点的对等节点名额已满，且没有任何对等节点持有它需要的范围，它可以断开一个连接，去寻找更合适的对等节点。由于这属于网络层变更，不需要硬分叉。

## 示例代码

提案中的消息格式（RLP 风格表示）：

```
# eth/69 Status (as referenced by the proposal)
[version, networkid, blockhash, genesis, forkid]

# eth/70 Status (proposed)
[version, networkid, blockhash, genesis, forkid, [startBlock, endBlock]]

# RequestBlockRange (0x0b)
[]

# SendBlockRange (0x0c)
[startBlock: uint64, endBlock: uint64]
```

为历史数据请求选择对等节点（伪代码）：

```python
def pick_peer(peers, wanted_block):
    candidates = [p for p in peers if p.start_block <= wanted_block <= p.end_block]
    return random.choice(candidates) if candidates else None
```

## 需要注意

- 状态为 **Withdrawn**。根据 [EIP-7642](/eip-7642/)，它被撤回是因为当时尚未就历史过期做出决定。
- 这一想法延续在 [EIP-7642](/eip-7642/)（eth/69，Final）中：它在 `Status` 中加入 `earliestBlock` / `latestBlock`，并增加了 `BlockRangeUpdate (0x11)` 消息，在范围变化时主动推送，而不是请求/响应的方式。
- `eth/70` 这个版本号后来被其他提案使用，例如 [EIP-7639](/eip-7639/) 和 [EIP-7975](/eip-7975/)，所以不要默认"eth/70"指的就是这个设计。
- 规范强调，公布区块范围并不是在其替代存储方案出现之前就可以停止提供历史数据的许可。


---

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