Skip to content

Commit

Permalink
[DRAFT] EIP-3978: Introduce gas refunds on reverts (ethereum#3978)
Browse files Browse the repository at this point in the history
* Introduce gas refunds on reverts

* Update EIPS/eip-3978.md

Co-authored-by: lightclient <14004106+lightclient@users.noreply.github.com>

* Fixes

* Update EIPS/eip-3978.md

Co-authored-by: lightclient <14004106+lightclient@users.noreply.github.com>

* Fix narrative

* Update EIPS/eip-3978.md

Co-authored-by: Micah Zoltu <micah@zoltu.net>

* Update EIPS/eip-3978.md

Co-authored-by: Micah Zoltu <micah@zoltu.net>

Co-authored-by: lightclient <14004106+lightclient@users.noreply.github.com>
Co-authored-by: Micah Zoltu <micah@zoltu.net>
  • Loading branch information
3 people authored and PhABC committed Jan 25, 2022
1 parent 404fac6 commit 6f57901
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions EIPS/eip-3978.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
eip: 3978
title: Gas refunds on reverts
description: Do not erase gas refunds on transaction subcall reverts, due users pay a lot of gas for storage non-modification.
author: Anton Bukov (@k06a), Mikhail Melnik (@ZumZoom)
discussions-to: https://ethereum-magicians.org/t/eip-3978-gas-refunds-on-reverts/7071/
status: Draft
type: Standards Track
category: Core
created: 2021-09-16
---

## Abstract

Since [EIP-3298](./eip-3298.md) gas refunds works for storage restores only inside the same transaction. For example [ERC-20](./eip-20.md) `approve` + `transferFrom` flow between 2 smart contracts according to [EIP-2200](./eip-2200.md) and [EIP-2929](./eip-2929.md) 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.

## 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 count all SSTORE gas costs within every subcall, excluding access costs. And on reverting any subcall let's not erase refund counter, but:
```
tx.gas_refund_counter = tx.gas_refund_counter - call.gas_refund_counter + MIN(call.gas_refund_counter, call.all_sstores_gas_cost)
```

## Rationale

TBD

## Backwards Compatibility

No known backward incompatibilities.

## Test Cases

TBD

## Reference Implementation

TBD

## Security Considerations

TBD

## Copyright
Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/).

0 comments on commit 6f57901

Please sign in to comment.