EIPs Explained

EIP-3300 · Stagnant · Core · 2020-02-26

EIP-3300: Phase out refunds

A stagnant proposal to phase out SSTORE and SELFDESTRUCT gas refunds gradually, shaving 1 gas off every refund each 100 blocks, instead of removing them overnight.

What problem does it solve?

The EVM used to refund gas for clearing storage (SSTORE to zero) and for SELFDESTRUCT. Refunds were meant to encourage state cleanup, but they had side effects:

  • Block elasticity: refunds let a block execute up to about 2× its nominal gas limit, which made miners wary of raising the limit.
  • Gas tokens: people "stored" gas by filling storage or creating contracts when gas was cheap, then destroying them for refunds when gas was expensive, bloating the state.

Removing refunds abruptly would wipe out the value of existing gas tokens overnight and shock the gas market. EIP-3300 proposed a slow, predictable decay so holders would use up their refunds (cleaning the state) while they were still worth something.

How it works

Parameters:

  • REFUND_DECAY_STEP = 1 gas
  • REFUND_DECAY_FREQUENCY = 100 blocks
  • REFUND_DECAY = REFUND_DECAY_STEP × ceil((block.number + 1 - FORK_BLOCK_NUM) / REFUND_DECAY_FREQUENCY)

Every refund — the 24,000 SELFDESTRUCT refund, the 15,000 storage-clear refund, and the SSTORE restore refunds from EIP-2929 — is reduced by the current REFUND_DECAY, never below 0. Where a refund is later removed (net gas metering cancelling a prior clear refund), the removal shrinks by the same amount so the refund counter can never go negative.

By the author's estimate, SELFDESTRUCT refunds would fall below their creation cost after about 1.9 million blocks and SSTORE refunds after about 1 million — roughly a year — after which a follow-up fork could remove them entirely.

Sample code

Pseudocode for applying the decay:

from math import ceil

REFUND_DECAY_STEP = 1
REFUND_DECAY_FREQUENCY = 100

def refund_decay(block_number: int) -> int:
    if block_number < FORK_BLOCK_NUM:
        return 0
    periods = ceil((block_number + 1 - FORK_BLOCK_NUM) / REFUND_DECAY_FREQUENCY)
    return REFUND_DECAY_STEP * periods

def decayed(refund: int, block_number: int) -> int:
    return max(0, refund - refund_decay(block_number))

# e.g. SSTORE clear refund 1,000,000 blocks after activation
print(decayed(15_000, FORK_BLOCK_NUM + 1_000_000))  # 4999

Things to know

  • Status is Stagnant. Ethereum took a different route: EIP-3529 (London, 2021) removed the SELFDESTRUCT refund outright, cut the storage-clear refund and capped total refunds at one fifth of gas used. EIP-3403 was another competing approach.
  • The author notes the change would increase gas-price volatility, since refunds contributed to block elasticity.
  • SELFDESTRUCT itself was later neutered by EIP-6780.

#gas #refunds #sstore #selfdestruct #core #stagnant

Details

Authors
William Morriss (@wjmelements)
Status
Stagnant
Type
Standards Track / Core
Created
2020-02-26

Machine-readable: Markdown · JSON