EIPs Explained

EIP-2028 · Final · Core · 2019-05-03

EIP-2028: Transaction data gas cost reduction

Cut the gas cost of non-zero calldata bytes from 68 to 16, making it far cheaper to post data on chain, which rollups and proof systems depend on.

What problem does it solve?

Every byte of transaction input data (calldata) costs gas. Since Frontier, a non-zero byte cost 68 gas (GTXDATANONZERO) and a zero byte 4 gas. That price was set conservatively and made data-heavy uses expensive:

  • Layer-2 rollups post batches of transactions or state diffs to L1 as calldata for data availability.
  • Proof systems (SNARKs, STARKs) submit large proofs and public inputs.
  • Fraud proofs and stateless designs move Merkle proofs around instead of reading storage.

The authors (including the StarkWare team) argued that data mainly costs network bandwidth and block propagation time, and that 68 gas overstated that cost. EIP-2028 lowered it and shipped in the Istanbul upgrade.

How it works

One constant changes:

Byte value Before After
zero (0x00) 4 gas 4 gas (unchanged)
non-zero 68 gas 16 gas

This is part of the intrinsic gas of a transaction, charged before execution: 21000 + 4·zeroBytes + 16·nonZeroBytes (plus contract-creation and access-list costs where they apply).

The rationale uses a model from Sompolinsky–Zohar and Pass–Seeman–Shelat that links block propagation delay to security: bigger blocks propagate slower, which wastes more honest hash power on stale blocks and lowers the cost of an attack. The proposal splits delay into transmission and processing parts and argues that calldata mostly adds transmission delay, which the network could absorb at 16 gas per byte.

Sample code

Computing the calldata portion of intrinsic gas (TypeScript, ethers v6):

import { getBytes, Interface, parseEther } from "ethers";

function calldataGas(data: string): number {
  let gas = 0;
  for (const b of getBytes(data)) gas += b === 0 ? 4 : 16; // post-EIP-2028 prices
  return gas;
}

// transfer(address,uint256) has many zero bytes from ABI padding
const erc20 = new Interface(["function transfer(address to, uint256 value)"]);
const data = erc20.encodeFunctionData("transfer", [
  "0x000000000000000000000000000000000000dEaD",
  parseEther("1"),
]);

console.log(21_000 + calldataGas(data)); // intrinsic gas for this simple call

Things to know

  • Zero bytes are still cheaper, so compact encodings that avoid non-zero padding (or use zero-heavy layouts) save gas.
  • Cheaper calldata was a major enabler for early optimistic and ZK rollups, which used calldata for data availability.
  • Rollup data later moved to blobs with EIP-4844, which have their own fee market.
  • EIP-7623 later introduced a higher floor price for data-heavy transactions, so very calldata-heavy transactions no longer pay the plain 16-gas rate. Check the rules of the fork you target when estimating costs.

#gas #calldata #transactions #scaling #istanbul

Details

Authors
Alexey Akhunov (@AlexeyAkhunov), Eli Ben Sasson <[email protected]>, Tom Brand <[email protected]>, Louis Guthmann <[email protected]>, Avihu Levy <[email protected]>
Status
Final
Type
Standards Track / Core
Created
2019-05-03
Required by

Machine-readable: Markdown · JSON