-
Notifications
You must be signed in to change notification settings - Fork 697
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
Allow to pass a bound on StorageCountedMap::remove_all (similarly to StorageMap::removal_all) #294
Comments
Hello @thiolliere I saw you mentioned the previous issue you closed(#10288) which I attempted on this current issue. |
you there @thiolliere ? |
I didn't work last weekend why did you expect me to answer a low priority question ? EDIT: I also find the tone of your sentence disrespectful. |
The solution I suggested in the issue paritytech/substrate#10288 doesn't work. There might be a way found by Shawn that I explained in the top message. This consist of looking at the number of key in the backend by looking the value of the counter in the backend (maybe by using the parent block hash or something I don't know). I don't have a precise idea about how to fetch the value of the counter in the backend. But if we have it then we can implement remove_all with some limit, and update the counter with the value: counter in backend minus number of key removed from backend. Because all keys are removed from overlay this should work. |
@thiolliere I am sorry for the tone I used, never knew you'd get offended by it. I will do better next time. |
If i can get you correctly, we need to implement a limit on remove_all function The caller of the function will definitely include the limit while calling this function right? or is the More so, will one implement a v2 for |
Hey @thiolliere , I skimmed through the code and found this comment in the existing But it does not seem to be true anymore, as the Also the comment of sp_io::clear_prefix seems outdated as it mentiones a boolean return value. So maybe this can now be implemented straight forward? |
I think the comment in the code should be updated, it was a mistake from me to think that having the number of key deleted from overlay would be sufficient to implement this feature. This comment should explain it paritytech/substrate#10288 (comment) Basically we can have the same key in both overlay and backend. (when they are overriden for example). So even if we know that N and M keys are removed from overlay and backend we don't know how many key we actually deleted from the counted storage map. |
Oh, I see. And the approach @shawntabrizi suggested is using a "counter" for the backend to determine how many backend operations happend during the removal and take this number into account for the limit. What exactly is this counter, is it the |
Shawn solution was to fetch the value of the counter in the backend itself as it should hold as it shouldn't take into account the value added in the overlay. I don't think sp_io::storage provides a way to read this value. Maybe we would want to introduce |
* changed log level from error to trace * incomplete during submit != synced
* changed log level from error to trace * incomplete during submit != synced
* changed log level from error to trace * incomplete during submit != synced
* changed log level from error to trace * incomplete during submit != synced
* changed log level from error to trace * incomplete during submit != synced
* changed log level from error to trace * incomplete during submit != synced
* changed log level from error to trace * incomplete during submit != synced
* changed log level from error to trace * incomplete during submit != synced
* changed log level from error to trace * incomplete during submit != synced
* changed log level from error to trace * incomplete during submit != synced
* changed log level from error to trace * incomplete during submit != synced
StorageMap::remove_all
take as argument the limit of key to remove from backend. This is useful when user want to remove all keys from a map but without using too much of the block weight.StorageCountedMap::remove_all
cannot implement this limit easily. Because when the runtime apiclear_prefix
return the number of key removed from backend, but we don't know how many keys were actually removed (some key are in the overlay and some are in both overlay and backend), so we can't update the counter.One solution suggested by Shawn is to look at the value of the counter in the backend. and update the counter with:
counter in the backend - number of key removed in the backend by this operation
.Maybe this is a way to implement the limit.
context:
The text was updated successfully, but these errors were encountered: