Skip to content

EIP-3300: Phase Out Refunds#3300

Merged
MicahZoltu merged 18 commits intoethereum:masterfrom
wjmelements:phase-out-refunds
Mar 2, 2021
Merged

EIP-3300: Phase Out Refunds#3300
MicahZoltu merged 18 commits intoethereum:masterfrom
wjmelements:phase-out-refunds

Conversation

@wjmelements
Copy link
Contributor

Phase out refunds for SSTORE and SELFDESTRUCT
Reviewer @lightclient

@wjmelements wjmelements changed the title Phase Out Refunds EIP-3300: Phase Out Refunds Feb 27, 2021
@vorot93
Copy link

vorot93 commented Feb 27, 2021

GasTokens are effectively an exploit, and their authors warned that it may be fixed at core devs leisure.

It's not our fault that certain people hoarded them against this advice. And most certainly it shouldn't lead to stretching out selfdestruct phase out.

@wjmelements
Copy link
Contributor Author

wjmelements commented Feb 27, 2021 via email

Copy link

@MicahZoltu MicahZoltu left a comment

Choose a reason for hiding this comment

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

Some changes required to the formatting and the metadata. My comments about improving the specification section can be dealt with sometime before Review.

EIPS/eip-3300.md Outdated
Comment on lines 38 to 41
On the block this EIP activates, and again every 100 blocks, the gas refunds for `SELFDESTRUCT` and `SSTORE` would diminish by 1, until reaching their refund activation cost.
When reaching their refund activation cost, refunds will be removed.
The refund activation cost of `SSTORE` is defined to be the lowest possible opcode cost of setting a nonzero value to zero.
The refund activation cost of `SELFDETRUCT` is defined to be the lowest possible opcode cost of `SELFDESTRUCT`.

Choose a reason for hiding this comment

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

It would be valuable to spec this out a little more clearly. Defining the refund provided for each operation as a function of block number would be the best I think. It would also be good to include details on how this interacts with the various refunds of SSTOREs based on their previous and new values and mention how this interacts with the SSTORE counters from EIP-1283.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The lack of clarification is deliberate because the SSTORE pricing seems to change with every hard fork, and might be changed again in London. But I can be more absolute.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see why the prior specification was insufficient; metering approaches can be complex. If 2929 happens in Berlin I'll specify that behavior too, but it currently seems to be excluded from the hard fork meta.

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay. I thought perhaps it was removed because it wasn't in EIP-2070.

@wjmelements
Copy link
Contributor Author

I think removing the early removal "activation cost" specification is worth it for simplification. It also plays nicer with metering.

Copy link

@MicahZoltu MicahZoltu left a comment

Choose a reason for hiding this comment

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

Minor cleanup suggestions for consistency with one real suggestion. Nothing blocking merge as draft though.

There is also a case where `SSTORE_CLEARS_SCHEDULE` is removed from the refund counter.
That removal will also diminish by `REFUND_DECAY_STEP` until 0, maintaining the non-negative refund counter invariant.


Choose a reason for hiding this comment

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

Suggested change


This change is less work for the protocol developers than compensation and cleanup, while likely still achieving cleanup.


Choose a reason for hiding this comment

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

Suggested change

* `SSTORE_SET_GAS - SLOAD_GAS` (20000 - 100)
* `SSTORE_CLEARS_SCHEDULE` (15000)


Choose a reason for hiding this comment

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

Suggested change


For gas-cost regimes with refund removals that cancel prior refunds, the invariant that the refund counter cannot go negative will be preserved by diminishing the magnitude of those removals by `REFUND_DECAY`, until 0.


Choose a reason for hiding this comment

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

Suggested change

Computed:
* `REFUND_DECAY`: `REFUND_DECAY_STEP * ceil((block.number + 1 - FORK_BLOCK_NUM) / REFUND_DECAY_FREQUENCY)`


Choose a reason for hiding this comment

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

