Skip to content

Commit

Permalink
[EIP-3978] Add LOGs gas refunds (ethereum#4691)
Browse files Browse the repository at this point in the history
  • Loading branch information
k06a authored and PowerStream3604 committed May 19, 2022
1 parent 80af24a commit 73f4284
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions EIPS/eip-3978.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ status: Draft
type: Standards Track
category: Core
created: 2021-09-16
updated: 2021-12-30
updated: 2022-01-17
---

## 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.
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. Moreover it makes sense to have gas refund for reverted logs (events).

## Motivation

Expand All @@ -23,7 +23,7 @@ updated: 2021-12-30

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;
tx.gas_refund_counter = tx.gas_refund_counter - call.gas_refund_counter + call.sstores_sloads_diff_counter + call.log_gas_counter;
```

## Rationale
Expand Down

0 comments on commit 73f4284

Please sign in to comment.