Skip to content

Update EIP-3403: reopen #9431 (eip-3403) #9673

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions EIPS/eip-3403.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---

Check warning on line 1 in EIPS/eip-3403.md

View workflow job for this annotation

GitHub Actions / EIP Walidator

preamble is missing header(s): `description`

warning[preamble-req]: preamble is missing header(s): `description` --> EIPS/eip-3403.md | | = help: see https://ethereum.github.io/eipw/preamble-req/

Check warning on line 1 in EIPS/eip-3403.md

View workflow job for this annotation

GitHub Actions / EIP Walidator

preamble is missing header(s): `description`

warning[preamble-req]: preamble is missing header(s): `description` --> EIPS/eip-3403.md | | = help: see https://ethereum.github.io/eipw/preamble-req/
eip: 3403
title: Partial removal of refunds
author: Vitalik Buterin (@vbuterin), Martin Swende (@holiman)
Expand All @@ -8,8 +8,8 @@
category: Core
created: 2021-03-16
---

Check warning on line 11 in EIPS/eip-3403.md

View workflow job for this annotation

GitHub Actions / EIP Walidator

body is missing section(s): `Abstract`

warning[markdown-req-section]: body is missing section(s): `Abstract` --> EIPS/eip-3403.md | | = help: must be at the second level (`## Heading`) = help: see https://ethereum.github.io/eipw/markdown-req-section/

Check warning on line 11 in EIPS/eip-3403.md

View workflow job for this annotation

GitHub Actions / EIP Walidator

body is missing section(s): `Abstract`

warning[markdown-req-section]: body is missing section(s): `Abstract` --> EIPS/eip-3403.md | | = help: must be at the second level (`## Heading`) = help: see https://ethereum.github.io/eipw/markdown-req-section/
## Simple Summary

Check warning on line 12 in EIPS/eip-3403.md

View workflow job for this annotation

GitHub Actions / EIP Walidator

body has extra section(s)

warning[markdown-order-section]: body has extra section(s) --> EIPS/eip-3403.md | 12 | ## Simple Summary | = help: see https://ethereum.github.io/eipw/markdown-order-section/

Check warning on line 12 in EIPS/eip-3403.md

View workflow job for this annotation

GitHub Actions / EIP Walidator

body has extra section(s)

warning[markdown-order-section]: body has extra section(s) --> EIPS/eip-3403.md | 12 | ## Simple Summary | = help: see https://ethereum.github.io/eipw/markdown-order-section/

Remove gas refunds for SELFDESTRUCT, and restrict gas refunds for SSTORE to one specific case.

Expand All @@ -20,22 +20,22 @@
Gas refunds additionally have multiple harmful consequences:

