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

Enable cost differences between SSTORE8-248 #93

Closed
VoR0220 opened this issue Apr 17, 2016 · 7 comments
Closed

Enable cost differences between SSTORE8-248 #93

VoR0220 opened this issue Apr 17, 2016 · 7 comments

Comments

@VoR0220
Copy link
Member

VoR0220 commented Apr 17, 2016

Currently in solidity, there is this very unintuitive way of declaring variables. You would think that taking up less storage with a uint8 would end up costing less in gas than a uint256, but in actuality you end up being charged more in gas for a uint8 than a uint256. This proposal is for a set of EVM opcodes to mimic SSTORE but with specific sizes and ascending gas costs from 8-248. I will add to this more, but this is an initial posting to get this out there. Let me know your initial thoughts and concerns.

@janx
Copy link
Member

janx commented Apr 19, 2016

I think the cause is in solidity instead of EVM, as SSTORE gas cost is not related to value size.

Ref:

@VoR0220
Copy link
Member Author

VoR0220 commented Apr 19, 2016

@janx shouldn't it be though? You're storing a value, should it not be cheaper if the size capability of the value is smaller?

@chriseth
Copy link
Contributor

The main cost for sstore is not created from the size of the stored value (at least not for sizes up to 32 bytes), but from the actual insertion, so I don't think it is reasonable to reduce the costs for smaller values.

The gas savings for smaller values in solidity does not arise from taking up less space but from being able to combine multiple variable assignments into a single sstore.

@janx
Copy link
Member

janx commented Apr 20, 2016

@VoR0220 it would be cool. My point is adding SSTORE8-248 alone may not work, since variable assignment in solidity will be compiled to opcodes more than SSTORE.

And as @chriseth pointed out, right now the main cost is from actual insertion, that should be taken into consideration too.

Also related:

@VoR0220
Copy link
Member Author

VoR0220 commented Apr 20, 2016

@janx @chriseth thanks for the input. Let me stew on this for a bit.

@vbuterin
Copy link
Contributor

The bulk of the actual underlying computational effort is in updating the merkle branch, which doesn't depend too much on the size of storage especially for values under 32 bytes; hence, Chris is entirely correct in that the larger gains come in batching multiple storage update operations (something that SSTOREBYTES in #86 is intended to make much more widely applicable as an optimization strategy).

@VoR0220
Copy link
Member Author

VoR0220 commented Jan 9, 2017

closing

@VoR0220 VoR0220 closed this as completed Jan 9, 2017
bumblefudge added a commit to bumblefudge/EIPs that referenced this issue Feb 16, 2024
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

No branches or pull requests

4 participants