⚠️ This EIP is not recommended for general use or implementation as it is likely to change.

EIP-3978: Gas refunds on reverts Source

Do not erase gas refunds on transaction subcall reverts, due users pay a lot of gas for storage non-modification.

AuthorAnton Bukov, Mikhail Melnik
Discussions-Tohttps://ethereum-magicians.org/t/eip-3978-gas-refunds-on-reverts/7071/
StatusDraft
TypeStandards Track
CategoryCore
Created2021-09-16
Updated2022-01-17

Abstract

Since EIP-3298 gas refunds works for storage restores only inside the same transaction. For example ERC-20 approve + transferFrom flow between 2 smart contracts according to EIP-2200 and EIP-2929 will cost nearly to 21600 gas with gas refund counter 20000. But in case of reverting this subcall (containing both approve and transferForm) gas refund will be erased, while smart contract storage will remain unmodified. I think it should keep storage access costs, but still refund modification costs. Moreover it makes sense to have gas refund for reverted logs (events).

Motivation

Сurrent full cancelling of gas refunds on internal reverts is too unfair. Users pay for non-modification same cost as for modification.

Specification

Let’s consider all reverted SSTOREs as SLOADs (access) costs. This requires to remember (SSTORE - SLOAD) costs for each SSTORE inside every internal call excluding its subcalls and on revert let’s update gas refund counter in the following manner:

tx.gas_refund_counter = tx.gas_refund_counter - call.gas_refund_counter + call.sstores_sloads_diff_counter + call.log_gas_counter;

Rationale

TBD

Backwards Compatibility

No known backward incompatibilities.

Test Cases

TBD

Reference Implementation

TBD

Security Considerations

TBD

Copyright and related rights waived via CC0.

Citation

Please cite this document as:

Anton Bukov, Mikhail Melnik, "EIP-3978: Gas refunds on reverts [DRAFT]," Ethereum Improvement Proposals, no. 3978, September 2021. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-3978.