-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
EIP 104 (Serenity): Unlimited storage key or value size #36
Comments
Downsides I can see here:
My main concerns are that we lose some kind of type safety: If your contract assumes that you only store 16 bytes at a key, but it actually stores more, then loading from it will truncate the value. Note that our high-level-language already handle storing variably-sized types quite efficiently. |
Can't this be easily handled at the HLL level? If you are dealing with a 16-byte data type, then your code should not try storing more than 16 bytes there. I'll accept the idea of Regarding efficiency concerns, I actually think that this will increase efficiency far more than it will decrease it. Every SLOAD/SSTORE requires trie operations and in the case of SSTORE that includes hashing, and so if you use solidity's current trick for storing large data types in storage you will end up losing a lot of time on multiple trie reorganizations and particularly on the MLOADs, JUMPs, etc involved in processing the loop; all this is much greater than the requirement to do an extra MLOAD and PUSH. |
Less trie lookups is a big win. |
Sure, caring about using the same size for data can be handled at a higher level, but it adds some level of danger nevertheless. I agree about efficiency on the trie level for storing e.g. long strings or multiple array elements at the same time, but I'm not sure if this is one of the main use cases of storage. Initially, you might store a long array, but most of the time you probably read and modify single elements. And if you store large arrays (including byte arrays and strings) in a single slot, you have to read and write the whole slot if you only change a single element. This gets more and more expensive the longer the array is, so a higher level language might determine a length where the array is chopped into smaller pieces, at which point we again arrive at the situation we currently are in (especially there will always be loops when copying and slot calculations when accessing) just with larger constants and more complex gas calculations. I am not really opposed to this change - not forcing a word size is a good thing - I just think that it is not that simple. |
I am in favor of this. |
If there's a limit of the read size, perhaps it is useful to also include a start offset:
And in that case it probably would make sense adding that to |
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. |
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. |
…lication to add jekyll publication system
Instead of storage keys and values being 32 bytes, they have unlimited size. We could have opcodes:
SSTORE(key_mstart, key_msz, value_mstart, value_msz)
SLOAD(key_mstart, key_msz, value_output_mstart, value_output_maxsize)
SLOAD
can have gas cost equal to40 + len(key) + len(min(value_output_maxsize, size_of_actual_output))
The gas cost for
SSTORE
can be:Where
key_length
is the length of the key,value_length
is the length of the value, andprev_value_length
is the length of the previous value at that key. If the function returns a value less than 2500, the difference is instead accounted for as a refund (eg. ifcompute_gascost
returns 1300, that's a 2500 cost plus a 1200 refund, if it returns -700 that's a 2500 cost plus a 3200 refund, etc).Motivations
The text was updated successfully, but these errors were encountered: