EIP-7830 Raising the EOF contract size limit (Contract size limit increase for EOF)

No call decision · EVM & execution · EIP status Stagnant · created 2024-11-29

Raises the code size limit for contracts deployed in EOF format from 24KiB to 64KiB. Legacy-format contracts retain the current 24KiB limit as before.

Why it is needed

Right now each Ethereum contract can only deploy up to 24KiB (24,576 bytes) of code. This limit is a safeguard created to prevent attacks aimed at halting the network (DoS). Legacy-format contracts must check jump destinations (JUMPDEST) before execution, and many of the algorithms that perform this check can become unpredictably slower as code gets longer, which has made people hesitant to raise the limit. These days, though, contracts are adding features like friendly error reporting, which uses up more space and makes this limit a real obstacle. Developers have resorted to workarounds such as libraries (DELEGATECALL), splitting logic across multiple contracts, and proxies (the diamond pattern). These structures have caused bugs and loss of funds in deployed contracts. In the new contract format EOF, this check is performed only once at deployment time, and its cost is already reflected in the gas fee, so raising the limit poses no known issues.

What changes

Today

After EIP-7830

Who is affected

In depth

Specification of the limit change

EIP-170 sets MAX_CODE_SIZE to 24576 bytes, and EIP-3860 sets MAX_INITCODE_SIZE to twice that, 49152 bytes. This proposal changes MAX_CODE_SIZE to 65536 bytes (64 KiB) starting from FORK_BLOCK, but only for EOF initcode and code that begins with the bytes 0xEF 0x00. As a result, MAX_INITCODE_SIZE becomes 131072 bytes (128 KiB). The existing limit continues to apply to legacy contracts.

Why the increase is possible only for EOF

The existing limit was introduced as a defense against DoS attacks. Legacy contracts require JUMPDEST analysis, and many of the algorithms that perform it are non-linear or carry unknown risks. This is one reason raising the limit has been approached with caution. In EOF, JUMPDEST analysis is removed from execution time, and validation is performed only once, at deployment. Since the initcode cost introduced by EIP-3860 already accounts for this validation, raising the limit for EOF poses no known issues. Storage costs are also already paid per byte of contract code.

Why 64 KiB

64 KiB is more than double the existing limit, but it is not a drastic increase, and it is a realistic ceiling given the constraints of initcode. In EOF deployment, the code to be deployed is stored in a section (a 'subcontainer'), and this section has a size limit of 64 KiB. So without introducing a new, larger or variable-length-encoded size field, larger contracts cannot be deployed. The source text notes that such a change could be made to EOF later to propose a further increase.

Gas cost analysis

According to a simple analysis in the source text, deploying a 64 KiB contract costs between 14 million and 16 million gas, which is roughly close to the current 15 million gas target. In the example calculation, deploying 65,536 bytes (with a 10% zero-byte ratio) comes to: 53,000 intrinsic gas, 972,893 calldata gas, 131,472 EIP-3860 gas, 100,000 EVM execution, and 13,107,200 Code Deposit, for a total of 14,364,565 gas. Under the same conditions, deploying 24,576 bytes under Cancun totals 5,484,437 gas. The maximum size possible at 30 million gas, 135 KiB, is outside the scope of this proposal, and is included in the table only to show what it would take to exceed the current gas limit. For reference, at the time of EIP-170 the limit was set 'somewhat higher than what the gas limit at the time allowed,' and the gas limit back then never exceeded 5 million.

Backward compatibility and security considerations

This is a backward-compatible change. Existing contracts are unaffected; only new deployments benefit. Since the cost of analysis is paid at deployment time, contract size should not affect execution-time performance. However, the source text notes that further careful analysis may be needed to determine whether the proposed limit creates risk due to client storage structures.

Document status

The status of this proposal in the source text is Stagnant. It is a Standards Track Core proposal, but it is classified as having stalled, and since it is not a finalized specification its contents may change or it may not proceed as is. There is no record of a decision to include this proposal in a fork from the call notes.

Original EIP · ← EIPs