Skip to content

Commit

Permalink
Use MaxDisabledValidators to bound disabled validators
Browse files Browse the repository at this point in the history
  • Loading branch information
re-gius committed Dec 3, 2024
1 parent 47863bb commit 50ce1a1
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 8 deletions.
1 change: 1 addition & 0 deletions polkadot/runtime/test-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ impl pallet_staking::Config for Runtime {
type MaxInvulnerables = ConstU32<20>;
type MaxRewardPagesPerValidator = ConstU32<20>;
type MaxValidatorsCount = ConstU32<300>;
type MaxDisabledValidators = ConstU32<100>;
}

parameter_types! {
Expand Down
1 change: 1 addition & 0 deletions polkadot/runtime/westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,7 @@ impl pallet_staking::Config for Runtime {
type MaxInvulnerables = frame_support::traits::ConstU32<20>;
type MaxRewardPagesPerValidator = frame_support::traits::ConstU32<20>;
type MaxValidatorsCount = dynamic_params::staking::MaxValidatorsCount;
type MaxDisabledValidators = ConstU32<100>;
}

impl pallet_fast_unstake::Config for Runtime {
Expand Down
1 change: 1 addition & 0 deletions substrate/bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,7 @@ impl pallet_staking::Config for Runtime {
type MaxInvulnerables = ConstU32<20>;
type MaxRewardPagesPerValidator = ConstU32<20>;
type MaxValidatorsCount = ConstU32<300>;
type MaxDisabledValidators = ConstU32<100>;
}

impl pallet_fast_unstake::Config for Runtime {
Expand Down
1 change: 1 addition & 0 deletions substrate/frame/staking/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ impl crate::pallet::pallet::Config for Test {
type MaxInvulnerables = ConstU32<20>;
type MaxRewardPagesPerValidator = ConstU32<20>;
type MaxValidatorsCount = ConstU32<300>;
type MaxDisabledValidators = ConstU32<100>;
}

pub struct WeightedNominationsQuota<const MAX: u32>;
Expand Down
15 changes: 7 additions & 8 deletions substrate/frame/staking/src/pallet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,10 @@ pub mod pallet {
#[pallet::constant]
type MaxInvulnerables: Get<u32>;

/// Maximum number of disabled validators.
#[pallet::constant]
type MaxDisabledValidators: Get<u32>;

/// Some parameters of the benchmarking.
#[cfg(feature = "std")]
type BenchmarkingConfig: BenchmarkingConfig;
Expand Down Expand Up @@ -368,6 +372,7 @@ pub mod pallet {
type MaxInvulnerables = ConstU32<20>;
type MaxRewardPagesPerValidator = ConstU32<20>;
type MaxValidatorsCount = ConstU32<300>;
type MaxDisabledValidators = ConstU32<100>;
#[cfg(feature = "std")]
type BenchmarkingConfig = crate::TestBenchmarkingConfig;
type WeightInfo = ();
Expand Down Expand Up @@ -683,14 +688,8 @@ pub mod pallet {
/// Additionally, each disabled validator is associated with an `OffenceSeverity` which
/// represents how severe is the offence that got the validator disabled.
#[pallet::storage]
pub type DisabledValidators<T: Config> = StorageValue<
_,
WeakBoundedVec<
(u32, OffenceSeverity),
<T::ElectionProvider as ElectionProviderBase>::MaxWinners,
>,
ValueQuery,
>;
pub type DisabledValidators<T: Config> =
StorageValue<_, BoundedVec<(u32, OffenceSeverity), T::MaxDisabledValidators>, ValueQuery>;

/// The threshold for when users can start calling `chill_other` for other validators /
/// nominators. The threshold is compared to the actual number of validators / nominators
Expand Down

0 comments on commit 50ce1a1

Please sign in to comment.