---
eip: 8071
label: EIP-8071
title: Prevent using consolidations as withdrawals
status: Draft
type: Standards Track
category: Core
created: 2025-10-29
official: https://eips.ethereum.org/EIPS/eip-8071
source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-8071.md
canonical: https://eips.huatuo.xyz/zh/eip-8071/
lang: zh
tldr: 取消会使目标验证者超过最大有效余额的验证者合并请求，堵上让质押者把合并队列当作更快退出队列的漏洞。
tags: [consensus, staking, consolidation, withdrawals, pectra]
---

# EIP-8071: Prevent using consolidations as withdrawals

> Cancels consolidation if the max effective balance of the target validator will be exceeded, preventing the withdrawal of the unused balance

**TL;DR:** 取消会使目标验证者超过最大有效余额的验证者合并请求，堵上让质押者把合并队列当作更快退出队列的漏洞。

## 它解决什么问题？

[EIP-7251](/eip-7251/)（Pectra）把最大有效余额提高到 2048 ETH，并加入了**合并（consolidation）**：一个验证者可以把自己的质押并入另一个具有 compounding 凭证的验证者。源验证者通过合并队列退出，其余额被转移到目标验证者。

缺陷在于：如果目标验证者的余额超过最大有效余额，超出部分会被直接提取。所以当合并队列比常规退出队列走得更快时，质押者可以“合并”到一个几乎满额的验证者，比正常退出更快地取出 ETH。规范称，在撰写时这一做法正被大量利用，并且已有公开文章介绍该方法。它被定性为用户体验和公平性问题，而不是安全漏洞：合并队列本来就不是用来提款的。

## 它如何运作

共识层的 `process_consolidation_request` 增加了一项检查。在接受请求之前，它计算：

```
target balance after = pending consolidations already queued for the target
                     + source effective balance
                     + target's current balance
```

如果结果超过目标的最大有效余额，该请求会像其他无效的合并请求一样被静默忽略。

新的辅助函数 `get_pending_balance_to_consolidate` 会把已经排队指向同一目标的所有源验证者的有效余额相加。这样就能捕捉到这种情况：多个请求单独看都没问题，但合在一起会使目标溢出。

## 示例代码

规范中新增的辅助函数和检查：

```python
def get_pending_balance_to_consolidate(state: BeaconState, target_index: ValidatorIndex) -> Gwei:
    total = Gwei(0)
    for pc in state.pending_consolidations:
        if pc.target_index == target_index:
            total += state.validators[pc.source_index].effective_balance
    return total

# inside process_consolidation_request, after the existing checks:
target_balance_after_consolidation = (
    get_pending_balance_to_consolidate(state, target_index)
    + source_validator.effective_balance
    + state.balances[target_index]
)
if target_balance_after_consolidation > get_max_effective_balance(target_validator):
    return  # cancelled: excess would otherwise be withdrawn
```

## 需要注意

- **状态：Draft。** 这是共识层改动，需要一次计划中的网络升级。
- 被取消的请求会在共识层被丢弃，但**执行层的请求费用和 gas 不会退还**。提交前请检查目标的剩余额度。
- 该检查使用目标的实际余额，而不仅仅是有效余额，因此目标上累积的奖励也会计入上限。
- 为切换到 compounding 凭证而进行的自我合并不受影响。
- 要退出，请使用常规退出队列或执行层触发的退出（[EIP-7002](/eip-7002/)）。


---

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