* Refunds give rise to GasToken. GasToken has benefits in moving gas space from low-fee periods to high-fee periods, but it also has downsides to the network, particularly in exacerbating state size (as state slots are effectively used as a "battery" to save up gas) and inefficiently clogging blockchain gas usage
* Refunds increase block size variance. The theoretical maximum amount of actual gas consumed in a block is nearly twice the on-paper gas limit (as refunds add gas space for subsequent transactions in a block, though refunds are capped at 50% of a transaction's gas used). This is not fatal, but is still undesirable, especially given that refunds can be used to maintain 2x usage spikes for far longer than EIP 1559 can.
* Refunds increase block size variance. The theoretical maximum amount of actual gas consumed in a block is nearly twice the on-paper gas limit (as refunds add gas space for subsequent transactions in a block, though refunds are capped at 50% of a transaction's gas used). This is not fatal, but is still undesirable, especially given that refunds can be used to maintain 2x usage spikes for far longer than [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559) can.

Check warning on line 23 in EIPS/eip-3403.md

View workflow job for this annotation

GitHub Actions / EIP Walidator

non-relative link or image

warning[markdown-rel-links]: non-relative link or image --> EIPS/eip-3403.md | 23 | * Refunds increase block size variance. The theoretical maximum amount of actual gas consumed in a block is nearly twice the on-pape... | = help: use `./eip-1559.md` instead = help: see https://ethereum.github.io/eipw/markdown-rel-links/

Check warning on line 23 in EIPS/eip-3403.md

View workflow job for this annotation

GitHub Actions / EIP Walidator

non-relative link or image

warning[markdown-rel-links]: non-relative link or image --> EIPS/eip-3403.md | 23 | * Refunds increase block size variance. The theoretical maximum amount of actual gas consumed in a block is nearly twice the on-pape... | = help: use `./eip-1559.md` instead = help: see https://ethereum.github.io/eipw/markdown-rel-links/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Refunds increase block size variance. The theoretical maximum amount of actual gas consumed in a block is nearly twice the on-paper gas limit (as refunds add gas space for subsequent transactions in a block, though refunds are capped at 50% of a transaction's gas used). This is not fatal, but is still undesirable, especially given that refunds can be used to maintain 2x usage spikes for far longer than [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559) can.
* Refunds increase block size variance. The theoretical maximum amount of actual gas consumed in a block is nearly twice the on-paper gas limit (as refunds add gas space for subsequent transactions in a block, though refunds are capped at 50% of a transaction's gas used). This is not fatal, but is still undesirable, especially given that refunds can be used to maintain 2x usage spikes for far longer than [EIP-1559](./eip-1559) can.

better to self refer EIPs


### The mutex usecase

There are two typical ways to implement mutexes: '0-1-0' and '1-2-1. Let's see how they differ

- '0-1-0':

Check failure on line 29 in EIPS/eip-3403.md

View workflow job for this annotation

GitHub Actions / Markdown Linter

Unordered list style [Expected: asterisk; Actual: dash]

EIPS/eip-3403.md:29:1 MD004/ul-style Unordered list style [Expected: asterisk; Actual: dash]

Check failure on line 29 in EIPS/eip-3403.md

View workflow job for this annotation

GitHub Actions / Markdown Linter

Unordered list style [Expected: asterisk; Actual: dash]

EIPS/eip-3403.md:29:1 MD004/ul-style Unordered list style [Expected: asterisk; Actual: dash]
- Istanbul: 1612

Check failure on line 30 in EIPS/eip-3403.md

View workflow job for this annotation

GitHub Actions / Markdown Linter

Unordered list style [Expected: asterisk; Actual: dash]

EIPS/eip-3403.md:30:1 MD004/ul-style Unordered list style [Expected: asterisk; Actual: dash]

Check failure on line 30 in EIPS/eip-3403.md

View workflow job for this annotation

GitHub Actions / Markdown Linter

Unordered list style [Expected: asterisk; Actual: dash]

EIPS/eip-3403.md:30:1 MD004/ul-style Unordered list style [Expected: asterisk; Actual: dash]
- Berlin: 212

Check failure on line 31 in EIPS/eip-3403.md

View workflow job for this annotation

GitHub Actions / Markdown Linter

Unordered list style [Expected: asterisk; Actual: dash]

EIPS/eip-3403.md:31:1 MD004/ul-style Unordered list style [Expected: asterisk; Actual: dash]

Check failure on line 31 in EIPS/eip-3403.md

View workflow job for this annotation

GitHub Actions / Markdown Linter

Unordered list style [Expected: asterisk; Actual: dash]

EIPS/eip-3403.md:31:1 MD004/ul-style Unordered list style [Expected: asterisk; Actual: dash]
- NoRefund: 20112

Check failure on line 32 in EIPS/eip-3403.md

View workflow job for this annotation

GitHub Actions / Markdown Linter

Unordered list style [Expected: asterisk; Actual: dash]

EIPS/eip-3403.md:32:1 MD004/ul-style Unordered list style [Expected: asterisk; Actual: dash]

Check failure on line 32 in EIPS/eip-3403.md

View workflow job for this annotation

GitHub Actions / Markdown Linter

Unordered list style [Expected: asterisk; Actual: dash]

EIPS/eip-3403.md:32:1 MD004/ul-style Unordered list style [Expected: asterisk; Actual: dash]
- EIP-3403: 1112
- [EIP-3403](https://eips.ethereum.org/EIPS/eip-3403): 1112

Check failure on line 33 in EIPS/eip-3403.md

View workflow job for this annotation

GitHub Actions / Markdown Linter

Unordered list style [Expected: asterisk; Actual: dash]

EIPS/eip-3403.md:33:1 MD004/ul-style Unordered list style [Expected: asterisk; Actual: dash]

Check warning on line 33 in EIPS/eip-3403.md

View workflow job for this annotation

GitHub Actions / EIP Walidator

non-relative link or image

warning[markdown-rel-links]: non-relative link or image --> EIPS/eip-3403.md | 33 | - [EIP-3403](https://eips.ethereum.org/EIPS/eip-3403): 1112 | = help: use `./eip-3403.md` instead

Check warning on line 33 in EIPS/eip-3403.md

View workflow job for this annotation

GitHub Actions / EIP Walidator

non-relative link or image

warning[markdown-rel-links]: non-relative link or image --> EIPS/eip-3403.md | 33 | - [EIP-3403](https://eips.ethereum.org/EIPS/eip-3403): 1112 | = help: use `./eip-3403.md` instead

Check failure on line 33 in EIPS/eip-3403.md

View workflow job for this annotation

GitHub Actions / Markdown Linter

Unordered list style [Expected: asterisk; Actual: dash]

EIPS/eip-3403.md:33:1 MD004/ul-style Unordered list style [Expected: asterisk; Actual: dash]
- '1-2-1':

Check failure on line 34 in EIPS/eip-3403.md

View workflow job for this annotation

GitHub Actions / Markdown Linter

Unordered list style [Expected: asterisk; Actual: dash]

EIPS/eip-3403.md:34:1 MD004/ul-style Unordered list style [Expected: asterisk; Actual: dash]

Check failure on line 34 in EIPS/eip-3403.md

View workflow job for this annotation

GitHub Actions / Markdown Linter

Unordered list style [Expected: asterisk; Actual: dash]

EIPS/eip-3403.md:34:1 MD004/ul-style Unordered list style [Expected: asterisk; Actual: dash]
- Istanbul: 1612

Check failure on line 35 in EIPS/eip-3403.md

View workflow job for this annotation

GitHub Actions / Markdown Linter

Unordered list style [Expected: asterisk; Actual: dash]

EIPS/eip-3403.md:35:1 MD004/ul-style Unordered list style [Expected: asterisk; Actual: dash]

Check failure on line 35 in EIPS/eip-3403.md

View workflow job for this annotation

GitHub Actions / Markdown Linter

Unordered list style [Expected: asterisk; Actual: dash]

EIPS/eip-3403.md:35:1 MD004/ul-style Unordered list style [Expected: asterisk; Actual: dash]
- Berlin: 212

Check failure on line 36 in EIPS/eip-3403.md

View workflow job for this annotation

GitHub Actions / Markdown Linter

Unordered list style [Expected: asterisk; Actual: dash]

EIPS/eip-3403.md:36:1 MD004/ul-style Unordered list style [Expected: asterisk; Actual: dash]

Check failure on line 36 in EIPS/eip-3403.md

View workflow job for this annotation

GitHub Actions / Markdown Linter

Unordered list style [Expected: asterisk; Actual: dash]

EIPS/eip-3403.md:36:1 MD004/ul-style Unordered list style [Expected: asterisk; Actual: dash]
- NoRefund: 3012

Check failure on line 37 in EIPS/eip-3403.md

View workflow job for this annotation

GitHub Actions / Markdown Linter

Unordered list style [Expected: asterisk; Actual: dash]

EIPS/eip-3403.md:37:1 MD004/ul-style Unordered list style [Expected: asterisk; Actual: dash]

Check failure on line 37 in EIPS/eip-3403.md

View workflow job for this annotation

GitHub Actions / Markdown Linter

Unordered list style [Expected: asterisk; Actual: dash]

EIPS/eip-3403.md:37:1 MD004/ul-style Unordered list style [Expected: asterisk; Actual: dash]
- EIP-3403: 3012
- [EIP-3403](https://eips.ethereum.org/EIPS/eip-3403): 3012

Check failure on line 38 in EIPS/eip-3403.md

View workflow job for this annotation

GitHub Actions / Markdown Linter

Unordered list style [Expected: asterisk; Actual: dash]

EIPS/eip-3403.md:38:1 MD004/ul-style Unordered list style [Expected: asterisk; Actual: dash]

Check warning on line 38 in EIPS/eip-3403.md

View workflow job for this annotation

GitHub Actions / EIP Walidator

non-relative link or image

warning[markdown-rel-links]: non-relative link or image --> EIPS/eip-3403.md | 38 | - [EIP-3403](https://eips.ethereum.org/EIPS/eip-3403): 3012 | = help: use `./eip-3403.md` instead

Check warning on line 38 in EIPS/eip-3403.md

View workflow job for this annotation

GitHub Actions / EIP Walidator

non-relative link or image

warning[markdown-rel-links]: non-relative link or image --> EIPS/eip-3403.md | 38 | - [EIP-3403](https://eips.ethereum.org/EIPS/eip-3403): 3012 | = help: use `./eip-3403.md` instead

Check failure on line 38 in EIPS/eip-3403.md

View workflow job for this annotation

GitHub Actions / Markdown Linter

Unordered list style [Expected: asterisk; Actual: dash]

EIPS/eip-3403.md:38:1 MD004/ul-style Unordered list style [Expected: asterisk; Actual: dash]


**Note**: In reality, there are never a negative gas cost, since the refund is capped at 0.5 * gasUsed.
Expand All @@ -54,16 +54,16 @@
For blocks where `block.number >= FORK_BLOCK`, the following changes apply.

1. Remove the `SELFDESTRUCT` refund.
2. Remove the `SSTORE` refund in all cases except for one specific case: if the _new value_ and _original value_ of the storage slot both equal 0 but the _current value_ does not (those terms being defined as in [EIP-1283](https://eips.ethereum.org/EIPS/eip-1283)), refund `SSTORE_REFUND_GAS` gas.

Check warning on line 57 in EIPS/eip-3403.md

View workflow job for this annotation

GitHub Actions / EIP Walidator

non-relative link or image

warning[markdown-rel-links]: non-relative link or image --> EIPS/eip-3403.md | 57 | 2. Remove the `SSTORE` refund in all cases except for one specific case: if the _new value_ and _original value_ of the storage slot... | = help: use `./eip-1283.md` instead

Check warning on line 57 in EIPS/eip-3403.md

View workflow job for this annotation

GitHub Actions / EIP Walidator

non-relative link or image

warning[markdown-rel-links]: non-relative link or image --> EIPS/eip-3403.md | 57 | 2. Remove the `SSTORE` refund in all cases except for one specific case: if the _new value_ and _original value_ of the storage slot... | = help: use `./eip-1283.md` instead

## Rationale

Preserving refunds in the `new = original = 0 != current` case ensures that a few key use cases that deserve favorable gas cost treatment continue to receive favorable gas cost treatment, particularly:

* Anti-reentrancy locks (typically flipped from 0 to 1 right before a child call begins, and then flipped back to 0 when the child call ends)
* ERC20 approve-and-send (the "approved value" goes from zero to nonzero when the token transfer is approved, and then back to zero when the token transfer processes)

Check warning on line 64 in EIPS/eip-3403.md

View workflow job for this annotation

GitHub Actions / EIP Walidator

proposals must be referenced with the form `ERC-N` (not `ERCN` or `ERC N`)

warning[markdown-re-erc-dash]: proposals must be referenced with the form `ERC-N` (not `ERCN` or `ERC N`) --> EIPS/eip-3403.md | 64 | * ERC20 approve-and-send (the "approved value" goes from zero to nonzero when the token transfer is approved, and then back to zero ... | = info: the pattern in question: `(?i)erc[\s]*[0-9]+` = help: see https://ethereum.github.io/eipw/markdown-re-erc-dash/

Check warning on line 64 in EIPS/eip-3403.md

View workflow job for this annotation

GitHub Actions / EIP Walidator

proposals must be referenced with the form `ERC-N` (not `ERCN` or `ERC N`)

warning[markdown-re-erc-dash]: proposals must be referenced with the form `ERC-N` (not `ERCN` or `ERC N`) --> EIPS/eip-3403.md | 64 | * ERC20 approve-and-send (the "approved value" goes from zero to nonzero when the token transfer is approved, and then back to zero ... | = info: the pattern in question: `(?i)erc[\s]*[0-9]+` = help: see https://ethereum.github.io/eipw/markdown-re-erc-dash/

It also preserves two key goals of EIP 3298:

Check warning on line 66 in EIPS/eip-3403.md

View workflow job for this annotation

GitHub Actions / EIP Walidator

proposals must be referenced with the form `EIP-N` (not `EIPN` or `EIP N`)

warning[markdown-re-eip-dash]: proposals must be referenced with the form `EIP-N` (not `EIPN` or `EIP N`) --> EIPS/eip-3403.md | 66 | It also preserves two key goals of EIP 3298: | = info: the pattern in question: `(?i)eip[\s]*[0-9]+` = help: see https://ethereum.github.io/eipw/markdown-re-eip-dash/

Check warning on line 66 in EIPS/eip-3403.md

View workflow job for this annotation

GitHub Actions / EIP Walidator

proposals must be referenced with the form `EIP-N` (not `EIPN` or `EIP N`)

warning[markdown-re-eip-dash]: proposals must be referenced with the form `EIP-N` (not `EIPN` or `EIP N`) --> EIPS/eip-3403.md | 66 | It also preserves two key goals of EIP 3298: | = info: the pattern in question: `(?i)eip[\s]*[0-9]+` = help: see https://ethereum.github.io/eipw/markdown-re-eip-dash/

1. Gas tokens continue to be non-viable, because each 19000 refund is only possible because of 19000 extra gas that was paid for flipping that storage slot from zero to nonzero earlier in the same transaction, so you can't clear some storage slots and use that saved gas to fill others.
2. The total amount of gas _spent on execution_ is capped at the gas limit. Every 19000 refund for flipping a storage slot non from zero -> zero is only possible because of 19000 extra gas paid for flipping that slot from zero -> nonzero earlier in the same transaction; that gas paid for a storage write and expansion that were both reverted and so do not actually need to be applied to the Merkle tree. Hence, this extra gas does not contribute to risk.
Expand Down Expand Up @@ -102,7 +102,7 @@

### With EIP-3403 partial refunds

If refunds were to be partially removed, as specified [here](https://github.com/ethereum/EIPs/pull/3403/), this would be the comparative table. **This table also assumes touched storage slots were already 'hot'**.

Check warning on line 105 in EIPS/eip-3403.md

View workflow job for this annotation

GitHub Actions / EIP Walidator

non-relative link or image

warning[markdown-rel-links]: non-relative link or image --> EIPS/eip-3403.md | 105 | If refunds were to be partially removed, as specified [here](https://github.com/ethereum/EIPs/pull/3403/), this would be the compar... |

Check warning on line 105 in EIPS/eip-3403.md

View workflow job for this annotation

GitHub Actions / EIP Walidator

non-relative link or image

warning[markdown-rel-links]: non-relative link or image --> EIPS/eip-3403.md | 105 | If refunds were to be partially removed, as specified [here](https://github.com/ethereum/EIPs/pull/3403/), this would be the compar... |

| Code | Used Gas | Refund | Original | 1st | 2nd | 3rd | Effective gas (after refund)
| -- | -- | -- | -- | -- | -- | -- | -- |
Expand Down
Loading