EIP-3403 · Stagnant · Core · 2021-03-16
EIP-3403: Partial removal of refunds
Proposed removing the SELFDESTRUCT refund and all SSTORE refunds except the 0→nonzero→0 case, killing gas tokens while keeping reentrancy locks cheap.
What problem does it solve?
Ethereum used to refund gas when a transaction cleared storage (SSTORE to zero) or destroyed a contract (SELFDESTRUCT). The idea was to reward "state hygiene", but in practice it mostly caused harm:
- GasToken: people filled storage when gas was cheap and cleared it when gas was expensive to collect refunds, bloating state and wasting block space.
- Block size variance: refunds (capped at 50 % of gas used) let a block do almost twice its nominal gas limit of real work.
EIP-3298 proposed removing refunds entirely, but that would make common patterns such as reentrancy locks much more expensive. EIP-3403 is the compromise by Vitalik Buterin and Martin Swende.
How it works
From the fork block:
- No refund for
SELFDESTRUCT. - No refund for
SSTORE, except one case: if a slot's original value (at the start of the transaction) is 0, its current value is non-zero, and the new value is 0, refundSSTORE_REFUND_GAS = 19000.
Terms original, current and new are as in net gas metering (EIP-1283 / EIP-2200).
Why that exception is safe: the 19,000 refunded is only possible because the same transaction already paid about 20,000 to flip that slot from zero to non-zero. Nothing is left in state, so nobody can store up refunds for later. Gas tokens stop working, but these stay cheap:
- Reentrancy locks using the 0 → 1 → 0 pattern.
- Approve-and-spend flows where an allowance goes from 0 to a value and back to 0 within one transaction.
From the spec's comparison (warm slot, after EIP-2929): a 0-1-0 mutex costs about 212 gas under Berlin rules, 20,112 with no refunds at all, and 1,112 under EIP-3403.
Sample code
The pattern EIP-3403 was designed to keep cheap, a 0-1-0 reentrancy guard:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
contract Guarded {
uint256 private locked; // 0 = unlocked, original value at tx start
modifier nonReentrant() {
require(locked == 0, "reentrant");
locked = 1; // 0 -> 1 : pays the zero-to-nonzero SSTORE cost
_;
locked = 0; // 1 -> 0 : original == new == 0 != current => refund kept
}
function withdraw() external nonReentrant {
// ...
}
}
Things to know
- Status is Stagnant. It was not the version adopted.
- The London upgrade shipped EIP-3529 instead: it removed the
SELFDESTRUCTrefund, reduced theSSTOREclearing refund, and lowered the overall refund cap from 1/2 to 1/5 of gas used. Gas tokens became unprofitable there too. - Under EIP-3403 the "1-2-1" mutex style (non-zero to non-zero) would get no refund, so 0-1-0 would have been the cheaper pattern. Today, transient storage (
TSTORE/TLOAD) is the cheapest way to build a reentrancy lock. - Refunds are applied only after execution, so removing them never makes code run out of gas mid-call; it only changes final cost.