EIP-3403 Partial repeal of gas refunds (Partial removal of refunds)
No call decision · Fees & gas · EIP status Stagnant · created 2021-03-16
Completely removes the SELFDESTRUCT gas refund and limits the SSTORE refund to the single case of resetting a storage slot's value back to 0.
Why it is needed
The original purpose of giving gas refunds for SSTORE and SELFDESTRUCT was to encourage application developers to clean up storage slots and contracts they no longer use. In practice, however, these refunds were rarely used for state cleanup, and the practice of using storage space carelessly persisted. It is now widely accepted that the problem of growing state size should be solved through other approaches such as statelessness or state expiry, and once such approaches are introduced, unused slots and contracts are automatically ignored. Moreover, gas refunds also produced harmful side effects. Techniques like GasToken emerged, which fill storage slots to stockpile gas when gas prices are cheap and clear them for a refund when prices are expensive, further growing state size and inefficiently clogging chain gas usage. Refunds also increase block size variance. Although refunds are capped at 50 percent of the gas used per transaction, the theoretical maximum amount of gas that can actually be consumed in a single block reaches nearly twice the stated gas limit.
What changes
Today
- A gas refund could be received when calling SELFDESTRUCT
- Resetting a storage slot to 0 via SSTORE generally received a refund
- Techniques like GasToken, which used refunds to stockpile gas when cheap and spend it when expensive, were in common use
- The gas actually consumed in a single block could grow to nearly twice the theoretical gas limit
After EIP-3403
- The SELFDESTRUCT refund disappears entirely
- The SSTORE refund is limited to 19000 gas, and only for the case where the original value and the new value are both 0 while the current value is not 0
- Patterns such as reentrancy-guard locks or ERC20 approve-and-send still receive favorable gas treatment
- GasToken becomes economically useless
Who is affected
- Ordinary users: The effective gas cost of transactions that relied on refunds changes.
- DeFi arbitrage bot operators: Code that used GasToken or custom gas-saving techniques loses its effect and must be rewritten to regain the benefit.
- Smart contract developers: If storage slot deletion or contract self-destruction was designed for refund purposes, it needs to be reconsidered.
- Client teams: We should fix the gas accounting logic, and the optimization that skips the actual storage write when new_value equals original_value becomes more important.
In depth
SELFDESTRUCT refund fully abolished
Per the spec, after FORK_BLOCK the gas refund previously paid for executing SELFDESTRUCT is removed entirely. Previously, self-destructing a contract earned a refund as compensation for clearing state, but this refund was not actually driving state cleanup in practice and instead produced side effects such as GasToken.
SSTORE refunds reduced to a single case
Based on the new value, original value, and current value as defined in EIP-1283, an SSTORE refund now returns SSTORE_REFUND_GAS (19000 gas) only when both new value and original value are 0 and current value is nonzero. Every other SSTORE refund path is removed.
Why this single case was kept
Per the Rationale, this case was kept to preserve favorable gas treatment for the reentrancy guard lock pattern, going from 0 to 1 and back to 0, and for patterns like ERC20 approve-and-send, where the approval value goes from 0 to nonzero and back to 0.
Still disables GasToken
The Rationale explains that this condition fully preserves the two goals of EIP-3298. First, the 19000 gas refund is only possible because the slot was changed from 0 to nonzero within the same transaction, which already cost an extra 19000 gas, so a GasToken-style transaction that clears unrelated slots to harvest gas and spend it elsewhere does not work. Second, the total gas used during execution is kept from exceeding the gas limit.
Backwards compatibility and impact on GasToken
Per Backwards Compatibility, refunds are only applied after transaction execution finishes, so they do not affect the gas available during execution, meaning existing code's execution itself is not broken. However, applications that economically depended on this refund, GasToken in particular, lose their value, and it notes that DeFi arbitrage bots using GasToken or their own gas-saving tricks would need to rewrite their code to remove the related calls in order to benefit.
Optimization clients should follow
Security Considerations states that since the refund is not visible in the execution logic itself, it does not affect transaction execution. However, it explains that an SSTORE that goes from 0 to nonzero and back to 0 within the same transaction does not actually need to touch the state tree, so it can be treated as an exception when computing a block's total execution gas, and it specifies that the optimization where a client skips the actual storage write when new_value equals original_value becomes more important now.
Parameters and current status
The spec's FORK_BLOCK value is TBD and not yet assigned, and this EIP's status is Stagnant. The provided call records contain no decision to include this EIP in any specific fork.