Suggested change

The rate of diminishing specified would currently require (24000-5000) * 100 = 1,900,000 blocks for `SELFDESTRUCT` and (15000-5000) * 100 = 1,000,000 blocks for `SSTORE`.
This timeframe is currently about a year, which should be enough flexibility for the remaining refunds to be consumed.


Choose a reason for hiding this comment

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

Suggested change

Comment on lines +48 to +49
### EIP-2929
The refunds as of EIP-2929 are as follows:

Choose a reason for hiding this comment

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

Suggested change
### EIP-2929
The refunds as of EIP-2929 are as follows:
The refunds are as follows:

Ideally, we should try to avoid creating dependencies between EIPs (when possible) and instead prefer to just assert the new behavior. This way, the EIP makes sense with or without the dependent EIP or knowledge of it. In this case, we can just state the new gas refunds as of this EIP's implementation and ignore 2929's existence.


## Specification
Parameters:
* `FORK_BLOCK_NUM`: EIP-3300 activation block

Choose a reason for hiding this comment

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

Suggested change
* `FORK_BLOCK_NUM`: EIP-3300 activation block
* `FORK_BLOCK_NUM`: TBD

The common way to handle this is to just say TBD here.

@MicahZoltu MicahZoltu merged commit e37dc7d into ethereum:master Mar 2, 2021
@wjmelements
Copy link
Contributor Author

Thanks for the review @MicahZoltu

Arachnid pushed a commit to Arachnid/EIPs that referenced this pull request Mar 6, 2021
* wip phase out refunds

* update create date and eip number

* discussions-to

* rename file to eip#

* fix discussions-to url error from Travis

* Update EIPS/eip-3300.md

Co-authored-by: Micah Zoltu <[email protected]>

* Update EIPS/eip-3300.md

Co-authored-by: Micah Zoltu <[email protected]>

* Update EIPS/eip-3300.md

Co-authored-by: Micah Zoltu <[email protected]>

* Update EIPS/eip-3300.md

Co-authored-by: Micah Zoltu <[email protected]>

* Update EIPS/eip-3300.md

Co-authored-by: Micah Zoltu <[email protected]>

* Update EIPS/eip-3300.md

Co-authored-by: Micah Zoltu <[email protected]>

* Update EIPS/eip-3300.md

Co-authored-by: Micah Zoltu <[email protected]>

* Update EIPS/eip-3300.md

Co-authored-by: Micah Zoltu <[email protected]>

* initial clarification

* specify 1283 behavior

* specify negative refund removal

* start specifying activation costs and then simplify by disregarding them

* cleanup activation cost specifications

Co-authored-by: Micah Zoltu <[email protected]>
phi-line pushed a commit to phi-line/EIPs that referenced this pull request Apr 29, 2021
* wip phase out refunds

* update create date and eip number

* discussions-to

* rename file to eip#

* fix discussions-to url error from Travis

* Update EIPS/eip-3300.md

Co-authored-by: Micah Zoltu <[email protected]>

* Update EIPS/eip-3300.md

Co-authored-by: Micah Zoltu <[email protected]>

* Update EIPS/eip-3300.md

Co-authored-by: Micah Zoltu <[email protected]>

* Update EIPS/eip-3300.md

Co-authored-by: Micah Zoltu <[email protected]>

* Update EIPS/eip-3300.md

Co-authored-by: Micah Zoltu <[email protected]>

* Update EIPS/eip-3300.md

Co-authored-by: Micah Zoltu <[email protected]>

* Update EIPS/eip-3300.md

Co-authored-by: Micah Zoltu <[email protected]>

* Update EIPS/eip-3300.md

Co-authored-by: Micah Zoltu <[email protected]>

* initial clarification

* specify 1283 behavior

* specify negative refund removal

* start specifying activation costs and then simplify by disregarding them

* cleanup activation cost specifications

Co-authored-by: Micah Zoltu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants