EIP-7623 · Final · Core · 2024-02-13
EIP-7623: Increase calldata cost
Adds a calldata floor price of 10/40 gas per zero/non-zero byte for data-heavy transactions, shrinking Ethereum's worst-case block size while leaving normal transactions' costs unchanged.
What problem does it solve?
Calldata has cost 4 gas per zero byte and 16 per non-zero byte since EIP-2028. Average blocks are small (around 100 KB per the spec), but a block stuffed with calldata could reach about 1.79 MB, or 7.15 MB with zero bytes before compression. Clients and the network have to be ready for that worst case, which blocks raising the gas limit or adding more blobs.
Since EIP-4844, rollups have a dedicated, cheaper place for data: blobs. There is little reason left for calldata to be the cheap way to post bulk data, so EIP-7623 makes data-heavy transactions pay more without touching ordinary users.
How it works
Calldata is counted in tokens: tokens = zero_bytes + nonzero_bytes * 4.
The gas used by a transaction becomes the larger of two numbers (on top of the base 21,000):
- the normal cost:
4 * tokens + execution gas (+ creation costs), and - a floor:
10 * tokens.
In other words, a transaction pays the floor of 10/40 gas per byte only if its calldata dominates its execution. A typical swap, transfer or mint spends enough on EVM execution that the floor never applies, so it pays exactly what it did before. A transaction that is mostly data, like a rollup posting batches in calldata, pays up to 2.5× more.
The floor must be covered by the gas limit up front: a transaction is invalid if its gas limit is below 21000 + 10 * tokens (or below the usual intrinsic gas). Per the spec, this cuts the maximum execution payload size to roughly 0.72 MB.
Sample code
The new gas-used formula from the spec:
STANDARD_TOKEN_COST = 4
TOTAL_COST_FLOOR_PER_TOKEN = 10
tokens_in_calldata = zero_bytes + nonzero_bytes * 4
tx_gas_used = 21000 + max(
STANDARD_TOKEN_COST * tokens_in_calldata
+ execution_gas_used
+ is_contract_creation * (32000 + INITCODE_WORD_COST * words(calldata)),
TOTAL_COST_FLOOR_PER_TOKEN * tokens_in_calldata,
)
Checking the minimum gas limit for a payload (TypeScript):
import { getBytes } from "ethers";
function floorGasLimit(data: string): bigint {
const bytes = getBytes(data);
const zeros = bytes.filter((b) => b === 0).length;
const tokens = BigInt(zeros + (bytes.length - zeros) * 4);
return 21000n + 10n * tokens;
}
Things to know
- Status is Final; it went live on Ethereum mainnet in the Pectra upgrade.
- Wallets and RPC
eth_estimateGasmust account for the floor. An estimate that ignores it can produce a gas limit that makes the transaction invalid. - Because
execution_gas_usedis after refunds, transactions that rely on large refunds can hit the floor. - Rollups that still post data as calldata pay more; blobs are the intended path.
- EIP-7976 proposes raising the floor further.