-
Couldn't load subscription status.
- Fork 2.7k
Use proper bounded vector type for nominations #10601
Conversation
|
|
||
| fn check_count() { | ||
| let nominator_count = Nominators::<Test>::iter().count() as u32; | ||
| let nominator_count = Nominators::<Test>::iter_keys().count() as u32; |
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.
the reason for this is subtle and rather tricky. See if it is clear to you as a reviewer.
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.
Because we can fail to decode?
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.
yes we might fail to decode the values (in the rare case that we suddenly reduce MaxNominators to e.g. 4), so iter().count() would return only the number of decodable ones, while iter_keys().count() is all of the nominators.
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.
Generally looks good but my main concern is the changes to chill_other
See
Co-authored-by: Zeke Mostov <[email protected]>
Co-authored-by: Zeke Mostov <[email protected]>
…strate into kiz-bound-nominator-votes
There is a change in behavior to chill. |
…nd-nominator-votes
|
bot merge |
|
Waiting for commit status. |
|
Merge cancelled due to error. Error: Checks failed for 7fe85d2 |
|
bot merge |
1 similar comment
|
bot merge |
|
Error: Github API says #10601 is not mergeable |
* Use proper bounded vector type for nominations * add docs and tweak chill_other for cleanup purposes * Fix the build * remove TODO * add a bit more doc * even more docs gushc * Update frame/staking/src/pallet/mod.rs Co-authored-by: Zeke Mostov <[email protected]> * Update frame/staking/src/pallet/mod.rs Co-authored-by: Zeke Mostov <[email protected]> * Fix the nasty bug * also bound the Snapshot type * fix doc test * document bounded_vec * self-review * remove unused * Fix build * frame-support: repetition overload for bounded_vec Signed-off-by: Oliver Tale-Yazdi <[email protected]> * fix * remove the need to allocate into unbounded voters etc etc * Don't expect * unbreal the build again * handle macro a bit better Co-authored-by: Zeke Mostov <[email protected]> Co-authored-by: Oliver Tale-Yazdi <[email protected]>
* Use proper bounded vector type for nominations * add docs and tweak chill_other for cleanup purposes * Fix the build * remove TODO * add a bit more doc * even more docs gushc * Update frame/staking/src/pallet/mod.rs Co-authored-by: Zeke Mostov <[email protected]> * Update frame/staking/src/pallet/mod.rs Co-authored-by: Zeke Mostov <[email protected]> * Fix the nasty bug * also bound the Snapshot type * fix doc test * document bounded_vec * self-review * remove unused * Fix build * frame-support: repetition overload for bounded_vec Signed-off-by: Oliver Tale-Yazdi <[email protected]> * fix * remove the need to allocate into unbounded voters etc etc * Don't expect * unbreal the build again * handle macro a bit better Co-authored-by: Zeke Mostov <[email protected]> Co-authored-by: Oliver Tale-Yazdi <[email protected]>
* Use proper bounded vector type for nominations * add docs and tweak chill_other for cleanup purposes * Fix the build * remove TODO * add a bit more doc * even more docs gushc * Update frame/staking/src/pallet/mod.rs Co-authored-by: Zeke Mostov <[email protected]> * Update frame/staking/src/pallet/mod.rs Co-authored-by: Zeke Mostov <[email protected]> * Fix the nasty bug * also bound the Snapshot type * fix doc test * document bounded_vec * self-review * remove unused * Fix build * frame-support: repetition overload for bounded_vec Signed-off-by: Oliver Tale-Yazdi <[email protected]> * fix * remove the need to allocate into unbounded voters etc etc * Don't expect * unbreal the build again * handle macro a bit better Co-authored-by: Zeke Mostov <[email protected]> Co-authored-by: Oliver Tale-Yazdi <[email protected]>
* Use proper bounded vector type for nominations * add docs and tweak chill_other for cleanup purposes * Fix the build * remove TODO * add a bit more doc * even more docs gushc * Update frame/staking/src/pallet/mod.rs Co-authored-by: Zeke Mostov <[email protected]> * Update frame/staking/src/pallet/mod.rs Co-authored-by: Zeke Mostov <[email protected]> * Fix the nasty bug * also bound the Snapshot type * fix doc test * document bounded_vec * self-review * remove unused * Fix build * frame-support: repetition overload for bounded_vec Signed-off-by: Oliver Tale-Yazdi <[email protected]> * fix * remove the need to allocate into unbounded voters etc etc * Don't expect * unbreal the build again * handle macro a bit better Co-authored-by: Zeke Mostov <[email protected]> Co-authored-by: Oliver Tale-Yazdi <[email protected]>
Small part of #9864, one little step at a time at making pallet-staking "bounded". Also needed and extracted out of my branch for paritytech/polkadot-sdk#461.
Please note carefully the fact that this might, in the VERY rare case that we reduce
MaxNominationon a live network, lead to corrupt state being created. Nonetheless, this non-decodable state is pretty harmless, and can be cleaned via the already existingchill_othercall.All in all though, this PR has ZERO logical changes. It is all a matter of abstraction.
Also, note that the scenario that we reduce
MAX_NOMINATIONScan also happen now, and we actually don't handle it. So if for any reason we don't merge this, we need to fix this case separately.Polkadot companion: paritytech/polkadot#4709