Skip to content

Commit 3f69cfc

Browse files
Remove invulnerables form staking-async (#10359)
The "staking-async" pallet has inherited the list of invulnerable validators from the "staking" pallet, but these are no longer used. We can therefore remove them, together with additional clean-up. Closes #10135 (comment) --------- Signed-off-by: Andrei Trandafir <[email protected]> Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent cf129b7 commit 3f69cfc

File tree

14 files changed

+168
-336
lines changed

14 files changed

+168
-336
lines changed

cumulus/parachains/runtimes/assets/asset-hub-westend/src/staking.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,6 @@ impl pallet_staking_async::Config for Runtime {
294294
type HistoryDepth = frame_support::traits::ConstU32<84>;
295295
type MaxControllersInDeprecationBatch = MaxControllersInDeprecationBatch;
296296
type EventListeners = (NominationPools, DelegatedStaking);
297-
type MaxInvulnerables = frame_support::traits::ConstU32<20>;
298297
type PlanningEraOffset =
299298
pallet_staking_async::PlanningEraOffsetOf<Runtime, RelaySessionDuration, ConstU32<5>>;
300299
type RcClientInterface = StakingRcClient;

cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_staking_async.rs

Lines changed: 158 additions & 172 deletions
Large diffs are not rendered by default.

prdoc/pr_10359.prdoc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
title: Remove invulnerables form staking-async
2+
doc:
3+
- audience: Runtime Dev
4+
description: |-
5+
The 'staking-async' pallet has inherited the list of invulnerable validators from the 'staking' pallet, but these are no longer used. We can therefore remove them, together with additional clean-up. This includes removing the 'set_invulnerables(...)' call together with the 'Invulnerables<T: Config>' storage type.
6+
crates:
7+
- name: asset-hub-westend-runtime
8+
bump: major
9+
- name: pallet-staking-async
10+
bump: major

substrate/frame/staking-async/ahm-test/src/ah/mock.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,6 @@ impl pallet_staking_async::Config for Runtime {
353353

354354
type MaxValidatorSet = MaxValidators;
355355
type MaxExposurePageSize = MaxExposurePageSize;
356-
type MaxInvulnerables = MaxValidators;
357356
type MaxUnlockingChunks = ConstU32<16>;
358357
type NominationsQuota = pallet_staking_async::FixedNominationsQuota<16>;
359358

substrate/frame/staking-async/runtimes/parachain/src/staking.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,6 @@ impl pallet_staking_async::Config for Runtime {
450450
type MaxControllersInDeprecationBatch = MaxControllersInDeprecationBatch;
451451
type EventListeners = (NominationPools, DelegatedStaking);
452452
type WeightInfo = pallet_staking_async::weights::SubstrateWeight<Runtime>;
453-
type MaxInvulnerables = frame_support::traits::ConstU32<20>;
454453
type MaxEraDuration = MaxEraDuration;
455454
type MaxPruningItems = MaxPruningItems;
456455
type PlanningEraOffset =

substrate/frame/staking-async/runtimes/parachain/src/weights/pallet_staking_async.rs

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ pub trait WeightInfo {
7373
fn force_no_eras() -> Weight;
7474
fn force_new_era() -> Weight;
7575
fn force_new_era_always() -> Weight;
76-
fn set_invulnerables(v: u32, ) -> Weight;
7776
fn deprecate_controller_batch(u: u32, ) -> Weight;
7877
fn force_unstake() -> Weight;
7978
fn cancel_deferred_slash(s: u32, ) -> Weight;
@@ -449,17 +448,6 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
449448
Weight::from_parts(11_000_000, 0)
450449
.saturating_add(T::DbWeight::get().writes(1_u64))
451450
}
452-
/// Storage: `Staking::Invulnerables` (r:0 w:1)
453-
/// Proof: `Staking::Invulnerables` (`max_values`: Some(1), `max_size`: Some(641), added: 1136, mode: `MaxEncodedLen`)
454-
/// The range of component `v` is `[0, 20]`.
455-
fn set_invulnerables(_v: u32, ) -> Weight {
456-
// Proof Size summary in bytes:
457-
// Measured: `0`
458-
// Estimated: `0`
459-
// Minimum execution time: 4_000_000 picoseconds.
460-
Weight::from_parts(6_000_000, 0)
461-
.saturating_add(T::DbWeight::get().writes(1_u64))
462-
}
463451
/// Storage: `Staking::Ledger` (r:1502 w:1502)
464452
/// Proof: `Staking::Ledger` (`max_values`: None, `max_size`: Some(753), added: 3228, mode: `MaxEncodedLen`)
465453
/// Storage: `Staking::Bonded` (r:751 w:751)
@@ -822,8 +810,6 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
822810
/// Proof: `Staking::ActiveEra` (`max_values`: Some(1), `max_size`: Some(13), added: 508, mode: `MaxEncodedLen`)
823811
/// Storage: `Staking::BondedEras` (r:1 w:0)
824812
/// Proof: `Staking::BondedEras` (`max_values`: Some(1), `max_size`: Some(25), added: 520, mode: `MaxEncodedLen`)
825-
/// Storage: `Staking::Invulnerables` (r:1 w:0)
826-
/// Proof: `Staking::Invulnerables` (`max_values`: Some(1), `max_size`: Some(641), added: 1136, mode: `MaxEncodedLen`)
827813
/// Storage: `Staking::ErasStakersOverview` (r:500 w:0)
828814
/// Proof: `Staking::ErasStakersOverview` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`)
829815
/// Storage: `Staking::ValidatorSlashInEra` (r:500 w:500)
@@ -1342,17 +1328,6 @@ impl WeightInfo for () {
13421328
Weight::from_parts(11_000_000, 0)
13431329
.saturating_add(RocksDbWeight::get().writes(1_u64))
13441330
}
1345-
/// Storage: `Staking::Invulnerables` (r:0 w:1)
1346-
/// Proof: `Staking::Invulnerables` (`max_values`: Some(1), `max_size`: Some(641), added: 1136, mode: `MaxEncodedLen`)
1347-
/// The range of component `v` is `[0, 20]`.
1348-
fn set_invulnerables(_v: u32, ) -> Weight {
1349-
// Proof Size summary in bytes:
1350-
// Measured: `0`
1351-
// Estimated: `0`
1352-
// Minimum execution time: 4_000_000 picoseconds.
1353-
Weight::from_parts(6_000_000, 0)
1354-
.saturating_add(RocksDbWeight::get().writes(1_u64))
1355-
}
13561331
/// Storage: `Staking::Ledger` (r:1502 w:1502)
13571332
/// Proof: `Staking::Ledger` (`max_values`: None, `max_size`: Some(753), added: 3228, mode: `MaxEncodedLen`)
13581333
/// Storage: `Staking::Bonded` (r:751 w:751)
@@ -1715,8 +1690,6 @@ impl WeightInfo for () {
17151690
/// Proof: `Staking::ActiveEra` (`max_values`: Some(1), `max_size`: Some(13), added: 508, mode: `MaxEncodedLen`)
17161691
/// Storage: `Staking::BondedEras` (r:1 w:0)
17171692
/// Proof: `Staking::BondedEras` (`max_values`: Some(1), `max_size`: Some(25), added: 520, mode: `MaxEncodedLen`)
1718-
/// Storage: `Staking::Invulnerables` (r:1 w:0)
1719-
/// Proof: `Staking::Invulnerables` (`max_values`: Some(1), `max_size`: Some(641), added: 1136, mode: `MaxEncodedLen`)
17201693
/// Storage: `Staking::ErasStakersOverview` (r:500 w:0)
17211694
/// Proof: `Staking::ErasStakersOverview` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`)
17221695
/// Storage: `Staking::ValidatorSlashInEra` (r:500 w:500)

substrate/frame/staking-async/runtimes/rc/src/weights/pallet_offences.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@ impl<T: frame_system::Config> pallet_offences::WeightInfo for WeightInfo<T> {
5959
/// Proof: `Staking::ActiveEra` (`max_values`: Some(1), `max_size`: Some(13), added: 508, mode: `MaxEncodedLen`)
6060
/// Storage: `Staking::ErasStartSessionIndex` (r:1 w:0)
6161
/// Proof: `Staking::ErasStartSessionIndex` (`max_values`: None, `max_size`: Some(16), added: 2491, mode: `MaxEncodedLen`)
62-
/// Storage: `Staking::Invulnerables` (r:1 w:0)
63-
/// Proof: `Staking::Invulnerables` (`max_values`: Some(1), `max_size`: Some(641), added: 1136, mode: `MaxEncodedLen`)
6462
/// Storage: `Staking::ErasStakersOverview` (r:1 w:0)
6563
/// Proof: `Staking::ErasStakersOverview` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`)
6664
/// Storage: `Session::DisabledValidators` (r:1 w:1)
@@ -94,8 +92,6 @@ impl<T: frame_system::Config> pallet_offences::WeightInfo for WeightInfo<T> {
9492
/// Proof: `Staking::ActiveEra` (`max_values`: Some(1), `max_size`: Some(13), added: 508, mode: `MaxEncodedLen`)
9593
/// Storage: `Staking::ErasStartSessionIndex` (r:1 w:0)
9694
/// Proof: `Staking::ErasStartSessionIndex` (`max_values`: None, `max_size`: Some(16), added: 2491, mode: `MaxEncodedLen`)
97-
/// Storage: `Staking::Invulnerables` (r:1 w:0)
98-
/// Proof: `Staking::Invulnerables` (`max_values`: Some(1), `max_size`: Some(641), added: 1136, mode: `MaxEncodedLen`)
9995
/// Storage: `Staking::ErasStakersOverview` (r:1 w:0)
10096
/// Proof: `Staking::ErasStakersOverview` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`)
10197
/// Storage: `Session::DisabledValidators` (r:1 w:1)

substrate/frame/staking-async/runtimes/rc/src/weights/polkadot_runtime_parachains_disputes_slashing.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ impl<T: frame_system::Config> polkadot_runtime_parachains::disputes::slashing::W
6565
/// Proof: `Staking::ActiveEra` (`max_values`: Some(1), `max_size`: Some(13), added: 508, mode: `MaxEncodedLen`)
6666
/// Storage: `Staking::ErasStartSessionIndex` (r:1 w:0)
6767
/// Proof: `Staking::ErasStartSessionIndex` (`max_values`: None, `max_size`: Some(16), added: 2491, mode: `MaxEncodedLen`)
68-
/// Storage: `Staking::Invulnerables` (r:1 w:0)
69-
/// Proof: `Staking::Invulnerables` (`max_values`: Some(1), `max_size`: Some(641), added: 1136, mode: `MaxEncodedLen`)
7068
/// Storage: `Staking::ErasStakersOverview` (r:1 w:0)
7169
/// Proof: `Staking::ErasStakersOverview` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`)
7270
/// Storage: `Session::DisabledValidators` (r:1 w:1)

substrate/frame/staking-async/src/benchmarking.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -594,20 +594,6 @@ mod benchmarks {
594594
assert_eq!(ForceEra::<T>::get(), Forcing::ForceAlways);
595595
}
596596

597-
#[benchmark]
598-
// Worst case scenario, the list of invulnerables is very long.
599-
fn set_invulnerables(v: Linear<0, { T::MaxInvulnerables::get() }>) {
600-
let mut invulnerables = Vec::new();
601-
for i in 0..v {
602-
invulnerables.push(account("invulnerable", i, SEED));
603-
}
604-
605-
#[extrinsic_call]
606-
_(RawOrigin::Root, invulnerables);
607-
608-
assert_eq!(Invulnerables::<T>::get().len(), v as usize);
609-
}
610-
611597
#[benchmark]
612598
fn deprecate_controller_batch(
613599
// We pass a dynamic number of controllers to the benchmark, up to

substrate/frame/staking-async/src/mock.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,6 @@ impl crate::pallet::pallet::Config for Test {
438438
type BondingDuration = BondingDuration;
439439
type MaxControllersInDeprecationBatch = MaxControllersInDeprecationBatch;
440440
type EventListeners = EventListenerMock;
441-
type MaxInvulnerables = ConstU32<20>;
442441
type MaxEraDuration = MaxEraDuration;
443442
type MaxPruningItems = MaxPruningItems;
444443
type PlanningEraOffset = PlanningEraOffset;
@@ -477,7 +476,6 @@ parameter_types! {
477476
pub struct ExtBuilder {
478477
nominate: bool,
479478
validator_count: u32,
480-
invulnerables: BoundedVec<AccountId, <Test as Config>::MaxInvulnerables>,
481479
has_stakers: bool,
482480
pub min_nominator_bond: Balance,
483481
min_validator_bond: Balance,
@@ -494,7 +492,6 @@ impl Default for ExtBuilder {
494492
nominate: true,
495493
validator_count: 2,
496494
balance_factor: 1,
497-
invulnerables: BoundedVec::new(),
498495
has_stakers: true,
499496
min_nominator_bond: ExistentialDeposit::get(),
500497
min_validator_bond: ExistentialDeposit::get(),
@@ -548,11 +545,6 @@ impl ExtBuilder {
548545
SlashDeferDuration::set(eras);
549546
self
550547
}
551-
pub(crate) fn invulnerables(mut self, invulnerables: Vec<AccountId>) -> Self {
552-
self.invulnerables = BoundedVec::try_from(invulnerables)
553-
.expect("Too many invulnerable validators: upper limit is MaxInvulnerables");
554-
self
555-
}
556548
pub(crate) fn session_per_era(self, length: SessionIndex) -> Self {
557549
SessionsPerEra::set(length);
558550
self
@@ -687,7 +679,6 @@ impl ExtBuilder {
687679
let _ = pallet_staking_async::GenesisConfig::<Test> {
688680
stakers: maybe_stakers,
689681
validator_count: self.validator_count,
690-
invulnerables: self.invulnerables,
691682
active_era: (0, 0, INIT_TIMESTAMP),
692683
slash_reward_fraction: Perbill::from_percent(10),
693684
min_nominator_bond: self.min_nominator_bond,

0 commit comments

Comments
 (0)