EIP-7706 · Stagnant · Core · 2024-05-13
EIP-7706: Separate gas type for calldata
Proposes giving calldata its own base fee and per-block gas limit, alongside execution gas and blob gas, to shrink worst-case block size while making calldata cheaper on average.
What problem does it solve?
Calldata and computation share one gas pool. A block can therefore be filled almost entirely with calldata, so the theoretical maximum block size (about 30,000,000 / 16 ≈ 1.87 MB at the gas limit when the EIP was written) is far above the typical size (around 100 kB, excluding blobs). That worst case is a major argument against raising the gas limit, cutting calldata prices, or adding blobs.
EIP-4844 solved the same issue for blob data by giving blobs their own fee market. EIP-7706 applies that recipe to calldata: a separate base fee and a separate limit. The maximum calldata per block drops sharply, while the target is set around 2× current average usage, so on average calldata should get cheaper.
How it works
Gas becomes a three-element vector: [execution, blob, calldata].
- New transaction type (number TBD, via EIP-2718) with
max_fees_per_gasandpriority_fees_per_gasas length-3 vectors. Its intrinsic cost drops the usual 16/4 gas per byte calldata charge, because calldata is now billed in its own dimension. - Calldata gas is counted the same way as today: 4 gas per zero byte, 16 per non-zero byte (expressed as 4 gas per "token", 4 tokens per non-zero byte).
- Per-block limits: execution uses the normal gas limit, blobs use
MAX_BLOB_GAS_PER_BLOCK, calldata getsgas_limit / 4. Targets are limit/2, limit/2 and limit/4 respectively. - One base-fee rule for all three: each dimension tracks
excess_gasand prices with the EIP-4844fake_exponentialformula. This replaces the separate EIP-1559 execution-gas rule. - Header changes:
gas_limit,gas_used,base_fee_per_gas,blob_gas_usedandexcess_blob_gasare replaced by vector fieldsgas_limits,gas_used,excess_gas.
Older transaction types are mapped into vectors automatically; for example a type-2 transaction uses its max_fee_per_gas for both execution and calldata.
Sample code
Core pricing logic, condensed from the spec (Python):
LIMIT_TARGET_RATIOS = [2, 2, 4] # execution, blob, calldata
BASE_FEE_UPDATE_FRACTION = 8
MIN_BASE_FEE_PER_GAS = 1
def calldata_gas(data: bytes) -> int:
zeros = data.count(0)
tokens = zeros + (len(data) - zeros) * 4
return tokens * 4
def targets(parent):
return [lim // r for lim, r in zip(parent.gas_limits, LIMIT_TARGET_RATIOS)]
def excess_gas(parent):
return [max(e + u - t, 0)
for e, u, t in zip(parent.excess_gas, parent.gas_used, targets(parent))]
def base_fees(parent):
return [fake_exponential(MIN_BASE_FEE_PER_GAS, e, t * BASE_FEE_UPDATE_FRACTION)
for e, t in zip(parent.excess_gas, targets(parent))]
def fees_per_gas(max_fees, priority_fees, block_base_fees):
assert all(b <= m for b, m in zip(block_base_fees, max_fees))
return [min(b + p, m) for b, p, m in zip(block_base_fees, priority_fees, max_fees)]
Things to know
- Status: Stagnant. It has not been scheduled for any upgrade, and the fork block and transaction type number are still TBD.
- Ethereum took a different, simpler route to cap worst-case calldata: EIP-7623 raises the calldata floor price for data-heavy transactions.
- Block building gets more complex with several independent limits, though the spec argues greedy strategies are close to optimal since most blocks are not full.
- Legacy-style transactions would keep working but pay slightly sub-optimally, since their calldata and execution fees are forced to be equal.