Skip to content

Commit 048a9c2

Browse files
Ross Bulatgpestana
andauthored
Staking: Add deprecate_controller_batch AdminOrigin call (#2589)
Partially Addresses #2500 Adds a `deprecate_controller_batch` call to the staking pallet that is callable by `Root` and `StakingAdmin`. To be used for controller account deprecation and removed thereafter. Adds `MaxControllersDeprecationBatch` pallet constant that defines max possible deprecations per call. - [x] Add `deprecate_controller_batch` call, and `MaxControllersInDeprecationBatch` constant. - [x] Add tests, benchmark, weights. Tests that weight is only consumed if unique pair. - [x] Adds `StakingAdmin` origin to staking's `AdminOrigin` type in westend runtime. - [x] Determined that worst case 5,900 deprecations does fit into `maxBlock` `proofSize` and `refTime` in both normal and operational thresholds, meaning we can deprecate all controllers for each network in one call. ## Block Weights By querying `consts.system.blockWeights` we can see that the `deprecate_controller_batch` weights fit within the `normal` threshold on Polkadot. #### `controller_deprecation_batch` where i = 5900: #### Ref time: 69,933,325,300 #### Proof size: 21,040,390 ### Polkadot ``` // consts.query.blockWeights maxBlock: { refTime: 2,000,000,000,000 proofSize: 18,446,744,073,709,551,615 } normal: { maxExtrinsic: { refTime: 1,479,873,955,000 proofSize: 13,650,590,614,545,068,195 } maxTotal: { refTime: 1,500,000,000,000 proofSize: 13,835,058,055,282,163,711 } } ``` ### Kusama ``` // consts.query.blockWeights maxBlock: { refTime: 2,000,000,000,000 proofSize: 18,446,744,073,709,551,615 } normal: { maxExtrinsic: { refTime: 1,479,875,294,000 proofSize: 13,650,590,614,545,068,195 } maxTotal: { refTime: 1,500,000,000,000 proofSize: 13,835,058,055,282,163,711 } } ``` --------- Co-authored-by: command-bot <> Co-authored-by: Gonçalo Pestana <[email protected]>
1 parent c2d45e7 commit 048a9c2

File tree

19 files changed

+624
-285
lines changed

19 files changed

+624
-285
lines changed

polkadot/runtime/test-runtime/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@ impl pallet_staking::Config for Runtime {
356356
type TargetList = pallet_staking::UseValidatorsMap<Runtime>;
357357
type NominationsQuota = pallet_staking::FixedNominationsQuota<MAX_QUOTA_NOMINATIONS>;
358358
type MaxUnlockingChunks = frame_support::traits::ConstU32<32>;
359+
type MaxControllersInDeprecationBatch = ConstU32<5900>;
359360
type HistoryDepth = frame_support::traits::ConstU32<84>;
360361
type BenchmarkingConfig = runtime_common::StakingBenchmarkingConfig;
361362
type EventListeners = ();

polkadot/runtime/westend/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,7 @@ parameter_types! {
672672
pub const MaxNominators: u32 = 64;
673673
pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(17);
674674
pub const MaxNominations: u32 = <NposCompactSolution16 as frame_election_provider_support::NposSolution>::LIMIT as u32;
675+
pub const MaxControllersInDeprecationBatch: u32 = 751;
675676
}
676677

677678
impl pallet_staking::Config for Runtime {
@@ -686,7 +687,7 @@ impl pallet_staking::Config for Runtime {
686687
type SessionsPerEra = SessionsPerEra;
687688
type BondingDuration = BondingDuration;
688689
type SlashDeferDuration = SlashDeferDuration;
689-
type AdminOrigin = EnsureRoot<AccountId>;
690+
type AdminOrigin = EitherOf<EnsureRoot<AccountId>, StakingAdmin>;
690691
type SessionInterface = Self;
691692
type EraPayout = pallet_staking::ConvertCurve<RewardCurve>;
692693
type MaxExposurePageSize = MaxExposurePageSize;
@@ -699,6 +700,7 @@ impl pallet_staking::Config for Runtime {
699700
type NominationsQuota = pallet_staking::FixedNominationsQuota<{ MaxNominations::get() }>;
700701
type MaxUnlockingChunks = frame_support::traits::ConstU32<32>;
701702
type HistoryDepth = frame_support::traits::ConstU32<84>;
703+
type MaxControllersInDeprecationBatch = MaxControllersInDeprecationBatch;
702704
type BenchmarkingConfig = runtime_common::StakingBenchmarkingConfig;
703705
type EventListeners = NominationPools;
704706
type WeightInfo = weights::pallet_staking::WeightInfo<Runtime>;

polkadot/runtime/westend/src/weights/pallet_staking.rs

Lines changed: 118 additions & 96 deletions
Large diffs are not rendered by default.

substrate/bin/node/runtime/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,7 @@ parameter_types! {
632632
pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE;
633633
pub const MaxNominators: u32 = 64;
634634
pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(17);
635+
pub const MaxControllersInDeprecationBatch: u32 = 5900;
635636
pub OffchainRepeat: BlockNumber = 5;
636637
pub HistoryDepth: u32 = 84;
637638
}
@@ -674,6 +675,7 @@ impl pallet_staking::Config for Runtime {
674675
// This a placeholder, to be introduced in the next PR as an instance of bags-list
675676
type TargetList = pallet_staking::UseValidatorsMap<Self>;
676677
type MaxUnlockingChunks = ConstU32<32>;
678+
type MaxControllersInDeprecationBatch = MaxControllersInDeprecationBatch;
677679
type HistoryDepth = HistoryDepth;
678680
type EventListeners = NominationPools;
679681
type WeightInfo = pallet_staking::weights::SubstrateWeight<Runtime>;

substrate/frame/babe/src/mock.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ impl pallet_staking::Config for Test {
183183
type TargetList = pallet_staking::UseValidatorsMap<Self>;
184184
type NominationsQuota = FixedNominationsQuota<16>;
185185
type MaxUnlockingChunks = ConstU32<32>;
186+
type MaxControllersInDeprecationBatch = ConstU32<100>;
186187
type HistoryDepth = ConstU32<84>;
187188
type EventListeners = ();
188189
type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig;

substrate/frame/beefy/src/mock.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ impl pallet_staking::Config for Test {
201201
type TargetList = pallet_staking::UseValidatorsMap<Self>;
202202
type NominationsQuota = pallet_staking::FixedNominationsQuota<16>;
203203
type MaxUnlockingChunks = ConstU32<32>;
204+
type MaxControllersInDeprecationBatch = ConstU32<100>;
204205
type HistoryDepth = ConstU32<84>;
205206
type EventListeners = ();
206207
type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig;

substrate/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ impl pallet_staking::Config for Runtime {
276276
type NominationsQuota = pallet_staking::FixedNominationsQuota<MAX_QUOTA_NOMINATIONS>;
277277
type TargetList = pallet_staking::UseValidatorsMap<Self>;
278278
type MaxUnlockingChunks = ConstU32<32>;
279+
type MaxControllersInDeprecationBatch = ConstU32<100>;
279280
type HistoryDepth = HistoryDepth;
280281
type EventListeners = ();
281282
type WeightInfo = pallet_staking::weights::SubstrateWeight<Runtime>;

substrate/frame/fast-unstake/src/mock.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ impl pallet_staking::Config for Runtime {
142142
type TargetList = pallet_staking::UseValidatorsMap<Self>;
143143
type NominationsQuota = pallet_staking::FixedNominationsQuota<16>;
144144
type MaxUnlockingChunks = ConstU32<32>;
145+
type MaxControllersInDeprecationBatch = ConstU32<100>;
145146
type EventListeners = ();
146147
type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig;
147148
type WeightInfo = ();

substrate/frame/grandpa/src/mock.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ impl pallet_staking::Config for Test {
206206
type TargetList = pallet_staking::UseValidatorsMap<Self>;
207207
type NominationsQuota = pallet_staking::FixedNominationsQuota<16>;
208208
type MaxUnlockingChunks = ConstU32<32>;
209+
type MaxControllersInDeprecationBatch = ConstU32<100>;
209210
type HistoryDepth = ConstU32<84>;
210211
type EventListeners = ();
211212
type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig;

substrate/frame/nomination-pools/benchmarking/src/mock.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ impl pallet_staking::Config for Runtime {
119119
type VoterList = VoterList;
120120
type TargetList = pallet_staking::UseValidatorsMap<Self>;
121121
type NominationsQuota = pallet_staking::FixedNominationsQuota<16>;
122+
type MaxControllersInDeprecationBatch = ConstU32<100>;
122123
type MaxUnlockingChunks = ConstU32<32>;
123124
type HistoryDepth = ConstU32<84>;
124125
type EventListeners = Pools;

0 commit comments

Comments
 (0)