Introduction

Hi, I'm cardene, a software engineer and technical writer focused on blockchain and AI.

I've also authored Japanese technical books on specification-driven development with LLMs and decentralized application (DApp) development.

I also build and publish a variety of tools, libraries, and open-source projects.

This article examines EIP-7907, a proposal to increase Ethereum's contract code size limit from 24 KiB to 256 KiB.

This article translates, summarizes, and supplements the material linked below.

I have also covered other EIPs.

This article describes the version of the proposal discussed in June 2025. Its parameters should not be assumed to represent the currently active Ethereum protocol rules.

Overview

EIP-7907 proposes increasing the existing contract code size limit from 24 KiB to 256 KiB.

It also increases the initialization code (initcode) size limit introduced by EIP-3860, from 48 KiB to 512 KiB.

See the following article for EIP-3860.

[EIP-3860] Metering and Limiting Initcode

Simply relaxing these limits could expose the network to denial-of-service risks. The proposal therefore introduces an additional charge of 2 gas per 32 bytes of code beyond 24 KiB.

This meters additional resource consumption while retaining Ethereum's principle that operations should pay for the resources they consume.

Motivation

The primary motivation is to improve the developer experience.

The 24 KiB limit was introduced by EIP-170 to protect the network. Large contracts can impose substantial disk access and proof-generation costs that were not adequately reflected in the gas schedule.

However, the limit also forces developers to split logic that could otherwise reside in one contract. Developers may need proxy patterns, delegatecall-based architectures, or advanced designs such as the Diamond Standard.

These workarounds can have several drawbacks.

  • More complex code structures.
  • Additional cross-contract calls and associated gas costs.
  • A larger and more expensive security audit scope.
  • Higher barriers to entry for beginners.

EIP-7907 aims to allow developers to construct smart contracts more directly. Consolidating logic into a single contract can improve readability, testing, and maintenance where appropriate.

Beginners could also develop functioning contracts before learning more complex architectural patterns.

Specification

Increasing the Contract Code Size Limit

EIP-170 limits the deployed bytecode of a contract to 24 KiB (0x6000 bytes).

The version of EIP-7907 discussed here increases this limit to 256 KiB (0x40000 bytes), enabling larger bodies of logic to be deployed in a single contract.

See the following article for EIP-170.

[EIP-170] Limiting Contract Code Size

Gas Adjustments for Code-Loading Opcodes

The four CALL-family opcodes (CALL, STATICCALL, DELEGATECALL, and CALLCODE) and EXTCODECOPY load the target contract's bytecode.

When the code exceeds 24 KiB, additional gas is charged to account for the associated resource consumption.

js
excess_contract_size = max(0, contract_size − 0x6000)       // 余分なバイト数
largeContractCost    = ceil32(excess_contract_size) / 32 * 2 // 32 バイト語あたり 2 ガス

The ceil32 function rounds up to a multiple of 32 bytes. The resulting surcharge is 2 gas for every additional 32-byte word.

Cold and Warm Code

Following the access-list model introduced by EIP-2929, the proposal distinguishes cold code from warm code and tracks code access separately from account access.

An account can already be warm while its code is still cold.

See the following article for EIP-2929.

[EIP-2929] Increasing Gas Costs for State Access Opcodes

State Access gas cost Typical condition
Cold account, cold code 2600 + largeContractCost First access outside the access list
Warm account, cold code 100 + largeContractCost The account has already been accessed, but its code has not been loaded
Warm account, warm code 100 (unchanged) The code has already been accessed
  • The base values of 2600 and 100 gas correspond to COLD_ACCOUNT_ACCESS_COST and WARM_STORAGE_READ_COST, respectively, as defined by EIP-2929.
  • Once code becomes warm within a transaction, subsequent applicable accesses do not incur the additional large-contract charge, subject to the access-tracking rules.

Increasing the Initcode Size Limit

The initcode executed during contract creation is also subject to a size limit. The proposal increases the 48 KiB (0xc000 bytes) limit established by EIP-3860 to 512 KiB (0x80000 bytes).

Initcode is not retained as the deployed runtime code, but the EVM must process it during contract creation, so a limit remains necessary.

Additional Notes

Rationale for the Gas Cost

EIP-7907 charges an additional 2 gas per 32 bytes beyond 24 KiB. The value is consistent with the word-based charge introduced by EIP-3860.

The rationale includes the following considerations.

  • Larger code increases disk I/O and loading costs.
  • The EVM's pre-execution JUMPDEST analysis requires more work.
  • Large contracts can increase the size and cost of block-validation witnesses.

Why Use a 24 KiB Threshold?

A simpler formula might charge ceil32(contract_size) / 32 * 2 over the entire code.

Instead, the proposal charges only for code exceeding 24 KiB, preserving the existing cost structure for contracts within the earlier size limit.

This limits the impact on existing contracts.

Why Include EXTCODECOPY?

In principle, EXTCODECOPY copies only the requested portion of another contract's bytecode.

However, Ethereum's code commitments and validation mechanisms can require the complete code, including in block-validation witnesses.

The proposal therefore includes EXTCODECOPY among the operations subject to the additional charge. If the protocol later supports partial code loading, this decision could be reconsidered.

Why Set the Contract Limit to 256 KiB?

At the approximately 35-million-gas block limit discussed in the original article, code deposit costs alone would constrain practical deployment sizes to around 170 KiB.

The proposed 256 KiB ceiling is intended to provide room for future gas-limit increases while bounding the impact on databases and peer-to-peer networking.

The article cites a 10 MB maximum devp2p packet size and a 512 KB Snap Sync packet limit as relevant networking considerations.

The ceiling is intended to avoid unexpected behavior within these constraints.

Why Set the Initcode Limit to 512 KiB?

Although initcode is not retained as runtime state, its execution still consumes resources, including memory and validation-related computation. Unlimited initcode could introduce uncertain resource requirements.

The proposal therefore follows EIP-3860's conservative guideline of limiting initcode to twice the runtime code size, resulting in a proposed 512 KiB limit.

This balances flexibility with resource constraints.

Compatibility

The proposal is intended to preserve compatibility for contracts within the existing code size limit.

Security

Execution clients such as Geth and Nethermind must account for code-loading costs before consuming excessive resources.

When code exceeds 24 KiB, the EVM must determine whether enough gas remains to pay largeContractCost.

If the client loads the entire code before checking the gas allowance, an operation with insufficient gas could still impose disproportionate resource costs.

Recommended mitigations include:

  • Storing code-size information separately from the actual code, keyed by code hash.
  • Retrieving that size information before loading the code and checking whether sufficient gas is available.

These measures help prevent unnecessary loading of large contracts when gas is insufficient.

They are implementation recommendations intended to preserve client efficiency rather than additional consensus requirements of the EIP.

Citation

Charles Cooper (@charles-cooper), Qi Zhou (@qizhou), "EIP-7907: Meter Contract Code Size And Increase Limit [DRAFT]," Ethereum Improvement Proposals, no. 7907, March 2025. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-7907.

Conclusion

The version of EIP-7907 discussed here proposes increasing Ethereum's contract code size limit from 24 KiB to 256 KiB while metering the additional resources consumed by large contracts.

If you have questions, feel free to contact me on Twitter.

Twitter @cardene777

I also publish articles on the following platforms.

https://chaldene.net/