Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions runtime/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ impl pallet_session::Config for Runtime {
}

impl pallet_session::historical::Config for Runtime {
type FullIdentification = pallet_staking::Exposure<AccountId, Balance>;
type FullIdentification = pallet_staking::Exposure<AccountId, Balance, MaxIndividualExposures>;
type FullIdentificationOf = pallet_staking::ExposureOf<Runtime>;
}

Expand Down Expand Up @@ -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 = <NposCompactSolution24 as sp_npos_elections::NposSolution>::LIMIT as u32;
pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(17);
}

Expand All @@ -552,8 +553,6 @@ impl frame_election_provider_support::onchain::Config for Runtime {
}

impl pallet_staking::Config for Runtime {
const MAX_NOMINATIONS: u32 =
<NposCompactSolution24 as sp_npos_elections::NposSolution>::LIMIT as u32;
type Currency = Balances;
type UnixTime = Timestamp;
type CurrencyToVote = CurrencyToVote;
Expand All @@ -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;
Expand Down
7 changes: 5 additions & 2 deletions runtime/kusama/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -50,7 +53,7 @@ fn sample_size_is_sensible() {
fn payout_weight_portion() {
use pallet_staking::WeightInfo;
let payout_weight = <Runtime as pallet_staking::Config>::WeightInfo::payout_stakers_alive_staked(
MaxNominatorRewardedPerValidator::get(),
<Runtime as pallet_staking::Config>::MaxRewardableIndividualExposures::get(),
) as f64;
let block_weight = BlockWeights::get().max_block as f64;

Expand Down
6 changes: 2 additions & 4 deletions runtime/kusama/src/weights/pallet_staking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ impl<T: frame_system::Config> pallet_staking::WeightInfo for WeightInfo<T> {
// 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)
Expand All @@ -120,7 +119,7 @@ impl<T: frame_system::Config> pallet_staking::WeightInfo for WeightInfo<T> {
// 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)
Expand Down Expand Up @@ -386,14 +385,13 @@ impl<T: frame_system::Config> pallet_staking::WeightInfo for WeightInfo<T> {
.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)
Expand Down
25 changes: 18 additions & 7 deletions runtime/polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ impl pallet_session::Config for Runtime {
}

impl pallet_session::historical::Config for Runtime {
type FullIdentification = pallet_staking::Exposure<AccountId, Balance>;
type FullIdentification = pallet_staking::Exposure<AccountId, Balance, MaxIndividualExposures>;
type FullIdentificationOf = pallet_staking::ExposureOf<Runtime>;
}

Expand Down Expand Up @@ -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 = <NposCompactSolution16 as sp_npos_elections::NposSolution>::LIMIT as u32;
pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(17);
}

Expand All @@ -548,8 +549,6 @@ impl frame_election_provider_support::onchain::Config for Runtime {
}

impl pallet_staking::Config for Runtime {
const MAX_NOMINATIONS: u32 =
<NposCompactSolution16 as sp_npos_elections::NposSolution>::LIMIT as u32;
type Currency = Balances;
type UnixTime = Timestamp;
type CurrencyToVote = CurrencyToVote;
Expand All @@ -564,7 +563,16 @@ impl pallet_staking::Config for Runtime {
type SlashCancelOrigin = SlashCancelOrigin;
type SessionInterface = Self;
type EraPayout = pallet_staking::ConvertCurve<RewardCurve>;
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;
Expand Down Expand Up @@ -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;
Expand All @@ -2124,7 +2135,7 @@ mod test_fees {
use pallet_staking::WeightInfo;
let payout_weight =
<Runtime as pallet_staking::Config>::WeightInfo::payout_stakers_alive_staked(
MaxNominatorRewardedPerValidator::get(),
<Runtime as pallet_staking::Config>::MaxRewardableIndividualExposures::get(),
) as f64;
let block_weight = BlockWeights::get().max_block as f64;

Expand Down
6 changes: 2 additions & 4 deletions runtime/polkadot/src/weights/pallet_staking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,12 @@ impl<T: frame_system::Config> pallet_staking::WeightInfo for WeightInfo<T> {
// 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)
Expand Down Expand Up @@ -364,14 +363,13 @@ impl<T: frame_system::Config> pallet_staking::WeightInfo for WeightInfo<T> {
.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)
Expand Down
16 changes: 12 additions & 4 deletions runtime/test-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ impl pallet_session::Config for Runtime {
}

impl pallet_session::historical::Config for Runtime {
type FullIdentification = pallet_staking::Exposure<AccountId, Balance>;
type FullIdentification = pallet_staking::Exposure<AccountId, Balance, MaxIndividualExposures>;
type FullIdentificationOf = pallet_staking::ExposureOf<Runtime>;
}

Expand All @@ -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;
}
Expand All @@ -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;
Expand All @@ -339,7 +338,16 @@ impl pallet_staking::Config for Runtime {
type SlashCancelOrigin = frame_system::EnsureNever<()>;
type SessionInterface = Self;
type EraPayout = pallet_staking::ConvertCurve<RewardCurve>;
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 =
Expand Down
18 changes: 13 additions & 5 deletions runtime/westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ impl pallet_session::Config for Runtime {
}

impl pallet_session::historical::Config for Runtime {
type FullIdentification = pallet_staking::Exposure<AccountId, Balance>;
type FullIdentification = pallet_staking::Exposure<AccountId, Balance, MaxIndividualExposures>;
type FullIdentificationOf = pallet_staking::ExposureOf<Runtime>;
}

Expand Down Expand Up @@ -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 = <NposCompactSolution16 as sp_npos_elections::NposSolution>::LIMIT as u32;
pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(17);
}

Expand All @@ -461,8 +462,6 @@ impl frame_election_provider_support::onchain::Config for Runtime {
}

impl pallet_staking::Config for Runtime {
const MAX_NOMINATIONS: u32 =
<NposCompactSolution16 as sp_npos_elections::NposSolution>::LIMIT as u32;
type Currency = Balances;
type UnixTime = Timestamp;
type CurrencyToVote = CurrencyToVote;
Expand All @@ -477,7 +476,16 @@ impl pallet_staking::Config for Runtime {
type SlashCancelOrigin = EnsureRoot<AccountId>;
type SessionInterface = Self;
type EraPayout = pallet_staking::ConvertCurve<RewardCurve>;
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;
Expand Down
6 changes: 2 additions & 4 deletions runtime/westend/src/weights/pallet_staking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ impl<T: frame_system::Config> pallet_staking::WeightInfo for WeightInfo<T> {
// 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)
Expand All @@ -120,7 +119,7 @@ impl<T: frame_system::Config> pallet_staking::WeightInfo for WeightInfo<T> {
// 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)
Expand Down Expand Up @@ -386,14 +385,13 @@ impl<T: frame_system::Config> pallet_staking::WeightInfo for WeightInfo<T> {
.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)
Expand Down