EIPs Explained

EIP-7830 · Stagnant · Core · 2024-11-29

EIP-7830: Contract size limit increase for EOF

Proposed raising the maximum contract code size from 24 KiB to 64 KiB, but only for EOF contracts, since EOF validates code once at deployment and removes the JUMPDEST analysis that made larger contracts risky.

What problem does it solve?

Since EIP-170 (2016), deployed contract code is capped at 24,576 bytes (24 KiB), and EIP-3860 caps initcode at twice that. The cap protects nodes from denial-of-service: legacy bytecode must undergo JUMPDEST analysis whenever it is loaded, and some implementations of that analysis are not linear.

For developers the limit is a constant pain. Contracts with good error messages and rich features hit it quickly, which pushes teams to split logic across libraries called via DELEGATECALL, multiple contracts, or proxy patterns such as the "diamond". The spec notes these workarounds have led to bugs and lost funds.

The EVM Object Format (EOF, EIP-3540 and related EIPs) validates code once at deployment and has no runtime JUMPDEST analysis. EIP-7830 argues that, for EOF code, the original reason for the cap no longer applies.

How it works

From the fork, for EOF code (bytes starting with 0xEF 0x00) only:

Limit Legacy (unchanged) EOF under EIP-7830
MAX_CODE_SIZE 24,576 bytes 65,536 bytes (64 KiB)
MAX_INITCODE_SIZE (2 × code) 49,152 bytes 131,072 bytes (128 KiB)

Why 64 KiB and not more: in EOF, the code to be deployed is carried as a subcontainer, which is itself limited to 64 KiB; going higher would need a larger or variable-length size field in the container format.

Gas already scales with size (code deposit is paid per byte, and EIP-3860 charges for initcode). The spec's analysis puts a full 64 KiB deployment at roughly 14M to 16M gas, close to the 15M target at the time.

Sample code

Checking which limit a piece of bytecode would face (TypeScript):

import { getBytes } from "ethers";

const LEGACY_MAX_CODE = 24_576;
const EOF_MAX_CODE = 65_536;

function maxCodeSize(code: Uint8Array): number {
  const isEof = code.length >= 2 && code[0] === 0xef && code[1] === 0x00;
  return isEof ? EOF_MAX_CODE : LEGACY_MAX_CODE;
}

const runtime = getBytes(artifact.deployedBytecode);
if (runtime.length > maxCodeSize(runtime)) {
  throw new Error(`code is ${runtime.length} bytes; limit ${maxCodeSize(runtime)}`);
}

Without EOF, Solidity users must stay under 24 KiB; the optimizer and viaIR in the standard JSON input often help:

{ "settings": { "optimizer": { "enabled": true, "runs": 200 }, "viaIR": true } }

Things to know

  • Status: Stagnant. It depends on EOF, which was not activated on mainnet (the EOF meta EIP, EIP-7692, is also Stagnant). Without EOF, this EIP changes nothing.
  • For a size increase that does not depend on EOF, see EIP-7907, which proposes metering contract code size in gas so the limit can be raised for all contracts.
  • Legacy contracts are entirely unaffected; this is backwards compatible.
  • The spec flags that client storage architectures may need further analysis before a larger limit is safe.

#eof #contract-size #evm #core

Details

Authors
Alex Beregszaszi (@axic), Danno Ferrin (@shemnon)
Status
Stagnant
Type
Standards Track / Core
Created
2024-11-29
Requires

Machine-readable: Markdown · JSON