EIP-8032 Gas pricing based on storage size (Size-Based Storage Gas Pricing)

No call decision · Fees & gas · EIP status Draft · created 2025-09-29

Records the number of storage slots a contract holds on the account, and raises SSTORE (storage write) gas cost once that count crosses an activation threshold, curbing state bloat.

Why it is needed

Ethereum's state (the set of all account and contract data) keeps growing, which directly affects node sync time, hardware requirements, and network health. The current gas model does not properly reflect the long-term cost of storing data indefinitely. As a result, using contracts with large storage as cheap data dumps or for spam remains economically viable, and the burden is shared by every network participant. In practice, the compute and I/O cost of creating and modifying storage slots grows with the number of slots a contract already holds, but gas prices do not rise to match. This proposal directly ties a contract's storage size to the cost of expanding it further, charging increasingly more for contracts that bloat state excessively while leaving small and medium-sized contracts unaffected.

What changes

Today

After EIP-8032

Who is affected

In depth

New account field storage_count

Adds an optional field storage_count to account RLP. Its value is the number of non-empty storage slots the account holds; it is attached only to accounts whose storage root hash is non-empty, and can be omitted if it is 0. It is encoded as a minimal-length big-endian byte string with no leading zeros, so up to 255 slots needs 1 byte and up to 4,294,967,295 needs 4 bytes. As of around block 23,000,000, the largest contract has about 80 million slots, and even at that scale the per-account addition is at most 6 bytes. Even assuming all 23,000,000 contract accounts use the worst case of 6 bytes, the upper bound is about 138MB, and the source states that in practice most use 2 to 4 bytes, making the impact on state size negligible.

SSTORE gas formula and fixing within a block

SSTORE cost is calculated as constant_sstore_gas(addr, slot) + LIN_FACTOR * ceil_log16(S_pre(addr)) // ACTIVATION_THRESHOLD. S_pre(A) is the storage_count(A) value recorded in the pre-state (the parent state) of the block being executed, and it must not change for that account throughout the block regardless of any writes occurring within it. If the field is absent at the start of the block, it is treated as 0. The source states the reason for fixing S_pre within the block is that it stabilizes gas estimation and makes it unaffected by transaction ordering. Specific values such as LIN_FACTOR and ACTIVATION_THRESHOLD (to be chosen around the 8GB data level) are still undecided (TBD).

storage_count update rules

After executing all transactions in a block, the storage_count of affected accounts is updated. Instead of recounting the entire storage every block, a delta is computed for each slot whose value changed and applied sequentially. A +1 occurs when an empty slot gains a value, a -1 when a slot that held a value becomes empty, and 0 if the occupancy state is unchanged. While the transition is in progress, deltas are fully applied to accounts whose traversal has already finished (accounts preceding cursor_account_hash), not applied to accounts not yet traversed, and for the account currently being traversed, applied only to slots already counted (preceding cursor_slot_hash). Since the transition traversal runs after transaction execution but before delta application, the change in gas cost for a contract traversed in this block applies starting from the next block.

Transition procedure, registry, and reorg safety

From the fork point, a transition begins that counts the slot count across all existing accounts. The progress cursor is stored in a system contract at TRANSITION_REGISTRY_ADDRESS, with cursor_account_hash at slot 0x00, cursor_slot_hash at 0x01, and cursor_accum (the number of non-zero slots counted so far in the current account) at 0x02. At the end of each block, up to TRANSITION_SLOTS_PER_BLOCK slots are traversed in lexicographically ascending order, and the number of accounts finalized per block is capped by TRANSITION_MAX_ACCOUNTS. The former limits read work and the latter limits write work, avoiding write amplification and performance degradation from large database compactions. Since both the cursor and storage_count are written to the block's post-state as ordinary state writes, if a reorg occurs, they revert to the ancestor values on the new canonical chain and are restored simply by re-executing blocks. No separate reorg handling is needed.

Why an in-protocol transition is needed

If counting started fresh from the fork point, every existing contract would start from storage_count 0. Then contracts that were already huge before the fork would pay only the unsurcharged base cost until a substantial portion of their past slots were rewritten, and during that time the gas price would underestimate the actual storage size. By deterministically traversing existing storage under consensus rules to populate storage_count, every contract's actual size is reflected after the fork regardless of whether it is rewritten. An alternative where clients pre-count in the background before the fork was also considered, but it was not adopted because nodes that upgraded late, nodes using snap sync, or nodes that were offline could not deterministically reconstruct the pre-fork tally, and reorgs would need separate handling. The transition method references EIP-7612.

Depth-based pricing, the unified tree, and the relationship with EIP-2926

Compared with the alternative of pricing by tree depth, the largest observed contract (XEN) sits at a depth of about 9. However, since the storage key that enters the tree is keccak256(slot_key), an attacker could compute the hash off-chain and fill any contract so it incurs only the same cost as XEN. That is why slot count rather than depth was chosen as the basis. Meanwhile, the source itself notes that if a move is made to a Verkle or binary unified tree, SSTORE's actual compute and I/O cost would depend on the global tree's branching factor, height, and overall key distribution rather than an individual account's slot count, so slot-count-based pricing could diverge from actual workload. Also, since EIP-2926 likewise requires an account transition for bytecode chunking, including both in the same fork would let the transitions be merged into one, reducing duplicate work and client complexity.

Backward compatibility and gas estimation

Since storage_count is an optional field defaulting to 0, contracts not yet reached by the traversal iterator are unaffected by the gas increase. However, this is a gas repricing without backward compatibility, so it requires a scheduled network upgrade (hard fork). Node operators need to update their gas estimation handling, and in particular RPC methods like eth_estimateGas need to reflect the new calculation formula when they encounter SSTORE. Users and wallets can continue using their usual methods since the RPC handles the change.

Still at the Draft stage

This EIP is in Draft status, so its content may change. Key constants such as FORK_TIMESTAMP, LIN_FACTOR, ACTIVATION_THRESHOLD, TRANSITION_REGISTRY_ADDRESS, TRANSITION_SLOTS_PER_BLOCK, and TRANSITION_MAX_ACCOUNTS are all undecided (TBD), the Test Cases and Reference Implementation sections are marked TODO, and the Security Considerations section only states that discussion is needed (Needs discussion). There is also no core developer call decision yet on whether to include it in a fork.

Original EIP · ← EIPs