Skip to content
This repository was archived by the owner on Sep 8, 2025. It is now read-only.

EIP-3529 Reduction in Refunds#2020

Merged
kclowes merged 2 commits into
ethereum:masterfrom
kclowes:eip-3529
Sep 10, 2021
Merged

EIP-3529 Reduction in Refunds#2020
kclowes merged 2 commits into
ethereum:masterfrom
kclowes:eip-3529

Conversation

@kclowes
Copy link
Copy Markdown
Collaborator

@kclowes kclowes commented Aug 30, 2021

What was wrong?

EIP-3529 was missing

How was it fixed?

Added it!

To-Do

  • Clean up commit history

Cute Animal Picture

@kclowes kclowes force-pushed the eip-3529 branch 3 times, most recently from 82e3e29 to f489f70 Compare August 30, 2021 18:01
@carver carver mentioned this pull request Aug 31, 2021
11 tasks
@kclowes kclowes force-pushed the eip-3529 branch 3 times, most recently from a416b74 to 17dcdac Compare September 10, 2021 18:56
@kclowes kclowes changed the title [WIP] EIP-3529 Reduction in Refunds EIP-3529 Reduction in Refunds Sep 10, 2021
@kclowes kclowes requested review from carver and fselmo September 10, 2021 18:57
Copy link
Copy Markdown
Contributor

@carver carver left a comment

Choose a reason for hiding this comment

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

LGTM! Just some nitpicks. (Plus squashing the commits to logical chunks)

Comment thread eth/vm/forks/frontier/state.py Outdated
transaction: SignedTransactionAPI,
computation: ComputationAPI) -> ComputationAPI:
transaction_context = self.vm_state.get_transaction_context(transaction)
def calculate_gas_refund(self,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks like this could be a classmethod. That helps show that it doesn't depend on anything besides the passed-in variables.

gas_remaining = computation.get_gas_remaining()
gas_used = transaction.gas - gas_remaining
gas_refund = min(gas_refunded, gas_used // 2)
gas_refund = self.calculate_gas_refund(computation, gas_used)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cool, seems like a good refactor to avoid too much duplication.

Comment thread eth/vm/forks/london/state.py Outdated
Comment on lines +92 to +97
def calculate_gas_refund(self,
computation: ComputationAPI,
gas_used: int) -> int:
gas_refunded = computation.get_gas_refund()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe note in a comment the intentional exclusion of selfdestruct refunds?

Comment thread eth/vm/forks/london/storage.py Outdated
Comment on lines +10 to +11
SSTORE_CLEARS_SCHEDULE_EIP_3529 = GAS_SCHEDULE_EIP2929.sstore_reset_gas + \
berlin_constants.ACCESS_LIST_STORAGE_KEY_COST_EIP_2930
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: I'll do almost anything to avoid the \ continuation. I prefer this style:

Suggested change
SSTORE_CLEARS_SCHEDULE_EIP_3529 = GAS_SCHEDULE_EIP2929.sstore_reset_gas + \
berlin_constants.ACCESS_LIST_STORAGE_KEY_COST_EIP_2930
SSTORE_CLEARS_SCHEDULE_EIP_3529 = (
GAS_SCHEDULE_EIP2929.sstore_reset_gas
+ berlin_constants.ACCESS_LIST_STORAGE_KEY_COST_EIP_2930
)

@carver
Copy link
Copy Markdown
Contributor

carver commented Sep 10, 2021

I've got the PR ready that flips on the London tests, after this is merged. Curious to see how many failures we have left!

@kclowes
Copy link
Copy Markdown
Collaborator Author

kclowes commented Sep 10, 2021

Me too! I'm cleaning up commits now, and then I'll merge!

- Replace SSTORE_CLEARS_SCHEDULE,
- Remove SELFDESTRUCT refund,
- Add new MAX_REFUND_QUOTIENT
@kclowes kclowes merged commit 1c9daf9 into ethereum:master Sep 10, 2021
@kclowes kclowes deleted the eip-3529 branch September 10, 2021 22:12
@kclowes kclowes mentioned this pull request Sep 14, 2021
2 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants