EIP-150 Gas cost increase for IO-intensive operations (Gas cost changes for IO-heavy operations)

Final · Fees & gas · EIP status Final · created 2016-09-24

Raises the gas cost of EVM operations that read state from disk to match their actual cost, and limits the gas that can be passed to a call to '63/64 of the remaining gas.' This is a hard fork applied at block 2,463,000 in response to the 2016 denial-of-service attacks.

Why it is needed

In 2016, Ethereum experienced a series of denial-of-service (DoS) attacks. Attackers exploited the fact that operations reading state stored on disk, such as account balances or contract code, were priced far too cheaply relative to their actual processing cost. Disk reads take a long time, but since the gas cost was only around 20 to 50, a small amount of money could force nodes to perform a massive amount of read work. This imbalance could not be resolved through software optimization alone, and such attack transactions would also pose a risk under future sharding designs, which would require tens of megabytes of Merkle proofs. This EIP therefore raises the gas cost of state-reading operations to match the actual burden of spam attacks, while also adjusting how gas is forwarded so that existing contracts would not break in the process.

What changes

Today

After EIP-150

Who is affected

In depth

Effective block and fork

Takes effect from block number 2,463,000 (FORK_BLKNUM) on mainnet (CHAIN_ID 1). This EIP is part of the Tangerine Whistle hard fork (summarized as meta by EIP-608), and its status is Final.

Gas cost increases for state-reading operations

EXTCODESIZE rises from 20 to 700, the base cost of EXTCODECOPY rises from 20 to 700, BALANCE rises from 20 to 400, and SLOAD rises from 50 to 200. CALL, DELEGATECALL, and CALLCODE rise from 40 to 700. All of these are operations that read the state tree and trigger disk access.

Introduction of the SELFDESTRUCT cost

Raises the gas cost of SELFDESTRUCT from 0 to 5000. Also, if SELFDESTRUCT targets a newly created account, an additional 25000 gas is charged, similar to CALL. This closes off a path that let account creation happen for free.

The 63/64 rule: a combination of EIP-90 and EIP-114

Defines 'all but one 64th' as N - floor(N / 64). If a call requests more gas than the permitted limit, instead of throwing an OOG error, only 63/64 of the remaining gas is forwarded and the call proceeds. The implementation sets max_call_gas(gas) = gas - (gas // 64), and when the remaining gas falls short of the requested amount, changes it to gas = min(gas, max_call_gas(remaining gas - extra_gas)). CREATE likewise provides only 63/64 of the parent's gas to the child. Without this mechanism, every existing contract relying on an assumption that call cost is 40, such as msg.gas - 40, would stop working, so this was introduced alongside the cost increase (the EIP-90 mechanism). At the same time, EIP-114 was combined in to replace the fixed call stack depth limit with a soft, gas based limit.

Basis for the cost figures

The new gas costs were derived from an updated version of the spreadsheet used to produce the 1.0 gas costs. The goal was to keep the data that must be read when processing a block under 8MB, estimating Merkle proof sizes at 500 bytes for SLOAD and 1000 bytes for accounts. On top of that, code loading cost (roughly 17 to 21kb in the worst case) was factored in, adding a fixed surcharge of 300 gas on top of the computed values. Keeping the specification simple was a design goal.

Eliminating call stack depth attacks

Since 1/64 of the gas stays with the parent on every call, the effective maximum call depth drops from roughly 1024 to roughly 340 under the given parameters. As a result, attacks that deliberately stack the call depth to force sub-calls to fail are no longer something contract developers need to worry about, and the damage from quadratic-complexity DoS attacks that rely on calls is also mitigated.

Recommendation to raise the gas limit

When computation costs rise across the board, fewer transactions can be processed within the same gas limit. To preserve the prior average throughput per second for an average contract, the recommended gas limit target is raised to 5.5 million.

Original EIP · ← EIPs