---
eip: 7045
label: EIP-7045
title: Increase max attestation inclusion slot
status: Final
type: Standards Track
category: Core
created: 2023-05-18
official: https://eips.ethereum.org/EIPS/eip-7045
source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-7045.md
canonical: https://eips.huatuo.xyz/zh/eip-7045/
lang: zh
tldr: 允许信标链的证明（attestation）在其产生所在 epoch 的下一个 epoch 结束之前都可以被打包，增强 LMD-GHOST 的安全性并支持快速确认规则；已随 Deneb 上线。
tags: [consensus, attestations, beacon-chain, deneb, dencun]
---

# EIP-7045: Increase max attestation inclusion slot

> Increases max attestation inclusion slot to the last slot in `N+1` where `N` is the epoch containing the attestation's slot.

**TL;DR:** 允许信标链的证明（attestation）在其产生所在 epoch 的下一个 epoch 结束之前都可以被打包，增强 LMD-GHOST 的安全性并支持快速确认规则；已随 Deneb 上线。

## 它解决什么问题？

验证者每个 epoch 都会发布证明（投票），区块提议者把它们打包进区块。在这一变更之前，在 slot `s` 产生的证明只能被打包到 slot `s + SLOTS_PER_EPOCH`（主网上是 32 个 slot 之后）。这个滑动的一个 epoch 窗口是在 Phase 0 选定的，因为它给每个证明提供了相同的时间。

后来的研究表明，另一种方案，即允许在**当前和下一个 epoch** 内打包，才是 LMD-GHOST 分叉选择安全性证明所需要的。它还支持一种新的**确认规则**，在正常的主网条件下，大约 3-4 个 slot 后就可以把区块视为已确认。

## 它如何运作

最大打包 slot 从"证明所在 slot + 32"改为"**epoch N+1 的最后一个 slot**"，其中 N 是证明所在 slot 所属的 epoch。在 epoch 早期产生的证明现在比晚期产生的拥有更长的窗口。

这仅是共识层的变更。它包含在 **Deneb** 共识层升级中，该升级与 Cancun 一起在主网上作为 Dencun 激活。执行层不变。具体变更如下：

- **`process_attestation`**：移除了 slot 的上限。有效性现在由最小打包延迟，加上证明的目标 epoch 必须是当前或上一个 epoch 这一规则决定。
- **`get_attestation_participation_flag_indices`**：无论 `inclusion_delay` 是多少都会设置 `TIMELY_TARGET_FLAG`，因此迟到但有效且目标投票正确的证明仍能获得非零奖励。这让提议者仍有动力打包它们。
- 证明和聚合的 **P2P gossip** 被放宽，以便在延长的范围内传播。

规范中列出的主网分叉时间戳为 `1710338135`。

## 示例代码

打包检查的简化前后对比（共识规范风格的 Python）：

```python
# Before (Altair..Capella)
assert data.target.epoch in (get_previous_epoch(state), get_current_epoch(state))
assert data.slot + MIN_ATTESTATION_INCLUSION_DELAY <= state.slot <= data.slot + SLOTS_PER_EPOCH

# After (Deneb, EIP-7045): no upper slot bound;
# the target-epoch check alone limits inclusion to the end of epoch N+1
assert data.target.epoch in (get_previous_epoch(state), get_current_epoch(state))
assert data.slot + MIN_ATTESTATION_INCLUSION_DELAY <= state.slot
```

以及奖励标志的变更：

```python
# Before
if is_matching_target and inclusion_delay <= SLOTS_PER_EPOCH:
    participation_flag_indices.append(TIMELY_TARGET_FLAG_INDEX)

# After (Deneb)
if is_matching_target:
    participation_flag_indices.append(TIMELY_TARGET_FLAG_INDEX)
```

## 需要注意

- **状态：Final**，自 Deneb 升级起已在主网上线。由于它改变了区块有效性规则，因此需要一次硬分叉。
- source 和 head 的及时性标志不变。只有 target 奖励与打包延迟脱钩，因此迟到的证明总体上获得的奖励仍低于及时的证明。
- 验证者无需做任何改动。更宽的窗口由客户端软件处理。
- 同一次升级中的其他共识层变更包括 [EIP-7044](/eip-7044/)（永久有效的自愿退出）和 [EIP-7514](/eip-7514/)（最大 epoch 流动上限）；[EIP-4844](/eip-4844/) 的 blob 是 Dencun 的头条特性。


---

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