---
eip: 7703
label: EIP-7703
title: Increase calldata cost
status: Stagnant
type: Standards Track
category: Core
created: 2024-05-07
official: https://eips.ethereum.org/EIPS/eip-7703
source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-7703.md
canonical: https://eips.huatuo.xyz/zh/eip-7703/
lang: zh
tldr: 提议将 calldata 的 gas 提高到三倍（零字节 4→12，非零字节 16→48），以缩小最坏情况下的区块大小，从而可以安全地提高 gas 上限。
tags: [gas, calldata, block-size, core, scaling]
---

# EIP-7703: Increase calldata cost

> Increase calldata cost to decrease the maximum block size

**TL;DR:** 提议将 calldata 的 gas 提高到三倍（零字节 4→12，非零字节 16→48），以缩小最坏情况下的区块大小，从而可以安全地提高 gas 上限。

## 它解决什么问题？

以太坊区块在字节数上的最大可能值，是在区块被廉价的 calldata 填满时达到的。大区块在网络中传播更慢，因此这种最坏情况，而不是典型使用，是阻碍提高区块 gas 上限的因素之一。

EIP-7703 采取了最直接的办法：让 calldata 贵三倍。在 gas 上限不变的情况下，最大区块大小缩小约三分之二，这就为提高 gas 上限留出了空间，同时不会让最坏情况变得更糟。

## 它如何运作

这个提案只改动两个常量，其他一概不动：

| 常量 | 现在 | EIP-7703 |
| --- | --- | --- |
| `G_CALLDATAZERO`（每个零字节） | 4 | 12 |
| `G_CALLDATANONZERO`（每个非零字节） | 16 | 48 |

每笔交易都要按 `data` 的每个字节支付这笔费用，作为其 intrinsic gas 的一部分。执行 gas、存储和 blob 定价（[EIP-4844](/eip-4844/)）都不受影响。

由于这一改动比较粗暴，它会提高所有携带 calldata 的交易的成本，包括普通的合约调用，而不仅仅是数据密集型交易。

## 示例代码

变更前后的 intrinsic calldata 成本（TypeScript，无依赖）：

```ts
function calldataGas(data: Uint8Array, zero: number, nonZero: number): number {
  let gas = 0;
  for (const b of data) gas += b === 0 ? zero : nonZero;
  return gas;
}

const hex = "a9059cbb000000000000000000000000d8da6bf26964af9d7eed9e10e5d4ba5f1c42e8f20000000000000000000000000000000000000000000000000de0b6b3a7640000";
const data = Uint8Array.from(hex.match(/../g)!.map((h) => parseInt(h, 16)));

console.log("today:   ", calldataGas(data, 4, 16));  // 21000 + this = intrinsic gas
console.log("EIP-7703:", calldataGas(data, 12, 48)); // exactly 3x
```

仅由 calldata 填满时的最大区块大小粗略估算：

```python
gas_limit = 30_000_000   # illustrative gas limit
print(gas_limit // 16)   # ~1.87 MB of non-zero calldata today
print(gas_limit // 48)   # ~0.62 MB under EIP-7703
```

## 需要注意

- 状态为 **Stagnant**。以太坊转而采用了 [EIP-7623](/eip-7623/)（Pectra），它引入了更高的*下限*价格，仅适用于大部分是数据、几乎不做执行的交易。这样既限制了最坏情况下的区块大小，又不改变普通交易的成本。[EIP-7976](/eip-7976/) 提议进一步提高这一下限。
- 规范指出，激活后，如果某些交易的 gas 上限是按旧价格估算的，它们可能会耗尽 gas；钱包需要在分叉之前就按新常量进行估算。
- 仍然以 calldata 而非 blob 发布数据的 rollup，本会受到一刀切三倍上涨的最大冲击。


---

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