[Feature] Part 1: add TargetList for validator ranking (#12034)

* [Feature] Part 1: add TargetList for validator ranking

* remove redundant todo

* remove typo

* cleanup

* implement score

* more fixes

* fix thresholds

* fmt

* Remove the stuff that has to come in the next PR, some fixes

* extended balance import

* Change all the references from VoteWeight to Self::Score

* Add a migration for VoterBagsList

* fix score

* add targetList to nomination-pools tests

* fix bench

* address review comments

* change get_npos_targets

* address more comments

* remove thresholds for the time being

* fix instance reference

* VoterBagsListInstance

* reus

* remove params that are not used yet

* Introduced pre/post upgrade try-runtime checks

* fix

* fixes

* fix migration

* fix migration

* fix post_upgrade

* change

* Fix

* eloquent PhantomData

* fix PD

* more fixes

* Update frame/staking/src/pallet/impls.rs

Co-authored-by: Squirrel <gilescope@gmail.com>

* is_nominator now works

* fix test-staking

* build fixes

* fix remote-tests

* Apply suggestions from code review

Co-authored-by: parity-processbot <>
Co-authored-by: kianenigma <kian@parity.io>
Co-authored-by: Squirrel <gilescope@gmail.com>
Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
This commit is contained in:
Roman Useinov
2022-09-18 11:28:16 +02:00
committed by GitHub
parent c0e007b50f
commit 1b24f562e6
20 changed files with 307 additions and 47 deletions
@@ -207,6 +207,10 @@ pub fn generate_thresholds<T: pallet_staking::Config>(
writeln!(buf, "//! Autogenerated bag thresholds.")?;
writeln!(buf, "//!")?;
writeln!(buf, "//! Generated on {}", now.to_rfc3339())?;
writeln!(buf, "//! Arguments")?;
writeln!(buf, "//! Total issuance: {}", &total_issuance)?;
writeln!(buf, "//! Minimum balance: {}", &minimum_balance)?;
writeln!(
buf,
"//! for the {} runtime.",
@@ -234,6 +238,17 @@ pub fn generate_thresholds<T: pallet_staking::Config>(
writeln!(buf)?;
writeln!(buf, "/// Upper thresholds delimiting the bag list.")?;
writeln!(buf, "pub const THRESHOLDS: [u64; {}] = [", thresholds.len())?;
for threshold in &thresholds {
num_buf.write_formatted(threshold, &format);
// u64::MAX, with spacers every 3 digits, is 26 characters wide
writeln!(buf, " {:>26},", num_buf.as_str())?;
}
writeln!(buf, "];")?;
// thresholds balance
writeln!(buf)?;
writeln!(buf, "/// Upper thresholds delimiting the bag list.")?;
writeln!(buf, "pub const THRESHOLDS_BALANCES: [u128; {}] = [", thresholds.len())?;
for threshold in thresholds {
num_buf.write_formatted(&threshold, &format);
// u64::MAX, with spacers every 3 digits, is 26 characters wide