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
[Staking] Kill unnecessary storage bloat #970
Conversation
For the migration part, would it be possible/preferable to remove the storage bloat through democracy? |
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.
Overall looks good. Made a few little comments. Only one I consider blocking is post_upgrade
.
<Points<T>>::remove(i); | ||
} | ||
// 5% of the max block weight as safety margin for computation | ||
db_weight.reads(reads) + db_weight.writes(writes) + 25_000_000_000 |
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.
Being a little pedantic here, but if you're intending it to be %5 of max block, you should express it as max_block / 20
or similar in code. Because the max_block
actually depends on the runtime in question.
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.
This code is in the pallet so how would I pass it this information (max block weight from the runtime where it's executed)?
It is used as a safety margin so it doesn't have to be accurate in this case.
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.
<T as frame_system::Config>::BlockWeights::get().max_block
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.
I agree it doesn't really need to be that accurate.
Co-authored-by: Joshy Orndorff <JoshOrndorff@users.noreply.github.com>
Co-authored-by: Joshy Orndorff <JoshOrndorff@users.noreply.github.com>
@notlesh It's not a heavy migration so I don't think this is necessarily preferable. Is there a test we could do to determine when this ought to be done? With that said, we could easily do this -- we'd just add an extrinsic gated by root |
I was thinking more about simplicity and resiliency; submitting an extrinsic is probably simpler than managing a migration and might be more resilient (less chance of something catastrophic happening). But neither of these are necessarily true. I don't have a strong opinion either way, just wanted to bring it up. As for it perhaps being too heavy, we could test this with
Would |
The proposal would need to be a batch of calls to killPrefix for all values > 2 rounds old for the two relevant storage maps. I'm sure it could be done, but it's easier for me to do it in a migration. |
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.
try-runtime and the unit test both look good to me!
Changes the
pay_stakers
code totake()
the storage itemsStaked
andPoints
instead of just getting them.Also includes a migration to remove the stored values that are older than 2 rounds ago (because any stored values less than 2 rounds old will be killed in
pay_stakers
during future payout which willtake()
these values).I separated this from #810 because this is a distinct change and I do not want to lump too many changes into that PR.