EIP-2035 · Stagnant · Core · 2019-05-16
EIP-2035: Stateless Clients - Repricing SLOAD and SSTORE to pay for block proofs
An early stateless-client proposal to charge extra gas for the first SLOAD or SSTORE of each storage slot in a transaction, to pay for the bandwidth of block proofs.
What problem does it solve?
Executing a block normally requires a node to hold the full Ethereum state and read it from a database, which is slow. The stateless client idea is to ship a block together with a block proof (witness) containing exactly the state the block touches, plus Merkle proofs, so a node can execute it without local state.
Those proofs cost bandwidth, and the cost grows with each storage slot accessed. EIP-2035, part of the State Rent research roadmap, proposes raising the price of SLOAD and SSTORE so transactions pay for the proof data they cause. In the first phase only contract storage would be covered; nodes would still need account data.
How it works
SLOADandSSTOREcost an extraXgas when the slot has not already been accessed earlier in the same transaction. Repeated access to the same slot pays no surcharge.Xwas not fixed. The author's estimate is that one uncached access adds at most about 1 KB to the block proof; at the then calldata price of 68 gas per byte that would mean roughly 69,000 extra gas, but the spec notes the increase could be much smaller if EIP-2028 lowered data costs.- A future variant would scale the surcharge by the size of the contract's storage, making small contracts cheaper.
- The spec notes it would partly supersede EIP-1884, which raised
SLOADfor execution-latency reasons.
Sample code
Pseudocode for the proposed per-transaction surcharge:
def storage_access_gas(tx_ctx, address, slot, base_cost):
key = (address, slot)
if key not in tx_ctx.accessed_slots:
tx_ctx.accessed_slots.add(key)
return base_cost + X # X: proof-bandwidth surcharge, not yet set
return base_cost
# SLOAD -> storage_access_gas(ctx, addr, slot, SLOAD_COST)
# SSTORE -> storage_access_gas(ctx, addr, slot, sstore_cost(...))
Things to know
- Status: Stagnant. The spec was explicitly informal and never finalised.
- The idea of charging more for the first ("cold") access to a slot within a transaction did reach mainnet in a different form: EIP-2929 in the Berlin upgrade introduced cold/warm pricing for storage and account access.
- Contracts that hard-code gas amounts for storage operations are the most exposed to any such repricing.
- The companion rent-prepayment proposal was EIP-2026.