-
Notifications
You must be signed in to change notification settings - Fork 764
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
Create a set_storage_or_clear
that deletes an storage item if 0u256 is passed as value
#6944
Comments
Good idea, I think we might just want to provide EVM tailored storage setters and getters but leave the more generic ones intact for other languages that are more flexible? Regarding For the getter, how I implemented it in |
Yes, the idea is to add two new functions tailored towards EVM and leave the other ones intact. |
Sounds good. I can take care of this, i.e. implementing those pallet-revive plus a companion in revive. But I'll not assign it just yet as it's also a good first issue for anyone wanting to help out. |
On Ethereum writing zero to a key constitutes deleting the key. We should add a new host function that behaves the same as
set_storage
except that the value is deleted if zero is passed. This is useful because it allows refunding the storage deposit when a key is deleted.Note that revive could do that without any new host function by calling
clear_storage
in case the key is zero. However, this would increase contract code by adding this additional check.In the same vein we could also add a
get_storage_or_zero
that returns 0 of the key does not exist. It would remove some code from the contract that is needed to check the return value ofget_storage
.cc @xermicus
The text was updated successfully, but these errors were encountered: