EIP-3860: metering the code that makes code
A contract's runtime bytecode has been size-capped since 2016 — but the initcode that produces it was neither capped nor charged for the O(n) work every node does to process it. Supply megabytes of initcode and the whole network scans it almost for free. EIP-3860 caps initcode and charges per word.
- contract creation (CREATE / CREATE2)
- gas & metering the network's work
Shanghai, April 2023. Deploying a contract is a two-part act. You send a small program — the initcode — and the EVM runs it; whatever bytes it returns become the contract’s permanent runtime code. Since 2016, runtime code has been capped at 24576 bytes (EIP-170), and you pay to store it. But the initcode itself slipped through: it was never size-limited, and the O(n) work the network must do just to process it wasn’t fully charged. That’s a small crack — and in gas economics, an unpriced O(n) operation is exactly the shape of a denial-of-service. EIP-3860 seals it. Let’s derive it.
The problem: initcode was uncapped and its O(n) work underpriced
When the EVM is handed initcode, it doesn’t just execute it — it must first do work proportional to the initcode’s length, regardless of what the code does. The clearest example is JUMPDEST analysis Before running bytecode, the EVM scans the entire program to mark which byte offsets are valid jump destinations (JUMPDEST opcodes). It's O(n) in the code length and must be done over the whole initcode — work every node repeats, whether or not the code ever runs to completion. : every node scans the whole initcode to find valid jump targets. Runtime code was capped and paid for, but initcode was uncapped, and this per-byte scanning wasn’t metered in proportion to its size. So an attacker could hand the network megabytes of initcode and make every node grind through it for a fee far below the real cost — an underpriced O(n) operation, the classic DoS shape.
→ Step 2: charge for the size, and bound it.
EIP-3860: two gas per word, plus a hard cap
The fix is the same principle Ethereum applies whenever it finds unpriced O(n) work: make the cost track the size. EIP-3860 adds an initcode word charge An extra 2 gas per 32-byte word of initcode, levied on CREATE, CREATE2, and contract-creation transactions. It directly prices the length-proportional work (like JUMPDEST analysis) the network does on the initcode. of 2 gas per 32-byte word of initcode on CREATE, CREATE2, and creation transactions — so the longer the initcode, the more you pay, exactly matching the scan. And it adds a initcode size cap A hard limit of 49152 bytes (MAX_INITCODE_SIZE = 2 × MAX_CODE_SIZE) on initcode. Exceeding it is an immediate failure, bounding the worst-case work a single creation can impose. of 49152 bytes — exactly twice the runtime limit — so no single creation can be unboundedly large. Cost now scales with work, and work is bounded.
→ Step 3: creation and runtime finally match.
The payoff: symmetric, DoS-safe creation
With EIP-3860, the two halves of a contract’s life are finally symmetric: initcode is capped at 49152 bytes and metered per word; runtime code is capped at 24576 bytes (EIP-170) and paid on deposit. Contract creation is DoS-safe — no unbounded input, no unpriced O(n) work. The change is nearly invisible to ordinary deployments and slightly raises the cost of CREATE2 factory A contract that deploys other contracts via CREATE2, often at deterministic addresses. Because these patterns deploy many contracts, the new per-word initcode charge is the place EIP-3860's cost is most noticeable. patterns, which deploy contracts en masse. It’s a small EIP with a clear pedigree: the same lesson as EIP-150 — when the network does work proportional to your input, you must pay proportionally.