-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Description
This is a general idea for an EIP, but I'd like to solicit informal feedback here before proceeding.
Many sophisticated users implement a trick, where they exploit the contract self-destruct refund to lower their gas usage on expensive transactions. In fact this is even so common, that there's even a token built around this. The idea is that you "store" gas by creating a bunch of dummy contracts, when gas is cheap. Then you "spend" it by self-destructing those dummy contracts when gas is expensive. Ballpark estimate is that 95%+ of calls to SELFDESTRUCT come from these gas tank contracts.
In general, I think this behavior is "good" for the health of the blockchain. In effect it acts as a shadow version of EIP-1559, by shifting gas usage from when the network is congested to when it is not. The downside is that in aggregate, the contract creation/self-destruct cycle burns a lot of gas unnecessarily. That part contributes to the gas shortage. Creating a contract costs 32k Gwei, plus more for the byte code. Self destruct spends another 5k Gwi, but refunds 19k. Overall, each one of these "gas-tank" contracts slurps up 20k Gwei from the aggregate gas supply. Not to mention, the cost associated with bookkeeping, like tracking contract owners. From an economic standpoint this is far too high a cost, since a "store-and-spend" cycle has a net zero impact on the long-term state growth.
Would it not be an improvement to simply incorporate "gas storage" as part of the EVM? That leaves the advantage of smoothing congestion, but doesn't needlessly waste gas supply. The second effect is it would democratize access to this ability, whereas now it's only available to highly sophisticated players. I propose the introduction of a new Opcode "BANKGAS" and "REFUNDGAS", which would let any contract directly store gas, and use it to refund later. Just the same as how contract self-destructs refund transaction gas.
(Secondarily, it may be a good idea to increase the refund ceiling from its current 50% of transaction cost. Given how volatile gas prices are, more smoothing is probably a good thing.)