Use updated bags list: Companion to #10997 (#5065)

* Use updated bags list: Companion to #10997

* Use Score, not Value

* update lockfile for {"substrate"}

* Fix match_types

* Fix

Co-authored-by: parity-processbot <>
This commit is contained in:
Zeke Mostov
2022-03-10 09:02:15 +00:00
committed by GitHub
parent 49f7e5cce4
commit b13bb87870
8 changed files with 180 additions and 180 deletions
+163 -162
View File
File diff suppressed because it is too large Load Diff
@@ -42,7 +42,7 @@ use sp_version::RuntimeVersion;
// A few exports that help ease life for downstream crates.
pub use frame_support::{
construct_runtime, match_type, parameter_types,
construct_runtime, match_types, parameter_types,
traits::{Everything, IsInVec, Randomness},
weights::{
constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},
@@ -349,7 +349,7 @@ parameter_types! {
pub const MaxAuthorities: u32 = 100_000;
}
match_type! {
match_types! {
pub type ParentOrParentsUnitPlurality: impl Contains<MultiLocation> = {
MultiLocation { parents: 1, interior: Here } |
MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Unit, .. }) }
+5 -9
View File
@@ -17,7 +17,7 @@
//! Code for elections.
use super::{BlockExecutionWeight, BlockLength, BlockWeights};
use frame_election_provider_support::{SortedListProvider, VoteWeight};
use frame_election_provider_support::SortedListProvider;
use frame_support::{
parameter_types,
weights::{DispatchClass, Weight},
@@ -76,6 +76,7 @@ impl<T: pallet_bags_list::Config + pallet_staking::Config> SortedListProvider<T:
for UseNominatorsAndUpdateBagsList<T>
{
type Error = pallet_bags_list::Error;
type Score = <T as pallet_bags_list::Config>::Score;
fn iter() -> Box<dyn Iterator<Item = T::AccountId>> {
Box::new(pallet_staking::Nominators::<T>::iter().map(|(n, _)| n))
@@ -89,11 +90,11 @@ impl<T: pallet_bags_list::Config + pallet_staking::Config> SortedListProvider<T:
pallet_bags_list::Pallet::<T>::contains(id)
}
fn on_insert(id: T::AccountId, weight: VoteWeight) -> Result<(), Self::Error> {
fn on_insert(id: T::AccountId, weight: Self::Score) -> Result<(), Self::Error> {
pallet_bags_list::Pallet::<T>::on_insert(id, weight)
}
fn on_update(id: &T::AccountId, new_weight: VoteWeight) {
fn on_update(id: &T::AccountId, new_weight: Self::Score) {
pallet_bags_list::Pallet::<T>::on_update(id, new_weight);
}
@@ -103,7 +104,7 @@ impl<T: pallet_bags_list::Config + pallet_staking::Config> SortedListProvider<T:
fn unsafe_regenerate(
all: impl IntoIterator<Item = T::AccountId>,
weight_of: Box<dyn Fn(&T::AccountId) -> VoteWeight>,
weight_of: Box<dyn Fn(&T::AccountId) -> Self::Score>,
) -> u32 {
pallet_bags_list::Pallet::<T>::unsafe_regenerate(all, weight_of)
}
@@ -115,9 +116,4 @@ impl<T: pallet_bags_list::Config + pallet_staking::Config> SortedListProvider<T:
fn unsafe_clear() {
pallet_bags_list::Pallet::<T>::unsafe_clear()
}
#[cfg(feature = "runtime-benchmarks")]
fn weight_update_worst_case(who: &T::AccountId, is_increase: bool) -> VoteWeight {
pallet_bags_list::Pallet::<T>::weight_update_worst_case(who, is_increase)
}
}
+2 -1
View File
@@ -466,9 +466,10 @@ parameter_types! {
impl pallet_bags_list::Config for Runtime {
type Event = Event;
type VoteWeightProvider = Staking;
type ScoreProvider = Staking;
type WeightInfo = weights::pallet_bags_list::WeightInfo<Runtime>;
type BagThresholds = BagThresholds;
type Score = sp_npos_elections::VoteWeight;
}
fn era_payout(
+2 -2
View File
@@ -21,7 +21,7 @@ use super::{
Runtime, WeightToFee, XcmPallet,
};
use frame_support::{
match_type, parameter_types,
match_types, parameter_types,
traits::{Everything, Nothing},
weights::Weight,
};
@@ -111,7 +111,7 @@ parameter_types! {
pub type TrustedTeleporters =
(xcm_builder::Case<KusamaForStatemine>, xcm_builder::Case<KusamaForEncointer>);
match_type! {
match_types! {
pub type OnlyParachains: impl Contains<MultiLocation> = {
MultiLocation { parents: 0, interior: X1(Parachain(_)) }
};
+2 -1
View File
@@ -507,9 +507,10 @@ parameter_types! {
impl pallet_bags_list::Config for Runtime {
type Event = Event;
type VoteWeightProvider = Staking;
type ScoreProvider = Staking;
type WeightInfo = weights::pallet_bags_list::WeightInfo<Runtime>;
type BagThresholds = BagThresholds;
type Score = sp_npos_elections::VoteWeight;
}
// TODO #6469: This shouldn't be static, but a lazily cached value, not built unless needed, and
+2 -2
View File
@@ -21,7 +21,7 @@ use super::{
Runtime, WeightToFee, XcmPallet,
};
use frame_support::{
match_type, parameter_types,
match_types, parameter_types,
traits::{Everything, Nothing},
weights::Weight,
};
@@ -107,7 +107,7 @@ parameter_types! {
pub type TrustedTeleporters = (xcm_builder::Case<PolkadotForStatemint>,);
match_type! {
match_types! {
pub type OnlyParachains: impl Contains<MultiLocation> = {
MultiLocation { parents: 0, interior: X1(Parachain(_)) }
};
+2 -1
View File
@@ -414,9 +414,10 @@ parameter_types! {
impl pallet_bags_list::Config for Runtime {
type Event = Event;
type VoteWeightProvider = Staking;
type ScoreProvider = Staking;
type WeightInfo = weights::pallet_bags_list::WeightInfo<Runtime>;
type BagThresholds = BagThresholds;
type Score = sp_npos_elections::VoteWeight;
}
pallet_staking_reward_curve::build! {