-
Notifications
You must be signed in to change notification settings - Fork 653
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
Recalculate storage usage based on the actual state #3824
Comments
@EgorKulikov I discussed with @evgenykuzyakov on this issue today and we agreed that what was originally proposed is not preferable because iterating over a large account is prohibitively expensive. We came up with the following approach:
Note that this works because the number of accounts created before the original bug was fixed is relatively small (I think < 50k). |
@bowenwang1996 good idea, only I would store delta between storage usage at dump and correct storage usage, as account can change between dump and following protocol update with this file, but delta would be the same (unless we'll underflow on storage, but it is only possible if more than 100 keys were removed from a single account during that bug period, we can check that no delta is more than 100) |
@EgorKulikov yeah that is what I meant. Sorry for not being clear. I'll update the original comment |
Due to a bug in the implementation of
DeleteKey
action, the storage usage on the Account structure was incorrectly updated. For every deleted access key, the storage usage was decreased by one extra bug.The bug was already fixed in a protocol upgrade and all places where the storage usage integer might underflow was switched to use
saturating_sub
, so it can't affect the consensus.But it still leaves some account in the invalid state, which have
storage_usage
value in theAccount
structure lower than the actual storage usage by this account.We need to create a protocol upgrade which addresses this problem by recalculating storage usage from the actual state.
There are a few items:
To recalculate, you can use an example from genesis recomputation:
nearcore/runtime/runtime/src/lib.rs
Line 1293 in 527d743
We'll have to recompute somewhat similarly, except using data from the Trie.
The text was updated successfully, but these errors were encountered: