---
eip: 3756
label: EIP-3756
title: Gas Limit Cap
status: Stagnant
type: Standards Track
category: Core
created: 2021-08-21
official: https://eips.ethereum.org/EIPS/eip-3756
source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-3756.md
canonical: https://eips.huatuo.xyz/zh/eip-3756/
lang: zh
tldr: 提议为每个区块设置 3000 万 gas 的硬性上限，使区块生产者可以调低 gas 上限，但永远不能把它调高到通过 EIP 流程设定的值之上。
tags: [gas, gas-limit, core, consensus, security]
---

# EIP-3756: Gas Limit Cap

> Set an in-protocol cap for the gas limit

**TL;DR:** 提议为每个区块设置 3000 万 gas 的硬性上限，使区块生产者可以调低 gas 上限，但永远不能把它调高到通过 EIP 流程设定的值之上。

## 它解决什么问题？

在以太坊上，区块 gas 上限不是由硬分叉设定的。区块生产者在生产每个区块时都会对它投票上调或下调一点，因此原则上他们可以把它推到任意高度，而无需经过 EIP 或 All Core Devs。

作者指出这有两个风险：

- **良性增长。** 更高的 gas 上限会让状态和历史增长得比节点所能承受的更快。
- **攻击。** 当区块能容纳更多 gas 时，某些拒绝服务攻击会造成更大的破坏。

EIP-3756 会让上限成为一条协议规则。这样要提高它就需要一次硬分叉，因此会在公开场合决定。

## 它如何运作

规范只有一条规则。从分叉区块起，任何 `gas_limit` 大于 `30,000,000` 的区块都是**无效**的。

提议者仍保有*调低* gas 上限的权力。其理由说明把这视为一个重要的安全杠杆：如果网络变得不稳定或遭到攻击，提议者可以在不等待分叉的情况下迅速缩小区块。这个上限只是一个天花板，而不是固定的 gas 上限。

其他一切都不变。限制 gas 上限在相邻区块间变动幅度的现有规则依然适用，[EIP-1559](/eip-1559/) 的 gas 目标（为上限的一半）也同样如此。

## 示例代码

客户端会增加的额外有效性检查，以伪代码表示：

```python
GAS_LIMIT_CAP = 30_000_000

def validate_header(header, parent, fork_block):
    # existing checks: gas limit may move only ~1/1024 per block, etc.
    validate_gas_limit_delta(header.gas_limit, parent.gas_limit)

    if header.number >= fork_block and header.gas_limit > GAS_LIMIT_CAP:
        raise InvalidBlock("gas_limit above protocol cap")
```

对照提议的上限检查当前的上限（ethers v6）：

```ts
import { JsonRpcProvider } from "ethers";

const provider = new JsonRpcProvider(process.env.RPC_URL);
const block = await provider.getBlock("latest");
const CAP = 30_000_000n;
console.log("gas limit:", block!.gasLimit.toString(),
            block!.gasLimit > CAP ? "(above the EIP-3756 cap)" : "(within the cap)");
```

## 需要注意

- **状态：Stagnant。** EIP-3756 从未被排入网络升级，以太坊没有协议内的 gas 上限硬顶。
- 规范把测试用例留作"TBD"，也没有指定分叉区块。
- 3000 万这个数字是撰写该 EIP 时主网的 gas 上限。此后验证者已把上限提高到了它之上。[EIP-7935](/eip-7935/) 提议为客户端设置新的默认值（6000 万），这表明方向一直是通过协调来提高上限，而不是固定一个天花板。
- 不要把它与 [EIP-7825](/eip-7825/) 混淆，后者限制的是单笔*交易*可使用的 gas。EIP-3756 限制的是整个*区块*。


---

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