---
eip: 7903
label: EIP-7903
title: Remove Initcode Size Limit
status: Stagnant
type: Standards Track
category: Core
created: 2025-03-05
requires: 170, 3860
official: https://eips.ethereum.org/EIPS/eip-7903
source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-7903.md
canonical: https://eips.huatuo.xyz/zh/eip-7903/
lang: zh
tldr: 一项已停滞的提案，旨在取消 EIP-3860 中 49,152 字节的 initcode 上限，使由多个子合约组成的大型逻辑合约可以在一笔交易中部署。
tags: [evm, initcode, deployment, core, contract-size]
---

# EIP-7903: Remove Initcode Size Limit

> Removes the initcode size limit introduced in EIP-3860

**TL;DR:** 一项已停滞的提案，旨在取消 EIP-3860 中 49,152 字节的 initcode 上限，使由多个子合约组成的大型逻辑合约可以在一笔交易中部署。

## 它解决什么问题？

以太坊把已部署（运行时）的合约代码限制在 24,576 字节（[EIP-170](/eip-170/)）。保留这一限制的一个常见理由是，编译器和高级语言可以把它隐藏起来：一个大型的"逻辑"合约可以在幕后拆分成多个"物理"子合约。

后来 [EIP-3860](/eip-3860/) 又增加了第二条限制：创建代码（`initcode`）最大为 49,152 字节，并且为 `JUMPDEST` 分析按每 32 字节字收取 2 gas。这个上限意味着，想要一次部署许多子合约的工厂合约可能会空间不足，被迫分多笔交易部署，破坏了语言想要提供的抽象。

EIP-7903 认为这个上限是不必要的，因为按字计费的 gas 已经为 initcode 合理定价。

## 它如何运作

改动很小：

- 取消合约创建（创建交易、`CREATE` 和 `CREATE2`）中 `initcode` 大小 49,152 字节的上限。
- 保持 EIP-3860 按字收取 initcode gas 的规则不变。
- 不触动 EIP-170 对已部署运行时代码的限制。

在实践中，initcode 仍然受到区块 gas 上限的约束，而且它必须已经作为 calldata 或内存扩展付过费。作者报告了基准测试结果：从 128 字节到约 15 MB 的代码，`JUMPDEST` 分析的每字节成本保持不变。

诸如简单地把上限翻倍之类的替代方案也曾被考虑，但因过于随意而被否决。

## 示例代码

变更前后有效性检查的伪代码：

```python
MAX_CODE_SIZE = 24576            # EIP-170, unchanged
MAX_INITCODE_SIZE = 2 * MAX_CODE_SIZE   # EIP-3860: 49152

def check_create(initcode, gas):
    # EIP-3860 today:
    # if len(initcode) > MAX_INITCODE_SIZE: fail
    # EIP-7903: the check above is removed.
    words = (len(initcode) + 31) // 32
    charge(gas, 2 * words)      # initcode word cost is kept
    runtime = execute(initcode)
    if len(runtime) > MAX_CODE_SIZE:
        fail()                  # deployed code limit still applies
```

一个会因此受益的工厂合约，在构造函数中部署多个大型子合约：

```solidity
contract BigAppFactory {
    address public partA;
    address public partB;
    constructor() {
        // Each part may be close to 24 KB of runtime code; together the
        // factory's initcode exceeds 49,152 bytes, which EIP-3860 forbids.
        partA = address(new PartA());
        partB = address(new PartB());
    }
}
```

## 需要注意

- **状态：Stagnant。** 该提案没有进展，也没有被安排进任何网络升级。
- 这纯粹是一种放宽：现有的合约和交易的行为都不会有任何不同。
- 它不会提高已部署代码的上限。关于涉及该上限的提案，请参见 [EIP-7907](/eip-7907/)。


---

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