EIP-5022 SSTORE new-storage gas cost doubled (Increase price of SSTORE from zero to non-zero to 40k gas)
No call decision · Fees & gas · EIP status Stagnant · created 2022-04-20
A proposal to raise the gas cost of writing the first value into an empty storage slot via the SSTORE operation from 20,000 to 40,000.
Why it is needed
Ethereum's state (the full data of accounts and storage) grows larger over time, and the cost of maintaining that larger state grows along with it. However, the gas cost charged for creating a new storage slot for the first time is fixed at the amount originally set, so it no longer matches the actual cost. As a result, the real cost of transactions that create new storage ends up being subsidized by all other users who perform other operations. This price distortion is also one reason raising the gas limit is something people are reluctant to do. This proposal is a stopgap measure that brings the price of state growth closer to its actual cost, so that storage creation is no longer subsidized by other users.
What changes
Today
- Writing the first value into an empty (zero) slot costs 20,000 SSTORE gas
- No matter how large the state grows, the cost of creating a new storage slot stays fixed
- The actual cost of storage creation is shared by all users performing other operations
- Concern over state growth is one reason the gas limit cannot be raised
After EIP-5022
- Writing the first value into an empty slot raises the SSTORE gas cost to 40,000
- The cost of changing an already-set slot to a different value stays the same
- Storage creation cost is more accurately reflected in price, easing the subsidy burden on other users
- Developers gain an incentive to prefer reusing existing slots over creating new ones
Who is affected
- Users: Fees rise for transactions that store new data for the first time, such as a token's first transfer or NFT minting.
- Smart contract developers: Contracts that hardcode gas costs may break when creating new state, so they should be designed around storage reuse.
- Client teams: The gas schedule change must be implemented based on FORK_BLOCK, with blocks before it applying the existing gas cost unchanged.
- Wallet and dApp developers: Gas estimation logic must reflect the change to the SSTORE new-storage cost.
In depth
Applicable conditions
This change applies only to SSTORE operations where the original slot value is zero and the new value is non-zero. In this case, the constant SSTORE_SET_GAS is changed from the existing 20,000 to the new constant NEW_STORAGE_PRICE, 40,000. The new gas schedule applies starting from blocks where block.number is at least FORK_BLOCK.
Costs that do not change
The cost of overwriting an already-set slot with a different non-zero value is not raised, since rewriting storage does not itself increase the size of the state. The author believes this rewrite cost may also be underpriced, but leaves it out of scope for this proposal. Increasing the gas refund given when a non-zero value is reset to zero is likewise not addressed, on the grounds that it needs further discussion.
Why 40,000
The current gas price was set using a simple benchmark that measured computation speed on a single laptop in the past, which was never a good fit for a resource like state whose cost grows over time, and the benchmark itself was also inaccurate. 40,000 is a figure closer to what a properly run version of that benchmark would have produced. It could be set higher, but doing so risks being too abrupt a change.
Why raise the price instead of a more fundamental fix
Structural solutions such as state rent or state expiry have been studied for a long time but are unlikely to be ready in the short to medium term. For that reason, adjusting the price as a stopgap measure is considered preferable. The reasoning also notes that changing the gas price of an opcode has been done multiple times before, so the burden on client developers is not large.
The author's position on impact
The author acknowledges that this change will significantly affect the gas costs of many applications. Still, the argument is that the network should not need to subsidize state growth by charging ordinary transactions higher fees, and that even if the change is abrupt, the overall health of the network improves as a result.
Backwards compatibility and implementation status
Contracts that hardcode gas costs may break when performing actions that create new state. Since this is a fork that changes the gas schedule itself, transactions from epochs before FORK_BLOCK must be processed using the existing gas cost. An implementation PR (24725) has been submitted to go-ethereum, but FORK_BLOCK in the specification remains TBD and the Security considerations section is still empty, marked TODO. The current status is Stagnant, and there is no record of a decision to include it in a fork.