---
eip: 2515
label: EIP-2515
title: Implement Difficulty Freeze
status: Stagnant
type: Standards Track
category: Core
created: 2020-02-10
official: https://eips.ethereum.org/EIPS/eip-2515
source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-2515.md
canonical: https://eips.huatuo.xyz/zh/eip-2515/
lang: zh
tldr: "提议用在固定区块高度触发、可预测的\"难度冻结\"取代呈指数增长的工作量证明难度炸弹，此后难度每个区块只增加 1%。"
tags: [difficulty-bomb, proof-of-work, consensus, core]
---

# EIP-2515: Implement Difficulty Freeze

> The difficulty Freeze is an alternative to the Difficulty Bomb that is implemented within the protocols difficulty adjustment algorithm. The Difficulty Freeze begins at a certain block height, determined in advance, freezes the difficulty and increases by 1% after that block forever.

**TL;DR:** 提议用在固定区块高度触发、可预测的"难度冻结"取代呈指数增长的工作量证明难度炸弹，此后难度每个区块只增加 1%。

## 它解决什么问题？

工作量证明时代的以太坊带有一颗**难度炸弹**（"冰河期"）：难度公式中一个呈指数增长的项，会让出块逐渐变慢，迫使开发者发布硬分叉把它推迟。实际上它很难建模。它出现得比预期更早（Muir Glacier 的推迟，即 [EIP-2384](/eip-2384/)，就是一次紧急响应），当升级因技术原因延期时，受害的是无力解决问题的矿工和用户。

EIP-2515 提议改用**难度冻结**：一种完全以区块高度为触发条件的机制，因此所有人都确切知道它何时生效，而其带来的痛苦主要落在唯一能够化解它的客户端开发者身上。

## 它如何运作

- 新增常量 `DIFFICULTY_FREEZE_HEIGHT`。
- 在该高度之前，难度根据父区块的难度和时间戳正常调整，使用通常的 `max(1 - Δt // 10, -99)` 调整公式。
- 超过该高度后，难度不再响应出块时间，而是永远每个区块简单地增加 1%。

由于冻结后难度不再跟踪算力，出块时间会漂移并最终变长，这就是促使升级的压力。1% 的增长是在收到反馈后加入的，因为单纯的冻结并不能可靠地产生期望的激励。

一个**可选变体**把冻结设置为相对于上一次分叉：`LAST_FORK_HEIGHT + DIFFICULTY_FREEZE_DIFFERENCE`（规范中的示例是 1,800,000 个区块，大约九个月）。这样每次升级都会自动重置冻结，代价是共识逻辑更复杂。

## 示例代码

规范中的核心规则，写成可运行的 Python：

```python
DIFFICULTY_FREEZE_HEIGHT = 10_000_000  # placeholder; the spec leaves the value open

def calc_difficulty(block_number, parent_diff, block_ts, parent_ts):
    if block_number <= DIFFICULTY_FREEZE_HEIGHT:
        adj = max(1 - (block_ts - parent_ts) // 10, -99)
        return parent_diff + parent_diff // 2048 * adj
    # frozen: ignore block times, grow 1% per block
    return parent_diff + parent_diff // 100
```

可选的、相对分叉的触发条件：

```python
def frozen(block_number, last_fork_height, dfd=1_800_000):
    return block_number > last_fork_height + dfd
```

## 需要注意

- **状态：Stagnant。** 它从未被采纳。以太坊保留了最初的炸弹，并通过 [EIP-3554](/eip-3554/) 和 [EIP-4345](/eip-4345/) 等硬分叉一再推迟它。
- 随着转向权益证明（[EIP-3675](/eip-3675/)），这个问题已无意义：合并之后不再有工作量证明难度。
- 规范列出了错过冻结时的三种结果（算力上升、下降或持平），都会导致出块时间变长，并认为客户端有动力避免这种情况。
- 测试用例和实现从未提供（规范中为"TBD"）。


---

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