Store validator self-vote in bags-list, and allow them to be trimmed for election (#10821)

* Implement the new validator-in-bags-list scenario + migration

* Apply suggestions from code review

Co-authored-by: Zeke Mostov <z.mostov@gmail.com>

* some review comments

* guard the migration

* some review comments

* Fix tests 🤦‍♂️

* Fix build

* fix weight_of_fn

* reformat line width

* make const

* use weight of fn cached

* SortedListProvider -> VoterList

* Fix all build and docs

* check post migration

Co-authored-by: Zeke Mostov <z.mostov@gmail.com>
This commit is contained in:
Kian Paimani
2022-03-23 14:17:26 +00:00
committed by GitHub
parent e0cef34921
commit 661d0ea5bb
17 changed files with 317 additions and 216 deletions
+2 -2
View File
@@ -38,11 +38,11 @@ const SEED: u32 = 0;
pub fn clear_validators_and_nominators<T: Config>() {
Validators::<T>::remove_all();
// whenever we touch nominators counter we should update `T::SortedListProvider` as well.
// whenever we touch nominators counter we should update `T::VoterList` as well.
Nominators::<T>::remove_all();
// NOTE: safe to call outside block production
T::SortedListProvider::unsafe_clear();
T::VoterList::unsafe_clear();
}
/// Grab a funded user.