-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Split ext_clear_storage out from ext_set_storage #5103
Conversation
It looks like @Robbepop signed our Contributor License Agreement. 👍 Many thanks, Parity Technologies CLA Bot |
As per offline discussion here is my take on this: The current style API and the proposed style APIs are mostly the same. One can easily imagine how to implement the same primitives both on the current style APIs and the proposed style. I would argue that they do not have significant differences, besides a better amenability for the static analysis in more cases, namely when a the language that targets contracts TBF, This
doesn't really apply since both the current style API and the proposed one will have the equivalent gas costs. That is, old My original answer was that I am indifferent on this and was inclined to leave the status quo, but now I think I am more for the change. The reason is that upcoming change #4590 (and #3263) will allows us dropping the Now, to the open questions part. I think the concern regarding interaction between zero sized entries and state rent is valid. However, I think it deserves it's own issue. (filled under #5107) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good!
331f642
to
0f95912
Compare
The proposition that this PR is based on seems flawed. Storage rent should be all the incentivisation needed to ensure that storage clean-ups occur. Trying to warp the prices away from the true costs for the storage operations in order to try to incentivise cleaning up or disincentivise wasteful usage seems accordingly ill-considered. |
You are right that the original proposition was flawed since we would never decouple gas prices of operations from their real performance impact on the system which the original proposition was based on. - Unfortunately I forgot to update after we had internal discussions about this. However, the code changes no longer reflect the original proposition. |
This implements the ink! side implementation of Substrate PR #5103: paritytech/substrate#5103
This implements the ink! side implementation of Substrate PR #5103: paritytech/substrate#5103
* split out ext_clear_storage from ext_set_storage contracts API * update tests to adjust for the ext_set_storage changes * adjust COMPLEXITY for the ext_set_storage API changes * remove value_len == 0 constraint for ext_set_storage * bump spec_version * remove guarantee from COMPLEXITY of ext_clear_storage Co-authored-by: Gavin Wood <gavin@parity.io>
* split out ext_clear_storage from ext_set_storage contracts API * update tests to adjust for the ext_set_storage changes * adjust COMPLEXITY for the ext_set_storage API changes * remove value_len == 0 constraint for ext_set_storage * bump spec_version * remove guarantee from COMPLEXITY of ext_clear_storage Co-authored-by: Gavin Wood <gavin@parity.io>
See: paritytech/substrate#5103 Signed-off-by: Sean Young <sean@mess.org>
See: paritytech/substrate#5103 Signed-off-by: Sean Young <sean@mess.org>
This PR splits the
into two APIs:
Motivation
We perform this change to make it simpler for static analyzers to analyze the underlying code semantically.
The old API with its
value_non_null
parameter is theoretically impossible to analyze statically since thevalue_non_null
parameter could be any runtime computed value. So it is potentially very hard for static analyzers to apply the correct gas costs in the case where we want to differentiate between setting and clearing contract storage entries.Why do we want to differentiate between those two operations?
The operations have completely different semantics:
Also as described above this makes it far simpler for static analyzers (or in some cases even possible) to reason about the underlying code. It slightly reduces overhead in some situations but that should generally be negligible.
Open Questions
While working on this PR one particular question arosed:
How do we currently treat empty storage entries? E.g. when setting
ext_set_storage
with avalue_len
of 0? This semantically is different from having a cleaned-up contract storage entry and thus should be taken into account for rental fees.Since we were not aware of any smart contract use cases that could even profit from creating or having occupied empty storage entries we also disallowed having them in the adjusted
ext_set_storage
. Upon trying to set a contract storage entry to be empty this function will trigger a host error and the contract will trap.We might change the semantics of this particular scenario once we are aware of a proper smart contracts use case.
Task List of this PR
ext_clear_storage
ext_set_storage
COMPLEXITY.md