Remove gas refunds for SSTORE and SELFDESTRUCT.
Gas refunds for SSTORE and SELFDESTRUCT were originally introduced to motivate application developers to write applications that practice "good state hygiene", clearing storage slots and contracts that are no longer needed. However, they are not widely used for this, and poor state hygiene continues to be the norm. It is now widely accepted that the only solution to state growth is some form of statelessness or state expiry, and if such a solution is implemented, then disused storage slots and contracts would start to be ignored automatically.
Gas refunds additionally have multiple harmful consequences:
Constant | Value |
---|---|
FORK_BLOCK |
TBD |
For blocks where block.number >= FORK_BLOCK
, the following changes apply.
Do not apply the refund
.
The description above is sufficient to describe the change, but for the sake of clarity we enumerate all places where gas refunds are currently used and which should/could be removed within a node implementation.
Remove all use of the "refund counter" in SSTORE gas accounting, as defined in EIP 2200. Particularly:
SSTORE_RESET_GAS
is deducted (plus COLD_SLOAD_COST
if prescribed by EIP 2929 rules), but no modifications to the refund counter are made.SLOAD_GAS
is deducted (plus COLD_SLOAD_COST
if prescribed by EIP 2929 rules), but no modifications to the refund counter are made.Remove the SELFDESTRUCT
refund.
A full removal of refunds is the simplest way to solve the issues with refunds; any gains from partial retention of the refund mechanism are not worth the complexity that that would leave remaining in the Ethereum protocol.
Refunds are currently only applied after transaction execution, so they cannot affect how much gas is available to any particular call frame during execution. Hence, removing them will not break the ability of any code to execute, though it will render some applications economically nonviable.
GasToken in particular will become valueless. DeFi arbitrage bots, which today frequently use either established GasToken schemes or a custom alternative to reduce on-chain costs, would benefit from rewriting their code to remove calls to these no-longer-functional gas storage mechanisms.
An implementation can be found here: https://gist.github.com/holiman/460f952716a74eeb9ab358bb1836d821#gistcomment-3642048
Gas costs are provided with refunds subtracted; if the number is negative this means that refunds exceed gas costs. The 50% refund limit is not applied (due to the implied assumption that this code is only a small fragment of a much larger execution).
If refunds were to be removed, this would be the comparative table
| Code | Original | 1st | 2nd | 3rd | Istanbul | Berlin (cold) | Berlin (hot)| Berlin (hot)+norefund |
| -- | -- | -- | -- | -- | -- | -- | -- | -- |
| 0x60006000556000600055
| 0 | 0 | 0 | | 1612 | 2312 | 212 | 212 |
| 0x60006000556001600055
| 0 | 0 | 1 | | 20812 | 22212 | 20112 | 20112 |
| 0x60016000556000600055
| 0 | 1 | 0 | | 1612 | 2312 | 212 | 20112 |
| 0x60016000556002600055
| 0 | 1 | 2 | | 20812 | 22212 | 20112 | 20112 |
| 0x60016000556001600055
| 0 | 1 | 1 | | 20812 | 22212 | 20112 | 20112 |
| 0x60006000556000600055
| 1 | 0 | 0 | | -9188 | -9888 | -11988 | 3012 |
| 0x60006000556001600055
| 1 | 0 | 1 | | 1612 | 2312 | 212 | 3012 |
| 0x60006000556002600055
| 1 | 0 | 2 | | 5812 | 5112 | 3012 | 3012 |
| 0x60026000556000600055
| 1 | 2 | 0 | | -9188 | -9888 | -11988 | 3012 |
| 0x60026000556003600055
| 1 | 2 | 3 | | 5812 | 5112 | 3012 | 3012 |
| 0x60026000556001600055
| 1 | 2 | 1 | | 1612 | 2312 | 212 | 3012 |
| 0x60026000556002600055
| 1 | 2 | 2 | | 5812 | 5112 | 3012 | 3012 |
| 0x60016000556000600055
| 1 | 1 | 0 | | -9188 | -9888 | -11988 | 3012 |
| 0x60016000556002600055
| 1 | 1 | 2 | | 5812 | 5112 | 3012 | 3012 |
| 0x60016000556001600055
| 1 | 1 | 1 | | 1612 | 2312 | 212 | 212 |
| 0x600160005560006000556001600055
| 0 | 1 | 0 | 1 | 21618 | 22318 | 20218 | 40118 |
| 0x600060005560016000556000600055
| 1 | 0 | 1 | 0 | -8382 | -9782 | -11882 | 5918 |
TBD
Copyright and related rights waived via CC0.