diff --git a/runtime/kusama/src/lib.rs b/runtime/kusama/src/lib.rs index 6a3710300b8e..2399bb4cc4ef 100644 --- a/runtime/kusama/src/lib.rs +++ b/runtime/kusama/src/lib.rs @@ -386,7 +386,7 @@ impl pallet_session::Config for Runtime { } impl pallet_session::historical::Config for Runtime { - type FullIdentification = pallet_staking::Exposure; + type FullIdentification = pallet_staking::Exposure; type FullIdentificationOf = pallet_staking::ExposureOf; } @@ -537,7 +537,8 @@ parameter_types! { pub const BondingDuration: pallet_staking::EraIndex = 28; // 27 eras in which slashes can be cancelled (slightly less than 7 days). pub const SlashDeferDuration: pallet_staking::EraIndex = 27; - pub const MaxNominatorRewardedPerValidator: u32 = 256; + pub const MaxIndividualExposures: u32 = 10_000; + pub const MaxNominations: u32 = ::LIMIT as u32; pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(17); } @@ -552,8 +553,6 @@ impl frame_election_provider_support::onchain::Config for Runtime { } impl pallet_staking::Config for Runtime { - const MAX_NOMINATIONS: u32 = - ::LIMIT as u32; type Currency = Balances; type UnixTime = Timestamp; type CurrencyToVote = CurrencyToVote; @@ -571,7 +570,16 @@ impl pallet_staking::Config for Runtime { type SessionInterface = Self; type EraPayout = EraPayout; type NextNewSession = Session; - type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator; + type MaxRewardableIndividualExposures = frame_support::traits::ConstU32<256>; + type MaxIndividualExposures = MaxIndividualExposures; + type MaxNominations = MaxNominations; + type MaxUnappliedSlashes = frame_support::traits::ConstU32<1_000>; + type MaxInvulnerablesCount = frame_support::traits::ConstU32<10>; + type MaxHistoryDepth = frame_support::traits::ConstU32<10_000>; + type MaxReportersCount = frame_support::traits::ConstU32<1_000>; + type MaxPriorSlashingSpans = frame_support::traits::ConstU32<1_000>; + type MaxValidatorsCount = frame_support::traits::ConstU32<4_000>; + type MaxUnlockingChunks = frame_support::traits::ConstU32<32>; type OffendingValidatorsThreshold = OffendingValidatorsThreshold; // Use the nominators map to iter voters, but also keep bags-list up-to-date. type SortedListProvider = BagsList; diff --git a/runtime/kusama/src/tests.rs b/runtime/kusama/src/tests.rs index c81848194fcd..b12fab1f174b 100644 --- a/runtime/kusama/src/tests.rs +++ b/runtime/kusama/src/tests.rs @@ -17,7 +17,10 @@ //! Tests for the Kusama Runtime Configuration use crate::*; -use frame_support::weights::{GetDispatchInfo, WeightToFeePolynomial}; +use frame_support::{ + traits::Get, + weights::{GetDispatchInfo, WeightToFeePolynomial}, +}; use keyring::Sr25519Keyring::Charlie; use pallet_transaction_payment::Multiplier; use parity_scale_codec::Encode; @@ -50,7 +53,7 @@ fn sample_size_is_sensible() { fn payout_weight_portion() { use pallet_staking::WeightInfo; let payout_weight = ::WeightInfo::payout_stakers_alive_staked( - MaxNominatorRewardedPerValidator::get(), + ::MaxRewardableIndividualExposures::get(), ) as f64; let block_weight = BlockWeights::get().max_block as f64; diff --git a/runtime/kusama/src/weights/pallet_staking.rs b/runtime/kusama/src/weights/pallet_staking.rs index 939af2665b84..6afacb05e3d0 100644 --- a/runtime/kusama/src/weights/pallet_staking.rs +++ b/runtime/kusama/src/weights/pallet_staking.rs @@ -111,7 +111,6 @@ impl pallet_staking::WeightInfo for WeightInfo { // Storage: Staking Ledger (r:1 w:0) // Storage: Staking MinValidatorBond (r:1 w:0) // Storage: Staking Validators (r:1 w:1) - // Storage: Staking MaxValidatorsCount (r:1 w:0) // Storage: Staking Nominators (r:1 w:1) // Storage: Staking CounterForNominators (r:1 w:1) // Storage: BagsList ListNodes (r:2 w:2) @@ -120,7 +119,7 @@ impl pallet_staking::WeightInfo for WeightInfo { // Storage: Staking CounterForValidators (r:1 w:1) fn validate() -> Weight { (63_555_000 as Weight) - .saturating_add(T::DbWeight::get().reads(11 as Weight)) + .saturating_add(T::DbWeight::get().reads(10 as Weight)) .saturating_add(T::DbWeight::get().writes(8 as Weight)) } // Storage: Staking Ledger (r:1 w:0) @@ -386,14 +385,13 @@ impl pallet_staking::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: Staking MinValidatorBond (r:0 w:1) - // Storage: Staking MaxValidatorsCount (r:0 w:1) // Storage: Staking ChillThreshold (r:0 w:1) // Storage: Staking MaxNominatorsCount (r:0 w:1) // Storage: Staking MinNominatorBond (r:0 w:1) // Storage: Staking MinCommission (r:0 w:1) fn set_staking_configs() -> Weight { (5_996_000 as Weight) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) + .saturating_add(T::DbWeight::get().writes(5 as Weight)) } // Storage: Staking Ledger (r:1 w:0) // Storage: Staking ChillThreshold (r:1 w:0) diff --git a/runtime/polkadot/src/lib.rs b/runtime/polkadot/src/lib.rs index d15ffcb04f3e..4adf2f6132e8 100644 --- a/runtime/polkadot/src/lib.rs +++ b/runtime/polkadot/src/lib.rs @@ -426,7 +426,7 @@ impl pallet_session::Config for Runtime { } impl pallet_session::historical::Config for Runtime { - type FullIdentification = pallet_staking::Exposure; + type FullIdentification = pallet_staking::Exposure; type FullIdentificationOf = pallet_staking::ExposureOf; } @@ -533,7 +533,8 @@ parameter_types! { pub const BondingDuration: pallet_staking::EraIndex = 28; pub const SlashDeferDuration: pallet_staking::EraIndex = 27; pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE; - pub const MaxNominatorRewardedPerValidator: u32 = 256; + pub const MaxIndividualExposures: u32 = 10_000; + pub const MaxNominations: u32 = ::LIMIT as u32; pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(17); } @@ -548,8 +549,6 @@ impl frame_election_provider_support::onchain::Config for Runtime { } impl pallet_staking::Config for Runtime { - const MAX_NOMINATIONS: u32 = - ::LIMIT as u32; type Currency = Balances; type UnixTime = Timestamp; type CurrencyToVote = CurrencyToVote; @@ -564,7 +563,16 @@ impl pallet_staking::Config for Runtime { type SlashCancelOrigin = SlashCancelOrigin; type SessionInterface = Self; type EraPayout = pallet_staking::ConvertCurve; - type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator; + type MaxRewardableIndividualExposures = frame_support::traits::ConstU32<256>; + type MaxIndividualExposures = MaxIndividualExposures; + type MaxNominations = MaxNominations; + type MaxUnappliedSlashes = frame_support::traits::ConstU32<1_000>; + type MaxInvulnerablesCount = frame_support::traits::ConstU32<10>; + type MaxHistoryDepth = frame_support::traits::ConstU32<10_000>; + type MaxReportersCount = frame_support::traits::ConstU32<1_000>; + type MaxPriorSlashingSpans = frame_support::traits::ConstU32<1_000>; + type MaxValidatorsCount = frame_support::traits::ConstU32<4_000>; + type MaxUnlockingChunks = frame_support::traits::ConstU32<32>; type OffendingValidatorsThreshold = OffendingValidatorsThreshold; type NextNewSession = Session; type ElectionProvider = ElectionProviderMultiPhase; @@ -2113,7 +2121,10 @@ sp_api::impl_runtime_apis! { #[cfg(test)] mod test_fees { use super::*; - use frame_support::weights::{GetDispatchInfo, WeightToFeePolynomial}; + use frame_support::{ + traits::Get, + weights::{GetDispatchInfo, WeightToFeePolynomial}, + }; use keyring::Sr25519Keyring::Charlie; use pallet_transaction_payment::Multiplier; use separator::Separatable; @@ -2124,7 +2135,7 @@ mod test_fees { use pallet_staking::WeightInfo; let payout_weight = ::WeightInfo::payout_stakers_alive_staked( - MaxNominatorRewardedPerValidator::get(), + ::MaxRewardableIndividualExposures::get(), ) as f64; let block_weight = BlockWeights::get().max_block as f64; diff --git a/runtime/polkadot/src/weights/pallet_staking.rs b/runtime/polkadot/src/weights/pallet_staking.rs index 67359e75ce90..0dc630bd1870 100644 --- a/runtime/polkadot/src/weights/pallet_staking.rs +++ b/runtime/polkadot/src/weights/pallet_staking.rs @@ -105,13 +105,12 @@ impl pallet_staking::WeightInfo for WeightInfo { // Storage: Staking Ledger (r:1 w:0) // Storage: Staking MinValidatorBond (r:1 w:0) // Storage: Staking Validators (r:1 w:1) - // Storage: Staking MaxValidatorsCount (r:1 w:0) // Storage: Staking Nominators (r:1 w:1) // Storage: Staking CounterForNominators (r:1 w:1) // Storage: Staking CounterForValidators (r:1 w:1) fn validate() -> Weight { (36_901_000 as Weight) - .saturating_add(T::DbWeight::get().reads(7 as Weight)) + .saturating_add(T::DbWeight::get().reads(6 as Weight)) .saturating_add(T::DbWeight::get().writes(4 as Weight)) } // Storage: Staking Ledger (r:1 w:0) @@ -364,14 +363,13 @@ impl pallet_staking::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: Staking MinValidatorBond (r:0 w:1) - // Storage: Staking MaxValidatorsCount (r:0 w:1) // Storage: Staking ChillThreshold (r:0 w:1) // Storage: Staking MaxNominatorsCount (r:0 w:1) // Storage: Staking MinNominatorBond (r:0 w:1) // Storage: Staking MinCommission (r:0 w:1) fn set_staking_configs() -> Weight { (5_996_000 as Weight) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) + .saturating_add(T::DbWeight::get().writes(5 as Weight)) } // Storage: Staking Ledger (r:1 w:0) // Storage: Staking ChillThreshold (r:1 w:0) diff --git a/runtime/test-runtime/src/lib.rs b/runtime/test-runtime/src/lib.rs index 2980e45e529e..d61cdc035e24 100644 --- a/runtime/test-runtime/src/lib.rs +++ b/runtime/test-runtime/src/lib.rs @@ -290,7 +290,7 @@ impl pallet_session::Config for Runtime { } impl pallet_session::historical::Config for Runtime { - type FullIdentification = pallet_staking::Exposure; + type FullIdentification = pallet_staking::Exposure; type FullIdentificationOf = pallet_staking::ExposureOf; } @@ -313,7 +313,7 @@ parameter_types! { // 27 eras in which slashes can be cancelled (a bit less than 7 days). pub storage SlashDeferDuration: pallet_staking::EraIndex = 27; pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE; - pub storage MaxNominatorRewardedPerValidator: u32 = 64; + pub const MaxIndividualExposures: u32 = 1_000; pub storage OffendingValidatorsThreshold: Perbill = Perbill::from_percent(17); pub const MaxAuthorities: u32 = 100_000; } @@ -324,7 +324,6 @@ impl frame_election_provider_support::onchain::Config for Runtime { } impl pallet_staking::Config for Runtime { - const MAX_NOMINATIONS: u32 = 16; type Currency = Balances; type UnixTime = Timestamp; type CurrencyToVote = frame_support::traits::U128CurrencyToVote; @@ -339,7 +338,16 @@ impl pallet_staking::Config for Runtime { type SlashCancelOrigin = frame_system::EnsureNever<()>; type SessionInterface = Self; type EraPayout = pallet_staking::ConvertCurve; - type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator; + type MaxRewardableIndividualExposures = frame_support::traits::ConstU32<64>; + type MaxIndividualExposures = MaxIndividualExposures; + type MaxNominations = frame_support::traits::ConstU32<16>; + type MaxUnappliedSlashes = frame_support::traits::ConstU32<1_000>; + type MaxInvulnerablesCount = frame_support::traits::ConstU32<10>; + type MaxHistoryDepth = frame_support::traits::ConstU32<10_000>; + type MaxReportersCount = frame_support::traits::ConstU32<1_000>; + type MaxPriorSlashingSpans = frame_support::traits::ConstU32<1_000>; + type MaxValidatorsCount = frame_support::traits::ConstU32<4_000>; + type MaxUnlockingChunks = frame_support::traits::ConstU32<32>; type OffendingValidatorsThreshold = OffendingValidatorsThreshold; type NextNewSession = Session; type ElectionProvider = diff --git a/runtime/westend/src/lib.rs b/runtime/westend/src/lib.rs index 91bba4262c20..9447a1bbe402 100644 --- a/runtime/westend/src/lib.rs +++ b/runtime/westend/src/lib.rs @@ -353,7 +353,7 @@ impl pallet_session::Config for Runtime { } impl pallet_session::historical::Config for Runtime { - type FullIdentification = pallet_staking::Exposure; + type FullIdentification = pallet_staking::Exposure; type FullIdentificationOf = pallet_staking::ExposureOf; } @@ -451,7 +451,8 @@ parameter_types! { // 27 eras in which slashes can be cancelled (slightly less than 7 days). pub const SlashDeferDuration: pallet_staking::EraIndex = 27; pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE; - pub const MaxNominatorRewardedPerValidator: u32 = 64; + pub const MaxIndividualExposures: u32 = 1_000; + pub const MaxNominations: u32 = ::LIMIT as u32; pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(17); } @@ -461,8 +462,6 @@ impl frame_election_provider_support::onchain::Config for Runtime { } impl pallet_staking::Config for Runtime { - const MAX_NOMINATIONS: u32 = - ::LIMIT as u32; type Currency = Balances; type UnixTime = Timestamp; type CurrencyToVote = CurrencyToVote; @@ -477,7 +476,16 @@ impl pallet_staking::Config for Runtime { type SlashCancelOrigin = EnsureRoot; type SessionInterface = Self; type EraPayout = pallet_staking::ConvertCurve; - type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator; + type MaxRewardableIndividualExposures = frame_support::traits::ConstU32<64>; + type MaxIndividualExposures = MaxIndividualExposures; + type MaxNominations = MaxNominations; + type MaxUnappliedSlashes = frame_support::traits::ConstU32<1_000>; + type MaxInvulnerablesCount = frame_support::traits::ConstU32<10>; + type MaxHistoryDepth = frame_support::traits::ConstU32<10_000>; + type MaxReportersCount = frame_support::traits::ConstU32<1_000>; + type MaxPriorSlashingSpans = frame_support::traits::ConstU32<1_000>; + type MaxValidatorsCount = frame_support::traits::ConstU32<4_000>; + type MaxUnlockingChunks = frame_support::traits::ConstU32<32>; type OffendingValidatorsThreshold = OffendingValidatorsThreshold; type NextNewSession = Session; type ElectionProvider = ElectionProviderMultiPhase; diff --git a/runtime/westend/src/weights/pallet_staking.rs b/runtime/westend/src/weights/pallet_staking.rs index f686213c6f3a..250f21626b0c 100644 --- a/runtime/westend/src/weights/pallet_staking.rs +++ b/runtime/westend/src/weights/pallet_staking.rs @@ -111,7 +111,6 @@ impl pallet_staking::WeightInfo for WeightInfo { // Storage: Staking Ledger (r:1 w:0) // Storage: Staking MinValidatorBond (r:1 w:0) // Storage: Staking Validators (r:1 w:1) - // Storage: Staking MaxValidatorsCount (r:1 w:0) // Storage: Staking Nominators (r:1 w:1) // Storage: Staking CounterForNominators (r:1 w:1) // Storage: BagsList ListNodes (r:2 w:2) @@ -120,7 +119,7 @@ impl pallet_staking::WeightInfo for WeightInfo { // Storage: Staking CounterForValidators (r:1 w:1) fn validate() -> Weight { (65_171_000 as Weight) - .saturating_add(T::DbWeight::get().reads(11 as Weight)) + .saturating_add(T::DbWeight::get().reads(10 as Weight)) .saturating_add(T::DbWeight::get().writes(8 as Weight)) } // Storage: Staking Ledger (r:1 w:0) @@ -386,14 +385,13 @@ impl pallet_staking::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: Staking MinValidatorBond (r:0 w:1) - // Storage: Staking MaxValidatorsCount (r:0 w:1) // Storage: Staking ChillThreshold (r:0 w:1) // Storage: Staking MaxNominatorsCount (r:0 w:1) // Storage: Staking MinNominatorBond (r:0 w:1) // Storage: Staking MinCommission (r:0 w:1) fn set_staking_configs() -> Weight { (5_996_000 as Weight) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) + .saturating_add(T::DbWeight::get().writes(5 as Weight)) } // Storage: Staking Ledger (r:1 w:0) // Storage: Staking ChillThreshold (r:1 w:0)