Skip to content
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

Fix max nominators per collator upgrade bug #751

Conversation

4meta5
Copy link
Contributor

@4meta5 4meta5 commented Aug 30, 2021

When we increased MaxNominatorsPerCollator from 10 -> 100 in #746 , we did not add a migration to push the bottom nominators into the top upon the change. The fix is a migration that fixes the top_nominators and bottom_nominators fields for all CollatorState.

It is naive in its current state and could be optimized by combining it with the other runtime upgrade instead of keeping it separate. I'm writing a unit test to verify correctness now.

@4meta5 4meta5 changed the title Patch max nominators per collator upgrade mistake Patch max nominators per collator upgrade bug Aug 30, 2021
@4meta5 4meta5 added A3-inprogress Pull request is in progress. No review needed at this stage. B7-runtimenoteworthy Changes should be noted in any runtime-upgrade release notes labels Aug 30, 2021
@4meta5 4meta5 changed the title Patch max nominators per collator upgrade bug Fix max nominators per collator upgrade bug Aug 30, 2021
@4meta5 4meta5 added the C7-high Elevates a release containing this PR to "high priority". label Aug 30, 2021
@4meta5 4meta5 marked this pull request as ready for review August 30, 2021 04:55
@4meta5 4meta5 merged commit 3cdf928 into patch-staking-bond-less-deletes-bottom-nominator-bug Aug 30, 2021
@4meta5 4meta5 deleted the amar-patch-max-nominations-upgrade-mistake branch August 30, 2021 05:00
crystalin pushed a commit that referenced this pull request Aug 30, 2021
* in progress

* update top nominators list upon changes and do not remove any bottom nominations

* test fix

* init migration to start to fix inconsistent state

* more progress on migration

* improve nomination increase decrease events

* fmt

* review and comment all uses of pop

* add two different errors for each source of inconsistency and init migration unit test

* add unreserve stakers extrinsic gated by root to unreserve the reserved non nominators

* in middle of testing migration and found bug wherein nominator can have no nominations after it runs

* fix migration, still needs weights

* rename root unreserve function and finish migration test

* last few changes to public visibility to keep the test without exposing storage write functionality to outside of crate

* fix comment

* Fix max nominators per collator upgrade bug (#751)

* init naive not tested

* fix compilation errors, still needs tests

* test

* fix total staked in hotfix_unreserve_nomination as well

* accept review comments

* fix weight returned in on runtime upgrade

* remove accounts due unreserved balance storage item and use btreemap in memory instead

* try fix

* no filtering condition on first migration loop

* merge migration functions into one function

* conservative weight estimate

* Update pallets/parachain-staking/src/lib.rs

Co-authored-by: girazoki <gorka.irazoki@gmail.com>

Co-authored-by: girazoki <gorka.irazoki@gmail.com>
crystalin pushed a commit that referenced this pull request Aug 30, 2021
* in progress

* update top nominators list upon changes and do not remove any bottom nominations

* test fix

* init migration to start to fix inconsistent state

* more progress on migration

* improve nomination increase decrease events

* fmt

* review and comment all uses of pop

* add two different errors for each source of inconsistency and init migration unit test

* add unreserve stakers extrinsic gated by root to unreserve the reserved non nominators

* in middle of testing migration and found bug wherein nominator can have no nominations after it runs

* fix migration, still needs weights

* rename root unreserve function and finish migration test

* last few changes to public visibility to keep the test without exposing storage write functionality to outside of crate

* fix comment

* Fix max nominators per collator upgrade bug (#751)

* init naive not tested

* fix compilation errors, still needs tests

* test

* fix total staked in hotfix_unreserve_nomination as well

* accept review comments

* fix weight returned in on runtime upgrade

* remove accounts due unreserved balance storage item and use btreemap in memory instead

* try fix

* no filtering condition on first migration loop

* merge migration functions into one function

* conservative weight estimate

* Update pallets/parachain-staking/src/lib.rs

Co-authored-by: girazoki <gorka.irazoki@gmail.com>

Co-authored-by: girazoki <gorka.irazoki@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A3-inprogress Pull request is in progress. No review needed at this stage. B7-runtimenoteworthy Changes should be noted in any runtime-upgrade release notes C7-high Elevates a release containing this PR to "high priority".
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant