Skip to content
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

EVM: SSTORE/SLOAD gas costs split into processing and storage costs #142

Closed
axic opened this issue Aug 29, 2016 · 7 comments
Closed

EVM: SSTORE/SLOAD gas costs split into processing and storage costs #142

axic opened this issue Aug 29, 2016 · 7 comments
Labels

Comments

@axic
Copy link
Member

axic commented Aug 29, 2016

Overview

Split the specified gas cost of SSTORE and SLOAD to processing and storage cost elements.

Specification

SSTORE to have the following gas costs:

  • processing: 50 gas
  • storage charges:
    • set to non-zero from zero: 19950
    • any other case: 4950
  • storage refunds:
    • set to zero from non-zero (ie. deletion): 15000

i.e. setting to non-zero from zero is a total of 20000, while setting to zero is a refund of 10000. (No change here to current behaviour)

Rationale

Based on the Merkle Patricia Tree Specification, inserts and lookups should be the same complexity.

As SLOAD currently takes 50 gas to load (lookup), we can assume that is the processing cost for traversing the trie. SSTORE should have the same cost for processing.

Making this split now will be beneficial when blockchain rent needs to define the rent figures as opposed to the processing costs.

@axic
Copy link
Member Author

axic commented Aug 29, 2016

The figures above are given as a starting point for discussion. The specification on trie complexity might be entirely off and that invalidates the above.

Based on the Yellow Paper, the processing fee is 5000 gas for SSTORE, because:

Gset - 20000 - Paid for an SSTORE operation when the storage value is set to non-zero from zero.
Gsreset - 5000 - Paid for an SSTORE operation when the storage value’s zeroness remains unchanged or is set to zero.
Rsclear - 15000 - Refund given (added into refund counter) when the storage value is set to zero from non-zero.

@chfast
Copy link
Contributor

chfast commented Sep 8, 2016

-15000 = -15050 + 50

@axic
Copy link
Member Author

axic commented Sep 14, 2016

@chfast thanks, updated!

@vbuterin
Copy link
Contributor

vbuterin commented Oct 3, 2016

The 5000 cost for a value-changing SSTORE is meant to represent the cost to history growth and the Merkle tree recalculations. So it should definitely be much larger than an SLOAD.

@axic
Copy link
Member Author

axic commented Oct 13, 2016

@chfast @vbuterin updated description to map the YP 1:1.

Is there a sensible way to split up the 5000 to processing and storage costs?

  • processing: 2000 gas (10x as much as SLOAD in EIP150.1)
  • storage charges:
    • set to non-zero from zero: 18000
    • any other case: 3000
  • storage refunds:
    • set to zero from non-zero (ie. deletion): 15000

@github-actions
Copy link

There has been no activity on this issue for two months. It will be closed in a week if no further activity occurs. If you would like to move this EIP forward, please respond to any outstanding feedback or add a comment indicating that you have addressed all required feedback and are ready for a review.

@github-actions github-actions bot added the stale label Jan 13, 2022
@github-actions
Copy link

This issue was closed due to inactivity. If you are still pursuing it, feel free to reopen it and respond to any feedback or request a review in a comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants