From b7df147769766c06780d4d696165946342ffad43 Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Sun, 3 Dec 2023 16:58:49 +0700 Subject: [PATCH 01/74] add deprecate_controller_batch call --- polkadot/runtime/westend/src/lib.rs | 1 + substrate/frame/staking/src/pallet/mod.rs | 43 +++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/polkadot/runtime/westend/src/lib.rs b/polkadot/runtime/westend/src/lib.rs index 36c8c12be217..918c797c571b 100644 --- a/polkadot/runtime/westend/src/lib.rs +++ b/polkadot/runtime/westend/src/lib.rs @@ -708,6 +708,7 @@ impl pallet_staking::Config for Runtime { type NominationsQuota = pallet_staking::FixedNominationsQuota<{ MaxNominations::get() }>; type MaxUnlockingChunks = frame_support::traits::ConstU32<32>; type HistoryDepth = frame_support::traits::ConstU32<84>; + type MaxControllersInBatch = frame_support::traits::ConstU32<751>; type BenchmarkingConfig = runtime_common::StakingBenchmarkingConfig; type EventListeners = NominationPools; type WeightInfo = weights::pallet_staking::WeightInfo; diff --git a/substrate/frame/staking/src/pallet/mod.rs b/substrate/frame/staking/src/pallet/mod.rs index ce80f22c2bbf..4a8c91d3db66 100644 --- a/substrate/frame/staking/src/pallet/mod.rs +++ b/substrate/frame/staking/src/pallet/mod.rs @@ -269,6 +269,9 @@ pub mod pallet { #[pallet::constant] type MaxUnlockingChunks: Get; + /// The maximum amount of controller accounts that can be deprecated in one batch. + type MaxControllersInBatch: Get; + /// Something that listens to staking updates and performs actions based on the data it /// receives. /// @@ -1920,6 +1923,46 @@ pub mod pallet { Ok(Pays::No.into()) } + + /// Updates a batch of controller accounts to their corresponding stash account if they are + /// not the same. Ignores any controller accounts that do not exist, and does not operate if + /// the stash and controller are already the same. + /// + /// Effects will be felt instantly (as soon as this function is completed successfully). + /// + /// The dispatch origin must be Root. + #[pallet::call_index(28)] + #[pallet::weight(T::WeightInfo::update_payee())] // TODO: insert real weight. + pub fn deprecate_controller_batch( + origin: OriginFor, + batch: BoundedVec, + ) -> DispatchResult { + ensure_root(origin)?; + + // Ignore controllers that do not exist or are already the same as stash. + let filtered_batch_with_leger: Vec<_> = batch + .iter() + .filter_map(|controller| { + let ledger = Self::ledger(StakingAccount::Controller(controller.clone())); + ledger.ok().map_or(None, |ledger| { + if ledger.stash != *controller { + Some((controller.clone(), ledger)) + } else { + None + } + }) + }) + .collect(); + + // Update unique pairs. + for (controller, ledger) in filtered_batch_with_leger { + let stash = ledger.stash.clone(); + >::remove(controller); + >::insert(&stash, stash.clone()); + >::insert(stash, ledger); + } + Ok(()) + } } } From bb8658d5f5b5a2e84f92b623fe5578fb2d83e3cb Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Sun, 3 Dec 2023 17:05:39 +0700 Subject: [PATCH 02/74] fix name --- substrate/frame/staking/src/pallet/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/substrate/frame/staking/src/pallet/mod.rs b/substrate/frame/staking/src/pallet/mod.rs index 4a8c91d3db66..2d6a8d90a98b 100644 --- a/substrate/frame/staking/src/pallet/mod.rs +++ b/substrate/frame/staking/src/pallet/mod.rs @@ -1940,7 +1940,7 @@ pub mod pallet { ensure_root(origin)?; // Ignore controllers that do not exist or are already the same as stash. - let filtered_batch_with_leger: Vec<_> = batch + let filtered_batch_with_ledger: Vec<_> = batch .iter() .filter_map(|controller| { let ledger = Self::ledger(StakingAccount::Controller(controller.clone())); @@ -1955,7 +1955,7 @@ pub mod pallet { .collect(); // Update unique pairs. - for (controller, ledger) in filtered_batch_with_leger { + for (controller, ledger) in filtered_batch_with_ledger { let stash = ledger.stash.clone(); >::remove(controller); >::insert(&stash, stash.clone()); From ce1b7d7ccf0583a13fde2fe04a2c9bd1352cb86c Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Sun, 3 Dec 2023 19:06:43 +0700 Subject: [PATCH 03/74] ledger controller to None --- substrate/frame/staking/src/pallet/mod.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/substrate/frame/staking/src/pallet/mod.rs b/substrate/frame/staking/src/pallet/mod.rs index 2d6a8d90a98b..a0232a46cab0 100644 --- a/substrate/frame/staking/src/pallet/mod.rs +++ b/substrate/frame/staking/src/pallet/mod.rs @@ -1340,7 +1340,7 @@ pub mod pallet { // update bond and ledger. >::remove(controller); >::insert(&stash, &stash); - >::insert(&stash, ledger); + >::insert(&stash, StakingLedger { controller: None, ..ledger}); Ok(()) })? } @@ -1946,7 +1946,7 @@ pub mod pallet { let ledger = Self::ledger(StakingAccount::Controller(controller.clone())); ledger.ok().map_or(None, |ledger| { if ledger.stash != *controller { - Some((controller.clone(), ledger)) + Some((controller.clone(), StakingLedger { controller: None, ..ledger })) } else { None } @@ -1957,8 +1957,9 @@ pub mod pallet { // Update unique pairs. for (controller, ledger) in filtered_batch_with_ledger { let stash = ledger.stash.clone(); + + >::insert(&stash, &stash); >::remove(controller); - >::insert(&stash, stash.clone()); >::insert(stash, ledger); } Ok(()) From 566ecd9a4f18e3ded0b42dd9ac0d80fa12bc53af Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Sun, 3 Dec 2023 19:08:50 +0700 Subject: [PATCH 04/74] MaxControllersInBatch to 10 --- polkadot/runtime/westend/src/lib.rs | 3 ++- substrate/frame/staking/src/mock.rs | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/polkadot/runtime/westend/src/lib.rs b/polkadot/runtime/westend/src/lib.rs index 918c797c571b..eb0f11e56a27 100644 --- a/polkadot/runtime/westend/src/lib.rs +++ b/polkadot/runtime/westend/src/lib.rs @@ -681,6 +681,7 @@ parameter_types! { pub const MaxNominators: u32 = 64; pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(17); pub const MaxNominations: u32 = ::LIMIT as u32; + pub const MaxControllersInBatch: u32 = 10; } impl pallet_staking::Config for Runtime { @@ -708,7 +709,7 @@ impl pallet_staking::Config for Runtime { type NominationsQuota = pallet_staking::FixedNominationsQuota<{ MaxNominations::get() }>; type MaxUnlockingChunks = frame_support::traits::ConstU32<32>; type HistoryDepth = frame_support::traits::ConstU32<84>; - type MaxControllersInBatch = frame_support::traits::ConstU32<751>; + type MaxControllersInBatch = MaxControllersInBatch; type BenchmarkingConfig = runtime_common::StakingBenchmarkingConfig; type EventListeners = NominationPools; type WeightInfo = weights::pallet_staking::WeightInfo; diff --git a/substrate/frame/staking/src/mock.rs b/substrate/frame/staking/src/mock.rs index 90b0ee0260dc..b3f6c3502940 100644 --- a/substrate/frame/staking/src/mock.rs +++ b/substrate/frame/staking/src/mock.rs @@ -122,6 +122,7 @@ parameter_types! { pub static SlashDeferDuration: EraIndex = 0; pub static Period: BlockNumber = 5; pub static Offset: BlockNumber = 0; + pub static MaxControllersInBatch: u32 = 10; } #[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)] @@ -316,6 +317,7 @@ impl crate::pallet::pallet::Config for Test { type NominationsQuota = WeightedNominationsQuota<16>; type MaxUnlockingChunks = MaxUnlockingChunks; type HistoryDepth = HistoryDepth; + type MaxControllersInBatch = MaxControllersInBatch; type EventListeners = EventListenerMock; type BenchmarkingConfig = TestBenchmarkingConfig; type WeightInfo = (); From eea28dcd045fc2ce82e65b54167750146b5d48de Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Sun, 3 Dec 2023 19:09:17 +0700 Subject: [PATCH 05/74] init deprecate_controller_batch_works test --- substrate/frame/staking/src/pallet/mod.rs | 4 +- substrate/frame/staking/src/tests.rs | 54 +++++++++++++++++++++++ 2 files changed, 56 insertions(+), 2 deletions(-) diff --git a/substrate/frame/staking/src/pallet/mod.rs b/substrate/frame/staking/src/pallet/mod.rs index a0232a46cab0..ed959cfb1859 100644 --- a/substrate/frame/staking/src/pallet/mod.rs +++ b/substrate/frame/staking/src/pallet/mod.rs @@ -1935,12 +1935,12 @@ pub mod pallet { #[pallet::weight(T::WeightInfo::update_payee())] // TODO: insert real weight. pub fn deprecate_controller_batch( origin: OriginFor, - batch: BoundedVec, + controllers: BoundedVec, ) -> DispatchResult { ensure_root(origin)?; // Ignore controllers that do not exist or are already the same as stash. - let filtered_batch_with_ledger: Vec<_> = batch + let filtered_batch_with_ledger: Vec<_> = controllers .iter() .filter_map(|controller| { let ledger = Self::ledger(StakingAccount::Controller(controller.clone())); diff --git a/substrate/frame/staking/src/tests.rs b/substrate/frame/staking/src/tests.rs index 7d967609f520..7340f4628837 100644 --- a/substrate/frame/staking/src/tests.rs +++ b/substrate/frame/staking/src/tests.rs @@ -6867,4 +6867,58 @@ mod ledger { assert_eq!(Payee::::get(&21), RewardDestination::Stash); }) } + + #[test] + fn deprecate_controller_batch_works() { + ExtBuilder::default().build_and_execute(|| { + // Given: + + let mut controllers: Vec<_> = vec![]; + for n in 1..MaxControllersInBatch::get().into() { + let stash = n + 10000; + Ledger::::insert( + n, + StakingLedger { + stash, + controller: None, + total: (1000 + n).into(), + active: (1000 + n).into(), + unlocking: Default::default(), + legacy_claimed_rewards: bounded_vec![], + }, + ); + Bonded::::insert(stash, n); + controllers.push(n); + } + + // When: + + let bounded_controllers: BoundedVec<_, ::MaxControllersInBatch> = + BoundedVec::try_from(controllers).unwrap(); + + assert_ok!(Staking::deprecate_controller_batch( + RuntimeOrigin::root(), + bounded_controllers + )); + + // Then: + + for n in 1..MaxControllersInBatch::get().into() { + let stash = n + 10000; + + // Ledger no longer keyed by controller. + assert_eq!(Ledger::::get(n), None); + // Bonded now maps to the stash. + assert_eq!(Bonded::::get(stash), Some(stash)); + + // Ledger is now keyed by stash. + let ledger_updated = Ledger::::get(stash).unwrap(); + assert_eq!(ledger_updated.stash, stash); + + // Check `active` and `total` values match the original ledger set by controller. + assert_eq!(ledger_updated.active, (1000 + n).into()); + assert_eq!(ledger_updated.total, (1000 + n).into()); + } + }) + } } From 37bf26d355a37d3b1d2833340c7f38859a0229ee Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Sun, 3 Dec 2023 19:12:59 +0700 Subject: [PATCH 06/74] add benchmark boilerplate --- substrate/frame/staking/src/benchmarking.rs | 42 +++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/substrate/frame/staking/src/benchmarking.rs b/substrate/frame/staking/src/benchmarking.rs index c0c6a838aa59..4e6c8d0356f2 100644 --- a/substrate/frame/staking/src/benchmarking.rs +++ b/substrate/frame/staking/src/benchmarking.rs @@ -525,6 +525,48 @@ benchmarks! { assert_eq!(Invulnerables::::get().len(), v as usize); } + deprecate_controller_batch { + let mut controllers: Vec<_> = vec![]; + for n in 1..MaxControllersInBatch::get().into() { + let stash = n + 10000; + Ledger::::insert( + n, + StakingLedger { + stash, + controller: None, + total: (1000 + n).into(), + active: (1000 + n).into(), + unlocking: Default::default(), + legacy_claimed_rewards: bounded_vec![], + }, + ); + Bonded::::insert(stash, n); + controllers.push(n); + } + + let bounded_controllers: BoundedVec<_, ::MaxControllersInBatch> = + BoundedVec::try_from(controllers).unwrap(); + + }: _(RawOrigin::Root, bounded_controllers) + verify { + for n in 1..MaxControllersInBatch::get().into() { + let stash = n + 10000; + + // Ledger no longer keyed by controller. + assert_eq!(Ledger::::get(n), None); + // Bonded now maps to the stash. + assert_eq!(Bonded::::get(stash), Some(stash)); + + // Ledger is now keyed by stash. + let ledger_updated = Ledger::::get(stash).unwrap(); + assert_eq!(ledger_updated.stash, stash); + + // Check `active` and `total` values match the original ledger set by controller. + assert_eq!(ledger_updated.active, (1000 + n).into()); + assert_eq!(ledger_updated.total, (1000 + n).into()); + } + } + force_unstake { // Slashing Spans let s in 0 .. MAX_SPANS; From acb3ebe6f274904589c0441f709c02d55ff13aac Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Sun, 3 Dec 2023 19:28:53 +0700 Subject: [PATCH 07/74] amend mocks --- substrate/frame/babe/src/mock.rs | 1 + substrate/frame/beefy/src/mock.rs | 1 + substrate/frame/grandpa/src/mock.rs | 1 + substrate/frame/offences/benchmarking/src/mock.rs | 1 + substrate/frame/root-offences/src/mock.rs | 1 + substrate/frame/session/benchmarking/src/mock.rs | 1 + 6 files changed, 6 insertions(+) diff --git a/substrate/frame/babe/src/mock.rs b/substrate/frame/babe/src/mock.rs index 0003c6f9f11a..f4658d1a674f 100644 --- a/substrate/frame/babe/src/mock.rs +++ b/substrate/frame/babe/src/mock.rs @@ -183,6 +183,7 @@ impl pallet_staking::Config for Test { type TargetList = pallet_staking::UseValidatorsMap; type NominationsQuota = FixedNominationsQuota<16>; type MaxUnlockingChunks = ConstU32<32>; + type MaxControllersInBatch = (); type HistoryDepth = ConstU32<84>; type EventListeners = (); type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig; diff --git a/substrate/frame/beefy/src/mock.rs b/substrate/frame/beefy/src/mock.rs index 53d523cf724d..a03f5d07bc46 100644 --- a/substrate/frame/beefy/src/mock.rs +++ b/substrate/frame/beefy/src/mock.rs @@ -201,6 +201,7 @@ impl pallet_staking::Config for Test { type TargetList = pallet_staking::UseValidatorsMap; type NominationsQuota = pallet_staking::FixedNominationsQuota<16>; type MaxUnlockingChunks = ConstU32<32>; + type MaxControllersInBatch = (); type HistoryDepth = ConstU32<84>; type EventListeners = (); type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig; diff --git a/substrate/frame/grandpa/src/mock.rs b/substrate/frame/grandpa/src/mock.rs index 4766d5c3780c..66cb4ed9b806 100644 --- a/substrate/frame/grandpa/src/mock.rs +++ b/substrate/frame/grandpa/src/mock.rs @@ -206,6 +206,7 @@ impl pallet_staking::Config for Test { type TargetList = pallet_staking::UseValidatorsMap; type NominationsQuota = pallet_staking::FixedNominationsQuota<16>; type MaxUnlockingChunks = ConstU32<32>; + type MaxControllersInBatch = (); type HistoryDepth = ConstU32<84>; type EventListeners = (); type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig; diff --git a/substrate/frame/offences/benchmarking/src/mock.rs b/substrate/frame/offences/benchmarking/src/mock.rs index 62ce1990112a..7069c8332ffd 100644 --- a/substrate/frame/offences/benchmarking/src/mock.rs +++ b/substrate/frame/offences/benchmarking/src/mock.rs @@ -185,6 +185,7 @@ impl pallet_staking::Config for Test { type TargetList = pallet_staking::UseValidatorsMap; type NominationsQuota = pallet_staking::FixedNominationsQuota<16>; type MaxUnlockingChunks = ConstU32<32>; + type MaxControllersInBatch = (); type HistoryDepth = ConstU32<84>; type EventListeners = (); type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig; diff --git a/substrate/frame/root-offences/src/mock.rs b/substrate/frame/root-offences/src/mock.rs index 5e04e9abc135..a70a31dc0d1d 100644 --- a/substrate/frame/root-offences/src/mock.rs +++ b/substrate/frame/root-offences/src/mock.rs @@ -188,6 +188,7 @@ impl pallet_staking::Config for Test { type NominationsQuota = pallet_staking::FixedNominationsQuota<16>; type MaxUnlockingChunks = ConstU32<32>; type HistoryDepth = ConstU32<84>; + type MaxControllersInBatch = (); type VoterList = pallet_staking::UseNominatorsAndValidatorsMap; type EventListeners = (); type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig; diff --git a/substrate/frame/session/benchmarking/src/mock.rs b/substrate/frame/session/benchmarking/src/mock.rs index 5c00d4bb4919..cae788a363ba 100644 --- a/substrate/frame/session/benchmarking/src/mock.rs +++ b/substrate/frame/session/benchmarking/src/mock.rs @@ -179,6 +179,7 @@ impl pallet_staking::Config for Test { type ElectionProvider = onchain::OnChainExecution; type GenesisElectionProvider = Self::ElectionProvider; type MaxUnlockingChunks = ConstU32<32>; + type MaxControllersInBatch = (); type HistoryDepth = ConstU32<84>; type VoterList = pallet_staking::UseNominatorsAndValidatorsMap; type TargetList = pallet_staking::UseValidatorsMap; From af012b6a7f944a66f774aea615f5ad253defe4d3 Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Sun, 3 Dec 2023 19:40:42 +0700 Subject: [PATCH 08/74] amend mocks --- .../election-provider-multi-phase/test-staking-e2e/src/mock.rs | 1 + substrate/frame/fast-unstake/src/mock.rs | 1 + substrate/frame/nomination-pools/test-staking/src/mock.rs | 1 + 3 files changed, 3 insertions(+) diff --git a/substrate/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs b/substrate/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs index 751ffc07aa5d..88d3c03c0cbd 100644 --- a/substrate/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs +++ b/substrate/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs @@ -276,6 +276,7 @@ impl pallet_staking::Config for Runtime { type NominationsQuota = pallet_staking::FixedNominationsQuota; type TargetList = pallet_staking::UseValidatorsMap; type MaxUnlockingChunks = ConstU32<32>; + type MaxControllersInBatch = (); type HistoryDepth = HistoryDepth; type EventListeners = (); type WeightInfo = pallet_staking::weights::SubstrateWeight; diff --git a/substrate/frame/fast-unstake/src/mock.rs b/substrate/frame/fast-unstake/src/mock.rs index 09a08f222b6b..b03a3ff15932 100644 --- a/substrate/frame/fast-unstake/src/mock.rs +++ b/substrate/frame/fast-unstake/src/mock.rs @@ -142,6 +142,7 @@ impl pallet_staking::Config for Runtime { type TargetList = pallet_staking::UseValidatorsMap; type NominationsQuota = pallet_staking::FixedNominationsQuota<16>; type MaxUnlockingChunks = ConstU32<32>; + type MaxControllersInBatch = (); type EventListeners = (); type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig; type WeightInfo = (); diff --git a/substrate/frame/nomination-pools/test-staking/src/mock.rs b/substrate/frame/nomination-pools/test-staking/src/mock.rs index ee24b53db067..8c02c2e369f4 100644 --- a/substrate/frame/nomination-pools/test-staking/src/mock.rs +++ b/substrate/frame/nomination-pools/test-staking/src/mock.rs @@ -134,6 +134,7 @@ impl pallet_staking::Config for Runtime { type TargetList = pallet_staking::UseValidatorsMap; type NominationsQuota = pallet_staking::FixedNominationsQuota<16>; type MaxUnlockingChunks = ConstU32<32>; + type MaxControllersInBatch = (); type HistoryDepth = ConstU32<84>; type EventListeners = Pools; type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig; From 68a75bb5ae8578c31a4a2c0dd35f84a890a988e6 Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Sun, 3 Dec 2023 19:49:38 +0700 Subject: [PATCH 09/74] benchmark tidy up --- substrate/frame/staking/src/benchmarking.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/substrate/frame/staking/src/benchmarking.rs b/substrate/frame/staking/src/benchmarking.rs index 4e6c8d0356f2..03e071a88e91 100644 --- a/substrate/frame/staking/src/benchmarking.rs +++ b/substrate/frame/staking/src/benchmarking.rs @@ -527,9 +527,9 @@ benchmarks! { deprecate_controller_batch { let mut controllers: Vec<_> = vec![]; - for n in 1..MaxControllersInBatch::get().into() { + for n in 1..T::MaxControllersInBatch::get() as u32 { let stash = n + 10000; - Ledger::::insert( + Ledger::::insert( n, StakingLedger { stash, @@ -540,25 +540,25 @@ benchmarks! { legacy_claimed_rewards: bounded_vec![], }, ); - Bonded::::insert(stash, n); + Bonded::::insert(stash, n); controllers.push(n); } - let bounded_controllers: BoundedVec<_, ::MaxControllersInBatch> = + let bounded_controllers: BoundedVec<_, T::MaxControllersInBatch> = BoundedVec::try_from(controllers).unwrap(); }: _(RawOrigin::Root, bounded_controllers) verify { - for n in 1..MaxControllersInBatch::get().into() { + for n in 1..T::MaxControllersInBatch::get() as u32 { let stash = n + 10000; // Ledger no longer keyed by controller. - assert_eq!(Ledger::::get(n), None); + assert_eq!(Ledger::::get(n), None); // Bonded now maps to the stash. - assert_eq!(Bonded::::get(stash), Some(stash)); + assert_eq!(Bonded::::get(stash), Some(stash)); // Ledger is now keyed by stash. - let ledger_updated = Ledger::::get(stash).unwrap(); + let ledger_updated = Ledger::::get(stash).unwrap(); assert_eq!(ledger_updated.stash, stash); // Check `active` and `total` values match the original ledger set by controller. From 4df272b01921b049836ae1e9c235eb560856e1d2 Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Sun, 3 Dec 2023 21:00:55 +0700 Subject: [PATCH 10/74] start test at account 1001 --- substrate/frame/staking/src/mock.rs | 2 +- substrate/frame/staking/src/tests.rs | 28 ++++++++++++++++------------ 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/substrate/frame/staking/src/mock.rs b/substrate/frame/staking/src/mock.rs index b3f6c3502940..f6668f6c0699 100644 --- a/substrate/frame/staking/src/mock.rs +++ b/substrate/frame/staking/src/mock.rs @@ -122,7 +122,7 @@ parameter_types! { pub static SlashDeferDuration: EraIndex = 0; pub static Period: BlockNumber = 5; pub static Offset: BlockNumber = 0; - pub static MaxControllersInBatch: u32 = 10; + pub static MaxControllersInBatch: u32 = 100; } #[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)] diff --git a/substrate/frame/staking/src/tests.rs b/substrate/frame/staking/src/tests.rs index 7340f4628837..93681720c3bf 100644 --- a/substrate/frame/staking/src/tests.rs +++ b/substrate/frame/staking/src/tests.rs @@ -6873,22 +6873,25 @@ mod ledger { ExtBuilder::default().build_and_execute(|| { // Given: + let start = 1001; let mut controllers: Vec<_> = vec![]; - for n in 1..MaxControllersInBatch::get().into() { - let stash = n + 10000; + for n in start..(start + MaxControllersInBatch::get()).into() { + let ctlr: u64 = n.into(); + let stash: u64 = (n + 10000).into(); + Ledger::::insert( - n, + ctlr, StakingLedger { stash, controller: None, - total: (1000 + n).into(), - active: (1000 + n).into(), + total: (1000 + ctlr).into(), + active: (1000 + ctlr).into(), unlocking: Default::default(), legacy_claimed_rewards: bounded_vec![], }, ); - Bonded::::insert(stash, n); - controllers.push(n); + Bonded::::insert(stash, ctlr); + controllers.push(ctlr); } // When: @@ -6903,11 +6906,12 @@ mod ledger { // Then: - for n in 1..MaxControllersInBatch::get().into() { - let stash = n + 10000; + for n in start..(start + MaxControllersInBatch::get()).into() { + let ctlr: u64 = n.into(); + let stash: u64 = (n + 10000).into(); // Ledger no longer keyed by controller. - assert_eq!(Ledger::::get(n), None); + assert_eq!(Ledger::::get(ctlr), None); // Bonded now maps to the stash. assert_eq!(Bonded::::get(stash), Some(stash)); @@ -6916,8 +6920,8 @@ mod ledger { assert_eq!(ledger_updated.stash, stash); // Check `active` and `total` values match the original ledger set by controller. - assert_eq!(ledger_updated.active, (1000 + n).into()); - assert_eq!(ledger_updated.total, (1000 + n).into()); + assert_eq!(ledger_updated.active, (1000 + ctlr).into()); + assert_eq!(ledger_updated.total, (1000 + ctlr).into()); } }) } From 759f3f4cfcb54d9fe5cc2a6e15e5cbaa80afdb93 Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Sun, 3 Dec 2023 21:03:53 +0700 Subject: [PATCH 11/74] some benchmark fixes --- substrate/frame/staking/src/benchmarking.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/substrate/frame/staking/src/benchmarking.rs b/substrate/frame/staking/src/benchmarking.rs index 03e071a88e91..9527d93d46c4 100644 --- a/substrate/frame/staking/src/benchmarking.rs +++ b/substrate/frame/staking/src/benchmarking.rs @@ -25,6 +25,7 @@ use codec::Decode; use frame_election_provider_support::{bounds::DataProviderBounds, SortedListProvider}; use frame_support::{ pallet_prelude::*, + storage::bounded_vec::BoundedVec, traits::{Currency, Get, Imbalance, UnfilteredDispatchable}, }; use sp_runtime::{ @@ -530,9 +531,9 @@ benchmarks! { for n in 1..T::MaxControllersInBatch::get() as u32 { let stash = n + 10000; Ledger::::insert( - n, + n.into(), StakingLedger { - stash, + stash: stash.into(), controller: None, total: (1000 + n).into(), active: (1000 + n).into(), @@ -540,8 +541,8 @@ benchmarks! { legacy_claimed_rewards: bounded_vec![], }, ); - Bonded::::insert(stash, n); - controllers.push(n); + Bonded::::insert(stash.into(), n.into()); + controllers.push(n.into()); } let bounded_controllers: BoundedVec<_, T::MaxControllersInBatch> = @@ -553,13 +554,13 @@ benchmarks! { let stash = n + 10000; // Ledger no longer keyed by controller. - assert_eq!(Ledger::::get(n), None); + assert_eq!(Ledger::::get(n.into()), None); // Bonded now maps to the stash. - assert_eq!(Bonded::::get(stash), Some(stash)); + assert_eq!(Bonded::::get(stash.into()), Some(stash.into())); // Ledger is now keyed by stash. - let ledger_updated = Ledger::::get(stash).unwrap(); - assert_eq!(ledger_updated.stash, stash); + let ledger_updated = Ledger::::get(stash.into()).unwrap(); + assert_eq!(ledger_updated.stash, stash.into()); // Check `active` and `total` values match the original ledger set by controller. assert_eq!(ledger_updated.active, (1000 + n).into()); From f72e1e3e19f2decbf4cf1f0a3cf1535e238d5423 Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Sun, 3 Dec 2023 21:18:53 +0700 Subject: [PATCH 12/74] benchmarks --- substrate/frame/staking/src/benchmarking.rs | 24 +++++++++++++-------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/substrate/frame/staking/src/benchmarking.rs b/substrate/frame/staking/src/benchmarking.rs index 9527d93d46c4..38ee2a001bc8 100644 --- a/substrate/frame/staking/src/benchmarking.rs +++ b/substrate/frame/staking/src/benchmarking.rs @@ -29,6 +29,7 @@ use frame_support::{ traits::{Currency, Get, Imbalance, UnfilteredDispatchable}, }; use sp_runtime::{ + bounded_vec, traits::{Bounded, One, StaticLookup, TrailingZeroInput, Zero}, Perbill, Percent, Saturating, }; @@ -529,11 +530,14 @@ benchmarks! { deprecate_controller_batch { let mut controllers: Vec<_> = vec![]; for n in 1..T::MaxControllersInBatch::get() as u32 { - let stash = n + 10000; + let stash_index = n + 10000; + let stash = create_funded_user::("stash_".to_owned() + &stash_index.to_string(), stash_index, 0); + let ctlr = create_funded_user::("controller_".to_owned() + &n.to_string(), n, 0); + Ledger::::insert( n.into(), StakingLedger { - stash: stash.into(), + stash, controller: None, total: (1000 + n).into(), active: (1000 + n).into(), @@ -541,8 +545,8 @@ benchmarks! { legacy_claimed_rewards: bounded_vec![], }, ); - Bonded::::insert(stash.into(), n.into()); - controllers.push(n.into()); + Bonded::::insert(stash, ctlr); + controllers.push(ctlr); } let bounded_controllers: BoundedVec<_, T::MaxControllersInBatch> = @@ -551,16 +555,18 @@ benchmarks! { }: _(RawOrigin::Root, bounded_controllers) verify { for n in 1..T::MaxControllersInBatch::get() as u32 { - let stash = n + 10000; + let stash_index = n + 10000; + let stash = create_funded_user::("stash_".to_owned() + &stash_index.to_string(), stash_index, 0); + let ctlr = create_funded_user::("controller_".to_owned() + &n.to_string(), n, 0); // Ledger no longer keyed by controller. - assert_eq!(Ledger::::get(n.into()), None); + assert_eq!(Ledger::::get(ctlr), None); // Bonded now maps to the stash. - assert_eq!(Bonded::::get(stash.into()), Some(stash.into())); + assert_eq!(Bonded::::get(stash), Some(stash)); // Ledger is now keyed by stash. - let ledger_updated = Ledger::::get(stash.into()).unwrap(); - assert_eq!(ledger_updated.stash, stash.into()); + let ledger_updated = Ledger::::get(stash).unwrap(); + assert_eq!(ledger_updated.stash, stash); // Check `active` and `total` values match the original ledger set by controller. assert_eq!(ledger_updated.active, (1000 + n).into()); From d75a2d0d25ea5cfb33c9a100e7c9dfcb60400f10 Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Sun, 3 Dec 2023 21:33:27 +0700 Subject: [PATCH 13/74] use create_unique_stash_controller --- substrate/frame/staking/src/benchmarking.rs | 29 ++++++++++++--------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/substrate/frame/staking/src/benchmarking.rs b/substrate/frame/staking/src/benchmarking.rs index 38ee2a001bc8..f0c8726efb7f 100644 --- a/substrate/frame/staking/src/benchmarking.rs +++ b/substrate/frame/staking/src/benchmarking.rs @@ -529,13 +529,18 @@ benchmarks! { deprecate_controller_batch { let mut controllers: Vec<_> = vec![]; - for n in 1..T::MaxControllersInBatch::get() as u32 { - let stash_index = n + 10000; - let stash = create_funded_user::("stash_".to_owned() + &stash_index.to_string(), stash_index, 0); - let ctlr = create_funded_user::("controller_".to_owned() + &n.to_string(), n, 0); + let mut stashes: Vec<_> = vec![]; + + for n in 0..T::MaxControllersInBatch::get() as u32 { + let (stash, controller) = create_unique_stash_controller::( + n, + 100, + RewardDestination::Staked, + false + )? Ledger::::insert( - n.into(), + controller, StakingLedger { stash, controller: None, @@ -545,8 +550,9 @@ benchmarks! { legacy_claimed_rewards: bounded_vec![], }, ); - Bonded::::insert(stash, ctlr); - controllers.push(ctlr); + Bonded::::insert(stash, controller); + controllers.push(controller); + stashes.push(stash); } let bounded_controllers: BoundedVec<_, T::MaxControllersInBatch> = @@ -554,13 +560,12 @@ benchmarks! { }: _(RawOrigin::Root, bounded_controllers) verify { - for n in 1..T::MaxControllersInBatch::get() as u32 { - let stash_index = n + 10000; - let stash = create_funded_user::("stash_".to_owned() + &stash_index.to_string(), stash_index, 0); - let ctlr = create_funded_user::("controller_".to_owned() + &n.to_string(), n, 0); + for n in 0..T::MaxControllersInBatch::get() as u32 { + let stash = stashes[n - 1]; + let controller = controllers[n - 1]; // Ledger no longer keyed by controller. - assert_eq!(Ledger::::get(ctlr), None); + assert_eq!(Ledger::::get(controller), None); // Bonded now maps to the stash. assert_eq!(Bonded::::get(stash), Some(stash)); From e8b2898134414e84865ff56397c4a06076088949 Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Sun, 3 Dec 2023 21:35:37 +0700 Subject: [PATCH 14/74] fmt --- substrate/frame/staking/src/benchmarking.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/substrate/frame/staking/src/benchmarking.rs b/substrate/frame/staking/src/benchmarking.rs index f0c8726efb7f..6188c4b8894a 100644 --- a/substrate/frame/staking/src/benchmarking.rs +++ b/substrate/frame/staking/src/benchmarking.rs @@ -533,9 +533,9 @@ benchmarks! { for n in 0..T::MaxControllersInBatch::get() as u32 { let (stash, controller) = create_unique_stash_controller::( - n, - 100, - RewardDestination::Staked, + n, + 100, + RewardDestination::Staked, false )? From 8f4fe14b884376da10bcb2ae61fdff77ce87cec7 Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Sun, 3 Dec 2023 22:06:22 +0700 Subject: [PATCH 15/74] fixes --- substrate/frame/staking/src/benchmarking.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/substrate/frame/staking/src/benchmarking.rs b/substrate/frame/staking/src/benchmarking.rs index 6188c4b8894a..2277933a6b9b 100644 --- a/substrate/frame/staking/src/benchmarking.rs +++ b/substrate/frame/staking/src/benchmarking.rs @@ -28,8 +28,8 @@ use frame_support::{ storage::bounded_vec::BoundedVec, traits::{Currency, Get, Imbalance, UnfilteredDispatchable}, }; +use sp_core::bounded_vec; use sp_runtime::{ - bounded_vec, traits::{Bounded, One, StaticLookup, TrailingZeroInput, Zero}, Perbill, Percent, Saturating, }; @@ -539,8 +539,7 @@ benchmarks! { false )? - Ledger::::insert( - controller, + Ledger::::insert(controller.clone(), StakingLedger { stash, controller: None, @@ -548,9 +547,9 @@ benchmarks! { active: (1000 + n).into(), unlocking: Default::default(), legacy_claimed_rewards: bounded_vec![], - }, + } ); - Bonded::::insert(stash, controller); + Bonded::::insert(stash, controller.clone()); controllers.push(controller); stashes.push(stash); } @@ -561,8 +560,8 @@ benchmarks! { }: _(RawOrigin::Root, bounded_controllers) verify { for n in 0..T::MaxControllersInBatch::get() as u32 { - let stash = stashes[n - 1]; - let controller = controllers[n - 1]; + let stash = stashes[n]; + let controller = controllers[n]; // Ledger no longer keyed by controller. assert_eq!(Ledger::::get(controller), None); From 186966bee607463e8d920902fc00e5d0d4480c30 Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Sun, 3 Dec 2023 23:21:42 +0700 Subject: [PATCH 16/74] fixes --- substrate/frame/staking/src/benchmarking.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/substrate/frame/staking/src/benchmarking.rs b/substrate/frame/staking/src/benchmarking.rs index 2277933a6b9b..b8e30fff10cb 100644 --- a/substrate/frame/staking/src/benchmarking.rs +++ b/substrate/frame/staking/src/benchmarking.rs @@ -28,8 +28,8 @@ use frame_support::{ storage::bounded_vec::BoundedVec, traits::{Currency, Get, Imbalance, UnfilteredDispatchable}, }; -use sp_core::bounded_vec; use sp_runtime::{ + bounded_vec, traits::{Bounded, One, StaticLookup, TrailingZeroInput, Zero}, Perbill, Percent, Saturating, }; @@ -560,8 +560,8 @@ benchmarks! { }: _(RawOrigin::Root, bounded_controllers) verify { for n in 0..T::MaxControllersInBatch::get() as u32 { - let stash = stashes[n]; - let controller = controllers[n]; + let stash = stashes[n as usize]; + let controller = controllers[n as usize]; // Ledger no longer keyed by controller. assert_eq!(Ledger::::get(controller), None); From 77b90caed71f66ef3e3714f074d7ccbbd45131a9 Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Sun, 3 Dec 2023 23:25:17 +0700 Subject: [PATCH 17/74] introduce i --- substrate/frame/staking/src/benchmarking.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/substrate/frame/staking/src/benchmarking.rs b/substrate/frame/staking/src/benchmarking.rs index b8e30fff10cb..c8d1f7fff243 100644 --- a/substrate/frame/staking/src/benchmarking.rs +++ b/substrate/frame/staking/src/benchmarking.rs @@ -528,10 +528,12 @@ benchmarks! { } deprecate_controller_batch { + let i in 1 .. T::MaxControllersInBatch::get(); + let mut controllers: Vec<_> = vec![]; let mut stashes: Vec<_> = vec![]; - for n in 0..T::MaxControllersInBatch::get() as u32 { + for n in 1..i as u32 { let (stash, controller) = create_unique_stash_controller::( n, 100, @@ -559,7 +561,7 @@ benchmarks! { }: _(RawOrigin::Root, bounded_controllers) verify { - for n in 0..T::MaxControllersInBatch::get() as u32 { + for n in 1..i as u32 { let stash = stashes[n as usize]; let controller = controllers[n as usize]; From 41df014aa6535905fbb3fb35f8a982fc8acd7e75 Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Sun, 3 Dec 2023 23:36:31 +0700 Subject: [PATCH 18/74] comments, use BoundedVec --- substrate/frame/staking/src/benchmarking.rs | 4 ++-- substrate/frame/staking/src/pallet/mod.rs | 11 +++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/substrate/frame/staking/src/benchmarking.rs b/substrate/frame/staking/src/benchmarking.rs index c8d1f7fff243..22324da9b7db 100644 --- a/substrate/frame/staking/src/benchmarking.rs +++ b/substrate/frame/staking/src/benchmarking.rs @@ -29,7 +29,6 @@ use frame_support::{ traits::{Currency, Get, Imbalance, UnfilteredDispatchable}, }; use sp_runtime::{ - bounded_vec, traits::{Bounded, One, StaticLookup, TrailingZeroInput, Zero}, Perbill, Percent, Saturating, }; @@ -528,6 +527,7 @@ benchmarks! { } deprecate_controller_batch { + // We pass a dynamic number of controllers to the benchmark, up to `MaxControllersInBatch`. let i in 1 .. T::MaxControllersInBatch::get(); let mut controllers: Vec<_> = vec![]; @@ -548,7 +548,7 @@ benchmarks! { total: (1000 + n).into(), active: (1000 + n).into(), unlocking: Default::default(), - legacy_claimed_rewards: bounded_vec![], + legacy_claimed_rewards: BoundedVec::default(), } ); Bonded::::insert(stash, controller.clone()); diff --git a/substrate/frame/staking/src/pallet/mod.rs b/substrate/frame/staking/src/pallet/mod.rs index ed959cfb1859..76279293f5b0 100644 --- a/substrate/frame/staking/src/pallet/mod.rs +++ b/substrate/frame/staking/src/pallet/mod.rs @@ -269,7 +269,7 @@ pub mod pallet { #[pallet::constant] type MaxUnlockingChunks: Get; - /// The maximum amount of controller accounts that can be deprecated in one batch. + /// The maximum amount of controller accounts that can be deprecated in one call. type MaxControllersInBatch: Get; /// Something that listens to staking updates and performs actions based on the data it @@ -1326,7 +1326,7 @@ pub mod pallet { pub fn set_controller(origin: OriginFor) -> DispatchResult { let stash = ensure_signed(origin)?; - // the bonded map and ledger are mutated directly as this extrinsic is related to a + // The bonded map and ledger are mutated directly as this extrinsic is related to a // (temporary) passive migration. Self::ledger(StakingAccount::Stash(stash.clone())).map(|ledger| { let controller = ledger.controller() @@ -1334,12 +1334,13 @@ pub mod pallet { .ok_or(Error::::NotController)?; if controller == stash { - // stash is already its own controller. + // Stash is already its own controller. return Err(Error::::AlreadyPaired.into()) } - // update bond and ledger. >::remove(controller); >::insert(&stash, &stash); + // The controller is never stored on-chain, and is instead derived from the `Bonded` storage + // item by `StakingLedger`. >::insert(&stash, StakingLedger { controller: None, ..ledger}); Ok(()) })? @@ -1946,6 +1947,8 @@ pub mod pallet { let ledger = Self::ledger(StakingAccount::Controller(controller.clone())); ledger.ok().map_or(None, |ledger| { if ledger.stash != *controller { + // Sets `controller` field back to `None`. The controller is never stored on-chain, + // and is instead derived from the `Bonded` storage item by `StakingLedger`. Some((controller.clone(), StakingLedger { controller: None, ..ledger })) } else { None From 3b3f7607b8575df079149b51173848b1356a98f2 Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Sun, 3 Dec 2023 23:38:57 +0700 Subject: [PATCH 19/74] fmt --- substrate/frame/staking/src/pallet/mod.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/substrate/frame/staking/src/pallet/mod.rs b/substrate/frame/staking/src/pallet/mod.rs index 76279293f5b0..d89fa3a1fc3e 100644 --- a/substrate/frame/staking/src/pallet/mod.rs +++ b/substrate/frame/staking/src/pallet/mod.rs @@ -1947,8 +1947,9 @@ pub mod pallet { let ledger = Self::ledger(StakingAccount::Controller(controller.clone())); ledger.ok().map_or(None, |ledger| { if ledger.stash != *controller { - // Sets `controller` field back to `None`. The controller is never stored on-chain, - // and is instead derived from the `Bonded` storage item by `StakingLedger`. + // Sets `controller` field back to `None`. The controller is never + // stored on-chain, and is instead derived from the `Bonded` storage + // item by `StakingLedger`. Some((controller.clone(), StakingLedger { controller: None, ..ledger })) } else { None From 85a2b7dd9d0306e6c168bf0be63b83975aefeca5 Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Sun, 3 Dec 2023 23:46:45 +0700 Subject: [PATCH 20/74] fix --- substrate/frame/staking/src/benchmarking.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/substrate/frame/staking/src/benchmarking.rs b/substrate/frame/staking/src/benchmarking.rs index 22324da9b7db..d984f7e1696d 100644 --- a/substrate/frame/staking/src/benchmarking.rs +++ b/substrate/frame/staking/src/benchmarking.rs @@ -539,7 +539,7 @@ benchmarks! { 100, RewardDestination::Staked, false - )? + )?; Ledger::::insert(controller.clone(), StakingLedger { From 24738d37532a0d364131bbca0346049860ba9745 Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Sun, 3 Dec 2023 23:48:39 +0700 Subject: [PATCH 21/74] tidy up benchmarl --- substrate/frame/staking/src/benchmarking.rs | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/substrate/frame/staking/src/benchmarking.rs b/substrate/frame/staking/src/benchmarking.rs index d984f7e1696d..b12fd65b32a0 100644 --- a/substrate/frame/staking/src/benchmarking.rs +++ b/substrate/frame/staking/src/benchmarking.rs @@ -540,25 +540,11 @@ benchmarks! { RewardDestination::Staked, false )?; - - Ledger::::insert(controller.clone(), - StakingLedger { - stash, - controller: None, - total: (1000 + n).into(), - active: (1000 + n).into(), - unlocking: Default::default(), - legacy_claimed_rewards: BoundedVec::default(), - } - ); - Bonded::::insert(stash, controller.clone()); controllers.push(controller); stashes.push(stash); } - let bounded_controllers: BoundedVec<_, T::MaxControllersInBatch> = BoundedVec::try_from(controllers).unwrap(); - }: _(RawOrigin::Root, bounded_controllers) verify { for n in 1..i as u32 { @@ -573,10 +559,6 @@ benchmarks! { // Ledger is now keyed by stash. let ledger_updated = Ledger::::get(stash).unwrap(); assert_eq!(ledger_updated.stash, stash); - - // Check `active` and `total` values match the original ledger set by controller. - assert_eq!(ledger_updated.active, (1000 + n).into()); - assert_eq!(ledger_updated.total, (1000 + n).into()); } } From e3646102dd947ac943025e9cfdb6e98c345424d6 Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Mon, 4 Dec 2023 00:02:27 +0700 Subject: [PATCH 22/74] more fixes --- substrate/frame/staking/src/benchmarking.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/substrate/frame/staking/src/benchmarking.rs b/substrate/frame/staking/src/benchmarking.rs index b12fd65b32a0..85d5c795f8bc 100644 --- a/substrate/frame/staking/src/benchmarking.rs +++ b/substrate/frame/staking/src/benchmarking.rs @@ -548,17 +548,17 @@ benchmarks! { }: _(RawOrigin::Root, bounded_controllers) verify { for n in 1..i as u32 { - let stash = stashes[n as usize]; - let controller = controllers[n as usize]; + let stash = &stashes[n as usize]; + let controller = &controllers[n as usize]; // Ledger no longer keyed by controller. assert_eq!(Ledger::::get(controller), None); // Bonded now maps to the stash. - assert_eq!(Bonded::::get(stash), Some(stash)); + assert_eq!(Bonded::::get(stash), Some(stash.clone())); // Ledger is now keyed by stash. let ledger_updated = Ledger::::get(stash).unwrap(); - assert_eq!(ledger_updated.stash, stash); + assert_eq!(ledger_updated.stash, *stash); } } From c98441952d1f5590a143f1b1ad596fec611b0f95 Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Mon, 4 Dec 2023 00:06:11 +0700 Subject: [PATCH 23/74] fix --- substrate/frame/staking/src/benchmarking.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/substrate/frame/staking/src/benchmarking.rs b/substrate/frame/staking/src/benchmarking.rs index 85d5c795f8bc..3d52d162157a 100644 --- a/substrate/frame/staking/src/benchmarking.rs +++ b/substrate/frame/staking/src/benchmarking.rs @@ -544,7 +544,7 @@ benchmarks! { stashes.push(stash); } let bounded_controllers: BoundedVec<_, T::MaxControllersInBatch> = - BoundedVec::try_from(controllers).unwrap(); + BoundedVec::try_from(controllers.clone()).unwrap(); }: _(RawOrigin::Root, bounded_controllers) verify { for n in 1..i as u32 { From 125389472c07ee8bc4fc1746fecb65f27f3a9553 Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Mon, 4 Dec 2023 00:17:08 +0700 Subject: [PATCH 24/74] amend runtime MaxControllersInBatch --- polkadot/runtime/westend/src/lib.rs | 2 +- substrate/bin/node/runtime/src/lib.rs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/polkadot/runtime/westend/src/lib.rs b/polkadot/runtime/westend/src/lib.rs index eb0f11e56a27..a58a4d7e1b12 100644 --- a/polkadot/runtime/westend/src/lib.rs +++ b/polkadot/runtime/westend/src/lib.rs @@ -681,7 +681,7 @@ parameter_types! { pub const MaxNominators: u32 = 64; pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(17); pub const MaxNominations: u32 = ::LIMIT as u32; - pub const MaxControllersInBatch: u32 = 10; + pub const MaxControllersInBatch: u32 = 100; } impl pallet_staking::Config for Runtime { diff --git a/substrate/bin/node/runtime/src/lib.rs b/substrate/bin/node/runtime/src/lib.rs index e2746b1c35bc..a2ae2523c363 100644 --- a/substrate/bin/node/runtime/src/lib.rs +++ b/substrate/bin/node/runtime/src/lib.rs @@ -634,6 +634,7 @@ parameter_types! { pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE; pub const MaxNominators: u32 = 64; pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(17); + pub const MaxControllersInBatch: u32 = 100; pub OffchainRepeat: BlockNumber = 5; pub HistoryDepth: u32 = 84; } @@ -676,6 +677,7 @@ impl pallet_staking::Config for Runtime { // This a placeholder, to be introduced in the next PR as an instance of bags-list type TargetList = pallet_staking::UseValidatorsMap; type MaxUnlockingChunks = ConstU32<32>; + type MaxControllersInBatch = MaxControllersInBatch; type HistoryDepth = HistoryDepth; type EventListeners = NominationPools; type WeightInfo = pallet_staking::weights::SubstrateWeight; From 99ab57d7880736fac9264fc29df3064c775966e7 Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Mon, 4 Dec 2023 09:05:03 +0700 Subject: [PATCH 25/74] rename --- polkadot/runtime/westend/src/lib.rs | 4 ++-- substrate/bin/node/runtime/src/lib.rs | 4 ++-- substrate/frame/babe/src/mock.rs | 2 +- substrate/frame/beefy/src/mock.rs | 2 +- .../test-staking-e2e/src/mock.rs | 2 +- substrate/frame/fast-unstake/src/mock.rs | 2 +- substrate/frame/grandpa/src/mock.rs | 2 +- substrate/frame/nomination-pools/test-staking/src/mock.rs | 2 +- substrate/frame/offences/benchmarking/src/mock.rs | 2 +- substrate/frame/root-offences/src/mock.rs | 2 +- substrate/frame/session/benchmarking/src/mock.rs | 2 +- substrate/frame/staking/src/benchmarking.rs | 6 +++--- substrate/frame/staking/src/mock.rs | 4 ++-- substrate/frame/staking/src/pallet/mod.rs | 4 ++-- substrate/frame/staking/src/tests.rs | 6 +++--- 15 files changed, 23 insertions(+), 23 deletions(-) diff --git a/polkadot/runtime/westend/src/lib.rs b/polkadot/runtime/westend/src/lib.rs index a58a4d7e1b12..144ae86fe5b9 100644 --- a/polkadot/runtime/westend/src/lib.rs +++ b/polkadot/runtime/westend/src/lib.rs @@ -681,7 +681,7 @@ parameter_types! { pub const MaxNominators: u32 = 64; pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(17); pub const MaxNominations: u32 = ::LIMIT as u32; - pub const MaxControllersInBatch: u32 = 100; + pub const MaxControllersInDeprecationBatch: u32 = 100; } impl pallet_staking::Config for Runtime { @@ -709,7 +709,7 @@ impl pallet_staking::Config for Runtime { type NominationsQuota = pallet_staking::FixedNominationsQuota<{ MaxNominations::get() }>; type MaxUnlockingChunks = frame_support::traits::ConstU32<32>; type HistoryDepth = frame_support::traits::ConstU32<84>; - type MaxControllersInBatch = MaxControllersInBatch; + type MaxControllersInDeprecationBatch = MaxControllersInDeprecationBatch; type BenchmarkingConfig = runtime_common::StakingBenchmarkingConfig; type EventListeners = NominationPools; type WeightInfo = weights::pallet_staking::WeightInfo; diff --git a/substrate/bin/node/runtime/src/lib.rs b/substrate/bin/node/runtime/src/lib.rs index a2ae2523c363..0347b3eb9912 100644 --- a/substrate/bin/node/runtime/src/lib.rs +++ b/substrate/bin/node/runtime/src/lib.rs @@ -634,7 +634,7 @@ parameter_types! { pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE; pub const MaxNominators: u32 = 64; pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(17); - pub const MaxControllersInBatch: u32 = 100; + pub const MaxControllersInDeprecationBatch: u32 = 100; pub OffchainRepeat: BlockNumber = 5; pub HistoryDepth: u32 = 84; } @@ -677,7 +677,7 @@ impl pallet_staking::Config for Runtime { // This a placeholder, to be introduced in the next PR as an instance of bags-list type TargetList = pallet_staking::UseValidatorsMap; type MaxUnlockingChunks = ConstU32<32>; - type MaxControllersInBatch = MaxControllersInBatch; + type MaxControllersInDeprecationBatch = MaxControllersInDeprecationBatch; type HistoryDepth = HistoryDepth; type EventListeners = NominationPools; type WeightInfo = pallet_staking::weights::SubstrateWeight; diff --git a/substrate/frame/babe/src/mock.rs b/substrate/frame/babe/src/mock.rs index f4658d1a674f..bb3a82cd73b7 100644 --- a/substrate/frame/babe/src/mock.rs +++ b/substrate/frame/babe/src/mock.rs @@ -183,7 +183,7 @@ impl pallet_staking::Config for Test { type TargetList = pallet_staking::UseValidatorsMap; type NominationsQuota = FixedNominationsQuota<16>; type MaxUnlockingChunks = ConstU32<32>; - type MaxControllersInBatch = (); + type MaxControllersInDeprecationBatch = (); type HistoryDepth = ConstU32<84>; type EventListeners = (); type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig; diff --git a/substrate/frame/beefy/src/mock.rs b/substrate/frame/beefy/src/mock.rs index a03f5d07bc46..e27e0ef2faec 100644 --- a/substrate/frame/beefy/src/mock.rs +++ b/substrate/frame/beefy/src/mock.rs @@ -201,7 +201,7 @@ impl pallet_staking::Config for Test { type TargetList = pallet_staking::UseValidatorsMap; type NominationsQuota = pallet_staking::FixedNominationsQuota<16>; type MaxUnlockingChunks = ConstU32<32>; - type MaxControllersInBatch = (); + type MaxControllersInDeprecationBatch = (); type HistoryDepth = ConstU32<84>; type EventListeners = (); type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig; diff --git a/substrate/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs b/substrate/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs index 88d3c03c0cbd..678a066d7b9c 100644 --- a/substrate/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs +++ b/substrate/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs @@ -276,7 +276,7 @@ impl pallet_staking::Config for Runtime { type NominationsQuota = pallet_staking::FixedNominationsQuota; type TargetList = pallet_staking::UseValidatorsMap; type MaxUnlockingChunks = ConstU32<32>; - type MaxControllersInBatch = (); + type MaxControllersInDeprecationBatch = (); type HistoryDepth = HistoryDepth; type EventListeners = (); type WeightInfo = pallet_staking::weights::SubstrateWeight; diff --git a/substrate/frame/fast-unstake/src/mock.rs b/substrate/frame/fast-unstake/src/mock.rs index b03a3ff15932..44ef24b833b0 100644 --- a/substrate/frame/fast-unstake/src/mock.rs +++ b/substrate/frame/fast-unstake/src/mock.rs @@ -142,7 +142,7 @@ impl pallet_staking::Config for Runtime { type TargetList = pallet_staking::UseValidatorsMap; type NominationsQuota = pallet_staking::FixedNominationsQuota<16>; type MaxUnlockingChunks = ConstU32<32>; - type MaxControllersInBatch = (); + type MaxControllersInDeprecationBatch = (); type EventListeners = (); type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig; type WeightInfo = (); diff --git a/substrate/frame/grandpa/src/mock.rs b/substrate/frame/grandpa/src/mock.rs index 66cb4ed9b806..89ffceac0e3b 100644 --- a/substrate/frame/grandpa/src/mock.rs +++ b/substrate/frame/grandpa/src/mock.rs @@ -206,7 +206,7 @@ impl pallet_staking::Config for Test { type TargetList = pallet_staking::UseValidatorsMap; type NominationsQuota = pallet_staking::FixedNominationsQuota<16>; type MaxUnlockingChunks = ConstU32<32>; - type MaxControllersInBatch = (); + type MaxControllersInDeprecationBatch = (); type HistoryDepth = ConstU32<84>; type EventListeners = (); type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig; diff --git a/substrate/frame/nomination-pools/test-staking/src/mock.rs b/substrate/frame/nomination-pools/test-staking/src/mock.rs index 8c02c2e369f4..aac0d54a30ad 100644 --- a/substrate/frame/nomination-pools/test-staking/src/mock.rs +++ b/substrate/frame/nomination-pools/test-staking/src/mock.rs @@ -134,7 +134,7 @@ impl pallet_staking::Config for Runtime { type TargetList = pallet_staking::UseValidatorsMap; type NominationsQuota = pallet_staking::FixedNominationsQuota<16>; type MaxUnlockingChunks = ConstU32<32>; - type MaxControllersInBatch = (); + type MaxControllersInDeprecationBatch = (); type HistoryDepth = ConstU32<84>; type EventListeners = Pools; type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig; diff --git a/substrate/frame/offences/benchmarking/src/mock.rs b/substrate/frame/offences/benchmarking/src/mock.rs index 7069c8332ffd..f9b67d753497 100644 --- a/substrate/frame/offences/benchmarking/src/mock.rs +++ b/substrate/frame/offences/benchmarking/src/mock.rs @@ -185,7 +185,7 @@ impl pallet_staking::Config for Test { type TargetList = pallet_staking::UseValidatorsMap; type NominationsQuota = pallet_staking::FixedNominationsQuota<16>; type MaxUnlockingChunks = ConstU32<32>; - type MaxControllersInBatch = (); + type MaxControllersInDeprecationBatch = (); type HistoryDepth = ConstU32<84>; type EventListeners = (); type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig; diff --git a/substrate/frame/root-offences/src/mock.rs b/substrate/frame/root-offences/src/mock.rs index a70a31dc0d1d..e4c375df8d70 100644 --- a/substrate/frame/root-offences/src/mock.rs +++ b/substrate/frame/root-offences/src/mock.rs @@ -188,7 +188,7 @@ impl pallet_staking::Config for Test { type NominationsQuota = pallet_staking::FixedNominationsQuota<16>; type MaxUnlockingChunks = ConstU32<32>; type HistoryDepth = ConstU32<84>; - type MaxControllersInBatch = (); + type MaxControllersInDeprecationBatch = (); type VoterList = pallet_staking::UseNominatorsAndValidatorsMap; type EventListeners = (); type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig; diff --git a/substrate/frame/session/benchmarking/src/mock.rs b/substrate/frame/session/benchmarking/src/mock.rs index cae788a363ba..c77b959535c5 100644 --- a/substrate/frame/session/benchmarking/src/mock.rs +++ b/substrate/frame/session/benchmarking/src/mock.rs @@ -179,7 +179,7 @@ impl pallet_staking::Config for Test { type ElectionProvider = onchain::OnChainExecution; type GenesisElectionProvider = Self::ElectionProvider; type MaxUnlockingChunks = ConstU32<32>; - type MaxControllersInBatch = (); + type MaxControllersInDeprecationBatch = (); type HistoryDepth = ConstU32<84>; type VoterList = pallet_staking::UseNominatorsAndValidatorsMap; type TargetList = pallet_staking::UseValidatorsMap; diff --git a/substrate/frame/staking/src/benchmarking.rs b/substrate/frame/staking/src/benchmarking.rs index 3d52d162157a..e3f517714f34 100644 --- a/substrate/frame/staking/src/benchmarking.rs +++ b/substrate/frame/staking/src/benchmarking.rs @@ -527,8 +527,8 @@ benchmarks! { } deprecate_controller_batch { - // We pass a dynamic number of controllers to the benchmark, up to `MaxControllersInBatch`. - let i in 1 .. T::MaxControllersInBatch::get(); + // We pass a dynamic number of controllers to the benchmark, up to `MaxControllersInDeprecationBatch`. + let i in 1 .. T::MaxControllersInDeprecationBatch::get(); let mut controllers: Vec<_> = vec![]; let mut stashes: Vec<_> = vec![]; @@ -543,7 +543,7 @@ benchmarks! { controllers.push(controller); stashes.push(stash); } - let bounded_controllers: BoundedVec<_, T::MaxControllersInBatch> = + let bounded_controllers: BoundedVec<_, T::MaxControllersInDeprecationBatch> = BoundedVec::try_from(controllers.clone()).unwrap(); }: _(RawOrigin::Root, bounded_controllers) verify { diff --git a/substrate/frame/staking/src/mock.rs b/substrate/frame/staking/src/mock.rs index f6668f6c0699..4feeb7fe6abf 100644 --- a/substrate/frame/staking/src/mock.rs +++ b/substrate/frame/staking/src/mock.rs @@ -122,7 +122,7 @@ parameter_types! { pub static SlashDeferDuration: EraIndex = 0; pub static Period: BlockNumber = 5; pub static Offset: BlockNumber = 0; - pub static MaxControllersInBatch: u32 = 100; + pub static MaxControllersInDeprecationBatch: u32 = 100; } #[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)] @@ -317,7 +317,7 @@ impl crate::pallet::pallet::Config for Test { type NominationsQuota = WeightedNominationsQuota<16>; type MaxUnlockingChunks = MaxUnlockingChunks; type HistoryDepth = HistoryDepth; - type MaxControllersInBatch = MaxControllersInBatch; + type MaxControllersInDeprecationBatch = MaxControllersInDeprecationBatch; type EventListeners = EventListenerMock; type BenchmarkingConfig = TestBenchmarkingConfig; type WeightInfo = (); diff --git a/substrate/frame/staking/src/pallet/mod.rs b/substrate/frame/staking/src/pallet/mod.rs index d89fa3a1fc3e..06ccc3cd52d1 100644 --- a/substrate/frame/staking/src/pallet/mod.rs +++ b/substrate/frame/staking/src/pallet/mod.rs @@ -270,7 +270,7 @@ pub mod pallet { type MaxUnlockingChunks: Get; /// The maximum amount of controller accounts that can be deprecated in one call. - type MaxControllersInBatch: Get; + type MaxControllersInDeprecationBatch: Get; /// Something that listens to staking updates and performs actions based on the data it /// receives. @@ -1936,7 +1936,7 @@ pub mod pallet { #[pallet::weight(T::WeightInfo::update_payee())] // TODO: insert real weight. pub fn deprecate_controller_batch( origin: OriginFor, - controllers: BoundedVec, + controllers: BoundedVec, ) -> DispatchResult { ensure_root(origin)?; diff --git a/substrate/frame/staking/src/tests.rs b/substrate/frame/staking/src/tests.rs index 93681720c3bf..a146ad52b589 100644 --- a/substrate/frame/staking/src/tests.rs +++ b/substrate/frame/staking/src/tests.rs @@ -6875,7 +6875,7 @@ mod ledger { let start = 1001; let mut controllers: Vec<_> = vec![]; - for n in start..(start + MaxControllersInBatch::get()).into() { + for n in start..(start + MaxControllersInDeprecationBatch::get()).into() { let ctlr: u64 = n.into(); let stash: u64 = (n + 10000).into(); @@ -6896,7 +6896,7 @@ mod ledger { // When: - let bounded_controllers: BoundedVec<_, ::MaxControllersInBatch> = + let bounded_controllers: BoundedVec<_, ::MaxControllersInDeprecationBatch> = BoundedVec::try_from(controllers).unwrap(); assert_ok!(Staking::deprecate_controller_batch( @@ -6906,7 +6906,7 @@ mod ledger { // Then: - for n in start..(start + MaxControllersInBatch::get()).into() { + for n in start..(start + MaxControllersInDeprecationBatch::get()).into() { let ctlr: u64 = n.into(); let stash: u64 = (n + 10000).into(); From 734722abfe0a91d32e04d611c594b0a58d70fa54 Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Mon, 4 Dec 2023 02:09:00 +0000 Subject: [PATCH 26/74] ".git/.scripts/commands/fmt/fmt.sh" --- substrate/frame/staking/src/tests.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/substrate/frame/staking/src/tests.rs b/substrate/frame/staking/src/tests.rs index a146ad52b589..b2198625c5de 100644 --- a/substrate/frame/staking/src/tests.rs +++ b/substrate/frame/staking/src/tests.rs @@ -6896,8 +6896,10 @@ mod ledger { // When: - let bounded_controllers: BoundedVec<_, ::MaxControllersInDeprecationBatch> = - BoundedVec::try_from(controllers).unwrap(); + let bounded_controllers: BoundedVec< + _, + ::MaxControllersInDeprecationBatch, + > = BoundedVec::try_from(controllers).unwrap(); assert_ok!(Staking::deprecate_controller_batch( RuntimeOrigin::root(), From ce6462e19f776cc4da68689589347d1646f286e3 Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Mon, 4 Dec 2023 09:20:50 +0700 Subject: [PATCH 27/74] add type --- substrate/frame/nomination-pools/benchmarking/src/mock.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/substrate/frame/nomination-pools/benchmarking/src/mock.rs b/substrate/frame/nomination-pools/benchmarking/src/mock.rs index 095df219dc84..2e32798522a3 100644 --- a/substrate/frame/nomination-pools/benchmarking/src/mock.rs +++ b/substrate/frame/nomination-pools/benchmarking/src/mock.rs @@ -119,6 +119,7 @@ impl pallet_staking::Config for Runtime { type VoterList = VoterList; type TargetList = pallet_staking::UseValidatorsMap; type NominationsQuota = pallet_staking::FixedNominationsQuota<16>; + type MaxControllersInDeprecationBatch = (); type MaxUnlockingChunks = ConstU32<32>; type HistoryDepth = ConstU32<84>; type EventListeners = Pools; From 5d9f1bea5e9e53ea6db16ad2d034ef87ca790339 Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Mon, 4 Dec 2023 09:32:41 +0700 Subject: [PATCH 28/74] test --- substrate/frame/staking/src/pallet/mod.rs | 50 +++++++++++------------ 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/substrate/frame/staking/src/pallet/mod.rs b/substrate/frame/staking/src/pallet/mod.rs index 06ccc3cd52d1..aa2162f93e79 100644 --- a/substrate/frame/staking/src/pallet/mod.rs +++ b/substrate/frame/staking/src/pallet/mod.rs @@ -1941,31 +1941,31 @@ pub mod pallet { ensure_root(origin)?; // Ignore controllers that do not exist or are already the same as stash. - let filtered_batch_with_ledger: Vec<_> = controllers - .iter() - .filter_map(|controller| { - let ledger = Self::ledger(StakingAccount::Controller(controller.clone())); - ledger.ok().map_or(None, |ledger| { - if ledger.stash != *controller { - // Sets `controller` field back to `None`. The controller is never - // stored on-chain, and is instead derived from the `Bonded` storage - // item by `StakingLedger`. - Some((controller.clone(), StakingLedger { controller: None, ..ledger })) - } else { - None - } - }) - }) - .collect(); - - // Update unique pairs. - for (controller, ledger) in filtered_batch_with_ledger { - let stash = ledger.stash.clone(); - - >::insert(&stash, &stash); - >::remove(controller); - >::insert(stash, ledger); - } + // let filtered_batch_with_ledger: Vec<_> = controllers + // .iter() + // .filter_map(|controller| { + // let ledger = Self::ledger(StakingAccount::Controller(controller.clone())); + // ledger.ok().map_or(None, |ledger| { + // if ledger.stash != *controller { + // // Sets `controller` field back to `None`. The controller is never + // // stored on-chain, and is instead derived from the `Bonded` storage + // // item by `StakingLedger`. + // Some((controller.clone(), StakingLedger { controller: None, ..ledger })) + // } else { + // None + // } + // }) + // }) + // .collect(); + + // // Update unique pairs. + // for (controller, ledger) in filtered_batch_with_ledger { + // let stash = ledger.stash.clone(); + + // >::insert(&stash, &stash); + // >::remove(controller); + // >::insert(stash, ledger); + // } Ok(()) } } From 3263180fa15e60ae321306df10c58209580be1f1 Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Mon, 4 Dec 2023 09:38:09 +0700 Subject: [PATCH 29/74] use u32 --- substrate/frame/babe/src/mock.rs | 2 +- substrate/frame/beefy/src/mock.rs | 2 +- .../election-provider-multi-phase/test-staking-e2e/src/mock.rs | 2 +- substrate/frame/fast-unstake/src/mock.rs | 2 +- substrate/frame/grandpa/src/mock.rs | 2 +- substrate/frame/nomination-pools/benchmarking/src/mock.rs | 2 +- substrate/frame/nomination-pools/test-staking/src/mock.rs | 2 +- substrate/frame/offences/benchmarking/src/mock.rs | 2 +- substrate/frame/root-offences/src/mock.rs | 2 +- substrate/frame/session/benchmarking/src/mock.rs | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/substrate/frame/babe/src/mock.rs b/substrate/frame/babe/src/mock.rs index bb3a82cd73b7..72abbc805db1 100644 --- a/substrate/frame/babe/src/mock.rs +++ b/substrate/frame/babe/src/mock.rs @@ -183,7 +183,7 @@ impl pallet_staking::Config for Test { type TargetList = pallet_staking::UseValidatorsMap; type NominationsQuota = FixedNominationsQuota<16>; type MaxUnlockingChunks = ConstU32<32>; - type MaxControllersInDeprecationBatch = (); + type MaxControllersInDeprecationBatch = ConstU32<100>; type HistoryDepth = ConstU32<84>; type EventListeners = (); type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig; diff --git a/substrate/frame/beefy/src/mock.rs b/substrate/frame/beefy/src/mock.rs index e27e0ef2faec..8dc30614c33b 100644 --- a/substrate/frame/beefy/src/mock.rs +++ b/substrate/frame/beefy/src/mock.rs @@ -201,7 +201,7 @@ impl pallet_staking::Config for Test { type TargetList = pallet_staking::UseValidatorsMap; type NominationsQuota = pallet_staking::FixedNominationsQuota<16>; type MaxUnlockingChunks = ConstU32<32>; - type MaxControllersInDeprecationBatch = (); + type MaxControllersInDeprecationBatch = ConstU32<100>; type HistoryDepth = ConstU32<84>; type EventListeners = (); type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig; diff --git a/substrate/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs b/substrate/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs index 678a066d7b9c..ecb2ae435b8c 100644 --- a/substrate/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs +++ b/substrate/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs @@ -276,7 +276,7 @@ impl pallet_staking::Config for Runtime { type NominationsQuota = pallet_staking::FixedNominationsQuota; type TargetList = pallet_staking::UseValidatorsMap; type MaxUnlockingChunks = ConstU32<32>; - type MaxControllersInDeprecationBatch = (); + type MaxControllersInDeprecationBatch = ConstU32<100>; type HistoryDepth = HistoryDepth; type EventListeners = (); type WeightInfo = pallet_staking::weights::SubstrateWeight; diff --git a/substrate/frame/fast-unstake/src/mock.rs b/substrate/frame/fast-unstake/src/mock.rs index 44ef24b833b0..f9326919fd3e 100644 --- a/substrate/frame/fast-unstake/src/mock.rs +++ b/substrate/frame/fast-unstake/src/mock.rs @@ -142,7 +142,7 @@ impl pallet_staking::Config for Runtime { type TargetList = pallet_staking::UseValidatorsMap; type NominationsQuota = pallet_staking::FixedNominationsQuota<16>; type MaxUnlockingChunks = ConstU32<32>; - type MaxControllersInDeprecationBatch = (); + type MaxControllersInDeprecationBatch = ConstU32<100>; type EventListeners = (); type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig; type WeightInfo = (); diff --git a/substrate/frame/grandpa/src/mock.rs b/substrate/frame/grandpa/src/mock.rs index 89ffceac0e3b..f1f51e0b1181 100644 --- a/substrate/frame/grandpa/src/mock.rs +++ b/substrate/frame/grandpa/src/mock.rs @@ -206,7 +206,7 @@ impl pallet_staking::Config for Test { type TargetList = pallet_staking::UseValidatorsMap; type NominationsQuota = pallet_staking::FixedNominationsQuota<16>; type MaxUnlockingChunks = ConstU32<32>; - type MaxControllersInDeprecationBatch = (); + type MaxControllersInDeprecationBatch = ConstU32<100>; type HistoryDepth = ConstU32<84>; type EventListeners = (); type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig; diff --git a/substrate/frame/nomination-pools/benchmarking/src/mock.rs b/substrate/frame/nomination-pools/benchmarking/src/mock.rs index 2e32798522a3..c58a66f6163a 100644 --- a/substrate/frame/nomination-pools/benchmarking/src/mock.rs +++ b/substrate/frame/nomination-pools/benchmarking/src/mock.rs @@ -119,7 +119,7 @@ impl pallet_staking::Config for Runtime { type VoterList = VoterList; type TargetList = pallet_staking::UseValidatorsMap; type NominationsQuota = pallet_staking::FixedNominationsQuota<16>; - type MaxControllersInDeprecationBatch = (); + type MaxControllersInDeprecationBatch = ConstU32<100>; type MaxUnlockingChunks = ConstU32<32>; type HistoryDepth = ConstU32<84>; type EventListeners = Pools; diff --git a/substrate/frame/nomination-pools/test-staking/src/mock.rs b/substrate/frame/nomination-pools/test-staking/src/mock.rs index aac0d54a30ad..491cd6191619 100644 --- a/substrate/frame/nomination-pools/test-staking/src/mock.rs +++ b/substrate/frame/nomination-pools/test-staking/src/mock.rs @@ -134,7 +134,7 @@ impl pallet_staking::Config for Runtime { type TargetList = pallet_staking::UseValidatorsMap; type NominationsQuota = pallet_staking::FixedNominationsQuota<16>; type MaxUnlockingChunks = ConstU32<32>; - type MaxControllersInDeprecationBatch = (); + type MaxControllersInDeprecationBatch = ConstU32<100>; type HistoryDepth = ConstU32<84>; type EventListeners = Pools; type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig; diff --git a/substrate/frame/offences/benchmarking/src/mock.rs b/substrate/frame/offences/benchmarking/src/mock.rs index f9b67d753497..1d642b9b4982 100644 --- a/substrate/frame/offences/benchmarking/src/mock.rs +++ b/substrate/frame/offences/benchmarking/src/mock.rs @@ -185,7 +185,7 @@ impl pallet_staking::Config for Test { type TargetList = pallet_staking::UseValidatorsMap; type NominationsQuota = pallet_staking::FixedNominationsQuota<16>; type MaxUnlockingChunks = ConstU32<32>; - type MaxControllersInDeprecationBatch = (); + type MaxControllersInDeprecationBatch = ConstU32<100>; type HistoryDepth = ConstU32<84>; type EventListeners = (); type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig; diff --git a/substrate/frame/root-offences/src/mock.rs b/substrate/frame/root-offences/src/mock.rs index e4c375df8d70..c0c83dd08d24 100644 --- a/substrate/frame/root-offences/src/mock.rs +++ b/substrate/frame/root-offences/src/mock.rs @@ -188,7 +188,7 @@ impl pallet_staking::Config for Test { type NominationsQuota = pallet_staking::FixedNominationsQuota<16>; type MaxUnlockingChunks = ConstU32<32>; type HistoryDepth = ConstU32<84>; - type MaxControllersInDeprecationBatch = (); + type MaxControllersInDeprecationBatch = ConstU32<100>; type VoterList = pallet_staking::UseNominatorsAndValidatorsMap; type EventListeners = (); type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig; diff --git a/substrate/frame/session/benchmarking/src/mock.rs b/substrate/frame/session/benchmarking/src/mock.rs index c77b959535c5..e1744fa43abb 100644 --- a/substrate/frame/session/benchmarking/src/mock.rs +++ b/substrate/frame/session/benchmarking/src/mock.rs @@ -179,7 +179,7 @@ impl pallet_staking::Config for Test { type ElectionProvider = onchain::OnChainExecution; type GenesisElectionProvider = Self::ElectionProvider; type MaxUnlockingChunks = ConstU32<32>; - type MaxControllersInDeprecationBatch = (); + type MaxControllersInDeprecationBatch = ConstU32<100>; type HistoryDepth = ConstU32<84>; type VoterList = pallet_staking::UseNominatorsAndValidatorsMap; type TargetList = pallet_staking::UseValidatorsMap; From 16faf72340fa2751024871c50b22a3b95f2a8423 Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Mon, 4 Dec 2023 09:47:07 +0700 Subject: [PATCH 30/74] uncomment --- substrate/frame/staking/src/pallet/mod.rs | 50 +++++++++++------------ 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/substrate/frame/staking/src/pallet/mod.rs b/substrate/frame/staking/src/pallet/mod.rs index aa2162f93e79..06ccc3cd52d1 100644 --- a/substrate/frame/staking/src/pallet/mod.rs +++ b/substrate/frame/staking/src/pallet/mod.rs @@ -1941,31 +1941,31 @@ pub mod pallet { ensure_root(origin)?; // Ignore controllers that do not exist or are already the same as stash. - // let filtered_batch_with_ledger: Vec<_> = controllers - // .iter() - // .filter_map(|controller| { - // let ledger = Self::ledger(StakingAccount::Controller(controller.clone())); - // ledger.ok().map_or(None, |ledger| { - // if ledger.stash != *controller { - // // Sets `controller` field back to `None`. The controller is never - // // stored on-chain, and is instead derived from the `Bonded` storage - // // item by `StakingLedger`. - // Some((controller.clone(), StakingLedger { controller: None, ..ledger })) - // } else { - // None - // } - // }) - // }) - // .collect(); - - // // Update unique pairs. - // for (controller, ledger) in filtered_batch_with_ledger { - // let stash = ledger.stash.clone(); - - // >::insert(&stash, &stash); - // >::remove(controller); - // >::insert(stash, ledger); - // } + let filtered_batch_with_ledger: Vec<_> = controllers + .iter() + .filter_map(|controller| { + let ledger = Self::ledger(StakingAccount::Controller(controller.clone())); + ledger.ok().map_or(None, |ledger| { + if ledger.stash != *controller { + // Sets `controller` field back to `None`. The controller is never + // stored on-chain, and is instead derived from the `Bonded` storage + // item by `StakingLedger`. + Some((controller.clone(), StakingLedger { controller: None, ..ledger })) + } else { + None + } + }) + }) + .collect(); + + // Update unique pairs. + for (controller, ledger) in filtered_batch_with_ledger { + let stash = ledger.stash.clone(); + + >::insert(&stash, &stash); + >::remove(controller); + >::insert(stash, ledger); + } Ok(()) } } From 5dcac5aadbd6ebf5e9f7015012f89e80c7d2f585 Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Mon, 4 Dec 2023 10:00:01 +0700 Subject: [PATCH 31/74] try using parameter_types! --- substrate/frame/babe/src/mock.rs | 3 ++- substrate/frame/beefy/src/mock.rs | 3 ++- .../election-provider-multi-phase/test-staking-e2e/src/mock.rs | 3 ++- substrate/frame/fast-unstake/src/mock.rs | 3 ++- substrate/frame/grandpa/src/mock.rs | 3 ++- substrate/frame/nomination-pools/benchmarking/src/mock.rs | 3 ++- substrate/frame/nomination-pools/test-staking/src/mock.rs | 3 ++- substrate/frame/offences/benchmarking/src/mock.rs | 3 ++- substrate/frame/root-offences/src/mock.rs | 3 ++- substrate/frame/session/benchmarking/src/mock.rs | 3 ++- 10 files changed, 20 insertions(+), 10 deletions(-) diff --git a/substrate/frame/babe/src/mock.rs b/substrate/frame/babe/src/mock.rs index 72abbc805db1..d6f7cc25bba2 100644 --- a/substrate/frame/babe/src/mock.rs +++ b/substrate/frame/babe/src/mock.rs @@ -146,6 +146,7 @@ parameter_types! { pub const SlashDeferDuration: EraIndex = 0; pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE; pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(16); + pub const MaxControllersInDeprecationBatch: u32 = 100; pub static ElectionsBounds: ElectionBounds = ElectionBoundsBuilder::default().build(); } @@ -183,7 +184,7 @@ impl pallet_staking::Config for Test { type TargetList = pallet_staking::UseValidatorsMap; type NominationsQuota = FixedNominationsQuota<16>; type MaxUnlockingChunks = ConstU32<32>; - type MaxControllersInDeprecationBatch = ConstU32<100>; + type MaxControllersInDeprecationBatch = MaxControllersInDeprecationBatch; type HistoryDepth = ConstU32<84>; type EventListeners = (); type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig; diff --git a/substrate/frame/beefy/src/mock.rs b/substrate/frame/beefy/src/mock.rs index 8dc30614c33b..d3a7921ff919 100644 --- a/substrate/frame/beefy/src/mock.rs +++ b/substrate/frame/beefy/src/mock.rs @@ -164,6 +164,7 @@ parameter_types! { pub const BondingDuration: EraIndex = 3; pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE; pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(17); + pub const MaxControllersInDeprecationBatch: u32 = 100; pub static ElectionsBoundsOnChain: ElectionBounds = ElectionBoundsBuilder::default().build(); } @@ -201,7 +202,7 @@ impl pallet_staking::Config for Test { type TargetList = pallet_staking::UseValidatorsMap; type NominationsQuota = pallet_staking::FixedNominationsQuota<16>; type MaxUnlockingChunks = ConstU32<32>; - type MaxControllersInDeprecationBatch = ConstU32<100>; + type MaxControllersInDeprecationBatch = MaxControllersInDeprecationBatch; type HistoryDepth = ConstU32<84>; type EventListeners = (); type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig; diff --git a/substrate/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs b/substrate/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs index ecb2ae435b8c..0b7270c31dfa 100644 --- a/substrate/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs +++ b/substrate/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs @@ -238,6 +238,7 @@ parameter_types! { pub const BondingDuration: sp_staking::EraIndex = 28; pub const SlashDeferDuration: sp_staking::EraIndex = 7; // 1/4 the bonding duration. pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(40); + pub const MaxControllersInDeprecationBatch: u32 = 100; pub HistoryDepth: u32 = 84; } @@ -276,7 +277,7 @@ impl pallet_staking::Config for Runtime { type NominationsQuota = pallet_staking::FixedNominationsQuota; type TargetList = pallet_staking::UseValidatorsMap; type MaxUnlockingChunks = ConstU32<32>; - type MaxControllersInDeprecationBatch = ConstU32<100>; + type MaxControllersInDeprecationBatch = MaxControllersInDeprecationBatch; type HistoryDepth = HistoryDepth; type EventListeners = (); type WeightInfo = pallet_staking::weights::SubstrateWeight; diff --git a/substrate/frame/fast-unstake/src/mock.rs b/substrate/frame/fast-unstake/src/mock.rs index f9326919fd3e..d5e1304447be 100644 --- a/substrate/frame/fast-unstake/src/mock.rs +++ b/substrate/frame/fast-unstake/src/mock.rs @@ -93,6 +93,7 @@ pallet_staking_reward_curve::build! { parameter_types! { pub const RewardCurve: &'static sp_runtime::curve::PiecewiseLinear<'static> = &I_NPOS; + pub const MaxControllersInDeprecationBatch: u32 = 100; pub static BondingDuration: u32 = 3; pub static CurrentEra: u32 = 0; pub static Ongoing: bool = false; @@ -142,7 +143,7 @@ impl pallet_staking::Config for Runtime { type TargetList = pallet_staking::UseValidatorsMap; type NominationsQuota = pallet_staking::FixedNominationsQuota<16>; type MaxUnlockingChunks = ConstU32<32>; - type MaxControllersInDeprecationBatch = ConstU32<100>; + type MaxControllersInDeprecationBatch = MaxControllersInDeprecationBatch; type EventListeners = (); type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig; type WeightInfo = (); diff --git a/substrate/frame/grandpa/src/mock.rs b/substrate/frame/grandpa/src/mock.rs index f1f51e0b1181..afb489850f31 100644 --- a/substrate/frame/grandpa/src/mock.rs +++ b/substrate/frame/grandpa/src/mock.rs @@ -169,6 +169,7 @@ parameter_types! { pub const BondingDuration: EraIndex = 3; pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE; pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(17); + pub const MaxControllersInDeprecationBatch: u32 = 100; pub static ElectionsBoundsOnChain: ElectionBounds = ElectionBoundsBuilder::default().build(); } @@ -206,7 +207,7 @@ impl pallet_staking::Config for Test { type TargetList = pallet_staking::UseValidatorsMap; type NominationsQuota = pallet_staking::FixedNominationsQuota<16>; type MaxUnlockingChunks = ConstU32<32>; - type MaxControllersInDeprecationBatch = ConstU32<100>; + type MaxControllersInDeprecationBatch = MaxControllersInDeprecationBatch; type HistoryDepth = ConstU32<84>; type EventListeners = (); type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig; diff --git a/substrate/frame/nomination-pools/benchmarking/src/mock.rs b/substrate/frame/nomination-pools/benchmarking/src/mock.rs index c58a66f6163a..bd975b9b773f 100644 --- a/substrate/frame/nomination-pools/benchmarking/src/mock.rs +++ b/substrate/frame/nomination-pools/benchmarking/src/mock.rs @@ -94,6 +94,7 @@ pallet_staking_reward_curve::build! { } parameter_types! { pub const RewardCurve: &'static sp_runtime::curve::PiecewiseLinear<'static> = &I_NPOS; + pub const MaxControllersInDeprecationBatch: u32 = 100; } impl pallet_staking::Config for Runtime { type Currency = Balances; @@ -119,7 +120,7 @@ impl pallet_staking::Config for Runtime { type VoterList = VoterList; type TargetList = pallet_staking::UseValidatorsMap; type NominationsQuota = pallet_staking::FixedNominationsQuota<16>; - type MaxControllersInDeprecationBatch = ConstU32<100>; + type MaxControllersInDeprecationBatch = MaxControllersInDeprecationBatch; type MaxUnlockingChunks = ConstU32<32>; type HistoryDepth = ConstU32<84>; type EventListeners = Pools; diff --git a/substrate/frame/nomination-pools/test-staking/src/mock.rs b/substrate/frame/nomination-pools/test-staking/src/mock.rs index 491cd6191619..fa2a1b593854 100644 --- a/substrate/frame/nomination-pools/test-staking/src/mock.rs +++ b/substrate/frame/nomination-pools/test-staking/src/mock.rs @@ -106,6 +106,7 @@ pallet_staking_reward_curve::build! { parameter_types! { pub const RewardCurve: &'static sp_runtime::curve::PiecewiseLinear<'static> = &I_NPOS; + pub const MaxControllersInDeprecationBatch: u32 = 100; pub static BondingDuration: u32 = 3; } @@ -134,7 +135,7 @@ impl pallet_staking::Config for Runtime { type TargetList = pallet_staking::UseValidatorsMap; type NominationsQuota = pallet_staking::FixedNominationsQuota<16>; type MaxUnlockingChunks = ConstU32<32>; - type MaxControllersInDeprecationBatch = ConstU32<100>; + type MaxControllersInDeprecationBatch = MaxControllersInDeprecationBatch; type HistoryDepth = ConstU32<84>; type EventListeners = Pools; type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig; diff --git a/substrate/frame/offences/benchmarking/src/mock.rs b/substrate/frame/offences/benchmarking/src/mock.rs index 1d642b9b4982..99919875586e 100644 --- a/substrate/frame/offences/benchmarking/src/mock.rs +++ b/substrate/frame/offences/benchmarking/src/mock.rs @@ -146,6 +146,7 @@ pallet_staking_reward_curve::build! { } parameter_types! { pub const RewardCurve: &'static sp_runtime::curve::PiecewiseLinear<'static> = &I_NPOS; + pub const MaxControllersInDeprecationBatch: u32 = 100; pub static ElectionsBounds: ElectionBounds = ElectionBoundsBuilder::default().build(); } @@ -185,7 +186,7 @@ impl pallet_staking::Config for Test { type TargetList = pallet_staking::UseValidatorsMap; type NominationsQuota = pallet_staking::FixedNominationsQuota<16>; type MaxUnlockingChunks = ConstU32<32>; - type MaxControllersInDeprecationBatch = ConstU32<100>; + type MaxControllersInDeprecationBatch = MaxControllersInDeprecationBatch; type HistoryDepth = ConstU32<84>; type EventListeners = (); type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig; diff --git a/substrate/frame/root-offences/src/mock.rs b/substrate/frame/root-offences/src/mock.rs index c0c83dd08d24..e794a29a1781 100644 --- a/substrate/frame/root-offences/src/mock.rs +++ b/substrate/frame/root-offences/src/mock.rs @@ -162,6 +162,7 @@ parameter_types! { pub const BondingDuration: EraIndex = 3; pub static LedgerSlashPerEra: (BalanceOf, BTreeMap>) = (Zero::zero(), BTreeMap::new()); pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(75); + pub const MaxControllersInDeprecationBatch: u32 = 100; } impl pallet_staking::Config for Test { @@ -188,7 +189,7 @@ impl pallet_staking::Config for Test { type NominationsQuota = pallet_staking::FixedNominationsQuota<16>; type MaxUnlockingChunks = ConstU32<32>; type HistoryDepth = ConstU32<84>; - type MaxControllersInDeprecationBatch = ConstU32<100>; + type MaxControllersInDeprecationBatch = MaxControllersInDeprecationBatch; type VoterList = pallet_staking::UseNominatorsAndValidatorsMap; type EventListeners = (); type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig; diff --git a/substrate/frame/session/benchmarking/src/mock.rs b/substrate/frame/session/benchmarking/src/mock.rs index e1744fa43abb..fee1c50a76b1 100644 --- a/substrate/frame/session/benchmarking/src/mock.rs +++ b/substrate/frame/session/benchmarking/src/mock.rs @@ -145,6 +145,7 @@ pallet_staking_reward_curve::build! { } parameter_types! { pub const RewardCurve: &'static sp_runtime::curve::PiecewiseLinear<'static> = &I_NPOS; + pub const MaxControllersInDeprecationBatch: u32 = 100; pub static ElectionsBounds: ElectionBounds = ElectionBoundsBuilder::default().build(); } @@ -179,7 +180,7 @@ impl pallet_staking::Config for Test { type ElectionProvider = onchain::OnChainExecution; type GenesisElectionProvider = Self::ElectionProvider; type MaxUnlockingChunks = ConstU32<32>; - type MaxControllersInDeprecationBatch = ConstU32<100>; + type MaxControllersInDeprecationBatch = MaxControllersInDeprecationBatch; type HistoryDepth = ConstU32<84>; type VoterList = pallet_staking::UseNominatorsAndValidatorsMap; type TargetList = pallet_staking::UseValidatorsMap; From 6b6363fa3fa9bc64ae0d82fa9106eab89c9ba8cc Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Mon, 4 Dec 2023 10:11:52 +0700 Subject: [PATCH 32/74] Revert "try using parameter_types!" This reverts commit 5dcac5aadbd6ebf5e9f7015012f89e80c7d2f585. --- substrate/frame/babe/src/mock.rs | 3 +-- substrate/frame/beefy/src/mock.rs | 3 +-- .../election-provider-multi-phase/test-staking-e2e/src/mock.rs | 3 +-- substrate/frame/fast-unstake/src/mock.rs | 3 +-- substrate/frame/grandpa/src/mock.rs | 3 +-- substrate/frame/nomination-pools/benchmarking/src/mock.rs | 3 +-- substrate/frame/nomination-pools/test-staking/src/mock.rs | 3 +-- substrate/frame/offences/benchmarking/src/mock.rs | 3 +-- substrate/frame/root-offences/src/mock.rs | 3 +-- substrate/frame/session/benchmarking/src/mock.rs | 3 +-- 10 files changed, 10 insertions(+), 20 deletions(-) diff --git a/substrate/frame/babe/src/mock.rs b/substrate/frame/babe/src/mock.rs index d6f7cc25bba2..72abbc805db1 100644 --- a/substrate/frame/babe/src/mock.rs +++ b/substrate/frame/babe/src/mock.rs @@ -146,7 +146,6 @@ parameter_types! { pub const SlashDeferDuration: EraIndex = 0; pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE; pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(16); - pub const MaxControllersInDeprecationBatch: u32 = 100; pub static ElectionsBounds: ElectionBounds = ElectionBoundsBuilder::default().build(); } @@ -184,7 +183,7 @@ impl pallet_staking::Config for Test { type TargetList = pallet_staking::UseValidatorsMap; type NominationsQuota = FixedNominationsQuota<16>; type MaxUnlockingChunks = ConstU32<32>; - type MaxControllersInDeprecationBatch = MaxControllersInDeprecationBatch; + type MaxControllersInDeprecationBatch = ConstU32<100>; type HistoryDepth = ConstU32<84>; type EventListeners = (); type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig; diff --git a/substrate/frame/beefy/src/mock.rs b/substrate/frame/beefy/src/mock.rs index d3a7921ff919..8dc30614c33b 100644 --- a/substrate/frame/beefy/src/mock.rs +++ b/substrate/frame/beefy/src/mock.rs @@ -164,7 +164,6 @@ parameter_types! { pub const BondingDuration: EraIndex = 3; pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE; pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(17); - pub const MaxControllersInDeprecationBatch: u32 = 100; pub static ElectionsBoundsOnChain: ElectionBounds = ElectionBoundsBuilder::default().build(); } @@ -202,7 +201,7 @@ impl pallet_staking::Config for Test { type TargetList = pallet_staking::UseValidatorsMap; type NominationsQuota = pallet_staking::FixedNominationsQuota<16>; type MaxUnlockingChunks = ConstU32<32>; - type MaxControllersInDeprecationBatch = MaxControllersInDeprecationBatch; + type MaxControllersInDeprecationBatch = ConstU32<100>; type HistoryDepth = ConstU32<84>; type EventListeners = (); type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig; diff --git a/substrate/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs b/substrate/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs index 0b7270c31dfa..ecb2ae435b8c 100644 --- a/substrate/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs +++ b/substrate/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs @@ -238,7 +238,6 @@ parameter_types! { pub const BondingDuration: sp_staking::EraIndex = 28; pub const SlashDeferDuration: sp_staking::EraIndex = 7; // 1/4 the bonding duration. pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(40); - pub const MaxControllersInDeprecationBatch: u32 = 100; pub HistoryDepth: u32 = 84; } @@ -277,7 +276,7 @@ impl pallet_staking::Config for Runtime { type NominationsQuota = pallet_staking::FixedNominationsQuota; type TargetList = pallet_staking::UseValidatorsMap; type MaxUnlockingChunks = ConstU32<32>; - type MaxControllersInDeprecationBatch = MaxControllersInDeprecationBatch; + type MaxControllersInDeprecationBatch = ConstU32<100>; type HistoryDepth = HistoryDepth; type EventListeners = (); type WeightInfo = pallet_staking::weights::SubstrateWeight; diff --git a/substrate/frame/fast-unstake/src/mock.rs b/substrate/frame/fast-unstake/src/mock.rs index d5e1304447be..f9326919fd3e 100644 --- a/substrate/frame/fast-unstake/src/mock.rs +++ b/substrate/frame/fast-unstake/src/mock.rs @@ -93,7 +93,6 @@ pallet_staking_reward_curve::build! { parameter_types! { pub const RewardCurve: &'static sp_runtime::curve::PiecewiseLinear<'static> = &I_NPOS; - pub const MaxControllersInDeprecationBatch: u32 = 100; pub static BondingDuration: u32 = 3; pub static CurrentEra: u32 = 0; pub static Ongoing: bool = false; @@ -143,7 +142,7 @@ impl pallet_staking::Config for Runtime { type TargetList = pallet_staking::UseValidatorsMap; type NominationsQuota = pallet_staking::FixedNominationsQuota<16>; type MaxUnlockingChunks = ConstU32<32>; - type MaxControllersInDeprecationBatch = MaxControllersInDeprecationBatch; + type MaxControllersInDeprecationBatch = ConstU32<100>; type EventListeners = (); type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig; type WeightInfo = (); diff --git a/substrate/frame/grandpa/src/mock.rs b/substrate/frame/grandpa/src/mock.rs index afb489850f31..f1f51e0b1181 100644 --- a/substrate/frame/grandpa/src/mock.rs +++ b/substrate/frame/grandpa/src/mock.rs @@ -169,7 +169,6 @@ parameter_types! { pub const BondingDuration: EraIndex = 3; pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE; pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(17); - pub const MaxControllersInDeprecationBatch: u32 = 100; pub static ElectionsBoundsOnChain: ElectionBounds = ElectionBoundsBuilder::default().build(); } @@ -207,7 +206,7 @@ impl pallet_staking::Config for Test { type TargetList = pallet_staking::UseValidatorsMap; type NominationsQuota = pallet_staking::FixedNominationsQuota<16>; type MaxUnlockingChunks = ConstU32<32>; - type MaxControllersInDeprecationBatch = MaxControllersInDeprecationBatch; + type MaxControllersInDeprecationBatch = ConstU32<100>; type HistoryDepth = ConstU32<84>; type EventListeners = (); type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig; diff --git a/substrate/frame/nomination-pools/benchmarking/src/mock.rs b/substrate/frame/nomination-pools/benchmarking/src/mock.rs index bd975b9b773f..c58a66f6163a 100644 --- a/substrate/frame/nomination-pools/benchmarking/src/mock.rs +++ b/substrate/frame/nomination-pools/benchmarking/src/mock.rs @@ -94,7 +94,6 @@ pallet_staking_reward_curve::build! { } parameter_types! { pub const RewardCurve: &'static sp_runtime::curve::PiecewiseLinear<'static> = &I_NPOS; - pub const MaxControllersInDeprecationBatch: u32 = 100; } impl pallet_staking::Config for Runtime { type Currency = Balances; @@ -120,7 +119,7 @@ impl pallet_staking::Config for Runtime { type VoterList = VoterList; type TargetList = pallet_staking::UseValidatorsMap; type NominationsQuota = pallet_staking::FixedNominationsQuota<16>; - type MaxControllersInDeprecationBatch = MaxControllersInDeprecationBatch; + type MaxControllersInDeprecationBatch = ConstU32<100>; type MaxUnlockingChunks = ConstU32<32>; type HistoryDepth = ConstU32<84>; type EventListeners = Pools; diff --git a/substrate/frame/nomination-pools/test-staking/src/mock.rs b/substrate/frame/nomination-pools/test-staking/src/mock.rs index fa2a1b593854..491cd6191619 100644 --- a/substrate/frame/nomination-pools/test-staking/src/mock.rs +++ b/substrate/frame/nomination-pools/test-staking/src/mock.rs @@ -106,7 +106,6 @@ pallet_staking_reward_curve::build! { parameter_types! { pub const RewardCurve: &'static sp_runtime::curve::PiecewiseLinear<'static> = &I_NPOS; - pub const MaxControllersInDeprecationBatch: u32 = 100; pub static BondingDuration: u32 = 3; } @@ -135,7 +134,7 @@ impl pallet_staking::Config for Runtime { type TargetList = pallet_staking::UseValidatorsMap; type NominationsQuota = pallet_staking::FixedNominationsQuota<16>; type MaxUnlockingChunks = ConstU32<32>; - type MaxControllersInDeprecationBatch = MaxControllersInDeprecationBatch; + type MaxControllersInDeprecationBatch = ConstU32<100>; type HistoryDepth = ConstU32<84>; type EventListeners = Pools; type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig; diff --git a/substrate/frame/offences/benchmarking/src/mock.rs b/substrate/frame/offences/benchmarking/src/mock.rs index 99919875586e..1d642b9b4982 100644 --- a/substrate/frame/offences/benchmarking/src/mock.rs +++ b/substrate/frame/offences/benchmarking/src/mock.rs @@ -146,7 +146,6 @@ pallet_staking_reward_curve::build! { } parameter_types! { pub const RewardCurve: &'static sp_runtime::curve::PiecewiseLinear<'static> = &I_NPOS; - pub const MaxControllersInDeprecationBatch: u32 = 100; pub static ElectionsBounds: ElectionBounds = ElectionBoundsBuilder::default().build(); } @@ -186,7 +185,7 @@ impl pallet_staking::Config for Test { type TargetList = pallet_staking::UseValidatorsMap; type NominationsQuota = pallet_staking::FixedNominationsQuota<16>; type MaxUnlockingChunks = ConstU32<32>; - type MaxControllersInDeprecationBatch = MaxControllersInDeprecationBatch; + type MaxControllersInDeprecationBatch = ConstU32<100>; type HistoryDepth = ConstU32<84>; type EventListeners = (); type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig; diff --git a/substrate/frame/root-offences/src/mock.rs b/substrate/frame/root-offences/src/mock.rs index e794a29a1781..c0c83dd08d24 100644 --- a/substrate/frame/root-offences/src/mock.rs +++ b/substrate/frame/root-offences/src/mock.rs @@ -162,7 +162,6 @@ parameter_types! { pub const BondingDuration: EraIndex = 3; pub static LedgerSlashPerEra: (BalanceOf, BTreeMap>) = (Zero::zero(), BTreeMap::new()); pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(75); - pub const MaxControllersInDeprecationBatch: u32 = 100; } impl pallet_staking::Config for Test { @@ -189,7 +188,7 @@ impl pallet_staking::Config for Test { type NominationsQuota = pallet_staking::FixedNominationsQuota<16>; type MaxUnlockingChunks = ConstU32<32>; type HistoryDepth = ConstU32<84>; - type MaxControllersInDeprecationBatch = MaxControllersInDeprecationBatch; + type MaxControllersInDeprecationBatch = ConstU32<100>; type VoterList = pallet_staking::UseNominatorsAndValidatorsMap; type EventListeners = (); type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig; diff --git a/substrate/frame/session/benchmarking/src/mock.rs b/substrate/frame/session/benchmarking/src/mock.rs index fee1c50a76b1..e1744fa43abb 100644 --- a/substrate/frame/session/benchmarking/src/mock.rs +++ b/substrate/frame/session/benchmarking/src/mock.rs @@ -145,7 +145,6 @@ pallet_staking_reward_curve::build! { } parameter_types! { pub const RewardCurve: &'static sp_runtime::curve::PiecewiseLinear<'static> = &I_NPOS; - pub const MaxControllersInDeprecationBatch: u32 = 100; pub static ElectionsBounds: ElectionBounds = ElectionBoundsBuilder::default().build(); } @@ -180,7 +179,7 @@ impl pallet_staking::Config for Test { type ElectionProvider = onchain::OnChainExecution; type GenesisElectionProvider = Self::ElectionProvider; type MaxUnlockingChunks = ConstU32<32>; - type MaxControllersInDeprecationBatch = MaxControllersInDeprecationBatch; + type MaxControllersInDeprecationBatch = ConstU32<100>; type HistoryDepth = ConstU32<84>; type VoterList = pallet_staking::UseNominatorsAndValidatorsMap; type TargetList = pallet_staking::UseValidatorsMap; From 85567a9d4384d8dec3cd69d5fa9bf0dbd74616ce Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Mon, 4 Dec 2023 10:12:42 +0700 Subject: [PATCH 33/74] fix test-runtime --- polkadot/runtime/test-runtime/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/polkadot/runtime/test-runtime/src/lib.rs b/polkadot/runtime/test-runtime/src/lib.rs index 7ec9f63748c0..2b289d5bccf5 100644 --- a/polkadot/runtime/test-runtime/src/lib.rs +++ b/polkadot/runtime/test-runtime/src/lib.rs @@ -366,6 +366,7 @@ impl pallet_staking::Config for Runtime { type TargetList = pallet_staking::UseValidatorsMap; type NominationsQuota = pallet_staking::FixedNominationsQuota; type MaxUnlockingChunks = frame_support::traits::ConstU32<32>; + type MaxControllersInDeprecationBatch = ConstU32<100>; type HistoryDepth = frame_support::traits::ConstU32<84>; type BenchmarkingConfig = runtime_common::StakingBenchmarkingConfig; type EventListeners = (); From 6c56e6c1501eda2452d1dcd823de180ddfc15368 Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Mon, 4 Dec 2023 10:29:05 +0700 Subject: [PATCH 34/74] fix --- substrate/frame/staking/src/benchmarking.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/substrate/frame/staking/src/benchmarking.rs b/substrate/frame/staking/src/benchmarking.rs index e3f517714f34..830dad11e0d8 100644 --- a/substrate/frame/staking/src/benchmarking.rs +++ b/substrate/frame/staking/src/benchmarking.rs @@ -528,12 +528,12 @@ benchmarks! { deprecate_controller_batch { // We pass a dynamic number of controllers to the benchmark, up to `MaxControllersInDeprecationBatch`. - let i in 1 .. T::MaxControllersInDeprecationBatch::get(); + let i in 0 .. T::MaxControllersInDeprecationBatch::get(); let mut controllers: Vec<_> = vec![]; let mut stashes: Vec<_> = vec![]; - for n in 1..i as u32 { + for n in 0..i as u32 { let (stash, controller) = create_unique_stash_controller::( n, 100, @@ -547,7 +547,7 @@ benchmarks! { BoundedVec::try_from(controllers.clone()).unwrap(); }: _(RawOrigin::Root, bounded_controllers) verify { - for n in 1..i as u32 { + for n in 0..i as u32 { let stash = &stashes[n as usize]; let controller = &controllers[n as usize]; From 6543b952f2c84dce450761a5d096fdc27541e393 Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Mon, 4 Dec 2023 02:09:00 +0000 Subject: [PATCH 35/74] ".git/.scripts/commands/fmt/fmt.sh" --- substrate/frame/staking/src/tests.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/substrate/frame/staking/src/tests.rs b/substrate/frame/staking/src/tests.rs index a146ad52b589..b2198625c5de 100644 --- a/substrate/frame/staking/src/tests.rs +++ b/substrate/frame/staking/src/tests.rs @@ -6896,8 +6896,10 @@ mod ledger { // When: - let bounded_controllers: BoundedVec<_, ::MaxControllersInDeprecationBatch> = - BoundedVec::try_from(controllers).unwrap(); + let bounded_controllers: BoundedVec< + _, + ::MaxControllersInDeprecationBatch, + > = BoundedVec::try_from(controllers).unwrap(); assert_ok!(Staking::deprecate_controller_batch( RuntimeOrigin::root(), From 9070a80e5b84e6d9edbc98851781b8a748ba3dee Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Mon, 4 Dec 2023 09:32:41 +0700 Subject: [PATCH 36/74] test --- substrate/frame/staking/src/pallet/mod.rs | 50 +++++++++++------------ 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/substrate/frame/staking/src/pallet/mod.rs b/substrate/frame/staking/src/pallet/mod.rs index 06ccc3cd52d1..aa2162f93e79 100644 --- a/substrate/frame/staking/src/pallet/mod.rs +++ b/substrate/frame/staking/src/pallet/mod.rs @@ -1941,31 +1941,31 @@ pub mod pallet { ensure_root(origin)?; // Ignore controllers that do not exist or are already the same as stash. - let filtered_batch_with_ledger: Vec<_> = controllers - .iter() - .filter_map(|controller| { - let ledger = Self::ledger(StakingAccount::Controller(controller.clone())); - ledger.ok().map_or(None, |ledger| { - if ledger.stash != *controller { - // Sets `controller` field back to `None`. The controller is never - // stored on-chain, and is instead derived from the `Bonded` storage - // item by `StakingLedger`. - Some((controller.clone(), StakingLedger { controller: None, ..ledger })) - } else { - None - } - }) - }) - .collect(); - - // Update unique pairs. - for (controller, ledger) in filtered_batch_with_ledger { - let stash = ledger.stash.clone(); - - >::insert(&stash, &stash); - >::remove(controller); - >::insert(stash, ledger); - } + // let filtered_batch_with_ledger: Vec<_> = controllers + // .iter() + // .filter_map(|controller| { + // let ledger = Self::ledger(StakingAccount::Controller(controller.clone())); + // ledger.ok().map_or(None, |ledger| { + // if ledger.stash != *controller { + // // Sets `controller` field back to `None`. The controller is never + // // stored on-chain, and is instead derived from the `Bonded` storage + // // item by `StakingLedger`. + // Some((controller.clone(), StakingLedger { controller: None, ..ledger })) + // } else { + // None + // } + // }) + // }) + // .collect(); + + // // Update unique pairs. + // for (controller, ledger) in filtered_batch_with_ledger { + // let stash = ledger.stash.clone(); + + // >::insert(&stash, &stash); + // >::remove(controller); + // >::insert(stash, ledger); + // } Ok(()) } } From ee5b86a75999486f8de158749b6ddd202868812d Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Mon, 4 Dec 2023 09:38:09 +0700 Subject: [PATCH 37/74] use u32 --- substrate/frame/babe/src/mock.rs | 2 +- substrate/frame/beefy/src/mock.rs | 2 +- .../election-provider-multi-phase/test-staking-e2e/src/mock.rs | 2 +- substrate/frame/fast-unstake/src/mock.rs | 2 +- substrate/frame/grandpa/src/mock.rs | 2 +- substrate/frame/nomination-pools/benchmarking/src/mock.rs | 2 +- substrate/frame/nomination-pools/test-staking/src/mock.rs | 2 +- substrate/frame/offences/benchmarking/src/mock.rs | 2 +- substrate/frame/root-offences/src/mock.rs | 2 +- substrate/frame/session/benchmarking/src/mock.rs | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/substrate/frame/babe/src/mock.rs b/substrate/frame/babe/src/mock.rs index bb3a82cd73b7..72abbc805db1 100644 --- a/substrate/frame/babe/src/mock.rs +++ b/substrate/frame/babe/src/mock.rs @@ -183,7 +183,7 @@ impl pallet_staking::Config for Test { type TargetList = pallet_staking::UseValidatorsMap; type NominationsQuota = FixedNominationsQuota<16>; type MaxUnlockingChunks = ConstU32<32>; - type MaxControllersInDeprecationBatch = (); + type MaxControllersInDeprecationBatch = ConstU32<100>; type HistoryDepth = ConstU32<84>; type EventListeners = (); type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig; diff --git a/substrate/frame/beefy/src/mock.rs b/substrate/frame/beefy/src/mock.rs index e27e0ef2faec..8dc30614c33b 100644 --- a/substrate/frame/beefy/src/mock.rs +++ b/substrate/frame/beefy/src/mock.rs @@ -201,7 +201,7 @@ impl pallet_staking::Config for Test { type TargetList = pallet_staking::UseValidatorsMap; type NominationsQuota = pallet_staking::FixedNominationsQuota<16>; type MaxUnlockingChunks = ConstU32<32>; - type MaxControllersInDeprecationBatch = (); + type MaxControllersInDeprecationBatch = ConstU32<100>; type HistoryDepth = ConstU32<84>; type EventListeners = (); type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig; diff --git a/substrate/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs b/substrate/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs index 678a066d7b9c..ecb2ae435b8c 100644 --- a/substrate/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs +++ b/substrate/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs @@ -276,7 +276,7 @@ impl pallet_staking::Config for Runtime { type NominationsQuota = pallet_staking::FixedNominationsQuota; type TargetList = pallet_staking::UseValidatorsMap; type MaxUnlockingChunks = ConstU32<32>; - type MaxControllersInDeprecationBatch = (); + type MaxControllersInDeprecationBatch = ConstU32<100>; type HistoryDepth = HistoryDepth; type EventListeners = (); type WeightInfo = pallet_staking::weights::SubstrateWeight; diff --git a/substrate/frame/fast-unstake/src/mock.rs b/substrate/frame/fast-unstake/src/mock.rs index 44ef24b833b0..f9326919fd3e 100644 --- a/substrate/frame/fast-unstake/src/mock.rs +++ b/substrate/frame/fast-unstake/src/mock.rs @@ -142,7 +142,7 @@ impl pallet_staking::Config for Runtime { type TargetList = pallet_staking::UseValidatorsMap; type NominationsQuota = pallet_staking::FixedNominationsQuota<16>; type MaxUnlockingChunks = ConstU32<32>; - type MaxControllersInDeprecationBatch = (); + type MaxControllersInDeprecationBatch = ConstU32<100>; type EventListeners = (); type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig; type WeightInfo = (); diff --git a/substrate/frame/grandpa/src/mock.rs b/substrate/frame/grandpa/src/mock.rs index 89ffceac0e3b..f1f51e0b1181 100644 --- a/substrate/frame/grandpa/src/mock.rs +++ b/substrate/frame/grandpa/src/mock.rs @@ -206,7 +206,7 @@ impl pallet_staking::Config for Test { type TargetList = pallet_staking::UseValidatorsMap; type NominationsQuota = pallet_staking::FixedNominationsQuota<16>; type MaxUnlockingChunks = ConstU32<32>; - type MaxControllersInDeprecationBatch = (); + type MaxControllersInDeprecationBatch = ConstU32<100>; type HistoryDepth = ConstU32<84>; type EventListeners = (); type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig; diff --git a/substrate/frame/nomination-pools/benchmarking/src/mock.rs b/substrate/frame/nomination-pools/benchmarking/src/mock.rs index 2e32798522a3..c58a66f6163a 100644 --- a/substrate/frame/nomination-pools/benchmarking/src/mock.rs +++ b/substrate/frame/nomination-pools/benchmarking/src/mock.rs @@ -119,7 +119,7 @@ impl pallet_staking::Config for Runtime { type VoterList = VoterList; type TargetList = pallet_staking::UseValidatorsMap; type NominationsQuota = pallet_staking::FixedNominationsQuota<16>; - type MaxControllersInDeprecationBatch = (); + type MaxControllersInDeprecationBatch = ConstU32<100>; type MaxUnlockingChunks = ConstU32<32>; type HistoryDepth = ConstU32<84>; type EventListeners = Pools; diff --git a/substrate/frame/nomination-pools/test-staking/src/mock.rs b/substrate/frame/nomination-pools/test-staking/src/mock.rs index aac0d54a30ad..491cd6191619 100644 --- a/substrate/frame/nomination-pools/test-staking/src/mock.rs +++ b/substrate/frame/nomination-pools/test-staking/src/mock.rs @@ -134,7 +134,7 @@ impl pallet_staking::Config for Runtime { type TargetList = pallet_staking::UseValidatorsMap; type NominationsQuota = pallet_staking::FixedNominationsQuota<16>; type MaxUnlockingChunks = ConstU32<32>; - type MaxControllersInDeprecationBatch = (); + type MaxControllersInDeprecationBatch = ConstU32<100>; type HistoryDepth = ConstU32<84>; type EventListeners = Pools; type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig; diff --git a/substrate/frame/offences/benchmarking/src/mock.rs b/substrate/frame/offences/benchmarking/src/mock.rs index f9b67d753497..1d642b9b4982 100644 --- a/substrate/frame/offences/benchmarking/src/mock.rs +++ b/substrate/frame/offences/benchmarking/src/mock.rs @@ -185,7 +185,7 @@ impl pallet_staking::Config for Test { type TargetList = pallet_staking::UseValidatorsMap; type NominationsQuota = pallet_staking::FixedNominationsQuota<16>; type MaxUnlockingChunks = ConstU32<32>; - type MaxControllersInDeprecationBatch = (); + type MaxControllersInDeprecationBatch = ConstU32<100>; type HistoryDepth = ConstU32<84>; type EventListeners = (); type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig; diff --git a/substrate/frame/root-offences/src/mock.rs b/substrate/frame/root-offences/src/mock.rs index e4c375df8d70..c0c83dd08d24 100644 --- a/substrate/frame/root-offences/src/mock.rs +++ b/substrate/frame/root-offences/src/mock.rs @@ -188,7 +188,7 @@ impl pallet_staking::Config for Test { type NominationsQuota = pallet_staking::FixedNominationsQuota<16>; type MaxUnlockingChunks = ConstU32<32>; type HistoryDepth = ConstU32<84>; - type MaxControllersInDeprecationBatch = (); + type MaxControllersInDeprecationBatch = ConstU32<100>; type VoterList = pallet_staking::UseNominatorsAndValidatorsMap; type EventListeners = (); type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig; diff --git a/substrate/frame/session/benchmarking/src/mock.rs b/substrate/frame/session/benchmarking/src/mock.rs index c77b959535c5..e1744fa43abb 100644 --- a/substrate/frame/session/benchmarking/src/mock.rs +++ b/substrate/frame/session/benchmarking/src/mock.rs @@ -179,7 +179,7 @@ impl pallet_staking::Config for Test { type ElectionProvider = onchain::OnChainExecution; type GenesisElectionProvider = Self::ElectionProvider; type MaxUnlockingChunks = ConstU32<32>; - type MaxControllersInDeprecationBatch = (); + type MaxControllersInDeprecationBatch = ConstU32<100>; type HistoryDepth = ConstU32<84>; type VoterList = pallet_staking::UseNominatorsAndValidatorsMap; type TargetList = pallet_staking::UseValidatorsMap; From 58f1fd05654ddcbb441ef9555033bf92ce696f0b Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Mon, 4 Dec 2023 09:47:07 +0700 Subject: [PATCH 38/74] uncomment --- substrate/frame/staking/src/pallet/mod.rs | 50 +++++++++++------------ 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/substrate/frame/staking/src/pallet/mod.rs b/substrate/frame/staking/src/pallet/mod.rs index aa2162f93e79..06ccc3cd52d1 100644 --- a/substrate/frame/staking/src/pallet/mod.rs +++ b/substrate/frame/staking/src/pallet/mod.rs @@ -1941,31 +1941,31 @@ pub mod pallet { ensure_root(origin)?; // Ignore controllers that do not exist or are already the same as stash. - // let filtered_batch_with_ledger: Vec<_> = controllers - // .iter() - // .filter_map(|controller| { - // let ledger = Self::ledger(StakingAccount::Controller(controller.clone())); - // ledger.ok().map_or(None, |ledger| { - // if ledger.stash != *controller { - // // Sets `controller` field back to `None`. The controller is never - // // stored on-chain, and is instead derived from the `Bonded` storage - // // item by `StakingLedger`. - // Some((controller.clone(), StakingLedger { controller: None, ..ledger })) - // } else { - // None - // } - // }) - // }) - // .collect(); - - // // Update unique pairs. - // for (controller, ledger) in filtered_batch_with_ledger { - // let stash = ledger.stash.clone(); - - // >::insert(&stash, &stash); - // >::remove(controller); - // >::insert(stash, ledger); - // } + let filtered_batch_with_ledger: Vec<_> = controllers + .iter() + .filter_map(|controller| { + let ledger = Self::ledger(StakingAccount::Controller(controller.clone())); + ledger.ok().map_or(None, |ledger| { + if ledger.stash != *controller { + // Sets `controller` field back to `None`. The controller is never + // stored on-chain, and is instead derived from the `Bonded` storage + // item by `StakingLedger`. + Some((controller.clone(), StakingLedger { controller: None, ..ledger })) + } else { + None + } + }) + }) + .collect(); + + // Update unique pairs. + for (controller, ledger) in filtered_batch_with_ledger { + let stash = ledger.stash.clone(); + + >::insert(&stash, &stash); + >::remove(controller); + >::insert(stash, ledger); + } Ok(()) } } From 791c737d265c889a54c97fe5351841b41dcba7c2 Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Mon, 4 Dec 2023 10:00:01 +0700 Subject: [PATCH 39/74] try using parameter_types! --- substrate/frame/babe/src/mock.rs | 3 ++- substrate/frame/beefy/src/mock.rs | 3 ++- .../election-provider-multi-phase/test-staking-e2e/src/mock.rs | 3 ++- substrate/frame/fast-unstake/src/mock.rs | 3 ++- substrate/frame/grandpa/src/mock.rs | 3 ++- substrate/frame/nomination-pools/benchmarking/src/mock.rs | 3 ++- substrate/frame/nomination-pools/test-staking/src/mock.rs | 3 ++- substrate/frame/offences/benchmarking/src/mock.rs | 3 ++- substrate/frame/root-offences/src/mock.rs | 3 ++- substrate/frame/session/benchmarking/src/mock.rs | 3 ++- 10 files changed, 20 insertions(+), 10 deletions(-) diff --git a/substrate/frame/babe/src/mock.rs b/substrate/frame/babe/src/mock.rs index 72abbc805db1..d6f7cc25bba2 100644 --- a/substrate/frame/babe/src/mock.rs +++ b/substrate/frame/babe/src/mock.rs @@ -146,6 +146,7 @@ parameter_types! { pub const SlashDeferDuration: EraIndex = 0; pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE; pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(16); + pub const MaxControllersInDeprecationBatch: u32 = 100; pub static ElectionsBounds: ElectionBounds = ElectionBoundsBuilder::default().build(); } @@ -183,7 +184,7 @@ impl pallet_staking::Config for Test { type TargetList = pallet_staking::UseValidatorsMap; type NominationsQuota = FixedNominationsQuota<16>; type MaxUnlockingChunks = ConstU32<32>; - type MaxControllersInDeprecationBatch = ConstU32<100>; + type MaxControllersInDeprecationBatch = MaxControllersInDeprecationBatch; type HistoryDepth = ConstU32<84>; type EventListeners = (); type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig; diff --git a/substrate/frame/beefy/src/mock.rs b/substrate/frame/beefy/src/mock.rs index 8dc30614c33b..d3a7921ff919 100644 --- a/substrate/frame/beefy/src/mock.rs +++ b/substrate/frame/beefy/src/mock.rs @@ -164,6 +164,7 @@ parameter_types! { pub const BondingDuration: EraIndex = 3; pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE; pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(17); + pub const MaxControllersInDeprecationBatch: u32 = 100; pub static ElectionsBoundsOnChain: ElectionBounds = ElectionBoundsBuilder::default().build(); } @@ -201,7 +202,7 @@ impl pallet_staking::Config for Test { type TargetList = pallet_staking::UseValidatorsMap; type NominationsQuota = pallet_staking::FixedNominationsQuota<16>; type MaxUnlockingChunks = ConstU32<32>; - type MaxControllersInDeprecationBatch = ConstU32<100>; + type MaxControllersInDeprecationBatch = MaxControllersInDeprecationBatch; type HistoryDepth = ConstU32<84>; type EventListeners = (); type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig; diff --git a/substrate/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs b/substrate/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs index ecb2ae435b8c..0b7270c31dfa 100644 --- a/substrate/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs +++ b/substrate/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs @@ -238,6 +238,7 @@ parameter_types! { pub const BondingDuration: sp_staking::EraIndex = 28; pub const SlashDeferDuration: sp_staking::EraIndex = 7; // 1/4 the bonding duration. pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(40); + pub const MaxControllersInDeprecationBatch: u32 = 100; pub HistoryDepth: u32 = 84; } @@ -276,7 +277,7 @@ impl pallet_staking::Config for Runtime { type NominationsQuota = pallet_staking::FixedNominationsQuota; type TargetList = pallet_staking::UseValidatorsMap; type MaxUnlockingChunks = ConstU32<32>; - type MaxControllersInDeprecationBatch = ConstU32<100>; + type MaxControllersInDeprecationBatch = MaxControllersInDeprecationBatch; type HistoryDepth = HistoryDepth; type EventListeners = (); type WeightInfo = pallet_staking::weights::SubstrateWeight; diff --git a/substrate/frame/fast-unstake/src/mock.rs b/substrate/frame/fast-unstake/src/mock.rs index f9326919fd3e..d5e1304447be 100644 --- a/substrate/frame/fast-unstake/src/mock.rs +++ b/substrate/frame/fast-unstake/src/mock.rs @@ -93,6 +93,7 @@ pallet_staking_reward_curve::build! { parameter_types! { pub const RewardCurve: &'static sp_runtime::curve::PiecewiseLinear<'static> = &I_NPOS; + pub const MaxControllersInDeprecationBatch: u32 = 100; pub static BondingDuration: u32 = 3; pub static CurrentEra: u32 = 0; pub static Ongoing: bool = false; @@ -142,7 +143,7 @@ impl pallet_staking::Config for Runtime { type TargetList = pallet_staking::UseValidatorsMap; type NominationsQuota = pallet_staking::FixedNominationsQuota<16>; type MaxUnlockingChunks = ConstU32<32>; - type MaxControllersInDeprecationBatch = ConstU32<100>; + type MaxControllersInDeprecationBatch = MaxControllersInDeprecationBatch; type EventListeners = (); type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig; type WeightInfo = (); diff --git a/substrate/frame/grandpa/src/mock.rs b/substrate/frame/grandpa/src/mock.rs index f1f51e0b1181..afb489850f31 100644 --- a/substrate/frame/grandpa/src/mock.rs +++ b/substrate/frame/grandpa/src/mock.rs @@ -169,6 +169,7 @@ parameter_types! { pub const BondingDuration: EraIndex = 3; pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE; pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(17); + pub const MaxControllersInDeprecationBatch: u32 = 100; pub static ElectionsBoundsOnChain: ElectionBounds = ElectionBoundsBuilder::default().build(); } @@ -206,7 +207,7 @@ impl pallet_staking::Config for Test { type TargetList = pallet_staking::UseValidatorsMap; type NominationsQuota = pallet_staking::FixedNominationsQuota<16>; type MaxUnlockingChunks = ConstU32<32>; - type MaxControllersInDeprecationBatch = ConstU32<100>; + type MaxControllersInDeprecationBatch = MaxControllersInDeprecationBatch; type HistoryDepth = ConstU32<84>; type EventListeners = (); type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig; diff --git a/substrate/frame/nomination-pools/benchmarking/src/mock.rs b/substrate/frame/nomination-pools/benchmarking/src/mock.rs index c58a66f6163a..bd975b9b773f 100644 --- a/substrate/frame/nomination-pools/benchmarking/src/mock.rs +++ b/substrate/frame/nomination-pools/benchmarking/src/mock.rs @@ -94,6 +94,7 @@ pallet_staking_reward_curve::build! { } parameter_types! { pub const RewardCurve: &'static sp_runtime::curve::PiecewiseLinear<'static> = &I_NPOS; + pub const MaxControllersInDeprecationBatch: u32 = 100; } impl pallet_staking::Config for Runtime { type Currency = Balances; @@ -119,7 +120,7 @@ impl pallet_staking::Config for Runtime { type VoterList = VoterList; type TargetList = pallet_staking::UseValidatorsMap; type NominationsQuota = pallet_staking::FixedNominationsQuota<16>; - type MaxControllersInDeprecationBatch = ConstU32<100>; + type MaxControllersInDeprecationBatch = MaxControllersInDeprecationBatch; type MaxUnlockingChunks = ConstU32<32>; type HistoryDepth = ConstU32<84>; type EventListeners = Pools; diff --git a/substrate/frame/nomination-pools/test-staking/src/mock.rs b/substrate/frame/nomination-pools/test-staking/src/mock.rs index 491cd6191619..fa2a1b593854 100644 --- a/substrate/frame/nomination-pools/test-staking/src/mock.rs +++ b/substrate/frame/nomination-pools/test-staking/src/mock.rs @@ -106,6 +106,7 @@ pallet_staking_reward_curve::build! { parameter_types! { pub const RewardCurve: &'static sp_runtime::curve::PiecewiseLinear<'static> = &I_NPOS; + pub const MaxControllersInDeprecationBatch: u32 = 100; pub static BondingDuration: u32 = 3; } @@ -134,7 +135,7 @@ impl pallet_staking::Config for Runtime { type TargetList = pallet_staking::UseValidatorsMap; type NominationsQuota = pallet_staking::FixedNominationsQuota<16>; type MaxUnlockingChunks = ConstU32<32>; - type MaxControllersInDeprecationBatch = ConstU32<100>; + type MaxControllersInDeprecationBatch = MaxControllersInDeprecationBatch; type HistoryDepth = ConstU32<84>; type EventListeners = Pools; type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig; diff --git a/substrate/frame/offences/benchmarking/src/mock.rs b/substrate/frame/offences/benchmarking/src/mock.rs index 1d642b9b4982..99919875586e 100644 --- a/substrate/frame/offences/benchmarking/src/mock.rs +++ b/substrate/frame/offences/benchmarking/src/mock.rs @@ -146,6 +146,7 @@ pallet_staking_reward_curve::build! { } parameter_types! { pub const RewardCurve: &'static sp_runtime::curve::PiecewiseLinear<'static> = &I_NPOS; + pub const MaxControllersInDeprecationBatch: u32 = 100; pub static ElectionsBounds: ElectionBounds = ElectionBoundsBuilder::default().build(); } @@ -185,7 +186,7 @@ impl pallet_staking::Config for Test { type TargetList = pallet_staking::UseValidatorsMap; type NominationsQuota = pallet_staking::FixedNominationsQuota<16>; type MaxUnlockingChunks = ConstU32<32>; - type MaxControllersInDeprecationBatch = ConstU32<100>; + type MaxControllersInDeprecationBatch = MaxControllersInDeprecationBatch; type HistoryDepth = ConstU32<84>; type EventListeners = (); type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig; diff --git a/substrate/frame/root-offences/src/mock.rs b/substrate/frame/root-offences/src/mock.rs index c0c83dd08d24..e794a29a1781 100644 --- a/substrate/frame/root-offences/src/mock.rs +++ b/substrate/frame/root-offences/src/mock.rs @@ -162,6 +162,7 @@ parameter_types! { pub const BondingDuration: EraIndex = 3; pub static LedgerSlashPerEra: (BalanceOf, BTreeMap>) = (Zero::zero(), BTreeMap::new()); pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(75); + pub const MaxControllersInDeprecationBatch: u32 = 100; } impl pallet_staking::Config for Test { @@ -188,7 +189,7 @@ impl pallet_staking::Config for Test { type NominationsQuota = pallet_staking::FixedNominationsQuota<16>; type MaxUnlockingChunks = ConstU32<32>; type HistoryDepth = ConstU32<84>; - type MaxControllersInDeprecationBatch = ConstU32<100>; + type MaxControllersInDeprecationBatch = MaxControllersInDeprecationBatch; type VoterList = pallet_staking::UseNominatorsAndValidatorsMap; type EventListeners = (); type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig; diff --git a/substrate/frame/session/benchmarking/src/mock.rs b/substrate/frame/session/benchmarking/src/mock.rs index e1744fa43abb..fee1c50a76b1 100644 --- a/substrate/frame/session/benchmarking/src/mock.rs +++ b/substrate/frame/session/benchmarking/src/mock.rs @@ -145,6 +145,7 @@ pallet_staking_reward_curve::build! { } parameter_types! { pub const RewardCurve: &'static sp_runtime::curve::PiecewiseLinear<'static> = &I_NPOS; + pub const MaxControllersInDeprecationBatch: u32 = 100; pub static ElectionsBounds: ElectionBounds = ElectionBoundsBuilder::default().build(); } @@ -179,7 +180,7 @@ impl pallet_staking::Config for Test { type ElectionProvider = onchain::OnChainExecution; type GenesisElectionProvider = Self::ElectionProvider; type MaxUnlockingChunks = ConstU32<32>; - type MaxControllersInDeprecationBatch = ConstU32<100>; + type MaxControllersInDeprecationBatch = MaxControllersInDeprecationBatch; type HistoryDepth = ConstU32<84>; type VoterList = pallet_staking::UseNominatorsAndValidatorsMap; type TargetList = pallet_staking::UseValidatorsMap; From d4bac69cd914871162965c2761000cffc520faac Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Mon, 4 Dec 2023 10:11:52 +0700 Subject: [PATCH 40/74] Revert "try using parameter_types!" This reverts commit 5dcac5aadbd6ebf5e9f7015012f89e80c7d2f585. --- substrate/frame/babe/src/mock.rs | 3 +-- substrate/frame/beefy/src/mock.rs | 3 +-- .../election-provider-multi-phase/test-staking-e2e/src/mock.rs | 3 +-- substrate/frame/fast-unstake/src/mock.rs | 3 +-- substrate/frame/grandpa/src/mock.rs | 3 +-- substrate/frame/nomination-pools/benchmarking/src/mock.rs | 3 +-- substrate/frame/nomination-pools/test-staking/src/mock.rs | 3 +-- substrate/frame/offences/benchmarking/src/mock.rs | 3 +-- substrate/frame/root-offences/src/mock.rs | 3 +-- substrate/frame/session/benchmarking/src/mock.rs | 3 +-- 10 files changed, 10 insertions(+), 20 deletions(-) diff --git a/substrate/frame/babe/src/mock.rs b/substrate/frame/babe/src/mock.rs index d6f7cc25bba2..72abbc805db1 100644 --- a/substrate/frame/babe/src/mock.rs +++ b/substrate/frame/babe/src/mock.rs @@ -146,7 +146,6 @@ parameter_types! { pub const SlashDeferDuration: EraIndex = 0; pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE; pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(16); - pub const MaxControllersInDeprecationBatch: u32 = 100; pub static ElectionsBounds: ElectionBounds = ElectionBoundsBuilder::default().build(); } @@ -184,7 +183,7 @@ impl pallet_staking::Config for Test { type TargetList = pallet_staking::UseValidatorsMap; type NominationsQuota = FixedNominationsQuota<16>; type MaxUnlockingChunks = ConstU32<32>; - type MaxControllersInDeprecationBatch = MaxControllersInDeprecationBatch; + type MaxControllersInDeprecationBatch = ConstU32<100>; type HistoryDepth = ConstU32<84>; type EventListeners = (); type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig; diff --git a/substrate/frame/beefy/src/mock.rs b/substrate/frame/beefy/src/mock.rs index d3a7921ff919..8dc30614c33b 100644 --- a/substrate/frame/beefy/src/mock.rs +++ b/substrate/frame/beefy/src/mock.rs @@ -164,7 +164,6 @@ parameter_types! { pub const BondingDuration: EraIndex = 3; pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE; pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(17); - pub const MaxControllersInDeprecationBatch: u32 = 100; pub static ElectionsBoundsOnChain: ElectionBounds = ElectionBoundsBuilder::default().build(); } @@ -202,7 +201,7 @@ impl pallet_staking::Config for Test { type TargetList = pallet_staking::UseValidatorsMap; type NominationsQuota = pallet_staking::FixedNominationsQuota<16>; type MaxUnlockingChunks = ConstU32<32>; - type MaxControllersInDeprecationBatch = MaxControllersInDeprecationBatch; + type MaxControllersInDeprecationBatch = ConstU32<100>; type HistoryDepth = ConstU32<84>; type EventListeners = (); type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig; diff --git a/substrate/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs b/substrate/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs index 0b7270c31dfa..ecb2ae435b8c 100644 --- a/substrate/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs +++ b/substrate/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs @@ -238,7 +238,6 @@ parameter_types! { pub const BondingDuration: sp_staking::EraIndex = 28; pub const SlashDeferDuration: sp_staking::EraIndex = 7; // 1/4 the bonding duration. pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(40); - pub const MaxControllersInDeprecationBatch: u32 = 100; pub HistoryDepth: u32 = 84; } @@ -277,7 +276,7 @@ impl pallet_staking::Config for Runtime { type NominationsQuota = pallet_staking::FixedNominationsQuota; type TargetList = pallet_staking::UseValidatorsMap; type MaxUnlockingChunks = ConstU32<32>; - type MaxControllersInDeprecationBatch = MaxControllersInDeprecationBatch; + type MaxControllersInDeprecationBatch = ConstU32<100>; type HistoryDepth = HistoryDepth; type EventListeners = (); type WeightInfo = pallet_staking::weights::SubstrateWeight; diff --git a/substrate/frame/fast-unstake/src/mock.rs b/substrate/frame/fast-unstake/src/mock.rs index d5e1304447be..f9326919fd3e 100644 --- a/substrate/frame/fast-unstake/src/mock.rs +++ b/substrate/frame/fast-unstake/src/mock.rs @@ -93,7 +93,6 @@ pallet_staking_reward_curve::build! { parameter_types! { pub const RewardCurve: &'static sp_runtime::curve::PiecewiseLinear<'static> = &I_NPOS; - pub const MaxControllersInDeprecationBatch: u32 = 100; pub static BondingDuration: u32 = 3; pub static CurrentEra: u32 = 0; pub static Ongoing: bool = false; @@ -143,7 +142,7 @@ impl pallet_staking::Config for Runtime { type TargetList = pallet_staking::UseValidatorsMap; type NominationsQuota = pallet_staking::FixedNominationsQuota<16>; type MaxUnlockingChunks = ConstU32<32>; - type MaxControllersInDeprecationBatch = MaxControllersInDeprecationBatch; + type MaxControllersInDeprecationBatch = ConstU32<100>; type EventListeners = (); type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig; type WeightInfo = (); diff --git a/substrate/frame/grandpa/src/mock.rs b/substrate/frame/grandpa/src/mock.rs index afb489850f31..f1f51e0b1181 100644 --- a/substrate/frame/grandpa/src/mock.rs +++ b/substrate/frame/grandpa/src/mock.rs @@ -169,7 +169,6 @@ parameter_types! { pub const BondingDuration: EraIndex = 3; pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE; pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(17); - pub const MaxControllersInDeprecationBatch: u32 = 100; pub static ElectionsBoundsOnChain: ElectionBounds = ElectionBoundsBuilder::default().build(); } @@ -207,7 +206,7 @@ impl pallet_staking::Config for Test { type TargetList = pallet_staking::UseValidatorsMap; type NominationsQuota = pallet_staking::FixedNominationsQuota<16>; type MaxUnlockingChunks = ConstU32<32>; - type MaxControllersInDeprecationBatch = MaxControllersInDeprecationBatch; + type MaxControllersInDeprecationBatch = ConstU32<100>; type HistoryDepth = ConstU32<84>; type EventListeners = (); type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig; diff --git a/substrate/frame/nomination-pools/benchmarking/src/mock.rs b/substrate/frame/nomination-pools/benchmarking/src/mock.rs index bd975b9b773f..c58a66f6163a 100644 --- a/substrate/frame/nomination-pools/benchmarking/src/mock.rs +++ b/substrate/frame/nomination-pools/benchmarking/src/mock.rs @@ -94,7 +94,6 @@ pallet_staking_reward_curve::build! { } parameter_types! { pub const RewardCurve: &'static sp_runtime::curve::PiecewiseLinear<'static> = &I_NPOS; - pub const MaxControllersInDeprecationBatch: u32 = 100; } impl pallet_staking::Config for Runtime { type Currency = Balances; @@ -120,7 +119,7 @@ impl pallet_staking::Config for Runtime { type VoterList = VoterList; type TargetList = pallet_staking::UseValidatorsMap; type NominationsQuota = pallet_staking::FixedNominationsQuota<16>; - type MaxControllersInDeprecationBatch = MaxControllersInDeprecationBatch; + type MaxControllersInDeprecationBatch = ConstU32<100>; type MaxUnlockingChunks = ConstU32<32>; type HistoryDepth = ConstU32<84>; type EventListeners = Pools; diff --git a/substrate/frame/nomination-pools/test-staking/src/mock.rs b/substrate/frame/nomination-pools/test-staking/src/mock.rs index fa2a1b593854..491cd6191619 100644 --- a/substrate/frame/nomination-pools/test-staking/src/mock.rs +++ b/substrate/frame/nomination-pools/test-staking/src/mock.rs @@ -106,7 +106,6 @@ pallet_staking_reward_curve::build! { parameter_types! { pub const RewardCurve: &'static sp_runtime::curve::PiecewiseLinear<'static> = &I_NPOS; - pub const MaxControllersInDeprecationBatch: u32 = 100; pub static BondingDuration: u32 = 3; } @@ -135,7 +134,7 @@ impl pallet_staking::Config for Runtime { type TargetList = pallet_staking::UseValidatorsMap; type NominationsQuota = pallet_staking::FixedNominationsQuota<16>; type MaxUnlockingChunks = ConstU32<32>; - type MaxControllersInDeprecationBatch = MaxControllersInDeprecationBatch; + type MaxControllersInDeprecationBatch = ConstU32<100>; type HistoryDepth = ConstU32<84>; type EventListeners = Pools; type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig; diff --git a/substrate/frame/offences/benchmarking/src/mock.rs b/substrate/frame/offences/benchmarking/src/mock.rs index 99919875586e..1d642b9b4982 100644 --- a/substrate/frame/offences/benchmarking/src/mock.rs +++ b/substrate/frame/offences/benchmarking/src/mock.rs @@ -146,7 +146,6 @@ pallet_staking_reward_curve::build! { } parameter_types! { pub const RewardCurve: &'static sp_runtime::curve::PiecewiseLinear<'static> = &I_NPOS; - pub const MaxControllersInDeprecationBatch: u32 = 100; pub static ElectionsBounds: ElectionBounds = ElectionBoundsBuilder::default().build(); } @@ -186,7 +185,7 @@ impl pallet_staking::Config for Test { type TargetList = pallet_staking::UseValidatorsMap; type NominationsQuota = pallet_staking::FixedNominationsQuota<16>; type MaxUnlockingChunks = ConstU32<32>; - type MaxControllersInDeprecationBatch = MaxControllersInDeprecationBatch; + type MaxControllersInDeprecationBatch = ConstU32<100>; type HistoryDepth = ConstU32<84>; type EventListeners = (); type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig; diff --git a/substrate/frame/root-offences/src/mock.rs b/substrate/frame/root-offences/src/mock.rs index e794a29a1781..c0c83dd08d24 100644 --- a/substrate/frame/root-offences/src/mock.rs +++ b/substrate/frame/root-offences/src/mock.rs @@ -162,7 +162,6 @@ parameter_types! { pub const BondingDuration: EraIndex = 3; pub static LedgerSlashPerEra: (BalanceOf, BTreeMap>) = (Zero::zero(), BTreeMap::new()); pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(75); - pub const MaxControllersInDeprecationBatch: u32 = 100; } impl pallet_staking::Config for Test { @@ -189,7 +188,7 @@ impl pallet_staking::Config for Test { type NominationsQuota = pallet_staking::FixedNominationsQuota<16>; type MaxUnlockingChunks = ConstU32<32>; type HistoryDepth = ConstU32<84>; - type MaxControllersInDeprecationBatch = MaxControllersInDeprecationBatch; + type MaxControllersInDeprecationBatch = ConstU32<100>; type VoterList = pallet_staking::UseNominatorsAndValidatorsMap; type EventListeners = (); type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig; diff --git a/substrate/frame/session/benchmarking/src/mock.rs b/substrate/frame/session/benchmarking/src/mock.rs index fee1c50a76b1..e1744fa43abb 100644 --- a/substrate/frame/session/benchmarking/src/mock.rs +++ b/substrate/frame/session/benchmarking/src/mock.rs @@ -145,7 +145,6 @@ pallet_staking_reward_curve::build! { } parameter_types! { pub const RewardCurve: &'static sp_runtime::curve::PiecewiseLinear<'static> = &I_NPOS; - pub const MaxControllersInDeprecationBatch: u32 = 100; pub static ElectionsBounds: ElectionBounds = ElectionBoundsBuilder::default().build(); } @@ -180,7 +179,7 @@ impl pallet_staking::Config for Test { type ElectionProvider = onchain::OnChainExecution; type GenesisElectionProvider = Self::ElectionProvider; type MaxUnlockingChunks = ConstU32<32>; - type MaxControllersInDeprecationBatch = MaxControllersInDeprecationBatch; + type MaxControllersInDeprecationBatch = ConstU32<100>; type HistoryDepth = ConstU32<84>; type VoterList = pallet_staking::UseNominatorsAndValidatorsMap; type TargetList = pallet_staking::UseValidatorsMap; From b693da0e4ac93acc65128c7a1feeb9dd27318ace Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Mon, 4 Dec 2023 10:12:42 +0700 Subject: [PATCH 41/74] fix test-runtime --- polkadot/runtime/test-runtime/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/polkadot/runtime/test-runtime/src/lib.rs b/polkadot/runtime/test-runtime/src/lib.rs index 7ec9f63748c0..2b289d5bccf5 100644 --- a/polkadot/runtime/test-runtime/src/lib.rs +++ b/polkadot/runtime/test-runtime/src/lib.rs @@ -366,6 +366,7 @@ impl pallet_staking::Config for Runtime { type TargetList = pallet_staking::UseValidatorsMap; type NominationsQuota = pallet_staking::FixedNominationsQuota; type MaxUnlockingChunks = frame_support::traits::ConstU32<32>; + type MaxControllersInDeprecationBatch = ConstU32<100>; type HistoryDepth = frame_support::traits::ConstU32<84>; type BenchmarkingConfig = runtime_common::StakingBenchmarkingConfig; type EventListeners = (); From e03c74dd8c7bfdfa4dbd75fa33d177378957be38 Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Mon, 4 Dec 2023 10:29:05 +0700 Subject: [PATCH 42/74] fix --- substrate/frame/staking/src/benchmarking.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/substrate/frame/staking/src/benchmarking.rs b/substrate/frame/staking/src/benchmarking.rs index e3f517714f34..830dad11e0d8 100644 --- a/substrate/frame/staking/src/benchmarking.rs +++ b/substrate/frame/staking/src/benchmarking.rs @@ -528,12 +528,12 @@ benchmarks! { deprecate_controller_batch { // We pass a dynamic number of controllers to the benchmark, up to `MaxControllersInDeprecationBatch`. - let i in 1 .. T::MaxControllersInDeprecationBatch::get(); + let i in 0 .. T::MaxControllersInDeprecationBatch::get(); let mut controllers: Vec<_> = vec![]; let mut stashes: Vec<_> = vec![]; - for n in 1..i as u32 { + for n in 0..i as u32 { let (stash, controller) = create_unique_stash_controller::( n, 100, @@ -547,7 +547,7 @@ benchmarks! { BoundedVec::try_from(controllers.clone()).unwrap(); }: _(RawOrigin::Root, bounded_controllers) verify { - for n in 1..i as u32 { + for n in 0..i as u32 { let stash = &stashes[n as usize]; let controller = &controllers[n as usize]; From 0c1795ac52ee3179056eae291ba582ec707de040 Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Mon, 4 Dec 2023 11:14:13 +0700 Subject: [PATCH 43/74] add weights --- substrate/frame/staking/src/pallet/mod.rs | 2 +- substrate/frame/staking/src/weights.rs | 38 +++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/substrate/frame/staking/src/pallet/mod.rs b/substrate/frame/staking/src/pallet/mod.rs index 06ccc3cd52d1..a0b91d9d6b41 100644 --- a/substrate/frame/staking/src/pallet/mod.rs +++ b/substrate/frame/staking/src/pallet/mod.rs @@ -1933,7 +1933,7 @@ pub mod pallet { /// /// The dispatch origin must be Root. #[pallet::call_index(28)] - #[pallet::weight(T::WeightInfo::update_payee())] // TODO: insert real weight. + #[pallet::weight(T::WeightInfo::deprecate_controller_batch(controllers.len() as u32))] pub fn deprecate_controller_batch( origin: OriginFor, controllers: BoundedVec, diff --git a/substrate/frame/staking/src/weights.rs b/substrate/frame/staking/src/weights.rs index ae00509eaa84..7bd77b3c5e87 100644 --- a/substrate/frame/staking/src/weights.rs +++ b/substrate/frame/staking/src/weights.rs @@ -79,6 +79,7 @@ pub trait WeightInfo { fn chill_other() -> Weight; fn force_apply_min_commission() -> Weight; fn set_min_commission() -> Weight; + fn deprecate_controller_batch(i: u32) -> Weight; } /// Weights for `pallet_staking` using the Substrate node and recommended hardware. @@ -782,6 +783,25 @@ impl WeightInfo for SubstrateWeight { Weight::from_parts(3_278_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } + /// Storage: `Staking::Ledger` (r:100 w:200) + /// Proof: `Staking::Ledger` (`max_values`: None, `max_size`: Some(1091), added: 3566, mode: `MaxEncodedLen`) + /// Storage: `Staking::Bonded` (r:0 w:100) + /// Proof: `Staking::Bonded` (`max_values`: None, `max_size`: Some(72), added: 2547, mode: `MaxEncodedLen`) + /// The range of component `i` is `[0, 100]`. + fn deprecate_controller_batch(i: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `710 + i * (105 ±0)` + // Estimated: `990 + i * (3566 ±0)` + // Minimum execution time: 2_000_000 picoseconds. + Weight::from_parts(6_001_362, 0) + .saturating_add(Weight::from_parts(0, 990)) + // Standard Error: 24_351 + .saturating_add(Weight::from_parts(9_567_945, 0).saturating_mul(i.into())) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(i.into()))) + .saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(i.into()))) + .saturating_add(Weight::from_parts(0, 3566).saturating_mul(i.into())) + } + } // For backwards compatibility and tests. @@ -1484,4 +1504,22 @@ impl WeightInfo for () { Weight::from_parts(3_278_000, 0) .saturating_add(RocksDbWeight::get().writes(1_u64)) } + /// Storage: `Staking::Ledger` (r:100 w:200) + /// Proof: `Staking::Ledger` (`max_values`: None, `max_size`: Some(1091), added: 3566, mode: `MaxEncodedLen`) + /// Storage: `Staking::Bonded` (r:0 w:100) + /// Proof: `Staking::Bonded` (`max_values`: None, `max_size`: Some(72), added: 2547, mode: `MaxEncodedLen`) + /// The range of component `i` is `[0, 100]`. + fn deprecate_controller_batch(i: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `710 + i * (105 ±0)` + // Estimated: `990 + i * (3566 ±0)` + // Minimum execution time: 2_000_000 picoseconds. + Weight::from_parts(6_001_362, 0) + .saturating_add(Weight::from_parts(0, 990)) + // Standard Error: 24_351 + .saturating_add(Weight::from_parts(9_567_945, 0).saturating_mul(i.into())) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(i.into()))) + .saturating_add(RocksDbWeight::get().writes((3_u64).saturating_mul(i.into()))) + .saturating_add(Weight::from_parts(0, 3566).saturating_mul(i.into())) + } } From 23343d4753ed0bf5ef0f8bb7f1a6467133c72e7b Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Mon, 4 Dec 2023 11:22:46 +0700 Subject: [PATCH 44/74] increase westend MaxControllersInDeprecationBatch --- polkadot/runtime/westend/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/polkadot/runtime/westend/src/lib.rs b/polkadot/runtime/westend/src/lib.rs index 144ae86fe5b9..6d7e94da4fd9 100644 --- a/polkadot/runtime/westend/src/lib.rs +++ b/polkadot/runtime/westend/src/lib.rs @@ -681,7 +681,7 @@ parameter_types! { pub const MaxNominators: u32 = 64; pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(17); pub const MaxNominations: u32 = ::LIMIT as u32; - pub const MaxControllersInDeprecationBatch: u32 = 100; + pub const MaxControllersInDeprecationBatch: u32 = 751; } impl pallet_staking::Config for Runtime { From 07b51b86b5ed80bf9061c3810554df15938f4ce6 Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Mon, 4 Dec 2023 11:24:26 +0700 Subject: [PATCH 45/74] + westend weights --- .../westend/src/weights/pallet_staking.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/polkadot/runtime/westend/src/weights/pallet_staking.rs b/polkadot/runtime/westend/src/weights/pallet_staking.rs index 87b603621e8d..91e0091066e8 100644 --- a/polkadot/runtime/westend/src/weights/pallet_staking.rs +++ b/polkadot/runtime/westend/src/weights/pallet_staking.rs @@ -774,4 +774,22 @@ impl pallet_staking::WeightInfo for WeightInfo { .saturating_add(Weight::from_parts(0, 0)) .saturating_add(T::DbWeight::get().writes(1)) } + /// Storage: `Staking::Ledger` (r:100 w:200) + /// Proof: `Staking::Ledger` (`max_values`: None, `max_size`: Some(1091), added: 3566, mode: `MaxEncodedLen`) + /// Storage: `Staking::Bonded` (r:0 w:100) + /// Proof: `Staking::Bonded` (`max_values`: None, `max_size`: Some(72), added: 2547, mode: `MaxEncodedLen`) + /// The range of component `i` is `[0, 100]`. + fn deprecate_controller_batch(i: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `710 + i * (105 ±0)` + // Estimated: `990 + i * (3566 ±0)` + // Minimum execution time: 2_000_000 picoseconds. + Weight::from_parts(6_001_362, 0) + .saturating_add(Weight::from_parts(0, 990)) + // Standard Error: 24_351 + .saturating_add(Weight::from_parts(9_567_945, 0).saturating_mul(i.into())) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(i.into()))) + .saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(i.into()))) + .saturating_add(Weight::from_parts(0, 3566).saturating_mul(i.into())) + } } From c91c912d863a4fff8d74afec42254f023e13c816 Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Mon, 4 Dec 2023 13:41:52 +0700 Subject: [PATCH 46/74] weights for max controllers --- polkadot/runtime/test-runtime/src/lib.rs | 2 +- .../westend/src/weights/pallet_staking.rs | 14 +++++----- substrate/bin/node/runtime/src/lib.rs | 2 +- substrate/frame/staking/src/weights.rs | 28 +++++++++---------- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/polkadot/runtime/test-runtime/src/lib.rs b/polkadot/runtime/test-runtime/src/lib.rs index 2b289d5bccf5..862d0f80ecc0 100644 --- a/polkadot/runtime/test-runtime/src/lib.rs +++ b/polkadot/runtime/test-runtime/src/lib.rs @@ -366,7 +366,7 @@ impl pallet_staking::Config for Runtime { type TargetList = pallet_staking::UseValidatorsMap; type NominationsQuota = pallet_staking::FixedNominationsQuota; type MaxUnlockingChunks = frame_support::traits::ConstU32<32>; - type MaxControllersInDeprecationBatch = ConstU32<100>; + type MaxControllersInDeprecationBatch = ConstU32<5900>; type HistoryDepth = frame_support::traits::ConstU32<84>; type BenchmarkingConfig = runtime_common::StakingBenchmarkingConfig; type EventListeners = (); diff --git a/polkadot/runtime/westend/src/weights/pallet_staking.rs b/polkadot/runtime/westend/src/weights/pallet_staking.rs index 91e0091066e8..7f70e9928c72 100644 --- a/polkadot/runtime/westend/src/weights/pallet_staking.rs +++ b/polkadot/runtime/westend/src/weights/pallet_staking.rs @@ -774,20 +774,20 @@ impl pallet_staking::WeightInfo for WeightInfo { .saturating_add(Weight::from_parts(0, 0)) .saturating_add(T::DbWeight::get().writes(1)) } - /// Storage: `Staking::Ledger` (r:100 w:200) + /// Storage: `Staking::Ledger` (r:5900 w:11800) /// Proof: `Staking::Ledger` (`max_values`: None, `max_size`: Some(1091), added: 3566, mode: `MaxEncodedLen`) - /// Storage: `Staking::Bonded` (r:0 w:100) + /// Storage: `Staking::Bonded` (r:0 w:5900) /// Proof: `Staking::Bonded` (`max_values`: None, `max_size`: Some(72), added: 2547, mode: `MaxEncodedLen`) - /// The range of component `i` is `[0, 100]`. + /// The range of component `i` is `[0, 5900]`. fn deprecate_controller_batch(i: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `710 + i * (105 ±0)` + // Measured: `1015 + i * (105 ±0)` // Estimated: `990 + i * (3566 ±0)` // Minimum execution time: 2_000_000 picoseconds. - Weight::from_parts(6_001_362, 0) + Weight::from_parts(2_000_000, 0) .saturating_add(Weight::from_parts(0, 990)) - // Standard Error: 24_351 - .saturating_add(Weight::from_parts(9_567_945, 0).saturating_mul(i.into())) + // Standard Error: 17_374 + .saturating_add(Weight::from_parts(11_852_767, 0).saturating_mul(i.into())) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(i.into()))) .saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(i.into()))) .saturating_add(Weight::from_parts(0, 3566).saturating_mul(i.into())) diff --git a/substrate/bin/node/runtime/src/lib.rs b/substrate/bin/node/runtime/src/lib.rs index 0347b3eb9912..3e2d3fa2040d 100644 --- a/substrate/bin/node/runtime/src/lib.rs +++ b/substrate/bin/node/runtime/src/lib.rs @@ -634,7 +634,7 @@ parameter_types! { pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE; pub const MaxNominators: u32 = 64; pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(17); - pub const MaxControllersInDeprecationBatch: u32 = 100; + pub const MaxControllersInDeprecationBatch: u32 = 5900; pub OffchainRepeat: BlockNumber = 5; pub HistoryDepth: u32 = 84; } diff --git a/substrate/frame/staking/src/weights.rs b/substrate/frame/staking/src/weights.rs index 7bd77b3c5e87..9674443dbadf 100644 --- a/substrate/frame/staking/src/weights.rs +++ b/substrate/frame/staking/src/weights.rs @@ -783,20 +783,20 @@ impl WeightInfo for SubstrateWeight { Weight::from_parts(3_278_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } - /// Storage: `Staking::Ledger` (r:100 w:200) + /// Storage: `Staking::Ledger` (r:5900 w:11800) /// Proof: `Staking::Ledger` (`max_values`: None, `max_size`: Some(1091), added: 3566, mode: `MaxEncodedLen`) - /// Storage: `Staking::Bonded` (r:0 w:100) + /// Storage: `Staking::Bonded` (r:0 w:5900) /// Proof: `Staking::Bonded` (`max_values`: None, `max_size`: Some(72), added: 2547, mode: `MaxEncodedLen`) - /// The range of component `i` is `[0, 100]`. + /// The range of component `i` is `[0, 5900]`. fn deprecate_controller_batch(i: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `710 + i * (105 ±0)` + // Measured: `1015 + i * (105 ±0)` // Estimated: `990 + i * (3566 ±0)` // Minimum execution time: 2_000_000 picoseconds. - Weight::from_parts(6_001_362, 0) + Weight::from_parts(2_000_000, 0) .saturating_add(Weight::from_parts(0, 990)) - // Standard Error: 24_351 - .saturating_add(Weight::from_parts(9_567_945, 0).saturating_mul(i.into())) + // Standard Error: 17_374 + .saturating_add(Weight::from_parts(11_852_767, 0).saturating_mul(i.into())) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(i.into()))) .saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(i.into()))) .saturating_add(Weight::from_parts(0, 3566).saturating_mul(i.into())) @@ -1504,20 +1504,20 @@ impl WeightInfo for () { Weight::from_parts(3_278_000, 0) .saturating_add(RocksDbWeight::get().writes(1_u64)) } - /// Storage: `Staking::Ledger` (r:100 w:200) + /// Storage: `Staking::Ledger` (r:5900 w:11800) /// Proof: `Staking::Ledger` (`max_values`: None, `max_size`: Some(1091), added: 3566, mode: `MaxEncodedLen`) - /// Storage: `Staking::Bonded` (r:0 w:100) + /// Storage: `Staking::Bonded` (r:0 w:5900) /// Proof: `Staking::Bonded` (`max_values`: None, `max_size`: Some(72), added: 2547, mode: `MaxEncodedLen`) - /// The range of component `i` is `[0, 100]`. + /// The range of component `i` is `[0, 5900]`. fn deprecate_controller_batch(i: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `710 + i * (105 ±0)` + // Measured: `1015 + i * (105 ±0)` // Estimated: `990 + i * (3566 ±0)` // Minimum execution time: 2_000_000 picoseconds. - Weight::from_parts(6_001_362, 0) + Weight::from_parts(2_000_000, 0) .saturating_add(Weight::from_parts(0, 990)) - // Standard Error: 24_351 - .saturating_add(Weight::from_parts(9_567_945, 0).saturating_mul(i.into())) + // Standard Error: 17_374 + .saturating_add(Weight::from_parts(11_852_767, 0).saturating_mul(i.into())) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(i.into()))) .saturating_add(RocksDbWeight::get().writes((3_u64).saturating_mul(i.into()))) .saturating_add(Weight::from_parts(0, 3566).saturating_mul(i.into())) From 866f388f3ec1fa01c684a88017164dcd5bd245b0 Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Mon, 4 Dec 2023 13:42:37 +0000 Subject: [PATCH 47/74] ".git/.scripts/commands/bench/bench.sh" --subcommand=runtime --runtime=westend --target_dir=polkadot --pallet=pallet_staking --- .../westend/src/weights/pallet_staking.rs | 228 +++++++++--------- 1 file changed, 115 insertions(+), 113 deletions(-) diff --git a/polkadot/runtime/westend/src/weights/pallet_staking.rs b/polkadot/runtime/westend/src/weights/pallet_staking.rs index 7f70e9928c72..f69a19743f8b 100644 --- a/polkadot/runtime/westend/src/weights/pallet_staking.rs +++ b/polkadot/runtime/westend/src/weights/pallet_staking.rs @@ -17,9 +17,9 @@ //! Autogenerated weights for `pallet_staking` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-11-21, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-12-04, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `runner-yprdrvc7-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` +//! HOSTNAME: `runner-r43aesjn-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` //! WASM-EXECUTION: `Compiled`, CHAIN: `Some("westend-dev")`, DB CACHE: 1024 // Executed Command: @@ -62,8 +62,8 @@ impl pallet_staking::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `894` // Estimated: `4764` - // Minimum execution time: 38_052_000 picoseconds. - Weight::from_parts(39_303_000, 0) + // Minimum execution time: 38_131_000 picoseconds. + Weight::from_parts(39_750_000, 0) .saturating_add(Weight::from_parts(0, 4764)) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(4)) @@ -84,8 +84,8 @@ impl pallet_staking::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `1921` // Estimated: `8877` - // Minimum execution time: 81_690_000 picoseconds. - Weight::from_parts(83_889_000, 0) + // Minimum execution time: 81_673_000 picoseconds. + Weight::from_parts(84_229_000, 0) .saturating_add(Weight::from_parts(0, 8877)) .saturating_add(T::DbWeight::get().reads(9)) .saturating_add(T::DbWeight::get().writes(7)) @@ -112,8 +112,8 @@ impl pallet_staking::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `2128` // Estimated: `8877` - // Minimum execution time: 84_409_000 picoseconds. - Weight::from_parts(87_330_000, 0) + // Minimum execution time: 85_412_000 picoseconds. + Weight::from_parts(87_733_000, 0) .saturating_add(Weight::from_parts(0, 8877)) .saturating_add(T::DbWeight::get().reads(12)) .saturating_add(T::DbWeight::get().writes(7)) @@ -133,11 +133,11 @@ impl pallet_staking::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `1075` // Estimated: `4764` - // Minimum execution time: 39_770_000 picoseconds. - Weight::from_parts(40_828_632, 0) + // Minimum execution time: 39_818_000 picoseconds. + Weight::from_parts(41_316_192, 0) .saturating_add(Weight::from_parts(0, 4764)) - // Standard Error: 824 - .saturating_add(Weight::from_parts(51_107, 0).saturating_mul(s.into())) + // Standard Error: 865 + .saturating_add(Weight::from_parts(46_320, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -174,11 +174,11 @@ impl pallet_staking::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `2127 + s * (4 ±0)` // Estimated: `6248 + s * (4 ±0)` - // Minimum execution time: 82_500_000 picoseconds. - Weight::from_parts(90_099_121, 0) + // Minimum execution time: 81_972_000 picoseconds. + Weight::from_parts(89_744_685, 0) .saturating_add(Weight::from_parts(0, 6248)) - // Standard Error: 3_280 - .saturating_add(Weight::from_parts(1_273_212, 0).saturating_mul(s.into())) + // Standard Error: 3_956 + .saturating_add(Weight::from_parts(1_272_172, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(13)) .saturating_add(T::DbWeight::get().writes(11)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(s.into()))) @@ -210,8 +210,8 @@ impl pallet_staking::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `1301` // Estimated: `4556` - // Minimum execution time: 48_236_000 picoseconds. - Weight::from_parts(49_518_000, 0) + // Minimum execution time: 48_774_000 picoseconds. + Weight::from_parts(50_515_000, 0) .saturating_add(Weight::from_parts(0, 4556)) .saturating_add(T::DbWeight::get().reads(11)) .saturating_add(T::DbWeight::get().writes(5)) @@ -225,11 +225,11 @@ impl pallet_staking::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `1243 + k * (569 ±0)` // Estimated: `4556 + k * (3033 ±0)` - // Minimum execution time: 28_280_000 picoseconds. - Weight::from_parts(29_182_740, 0) + // Minimum execution time: 28_844_000 picoseconds. + Weight::from_parts(26_928_199, 0) .saturating_add(Weight::from_parts(0, 4556)) - // Standard Error: 6_102 - .saturating_add(Weight::from_parts(6_412_107, 0).saturating_mul(k.into())) + // Standard Error: 10_206 + .saturating_add(Weight::from_parts(6_757_218, 0).saturating_mul(k.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(k.into()))) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(k.into()))) @@ -262,11 +262,11 @@ impl pallet_staking::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `1797 + n * (102 ±0)` // Estimated: `6248 + n * (2520 ±0)` - // Minimum execution time: 59_846_000 picoseconds. - Weight::from_parts(58_029_857, 0) + // Minimum execution time: 59_414_000 picoseconds. + Weight::from_parts(57_811_923, 0) .saturating_add(Weight::from_parts(0, 6248)) - // Standard Error: 15_967 - .saturating_add(Weight::from_parts(3_898_764, 0).saturating_mul(n.into())) + // Standard Error: 18_178 + .saturating_add(Weight::from_parts(3_948_815, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(12)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes(6)) @@ -290,8 +290,8 @@ impl pallet_staking::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `1581` // Estimated: `6248` - // Minimum execution time: 51_223_000 picoseconds. - Weight::from_parts(52_310_000, 0) + // Minimum execution time: 50_272_000 picoseconds. + Weight::from_parts(52_124_000, 0) .saturating_add(Weight::from_parts(0, 6248)) .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().writes(6)) @@ -306,8 +306,8 @@ impl pallet_staking::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `865` // Estimated: `4556` - // Minimum execution time: 15_762_000 picoseconds. - Weight::from_parts(16_381_000, 0) + // Minimum execution time: 15_822_000 picoseconds. + Weight::from_parts(16_429_000, 0) .saturating_add(Weight::from_parts(0, 4556)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) @@ -322,8 +322,8 @@ impl pallet_staking::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `932` // Estimated: `4556` - // Minimum execution time: 21_904_000 picoseconds. - Weight::from_parts(22_373_000, 0) + // Minimum execution time: 21_657_000 picoseconds. + Weight::from_parts(22_400_000, 0) .saturating_add(Weight::from_parts(0, 4556)) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(1)) @@ -336,8 +336,8 @@ impl pallet_staking::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `865` // Estimated: `4556` - // Minimum execution time: 18_869_000 picoseconds. - Weight::from_parts(19_422_000, 0) + // Minimum execution time: 18_721_000 picoseconds. + Weight::from_parts(19_168_000, 0) .saturating_add(Weight::from_parts(0, 4556)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(3)) @@ -348,8 +348,8 @@ impl pallet_staking::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_205_000 picoseconds. - Weight::from_parts(2_320_000, 0) + // Minimum execution time: 2_110_000 picoseconds. + Weight::from_parts(2_250_000, 0) .saturating_add(Weight::from_parts(0, 0)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -359,8 +359,8 @@ impl pallet_staking::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_179_000 picoseconds. - Weight::from_parts(7_843_000, 0) + // Minimum execution time: 7_283_000 picoseconds. + Weight::from_parts(7_716_000, 0) .saturating_add(Weight::from_parts(0, 0)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -370,8 +370,8 @@ impl pallet_staking::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_206_000 picoseconds. - Weight::from_parts(7_829_000, 0) + // Minimum execution time: 7_356_000 picoseconds. + Weight::from_parts(7_773_000, 0) .saturating_add(Weight::from_parts(0, 0)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -381,8 +381,8 @@ impl pallet_staking::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_414_000 picoseconds. - Weight::from_parts(7_770_000, 0) + // Minimum execution time: 7_309_000 picoseconds. + Weight::from_parts(7_605_000, 0) .saturating_add(Weight::from_parts(0, 0)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -393,13 +393,31 @@ impl pallet_staking::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_256_000 picoseconds. - Weight::from_parts(2_645_840, 0) + // Minimum execution time: 2_319_000 picoseconds. + Weight::from_parts(2_597_614, 0) .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 37 - .saturating_add(Weight::from_parts(10_207, 0).saturating_mul(v.into())) + // Standard Error: 77 + .saturating_add(Weight::from_parts(12_005, 0).saturating_mul(v.into())) .saturating_add(T::DbWeight::get().writes(1)) } + /// Storage: `Staking::Ledger` (r:751 w:1502) + /// Proof: `Staking::Ledger` (`max_values`: None, `max_size`: Some(1091), added: 3566, mode: `MaxEncodedLen`) + /// Storage: `Staking::Bonded` (r:0 w:751) + /// Proof: `Staking::Bonded` (`max_values`: None, `max_size`: Some(72), added: 2547, mode: `MaxEncodedLen`) + /// The range of component `i` is `[0, 751]`. + fn deprecate_controller_batch(i: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `670 + i * (101 ±0)` + // Estimated: `990 + i * (3566 ±0)` + // Minimum execution time: 1_757_000 picoseconds. + Weight::from_parts(1_852_000, 0) + .saturating_add(Weight::from_parts(0, 990)) + // Standard Error: 13_274 + .saturating_add(Weight::from_parts(9_581_951, 0).saturating_mul(i.into())) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(i.into()))) + .saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(i.into()))) + .saturating_add(Weight::from_parts(0, 3566).saturating_mul(i.into())) + } /// Storage: `Staking::SlashingSpans` (r:1 w:1) /// Proof: `Staking::SlashingSpans` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `Staking::Bonded` (r:1 w:1) @@ -433,11 +451,11 @@ impl pallet_staking::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `2127 + s * (4 ±0)` // Estimated: `6248 + s * (4 ±0)` - // Minimum execution time: 81_032_000 picoseconds. - Weight::from_parts(88_297_596, 0) + // Minimum execution time: 80_758_000 picoseconds. + Weight::from_parts(87_211_938, 0) .saturating_add(Weight::from_parts(0, 6248)) - // Standard Error: 3_070 - .saturating_add(Weight::from_parts(1_207_207, 0).saturating_mul(s.into())) + // Standard Error: 3_191 + .saturating_add(Weight::from_parts(1_212_350, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(13)) .saturating_add(T::DbWeight::get().writes(12)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(s.into()))) @@ -450,11 +468,11 @@ impl pallet_staking::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `66639` // Estimated: `70104` - // Minimum execution time: 131_456_000 picoseconds. - Weight::from_parts(935_254_517, 0) + // Minimum execution time: 133_849_000 picoseconds. + Weight::from_parts(1_204_195_716, 0) .saturating_add(Weight::from_parts(0, 70104)) - // Standard Error: 57_806 - .saturating_add(Weight::from_parts(4_823_189, 0).saturating_mul(s.into())) + // Standard Error: 77_028 + .saturating_add(Weight::from_parts(6_462_199, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -490,12 +508,12 @@ impl pallet_staking::WeightInfo for WeightInfo { fn payout_stakers_alive_staked(n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `8249 + n * (396 ±0)` - // Estimated: `10779 + n * (3774 ±0)` - // Minimum execution time: 129_233_000 picoseconds. - Weight::from_parts(165_096_042, 0) + // Estimated: `10779 + n * (3774 ±3)` + // Minimum execution time: 130_738_000 picoseconds. + Weight::from_parts(177_263_167, 0) .saturating_add(Weight::from_parts(0, 10779)) - // Standard Error: 29_598 - .saturating_add(Weight::from_parts(40_716_425, 0).saturating_mul(n.into())) + // Standard Error: 57_605 + .saturating_add(Weight::from_parts(42_162_920, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(14)) .saturating_add(T::DbWeight::get().reads((6_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes(4)) @@ -519,11 +537,11 @@ impl pallet_staking::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `1922 + l * (5 ±0)` // Estimated: `8877` - // Minimum execution time: 77_223_000 picoseconds. - Weight::from_parts(80_026_259, 0) + // Minimum execution time: 77_417_000 picoseconds. + Weight::from_parts(79_886_333, 0) .saturating_add(Weight::from_parts(0, 8877)) - // Standard Error: 4_493 - .saturating_add(Weight::from_parts(52_909, 0).saturating_mul(l.into())) + // Standard Error: 4_437 + .saturating_add(Weight::from_parts(57_506, 0).saturating_mul(l.into())) .saturating_add(T::DbWeight::get().reads(9)) .saturating_add(T::DbWeight::get().writes(7)) } @@ -558,11 +576,11 @@ impl pallet_staking::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `2127 + s * (4 ±0)` // Estimated: `6248 + s * (4 ±0)` - // Minimum execution time: 89_871_000 picoseconds. - Weight::from_parts(92_313_331, 0) + // Minimum execution time: 89_339_000 picoseconds. + Weight::from_parts(92_298_354, 0) .saturating_add(Weight::from_parts(0, 6248)) - // Standard Error: 3_321 - .saturating_add(Weight::from_parts(1_243_347, 0).saturating_mul(s.into())) + // Standard Error: 3_468 + .saturating_add(Weight::from_parts(1_211_827, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(12)) .saturating_add(T::DbWeight::get().writes(11)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(s.into()))) @@ -608,13 +626,13 @@ impl pallet_staking::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0 + n * (716 ±0) + v * (3594 ±0)` // Estimated: `456136 + n * (3566 ±0) + v * (3566 ±0)` - // Minimum execution time: 518_819_000 picoseconds. - Weight::from_parts(522_108_000, 0) + // Minimum execution time: 524_072_000 picoseconds. + Weight::from_parts(530_854_000, 0) .saturating_add(Weight::from_parts(0, 456136)) - // Standard Error: 1_987_848 - .saturating_add(Weight::from_parts(64_855_377, 0).saturating_mul(v.into())) - // Standard Error: 198_078 - .saturating_add(Weight::from_parts(18_343_485, 0).saturating_mul(n.into())) + // Standard Error: 2_163_307 + .saturating_add(Weight::from_parts(70_082_102, 0).saturating_mul(v.into())) + // Standard Error: 215_561 + .saturating_add(Weight::from_parts(19_364_205, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(184)) .saturating_add(T::DbWeight::get().reads((5_u64).saturating_mul(v.into()))) .saturating_add(T::DbWeight::get().reads((4_u64).saturating_mul(n.into()))) @@ -645,13 +663,13 @@ impl pallet_staking::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `3108 + n * (907 ±0) + v * (391 ±0)` // Estimated: `456136 + n * (3566 ±0) + v * (3566 ±0)` - // Minimum execution time: 34_976_277_000 picoseconds. - Weight::from_parts(35_245_501_000, 0) + // Minimum execution time: 35_973_199_000 picoseconds. + Weight::from_parts(37_068_877_000, 0) .saturating_add(Weight::from_parts(0, 456136)) - // Standard Error: 386_461 - .saturating_add(Weight::from_parts(5_145_210, 0).saturating_mul(v.into())) - // Standard Error: 386_461 - .saturating_add(Weight::from_parts(3_762_623, 0).saturating_mul(n.into())) + // Standard Error: 417_905 + .saturating_add(Weight::from_parts(5_666_298, 0).saturating_mul(v.into())) + // Standard Error: 417_905 + .saturating_add(Weight::from_parts(4_689_560, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(179)) .saturating_add(T::DbWeight::get().reads((5_u64).saturating_mul(v.into()))) .saturating_add(T::DbWeight::get().reads((4_u64).saturating_mul(n.into()))) @@ -668,11 +686,11 @@ impl pallet_staking::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `946 + v * (50 ±0)` // Estimated: `3510 + v * (2520 ±0)` - // Minimum execution time: 2_577_411_000 picoseconds. - Weight::from_parts(86_073_486, 0) + // Minimum execution time: 2_515_600_000 picoseconds. + Weight::from_parts(83_484_440, 0) .saturating_add(Weight::from_parts(0, 3510)) - // Standard Error: 8_363 - .saturating_add(Weight::from_parts(5_074_828, 0).saturating_mul(v.into())) + // Standard Error: 15_899 + .saturating_add(Weight::from_parts(5_080_559, 0).saturating_mul(v.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(v.into()))) .saturating_add(Weight::from_parts(0, 2520).saturating_mul(v.into())) @@ -693,8 +711,8 @@ impl pallet_staking::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_539_000 picoseconds. - Weight::from_parts(3_903_000, 0) + // Minimum execution time: 3_663_000 picoseconds. + Weight::from_parts(3_970_000, 0) .saturating_add(Weight::from_parts(0, 0)) .saturating_add(T::DbWeight::get().writes(6)) } @@ -714,11 +732,13 @@ impl pallet_staking::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_244_000 picoseconds. - Weight::from_parts(3_450_000, 0) + // Minimum execution time: 3_362_000 picoseconds. + Weight::from_parts(3_549_000, 0) .saturating_add(Weight::from_parts(0, 0)) .saturating_add(T::DbWeight::get().writes(6)) } + /// Storage: `Staking::Bonded` (r:1 w:0) + /// Proof: `Staking::Bonded` (`max_values`: None, `max_size`: Some(72), added: 2547, mode: `MaxEncodedLen`) /// Storage: `Staking::Ledger` (r:1 w:0) /// Proof: `Staking::Ledger` (`max_values`: None, `max_size`: Some(1091), added: 3566, mode: `MaxEncodedLen`) /// Storage: `Staking::Nominators` (r:1 w:1) @@ -741,12 +761,12 @@ impl pallet_staking::WeightInfo for WeightInfo { /// Proof: `VoterList::CounterForListNodes` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) fn chill_other() -> Weight { // Proof Size summary in bytes: - // Measured: `1704` + // Measured: `1870` // Estimated: `6248` - // Minimum execution time: 62_606_000 picoseconds. - Weight::from_parts(64_678_000, 0) + // Minimum execution time: 66_875_000 picoseconds. + Weight::from_parts(68_380_000, 0) .saturating_add(Weight::from_parts(0, 6248)) - .saturating_add(T::DbWeight::get().reads(11)) + .saturating_add(T::DbWeight::get().reads(12)) .saturating_add(T::DbWeight::get().writes(6)) } /// Storage: `Staking::MinCommission` (r:1 w:0) @@ -757,8 +777,8 @@ impl pallet_staking::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `658` // Estimated: `3510` - // Minimum execution time: 11_490_000 picoseconds. - Weight::from_parts(11_867_000, 0) + // Minimum execution time: 11_377_000 picoseconds. + Weight::from_parts(12_038_000, 0) .saturating_add(Weight::from_parts(0, 3510)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) @@ -769,27 +789,9 @@ impl pallet_staking::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_125_000 picoseconds. - Weight::from_parts(2_337_000, 0) + // Minimum execution time: 2_272_000 picoseconds. + Weight::from_parts(2_341_000, 0) .saturating_add(Weight::from_parts(0, 0)) .saturating_add(T::DbWeight::get().writes(1)) } - /// Storage: `Staking::Ledger` (r:5900 w:11800) - /// Proof: `Staking::Ledger` (`max_values`: None, `max_size`: Some(1091), added: 3566, mode: `MaxEncodedLen`) - /// Storage: `Staking::Bonded` (r:0 w:5900) - /// Proof: `Staking::Bonded` (`max_values`: None, `max_size`: Some(72), added: 2547, mode: `MaxEncodedLen`) - /// The range of component `i` is `[0, 5900]`. - fn deprecate_controller_batch(i: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `1015 + i * (105 ±0)` - // Estimated: `990 + i * (3566 ±0)` - // Minimum execution time: 2_000_000 picoseconds. - Weight::from_parts(2_000_000, 0) - .saturating_add(Weight::from_parts(0, 990)) - // Standard Error: 17_374 - .saturating_add(Weight::from_parts(11_852_767, 0).saturating_mul(i.into())) - .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(i.into()))) - .saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(i.into()))) - .saturating_add(Weight::from_parts(0, 3566).saturating_mul(i.into())) - } } From c3e482c556af6c36ded46f275e41df58d57e6586 Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Mon, 4 Dec 2023 15:14:23 +0000 Subject: [PATCH 48/74] ".git/.scripts/commands/bench/bench.sh" --subcommand=pallet --runtime=dev --target_dir=substrate --pallet=pallet_staking --- substrate/frame/staking/src/weights.rs | 441 ++++++++++++------------- 1 file changed, 219 insertions(+), 222 deletions(-) diff --git a/substrate/frame/staking/src/weights.rs b/substrate/frame/staking/src/weights.rs index 9674443dbadf..4d986db5408d 100644 --- a/substrate/frame/staking/src/weights.rs +++ b/substrate/frame/staking/src/weights.rs @@ -18,9 +18,9 @@ //! Autogenerated weights for `pallet_staking` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-11-27, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-12-04, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `runner-yprdrvc7-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` +//! HOSTNAME: `runner-r43aesjn-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` //! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` // Executed Command: @@ -66,6 +66,7 @@ pub trait WeightInfo { fn force_new_era() -> Weight; fn force_new_era_always() -> Weight; fn set_invulnerables(v: u32, ) -> Weight; + fn deprecate_controller_batch(i: u32, ) -> Weight; fn force_unstake(s: u32, ) -> Weight; fn cancel_deferred_slash(s: u32, ) -> Weight; fn payout_stakers_alive_staked(n: u32, ) -> Weight; @@ -79,7 +80,6 @@ pub trait WeightInfo { fn chill_other() -> Weight; fn force_apply_min_commission() -> Weight; fn set_min_commission() -> Weight; - fn deprecate_controller_batch(i: u32) -> Weight; } /// Weights for `pallet_staking` using the Substrate node and recommended hardware. @@ -99,8 +99,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `927` // Estimated: `4764` - // Minimum execution time: 42_895_000 picoseconds. - Weight::from_parts(44_924_000, 4764) + // Minimum execution time: 42_189_000 picoseconds. + Weight::from_parts(43_771_000, 4764) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -120,8 +120,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `1990` // Estimated: `8877` - // Minimum execution time: 87_734_000 picoseconds. - Weight::from_parts(90_762_000, 8877) + // Minimum execution time: 86_677_000 picoseconds. + Weight::from_parts(89_437_000, 8877) .saturating_add(T::DbWeight::get().reads(9_u64)) .saturating_add(T::DbWeight::get().writes(7_u64)) } @@ -147,8 +147,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `2195` // Estimated: `8877` - // Minimum execution time: 90_914_000 picoseconds. - Weight::from_parts(94_156_000, 8877) + // Minimum execution time: 90_824_000 picoseconds. + Weight::from_parts(92_907_000, 8877) .saturating_add(T::DbWeight::get().reads(12_u64)) .saturating_add(T::DbWeight::get().writes(7_u64)) } @@ -167,10 +167,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `1115` // Estimated: `4764` - // Minimum execution time: 43_141_000 picoseconds. - Weight::from_parts(45_081_969, 4764) - // Standard Error: 1_010 - .saturating_add(Weight::from_parts(39_539, 0).saturating_mul(s.into())) + // Minimum execution time: 42_837_000 picoseconds. + Weight::from_parts(44_269_425, 4764) + // Standard Error: 817 + .saturating_add(Weight::from_parts(43_253, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -207,10 +207,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `2196 + s * (4 ±0)` // Estimated: `6248 + s * (4 ±0)` - // Minimum execution time: 87_743_000 picoseconds. - Weight::from_parts(96_983_484, 6248) - // Standard Error: 4_271 - .saturating_add(Weight::from_parts(1_382_993, 0).saturating_mul(s.into())) + // Minimum execution time: 87_194_000 picoseconds. + Weight::from_parts(95_999_434, 6248) + // Standard Error: 3_674 + .saturating_add(Weight::from_parts(1_320_100, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(13_u64)) .saturating_add(T::DbWeight::get().writes(11_u64)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(s.into()))) @@ -242,8 +242,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `1372` // Estimated: `4556` - // Minimum execution time: 51_888_000 picoseconds. - Weight::from_parts(54_353_000, 4556) + // Minimum execution time: 51_574_000 picoseconds. + Weight::from_parts(54_444_000, 4556) .saturating_add(T::DbWeight::get().reads(11_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } @@ -256,10 +256,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `1280 + k * (569 ±0)` // Estimated: `4556 + k * (3033 ±0)` - // Minimum execution time: 28_944_000 picoseconds. - Weight::from_parts(31_116_533, 4556) - // Standard Error: 11_848 - .saturating_add(Weight::from_parts(6_422_601, 0).saturating_mul(k.into())) + // Minimum execution time: 28_579_000 picoseconds. + Weight::from_parts(31_179_862, 4556) + // Standard Error: 7_307 + .saturating_add(Weight::from_parts(6_198_340, 0).saturating_mul(k.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(k.into()))) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(k.into()))) @@ -292,10 +292,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `1866 + n * (102 ±0)` // Estimated: `6248 + n * (2520 ±0)` - // Minimum execution time: 63_921_000 picoseconds. - Weight::from_parts(62_662_863, 6248) - // Standard Error: 15_071 - .saturating_add(Weight::from_parts(3_950_084, 0).saturating_mul(n.into())) + // Minimum execution time: 62_856_000 picoseconds. + Weight::from_parts(60_783_406, 6248) + // Standard Error: 13_888 + .saturating_add(Weight::from_parts(3_953_896, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(12_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes(6_u64)) @@ -319,8 +319,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `1650` // Estimated: `6248` - // Minimum execution time: 54_605_000 picoseconds. - Weight::from_parts(56_406_000, 6248) + // Minimum execution time: 53_408_000 picoseconds. + Weight::from_parts(54_715_000, 6248) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(6_u64)) } @@ -334,8 +334,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `902` // Estimated: `4556` - // Minimum execution time: 16_826_000 picoseconds. - Weight::from_parts(17_326_000, 4556) + // Minimum execution time: 16_708_000 picoseconds. + Weight::from_parts(17_177_000, 4556) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -349,8 +349,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `969` // Estimated: `4556` - // Minimum execution time: 20_831_000 picoseconds. - Weight::from_parts(21_615_000, 4556) + // Minimum execution time: 20_516_000 picoseconds. + Weight::from_parts(21_240_000, 4556) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -362,8 +362,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `902` // Estimated: `4556` - // Minimum execution time: 20_190_000 picoseconds. - Weight::from_parts(20_993_000, 4556) + // Minimum execution time: 19_514_000 picoseconds. + Weight::from_parts(20_519_000, 4556) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -373,8 +373,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_603_000 picoseconds. - Weight::from_parts(2_747_000, 0) + // Minimum execution time: 2_477_000 picoseconds. + Weight::from_parts(2_792_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: `Staking::ForceEra` (r:0 w:1) @@ -383,8 +383,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 8_070_000 picoseconds. - Weight::from_parts(8_745_000, 0) + // Minimum execution time: 7_917_000 picoseconds. + Weight::from_parts(8_342_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: `Staking::ForceEra` (r:0 w:1) @@ -393,8 +393,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_999_000 picoseconds. - Weight::from_parts(8_624_000, 0) + // Minimum execution time: 8_212_000 picoseconds. + Weight::from_parts(8_506_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: `Staking::ForceEra` (r:0 w:1) @@ -403,8 +403,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 8_131_000 picoseconds. - Weight::from_parts(8_467_000, 0) + // Minimum execution time: 8_052_000 picoseconds. + Weight::from_parts(8_405_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: `Staking::Invulnerables` (r:0 w:1) @@ -414,12 +414,29 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_731_000 picoseconds. - Weight::from_parts(3_298_421, 0) - // Standard Error: 31 - .saturating_add(Weight::from_parts(10_075, 0).saturating_mul(v.into())) + // Minimum execution time: 2_676_000 picoseconds. + Weight::from_parts(3_288_767, 0) + // Standard Error: 69 + .saturating_add(Weight::from_parts(11_426, 0).saturating_mul(v.into())) .saturating_add(T::DbWeight::get().writes(1_u64)) } + /// Storage: `Staking::Ledger` (r:5900 w:11800) + /// Proof: `Staking::Ledger` (`max_values`: None, `max_size`: Some(1091), added: 3566, mode: `MaxEncodedLen`) + /// Storage: `Staking::Bonded` (r:0 w:5900) + /// Proof: `Staking::Bonded` (`max_values`: None, `max_size`: Some(72), added: 2547, mode: `MaxEncodedLen`) + /// The range of component `i` is `[0, 5900]`. + fn deprecate_controller_batch(i: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1015 + i * (105 ±0)` + // Estimated: `990 + i * (3566 ±0)` + // Minimum execution time: 2_104_000 picoseconds. + Weight::from_parts(2_155_000, 990) + // Standard Error: 22_751 + .saturating_add(Weight::from_parts(11_460_237, 0).saturating_mul(i.into())) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(i.into()))) + .saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(i.into()))) + .saturating_add(Weight::from_parts(0, 3566).saturating_mul(i.into())) + } /// Storage: `Staking::SlashingSpans` (r:1 w:1) /// Proof: `Staking::SlashingSpans` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `Staking::Bonded` (r:1 w:1) @@ -453,10 +470,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `2196 + s * (4 ±0)` // Estimated: `6248 + s * (4 ±0)` - // Minimum execution time: 86_305_000 picoseconds. - Weight::from_parts(94_494_401, 6248) - // Standard Error: 3_602 - .saturating_add(Weight::from_parts(1_339_477, 0).saturating_mul(s.into())) + // Minimum execution time: 85_268_000 picoseconds. + Weight::from_parts(93_698_590, 6248) + // Standard Error: 3_793 + .saturating_add(Weight::from_parts(1_323_467, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(13_u64)) .saturating_add(T::DbWeight::get().writes(12_u64)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(s.into()))) @@ -469,10 +486,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `66672` // Estimated: `70137` - // Minimum execution time: 100_007_000 picoseconds. - Weight::from_parts(894_033_025, 70137) - // Standard Error: 57_584 - .saturating_add(Weight::from_parts(4_870_504, 0).saturating_mul(s.into())) + // Minimum execution time: 103_919_000 picoseconds. + Weight::from_parts(1_163_897_466, 70137) + // Standard Error: 76_813 + .saturating_add(Weight::from_parts(6_482_249, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -509,10 +526,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `33297 + n * (377 ±0)` // Estimated: `30944 + n * (3774 ±0)` - // Minimum execution time: 142_575_000 picoseconds. - Weight::from_parts(196_320_577, 30944) - // Standard Error: 29_330 - .saturating_add(Weight::from_parts(45_325_062, 0).saturating_mul(n.into())) + // Minimum execution time: 141_186_000 picoseconds. + Weight::from_parts(170_953_387, 30944) + // Standard Error: 32_141 + .saturating_add(Weight::from_parts(45_316_107, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(14_u64)) .saturating_add(T::DbWeight::get().reads((6_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes(4_u64)) @@ -536,10 +553,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `1991 + l * (7 ±0)` // Estimated: `8877` - // Minimum execution time: 81_113_000 picoseconds. - Weight::from_parts(84_470_927, 8877) - // Standard Error: 5_588 - .saturating_add(Weight::from_parts(97_606, 0).saturating_mul(l.into())) + // Minimum execution time: 80_676_000 picoseconds. + Weight::from_parts(83_786_705, 8877) + // Standard Error: 4_547 + .saturating_add(Weight::from_parts(79_908, 0).saturating_mul(l.into())) .saturating_add(T::DbWeight::get().reads(9_u64)) .saturating_add(T::DbWeight::get().writes(7_u64)) } @@ -574,10 +591,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `2196 + s * (4 ±0)` // Estimated: `6248 + s * (4 ±0)` - // Minimum execution time: 94_810_000 picoseconds. - Weight::from_parts(99_292_156, 6248) - // Standard Error: 3_677 - .saturating_add(Weight::from_parts(1_345_598, 0).saturating_mul(s.into())) + // Minimum execution time: 94_239_000 picoseconds. + Weight::from_parts(98_128_278, 6248) + // Standard Error: 3_345 + .saturating_add(Weight::from_parts(1_323_942, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(12_u64)) .saturating_add(T::DbWeight::get().writes(11_u64)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(s.into()))) @@ -622,13 +639,13 @@ impl WeightInfo for SubstrateWeight { fn new_era(v: u32, n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0 + n * (720 ±0) + v * (3598 ±0)` - // Estimated: `512390 + n * (3566 ±4) + v * (3566 ±40)` - // Minimum execution time: 583_230_000 picoseconds. - Weight::from_parts(585_794_000, 512390) - // Standard Error: 1_984_644 - .saturating_add(Weight::from_parts(65_914_551, 0).saturating_mul(v.into())) - // Standard Error: 197_758 - .saturating_add(Weight::from_parts(18_105_424, 0).saturating_mul(n.into())) + // Estimated: `512390 + n * (3566 ±0) + v * (3566 ±0)` + // Minimum execution time: 561_749_000 picoseconds. + Weight::from_parts(565_657_000, 512390) + // Standard Error: 2_021_729 + .saturating_add(Weight::from_parts(67_864_146, 0).saturating_mul(v.into())) + // Standard Error: 201_454 + .saturating_add(Weight::from_parts(18_172_710, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(206_u64)) .saturating_add(T::DbWeight::get().reads((5_u64).saturating_mul(v.into()))) .saturating_add(T::DbWeight::get().reads((4_u64).saturating_mul(n.into()))) @@ -659,12 +676,12 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `3175 + n * (911 ±0) + v * (395 ±0)` // Estimated: `512390 + n * (3566 ±0) + v * (3566 ±0)` - // Minimum execution time: 33_312_958_000 picoseconds. - Weight::from_parts(4_949_866_209, 512390) - // Standard Error: 402_931 - .saturating_add(Weight::from_parts(16_448_367, 0).saturating_mul(v.into())) - // Standard Error: 402_931 - .saturating_add(Weight::from_parts(25_361_503, 0).saturating_mul(n.into())) + // Minimum execution time: 32_858_623_000 picoseconds. + Weight::from_parts(32_996_593_000, 512390) + // Standard Error: 356_817 + .saturating_add(Weight::from_parts(5_152_745, 0).saturating_mul(v.into())) + // Standard Error: 356_817 + .saturating_add(Weight::from_parts(3_183_518, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(201_u64)) .saturating_add(T::DbWeight::get().reads((5_u64).saturating_mul(v.into()))) .saturating_add(T::DbWeight::get().reads((4_u64).saturating_mul(n.into()))) @@ -681,10 +698,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `979 + v * (50 ±0)` // Estimated: `3510 + v * (2520 ±0)` - // Minimum execution time: 2_474_646_000 picoseconds. - Weight::from_parts(2_512_113_000, 3510) - // Standard Error: 33_996 - .saturating_add(Weight::from_parts(1_992_173, 0).saturating_mul(v.into())) + // Minimum execution time: 2_433_720_000 picoseconds. + Weight::from_parts(108_144_707, 3510) + // Standard Error: 6_825 + .saturating_add(Weight::from_parts(4_664_777, 0).saturating_mul(v.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(v.into()))) .saturating_add(Weight::from_parts(0, 2520).saturating_mul(v.into())) @@ -705,8 +722,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 5_466_000 picoseconds. - Weight::from_parts(5_861_000, 0) + // Minimum execution time: 5_259_000 picoseconds. + Weight::from_parts(5_726_000, 0) .saturating_add(T::DbWeight::get().writes(6_u64)) } /// Storage: `Staking::MinCommission` (r:0 w:1) @@ -725,8 +742,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 4_780_000 picoseconds. - Weight::from_parts(4_998_000, 0) + // Minimum execution time: 4_772_000 picoseconds. + Weight::from_parts(4_960_000, 0) .saturating_add(T::DbWeight::get().writes(6_u64)) } /// Storage: `Staking::Bonded` (r:1 w:0) @@ -755,8 +772,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `1939` // Estimated: `6248` - // Minimum execution time: 71_261_000 picoseconds. - Weight::from_parts(72_778_000, 6248) + // Minimum execution time: 69_269_000 picoseconds. + Weight::from_parts(71_478_000, 6248) .saturating_add(T::DbWeight::get().reads(12_u64)) .saturating_add(T::DbWeight::get().writes(6_u64)) } @@ -768,8 +785,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `691` // Estimated: `3510` - // Minimum execution time: 12_497_000 picoseconds. - Weight::from_parts(13_049_000, 3510) + // Minimum execution time: 12_436_000 picoseconds. + Weight::from_parts(12_749_000, 3510) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -779,29 +796,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_044_000 picoseconds. - Weight::from_parts(3_278_000, 0) + // Minimum execution time: 3_073_000 picoseconds. + Weight::from_parts(3_240_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } - /// Storage: `Staking::Ledger` (r:5900 w:11800) - /// Proof: `Staking::Ledger` (`max_values`: None, `max_size`: Some(1091), added: 3566, mode: `MaxEncodedLen`) - /// Storage: `Staking::Bonded` (r:0 w:5900) - /// Proof: `Staking::Bonded` (`max_values`: None, `max_size`: Some(72), added: 2547, mode: `MaxEncodedLen`) - /// The range of component `i` is `[0, 5900]`. - fn deprecate_controller_batch(i: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `1015 + i * (105 ±0)` - // Estimated: `990 + i * (3566 ±0)` - // Minimum execution time: 2_000_000 picoseconds. - Weight::from_parts(2_000_000, 0) - .saturating_add(Weight::from_parts(0, 990)) - // Standard Error: 17_374 - .saturating_add(Weight::from_parts(11_852_767, 0).saturating_mul(i.into())) - .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(i.into()))) - .saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(i.into()))) - .saturating_add(Weight::from_parts(0, 3566).saturating_mul(i.into())) - } - } // For backwards compatibility and tests. @@ -820,8 +818,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `927` // Estimated: `4764` - // Minimum execution time: 42_895_000 picoseconds. - Weight::from_parts(44_924_000, 4764) + // Minimum execution time: 42_189_000 picoseconds. + Weight::from_parts(43_771_000, 4764) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -841,8 +839,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1990` // Estimated: `8877` - // Minimum execution time: 87_734_000 picoseconds. - Weight::from_parts(90_762_000, 8877) + // Minimum execution time: 86_677_000 picoseconds. + Weight::from_parts(89_437_000, 8877) .saturating_add(RocksDbWeight::get().reads(9_u64)) .saturating_add(RocksDbWeight::get().writes(7_u64)) } @@ -868,8 +866,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `2195` // Estimated: `8877` - // Minimum execution time: 90_914_000 picoseconds. - Weight::from_parts(94_156_000, 8877) + // Minimum execution time: 90_824_000 picoseconds. + Weight::from_parts(92_907_000, 8877) .saturating_add(RocksDbWeight::get().reads(12_u64)) .saturating_add(RocksDbWeight::get().writes(7_u64)) } @@ -888,10 +886,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1115` // Estimated: `4764` - // Minimum execution time: 43_141_000 picoseconds. - Weight::from_parts(45_081_969, 4764) - // Standard Error: 1_010 - .saturating_add(Weight::from_parts(39_539, 0).saturating_mul(s.into())) + // Minimum execution time: 42_837_000 picoseconds. + Weight::from_parts(44_269_425, 4764) + // Standard Error: 817 + .saturating_add(Weight::from_parts(43_253, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -928,10 +926,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `2196 + s * (4 ±0)` // Estimated: `6248 + s * (4 ±0)` - // Minimum execution time: 87_743_000 picoseconds. - Weight::from_parts(96_983_484, 6248) - // Standard Error: 4_271 - .saturating_add(Weight::from_parts(1_382_993, 0).saturating_mul(s.into())) + // Minimum execution time: 87_194_000 picoseconds. + Weight::from_parts(95_999_434, 6248) + // Standard Error: 3_674 + .saturating_add(Weight::from_parts(1_320_100, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(13_u64)) .saturating_add(RocksDbWeight::get().writes(11_u64)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(s.into()))) @@ -963,8 +961,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1372` // Estimated: `4556` - // Minimum execution time: 51_888_000 picoseconds. - Weight::from_parts(54_353_000, 4556) + // Minimum execution time: 51_574_000 picoseconds. + Weight::from_parts(54_444_000, 4556) .saturating_add(RocksDbWeight::get().reads(11_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) } @@ -977,10 +975,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1280 + k * (569 ±0)` // Estimated: `4556 + k * (3033 ±0)` - // Minimum execution time: 28_944_000 picoseconds. - Weight::from_parts(31_116_533, 4556) - // Standard Error: 11_848 - .saturating_add(Weight::from_parts(6_422_601, 0).saturating_mul(k.into())) + // Minimum execution time: 28_579_000 picoseconds. + Weight::from_parts(31_179_862, 4556) + // Standard Error: 7_307 + .saturating_add(Weight::from_parts(6_198_340, 0).saturating_mul(k.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(k.into()))) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(k.into()))) @@ -1013,10 +1011,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1866 + n * (102 ±0)` // Estimated: `6248 + n * (2520 ±0)` - // Minimum execution time: 63_921_000 picoseconds. - Weight::from_parts(62_662_863, 6248) - // Standard Error: 15_071 - .saturating_add(Weight::from_parts(3_950_084, 0).saturating_mul(n.into())) + // Minimum execution time: 62_856_000 picoseconds. + Weight::from_parts(60_783_406, 6248) + // Standard Error: 13_888 + .saturating_add(Weight::from_parts(3_953_896, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(12_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(n.into()))) .saturating_add(RocksDbWeight::get().writes(6_u64)) @@ -1040,8 +1038,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1650` // Estimated: `6248` - // Minimum execution time: 54_605_000 picoseconds. - Weight::from_parts(56_406_000, 6248) + // Minimum execution time: 53_408_000 picoseconds. + Weight::from_parts(54_715_000, 6248) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(6_u64)) } @@ -1055,8 +1053,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `902` // Estimated: `4556` - // Minimum execution time: 16_826_000 picoseconds. - Weight::from_parts(17_326_000, 4556) + // Minimum execution time: 16_708_000 picoseconds. + Weight::from_parts(17_177_000, 4556) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1070,8 +1068,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `969` // Estimated: `4556` - // Minimum execution time: 20_831_000 picoseconds. - Weight::from_parts(21_615_000, 4556) + // Minimum execution time: 20_516_000 picoseconds. + Weight::from_parts(21_240_000, 4556) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1083,8 +1081,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `902` // Estimated: `4556` - // Minimum execution time: 20_190_000 picoseconds. - Weight::from_parts(20_993_000, 4556) + // Minimum execution time: 19_514_000 picoseconds. + Weight::from_parts(20_519_000, 4556) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -1094,8 +1092,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_603_000 picoseconds. - Weight::from_parts(2_747_000, 0) + // Minimum execution time: 2_477_000 picoseconds. + Weight::from_parts(2_792_000, 0) .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: `Staking::ForceEra` (r:0 w:1) @@ -1104,8 +1102,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 8_070_000 picoseconds. - Weight::from_parts(8_745_000, 0) + // Minimum execution time: 7_917_000 picoseconds. + Weight::from_parts(8_342_000, 0) .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: `Staking::ForceEra` (r:0 w:1) @@ -1114,8 +1112,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_999_000 picoseconds. - Weight::from_parts(8_624_000, 0) + // Minimum execution time: 8_212_000 picoseconds. + Weight::from_parts(8_506_000, 0) .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: `Staking::ForceEra` (r:0 w:1) @@ -1124,8 +1122,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 8_131_000 picoseconds. - Weight::from_parts(8_467_000, 0) + // Minimum execution time: 8_052_000 picoseconds. + Weight::from_parts(8_405_000, 0) .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: `Staking::Invulnerables` (r:0 w:1) @@ -1135,12 +1133,29 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_731_000 picoseconds. - Weight::from_parts(3_298_421, 0) - // Standard Error: 31 - .saturating_add(Weight::from_parts(10_075, 0).saturating_mul(v.into())) + // Minimum execution time: 2_676_000 picoseconds. + Weight::from_parts(3_288_767, 0) + // Standard Error: 69 + .saturating_add(Weight::from_parts(11_426, 0).saturating_mul(v.into())) .saturating_add(RocksDbWeight::get().writes(1_u64)) } + /// Storage: `Staking::Ledger` (r:5900 w:11800) + /// Proof: `Staking::Ledger` (`max_values`: None, `max_size`: Some(1091), added: 3566, mode: `MaxEncodedLen`) + /// Storage: `Staking::Bonded` (r:0 w:5900) + /// Proof: `Staking::Bonded` (`max_values`: None, `max_size`: Some(72), added: 2547, mode: `MaxEncodedLen`) + /// The range of component `i` is `[0, 5900]`. + fn deprecate_controller_batch(i: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1015 + i * (105 ±0)` + // Estimated: `990 + i * (3566 ±0)` + // Minimum execution time: 2_104_000 picoseconds. + Weight::from_parts(2_155_000, 990) + // Standard Error: 22_751 + .saturating_add(Weight::from_parts(11_460_237, 0).saturating_mul(i.into())) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(i.into()))) + .saturating_add(RocksDbWeight::get().writes((3_u64).saturating_mul(i.into()))) + .saturating_add(Weight::from_parts(0, 3566).saturating_mul(i.into())) + } /// Storage: `Staking::SlashingSpans` (r:1 w:1) /// Proof: `Staking::SlashingSpans` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `Staking::Bonded` (r:1 w:1) @@ -1174,10 +1189,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `2196 + s * (4 ±0)` // Estimated: `6248 + s * (4 ±0)` - // Minimum execution time: 86_305_000 picoseconds. - Weight::from_parts(94_494_401, 6248) - // Standard Error: 3_602 - .saturating_add(Weight::from_parts(1_339_477, 0).saturating_mul(s.into())) + // Minimum execution time: 85_268_000 picoseconds. + Weight::from_parts(93_698_590, 6248) + // Standard Error: 3_793 + .saturating_add(Weight::from_parts(1_323_467, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(13_u64)) .saturating_add(RocksDbWeight::get().writes(12_u64)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(s.into()))) @@ -1190,10 +1205,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `66672` // Estimated: `70137` - // Minimum execution time: 100_007_000 picoseconds. - Weight::from_parts(894_033_025, 70137) - // Standard Error: 57_584 - .saturating_add(Weight::from_parts(4_870_504, 0).saturating_mul(s.into())) + // Minimum execution time: 103_919_000 picoseconds. + Weight::from_parts(1_163_897_466, 70137) + // Standard Error: 76_813 + .saturating_add(Weight::from_parts(6_482_249, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1230,10 +1245,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `33297 + n * (377 ±0)` // Estimated: `30944 + n * (3774 ±0)` - // Minimum execution time: 142_575_000 picoseconds. - Weight::from_parts(196_320_577, 30944) - // Standard Error: 29_330 - .saturating_add(Weight::from_parts(45_325_062, 0).saturating_mul(n.into())) + // Minimum execution time: 141_186_000 picoseconds. + Weight::from_parts(170_953_387, 30944) + // Standard Error: 32_141 + .saturating_add(Weight::from_parts(45_316_107, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(14_u64)) .saturating_add(RocksDbWeight::get().reads((6_u64).saturating_mul(n.into()))) .saturating_add(RocksDbWeight::get().writes(4_u64)) @@ -1257,10 +1272,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1991 + l * (7 ±0)` // Estimated: `8877` - // Minimum execution time: 81_113_000 picoseconds. - Weight::from_parts(84_470_927, 8877) - // Standard Error: 5_588 - .saturating_add(Weight::from_parts(97_606, 0).saturating_mul(l.into())) + // Minimum execution time: 80_676_000 picoseconds. + Weight::from_parts(83_786_705, 8877) + // Standard Error: 4_547 + .saturating_add(Weight::from_parts(79_908, 0).saturating_mul(l.into())) .saturating_add(RocksDbWeight::get().reads(9_u64)) .saturating_add(RocksDbWeight::get().writes(7_u64)) } @@ -1295,10 +1310,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `2196 + s * (4 ±0)` // Estimated: `6248 + s * (4 ±0)` - // Minimum execution time: 94_810_000 picoseconds. - Weight::from_parts(99_292_156, 6248) - // Standard Error: 3_677 - .saturating_add(Weight::from_parts(1_345_598, 0).saturating_mul(s.into())) + // Minimum execution time: 94_239_000 picoseconds. + Weight::from_parts(98_128_278, 6248) + // Standard Error: 3_345 + .saturating_add(Weight::from_parts(1_323_942, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(12_u64)) .saturating_add(RocksDbWeight::get().writes(11_u64)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(s.into()))) @@ -1343,13 +1358,13 @@ impl WeightInfo for () { fn new_era(v: u32, n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0 + n * (720 ±0) + v * (3598 ±0)` - // Estimated: `512390 + n * (3566 ±4) + v * (3566 ±40)` - // Minimum execution time: 583_230_000 picoseconds. - Weight::from_parts(585_794_000, 512390) - // Standard Error: 1_984_644 - .saturating_add(Weight::from_parts(65_914_551, 0).saturating_mul(v.into())) - // Standard Error: 197_758 - .saturating_add(Weight::from_parts(18_105_424, 0).saturating_mul(n.into())) + // Estimated: `512390 + n * (3566 ±0) + v * (3566 ±0)` + // Minimum execution time: 561_749_000 picoseconds. + Weight::from_parts(565_657_000, 512390) + // Standard Error: 2_021_729 + .saturating_add(Weight::from_parts(67_864_146, 0).saturating_mul(v.into())) + // Standard Error: 201_454 + .saturating_add(Weight::from_parts(18_172_710, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(206_u64)) .saturating_add(RocksDbWeight::get().reads((5_u64).saturating_mul(v.into()))) .saturating_add(RocksDbWeight::get().reads((4_u64).saturating_mul(n.into()))) @@ -1380,12 +1395,12 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `3175 + n * (911 ±0) + v * (395 ±0)` // Estimated: `512390 + n * (3566 ±0) + v * (3566 ±0)` - // Minimum execution time: 33_312_958_000 picoseconds. - Weight::from_parts(4_949_866_209, 512390) - // Standard Error: 402_931 - .saturating_add(Weight::from_parts(16_448_367, 0).saturating_mul(v.into())) - // Standard Error: 402_931 - .saturating_add(Weight::from_parts(25_361_503, 0).saturating_mul(n.into())) + // Minimum execution time: 32_858_623_000 picoseconds. + Weight::from_parts(32_996_593_000, 512390) + // Standard Error: 356_817 + .saturating_add(Weight::from_parts(5_152_745, 0).saturating_mul(v.into())) + // Standard Error: 356_817 + .saturating_add(Weight::from_parts(3_183_518, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(201_u64)) .saturating_add(RocksDbWeight::get().reads((5_u64).saturating_mul(v.into()))) .saturating_add(RocksDbWeight::get().reads((4_u64).saturating_mul(n.into()))) @@ -1402,10 +1417,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `979 + v * (50 ±0)` // Estimated: `3510 + v * (2520 ±0)` - // Minimum execution time: 2_474_646_000 picoseconds. - Weight::from_parts(2_512_113_000, 3510) - // Standard Error: 33_996 - .saturating_add(Weight::from_parts(1_992_173, 0).saturating_mul(v.into())) + // Minimum execution time: 2_433_720_000 picoseconds. + Weight::from_parts(108_144_707, 3510) + // Standard Error: 6_825 + .saturating_add(Weight::from_parts(4_664_777, 0).saturating_mul(v.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(v.into()))) .saturating_add(Weight::from_parts(0, 2520).saturating_mul(v.into())) @@ -1426,8 +1441,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 5_466_000 picoseconds. - Weight::from_parts(5_861_000, 0) + // Minimum execution time: 5_259_000 picoseconds. + Weight::from_parts(5_726_000, 0) .saturating_add(RocksDbWeight::get().writes(6_u64)) } /// Storage: `Staking::MinCommission` (r:0 w:1) @@ -1446,8 +1461,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 4_780_000 picoseconds. - Weight::from_parts(4_998_000, 0) + // Minimum execution time: 4_772_000 picoseconds. + Weight::from_parts(4_960_000, 0) .saturating_add(RocksDbWeight::get().writes(6_u64)) } /// Storage: `Staking::Bonded` (r:1 w:0) @@ -1476,8 +1491,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1939` // Estimated: `6248` - // Minimum execution time: 71_261_000 picoseconds. - Weight::from_parts(72_778_000, 6248) + // Minimum execution time: 69_269_000 picoseconds. + Weight::from_parts(71_478_000, 6248) .saturating_add(RocksDbWeight::get().reads(12_u64)) .saturating_add(RocksDbWeight::get().writes(6_u64)) } @@ -1489,8 +1504,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `691` // Estimated: `3510` - // Minimum execution time: 12_497_000 picoseconds. - Weight::from_parts(13_049_000, 3510) + // Minimum execution time: 12_436_000 picoseconds. + Weight::from_parts(12_749_000, 3510) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1500,26 +1515,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_044_000 picoseconds. - Weight::from_parts(3_278_000, 0) + // Minimum execution time: 3_073_000 picoseconds. + Weight::from_parts(3_240_000, 0) .saturating_add(RocksDbWeight::get().writes(1_u64)) } - /// Storage: `Staking::Ledger` (r:5900 w:11800) - /// Proof: `Staking::Ledger` (`max_values`: None, `max_size`: Some(1091), added: 3566, mode: `MaxEncodedLen`) - /// Storage: `Staking::Bonded` (r:0 w:5900) - /// Proof: `Staking::Bonded` (`max_values`: None, `max_size`: Some(72), added: 2547, mode: `MaxEncodedLen`) - /// The range of component `i` is `[0, 5900]`. - fn deprecate_controller_batch(i: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `1015 + i * (105 ±0)` - // Estimated: `990 + i * (3566 ±0)` - // Minimum execution time: 2_000_000 picoseconds. - Weight::from_parts(2_000_000, 0) - .saturating_add(Weight::from_parts(0, 990)) - // Standard Error: 17_374 - .saturating_add(Weight::from_parts(11_852_767, 0).saturating_mul(i.into())) - .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(i.into()))) - .saturating_add(RocksDbWeight::get().writes((3_u64).saturating_mul(i.into()))) - .saturating_add(Weight::from_parts(0, 3566).saturating_mul(i.into())) - } } From cc807b36d8bb6a5b738da6fa852fbe9010dc066d Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Tue, 5 Dec 2023 11:56:29 +0700 Subject: [PATCH 49/74] add PostInfo --- substrate/frame/staking/src/pallet/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/substrate/frame/staking/src/pallet/mod.rs b/substrate/frame/staking/src/pallet/mod.rs index a0b91d9d6b41..2175077d5b44 100644 --- a/substrate/frame/staking/src/pallet/mod.rs +++ b/substrate/frame/staking/src/pallet/mod.rs @@ -1937,7 +1937,7 @@ pub mod pallet { pub fn deprecate_controller_batch( origin: OriginFor, controllers: BoundedVec, - ) -> DispatchResult { + ) -> DispatchResultWithPostInfo { ensure_root(origin)?; // Ignore controllers that do not exist or are already the same as stash. @@ -1966,7 +1966,7 @@ pub mod pallet { >::remove(controller); >::insert(stash, ledger); } - Ok(()) + Ok(Some(T::WeightInfo::deprecate_controller_batch(controllers.len() as u32)).into()) } } } From 637d4eada9eba8ff7c3244a9d4c4332c47c86c05 Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Tue, 5 Dec 2023 11:56:40 +0700 Subject: [PATCH 50/74] fmt --- polkadot/runtime/westend/src/weights/pallet_staking.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/polkadot/runtime/westend/src/weights/pallet_staking.rs b/polkadot/runtime/westend/src/weights/pallet_staking.rs index 7f70e9928c72..49fd0f64f43e 100644 --- a/polkadot/runtime/westend/src/weights/pallet_staking.rs +++ b/polkadot/runtime/westend/src/weights/pallet_staking.rs @@ -792,4 +792,4 @@ impl pallet_staking::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(i.into()))) .saturating_add(Weight::from_parts(0, 3566).saturating_mul(i.into())) } -} +} \ No newline at end of file From 6a9a6e3f8f43549c8e3c575a367f52c9274f07f0 Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Tue, 5 Dec 2023 11:56:51 +0700 Subject: [PATCH 51/74] test full weight scenario --- substrate/frame/staking/src/tests.rs | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/substrate/frame/staking/src/tests.rs b/substrate/frame/staking/src/tests.rs index b2198625c5de..8f9cfe8e0c83 100644 --- a/substrate/frame/staking/src/tests.rs +++ b/substrate/frame/staking/src/tests.rs @@ -6869,7 +6869,7 @@ mod ledger { } #[test] - fn deprecate_controller_batch_works() { + fn deprecate_controller_batch_works_full_weight() { ExtBuilder::default().build_and_execute(|| { // Given: @@ -6901,10 +6901,28 @@ mod ledger { ::MaxControllersInDeprecationBatch, > = BoundedVec::try_from(controllers).unwrap(); - assert_ok!(Staking::deprecate_controller_batch( - RuntimeOrigin::root(), - bounded_controllers - )); + // Only Root can sign. + assert_noop!( + Staking::deprecate_controller_batch( + RuntimeOrigin::signed(1), + bounded_controllers.clone() + ), + BadOrigin + ); + + let result = + Staking::deprecate_controller_batch(RuntimeOrigin::root(), bounded_controllers); + + //Successful call by Root. + assert_ok!(result); + + // Weight accounts for every controller was migrated. + assert_eq!( + result.unwrap().actual_weight.unwrap(), + ::WeightInfo::deprecate_controller_batch( + ::MaxControllersInDeprecationBatch::get() + ) + ); // Then: From 376e5e89e52c4635de3071d484b1e944ae7f8f02 Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Tue, 5 Dec 2023 12:10:42 +0700 Subject: [PATCH 52/74] add deprecate_controller_batch_works_half_weight --- substrate/frame/staking/src/mock.rs | 2 +- substrate/frame/staking/src/tests.rs | 81 ++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+), 1 deletion(-) diff --git a/substrate/frame/staking/src/mock.rs b/substrate/frame/staking/src/mock.rs index 4feeb7fe6abf..5332dbfdd5b2 100644 --- a/substrate/frame/staking/src/mock.rs +++ b/substrate/frame/staking/src/mock.rs @@ -122,7 +122,7 @@ parameter_types! { pub static SlashDeferDuration: EraIndex = 0; pub static Period: BlockNumber = 5; pub static Offset: BlockNumber = 0; - pub static MaxControllersInDeprecationBatch: u32 = 100; + pub static MaxControllersInDeprecationBatch: u32 = 5900; } #[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)] diff --git a/substrate/frame/staking/src/tests.rs b/substrate/frame/staking/src/tests.rs index 8f9cfe8e0c83..20c0a28ab73f 100644 --- a/substrate/frame/staking/src/tests.rs +++ b/substrate/frame/staking/src/tests.rs @@ -6945,4 +6945,85 @@ mod ledger { } }) } + + #[test] + fn deprecate_controller_batch_works_half_weight() { + ExtBuilder::default().build_and_execute(|| { + // Given: + + let start = 1001; + let mut controllers: Vec<_> = vec![]; + for n in start..(start + MaxControllersInDeprecationBatch::get()).into() { + let ctlr: u64 = n.into(); + // Only half of entries are unique pairs. + let stash: u64 = if n % 2 == 0 { (n + 10000).into() } else { ctlr }; + + Ledger::::insert( + ctlr, + StakingLedger { + stash, + controller: None, + total: (1000 + ctlr).into(), + active: (1000 + ctlr).into(), + unlocking: Default::default(), + legacy_claimed_rewards: bounded_vec![], + }, + ); + Bonded::::insert(stash, ctlr); + controllers.push(ctlr); + } + + // When: + let bounded_controllers: BoundedVec< + _, + ::MaxControllersInDeprecationBatch, + > = BoundedVec::try_from(controllers.clone()).unwrap(); + + // Only Root can sign. + assert_noop!( + Staking::deprecate_controller_batch( + RuntimeOrigin::signed(1), + bounded_controllers.clone() + ), + BadOrigin + ); + + let result = + Staking::deprecate_controller_batch(RuntimeOrigin::root(), bounded_controllers); + + //Successful call by Root. + assert_ok!(result); + + // Weight accounts for only half controller was migrated. + assert_eq!( + result.unwrap().actual_weight.unwrap(), + ::WeightInfo::deprecate_controller_batch(controllers.len() as u32) + ); + + // Then: + + for n in start..(start + MaxControllersInDeprecationBatch::get()).into() { + let unique_pair = n % 2 == 0; + let ctlr: u64 = n.into(); + let stash: u64 = if unique_pair { (n + 10000).into() } else { ctlr }; + + // Side effects of migration for unique pair. + if unique_pair { + // Ledger no longer keyed by controller. + assert_eq!(Ledger::::get(ctlr), None); + } + + // Bonded maps to the stash. + assert_eq!(Bonded::::get(stash), Some(stash)); + + // Ledger is keyed by stash. + let ledger_updated = Ledger::::get(stash).unwrap(); + assert_eq!(ledger_updated.stash, stash); + + // Check `active` and `total` values match the original ledger set by controller. + assert_eq!(ledger_updated.active, (1000 + ctlr).into()); + assert_eq!(ledger_updated.total, (1000 + ctlr).into()); + } + }) + } } From 954835bbd8c7d1ab4fb36d09aaf3b5de684e6a5e Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Tue, 5 Dec 2023 12:16:50 +0700 Subject: [PATCH 53/74] tidy up --- substrate/frame/staking/src/tests.rs | 33 ++++------------------------ 1 file changed, 4 insertions(+), 29 deletions(-) diff --git a/substrate/frame/staking/src/tests.rs b/substrate/frame/staking/src/tests.rs index 20c0a28ab73f..657c6dc44ce9 100644 --- a/substrate/frame/staking/src/tests.rs +++ b/substrate/frame/staking/src/tests.rs @@ -6882,12 +6882,10 @@ mod ledger { Ledger::::insert( ctlr, StakingLedger { - stash, controller: None, total: (1000 + ctlr).into(), active: (1000 + ctlr).into(), - unlocking: Default::default(), - legacy_claimed_rewards: bounded_vec![], + ..StakingLedger::default_from(stash.clone()) }, ); Bonded::::insert(stash, ctlr); @@ -6912,11 +6910,7 @@ mod ledger { let result = Staking::deprecate_controller_batch(RuntimeOrigin::root(), bounded_controllers); - - //Successful call by Root. assert_ok!(result); - - // Weight accounts for every controller was migrated. assert_eq!( result.unwrap().actual_weight.unwrap(), ::WeightInfo::deprecate_controller_batch( @@ -6955,18 +6949,17 @@ mod ledger { let mut controllers: Vec<_> = vec![]; for n in start..(start + MaxControllersInDeprecationBatch::get()).into() { let ctlr: u64 = n.into(); + // Only half of entries are unique pairs. let stash: u64 = if n % 2 == 0 { (n + 10000).into() } else { ctlr }; Ledger::::insert( ctlr, StakingLedger { - stash, controller: None, total: (1000 + ctlr).into(), active: (1000 + ctlr).into(), - unlocking: Default::default(), - legacy_claimed_rewards: bounded_vec![], + ..StakingLedger::default_from(stash.clone()) }, ); Bonded::::insert(stash, ctlr); @@ -6979,22 +6972,9 @@ mod ledger { ::MaxControllersInDeprecationBatch, > = BoundedVec::try_from(controllers.clone()).unwrap(); - // Only Root can sign. - assert_noop!( - Staking::deprecate_controller_batch( - RuntimeOrigin::signed(1), - bounded_controllers.clone() - ), - BadOrigin - ); - let result = Staking::deprecate_controller_batch(RuntimeOrigin::root(), bounded_controllers); - - //Successful call by Root. assert_ok!(result); - - // Weight accounts for only half controller was migrated. assert_eq!( result.unwrap().actual_weight.unwrap(), ::WeightInfo::deprecate_controller_batch(controllers.len() as u32) @@ -7007,22 +6987,17 @@ mod ledger { let ctlr: u64 = n.into(); let stash: u64 = if unique_pair { (n + 10000).into() } else { ctlr }; - // Side effects of migration for unique pair. + // Side effect of migration for unique pair. if unique_pair { // Ledger no longer keyed by controller. assert_eq!(Ledger::::get(ctlr), None); } - // Bonded maps to the stash. assert_eq!(Bonded::::get(stash), Some(stash)); // Ledger is keyed by stash. let ledger_updated = Ledger::::get(stash).unwrap(); assert_eq!(ledger_updated.stash, stash); - - // Check `active` and `total` values match the original ledger set by controller. - assert_eq!(ledger_updated.active, (1000 + ctlr).into()); - assert_eq!(ledger_updated.total, (1000 + ctlr).into()); } }) } From 9247185821962687d38b134ffe2d24878950eacd Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Tue, 5 Dec 2023 12:18:06 +0700 Subject: [PATCH 54/74] more tidy up --- substrate/frame/staking/src/tests.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/substrate/frame/staking/src/tests.rs b/substrate/frame/staking/src/tests.rs index 657c6dc44ce9..133294b5d2ca 100644 --- a/substrate/frame/staking/src/tests.rs +++ b/substrate/frame/staking/src/tests.rs @@ -6883,8 +6883,8 @@ mod ledger { ctlr, StakingLedger { controller: None, - total: (1000 + ctlr).into(), - active: (1000 + ctlr).into(), + total: (10 + ctlr).into(), + active: (10 + ctlr).into(), ..StakingLedger::default_from(stash.clone()) }, ); @@ -6934,8 +6934,8 @@ mod ledger { assert_eq!(ledger_updated.stash, stash); // Check `active` and `total` values match the original ledger set by controller. - assert_eq!(ledger_updated.active, (1000 + ctlr).into()); - assert_eq!(ledger_updated.total, (1000 + ctlr).into()); + assert_eq!(ledger_updated.active, (10 + ctlr).into()); + assert_eq!(ledger_updated.total, (10 + ctlr).into()); } }) } @@ -6957,8 +6957,6 @@ mod ledger { ctlr, StakingLedger { controller: None, - total: (1000 + ctlr).into(), - active: (1000 + ctlr).into(), ..StakingLedger::default_from(stash.clone()) }, ); @@ -6989,7 +6987,6 @@ mod ledger { // Side effect of migration for unique pair. if unique_pair { - // Ledger no longer keyed by controller. assert_eq!(Ledger::::get(ctlr), None); } // Bonded maps to the stash. From 32ecfa5e4d3f282bc9e9825b84cfb48a828ecdc6 Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Tue, 5 Dec 2023 12:22:56 +0700 Subject: [PATCH 55/74] remove comments --- substrate/frame/staking/src/pallet/mod.rs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/substrate/frame/staking/src/pallet/mod.rs b/substrate/frame/staking/src/pallet/mod.rs index 2175077d5b44..0e6c608128ff 100644 --- a/substrate/frame/staking/src/pallet/mod.rs +++ b/substrate/frame/staking/src/pallet/mod.rs @@ -1339,9 +1339,7 @@ pub mod pallet { } >::remove(controller); >::insert(&stash, &stash); - // The controller is never stored on-chain, and is instead derived from the `Bonded` storage - // item by `StakingLedger`. - >::insert(&stash, StakingLedger { controller: None, ..ledger}); + >::insert(&stash, ledger); Ok(()) })? } @@ -1947,10 +1945,7 @@ pub mod pallet { let ledger = Self::ledger(StakingAccount::Controller(controller.clone())); ledger.ok().map_or(None, |ledger| { if ledger.stash != *controller { - // Sets `controller` field back to `None`. The controller is never - // stored on-chain, and is instead derived from the `Bonded` storage - // item by `StakingLedger`. - Some((controller.clone(), StakingLedger { controller: None, ..ledger })) + Some((controller.clone(), ledger)) } else { None } From fb7732e6e6280009eed268c084bc1bd06243ecd1 Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Tue, 5 Dec 2023 12:27:07 +0700 Subject: [PATCH 56/74] tidy up benchmark --- substrate/frame/staking/src/benchmarking.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/substrate/frame/staking/src/benchmarking.rs b/substrate/frame/staking/src/benchmarking.rs index 830dad11e0d8..becb54a2d37a 100644 --- a/substrate/frame/staking/src/benchmarking.rs +++ b/substrate/frame/staking/src/benchmarking.rs @@ -532,7 +532,6 @@ benchmarks! { let mut controllers: Vec<_> = vec![]; let mut stashes: Vec<_> = vec![]; - for n in 0..i as u32 { let (stash, controller) = create_unique_stash_controller::( n, @@ -550,15 +549,12 @@ benchmarks! { for n in 0..i as u32 { let stash = &stashes[n as usize]; let controller = &controllers[n as usize]; - // Ledger no longer keyed by controller. assert_eq!(Ledger::::get(controller), None); // Bonded now maps to the stash. assert_eq!(Bonded::::get(stash), Some(stash.clone())); - // Ledger is now keyed by stash. - let ledger_updated = Ledger::::get(stash).unwrap(); - assert_eq!(ledger_updated.stash, *stash); + assert_eq!(Ledger::::get(stash).unwrap().stash, *stash); } } From c37c70d351656286880339addcdc8ba97580add8 Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Tue, 5 Dec 2023 15:36:55 +0700 Subject: [PATCH 57/74] rm clone --- substrate/frame/staking/src/tests.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/substrate/frame/staking/src/tests.rs b/substrate/frame/staking/src/tests.rs index 133294b5d2ca..b613e8c70e6a 100644 --- a/substrate/frame/staking/src/tests.rs +++ b/substrate/frame/staking/src/tests.rs @@ -6885,7 +6885,7 @@ mod ledger { controller: None, total: (10 + ctlr).into(), active: (10 + ctlr).into(), - ..StakingLedger::default_from(stash.clone()) + ..StakingLedger::default_from(stash) }, ); Bonded::::insert(stash, ctlr); @@ -6955,10 +6955,7 @@ mod ledger { Ledger::::insert( ctlr, - StakingLedger { - controller: None, - ..StakingLedger::default_from(stash.clone()) - }, + StakingLedger { controller: None, ..StakingLedger::default_from(stash) }, ); Bonded::::insert(stash, ctlr); controllers.push(ctlr); From f207395c0d3c290587af0de9c82c4e1b29ce8b6a Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Wed, 6 Dec 2023 09:28:58 +0700 Subject: [PATCH 58/74] address feedback --- polkadot/runtime/test-runtime/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/polkadot/runtime/test-runtime/src/lib.rs b/polkadot/runtime/test-runtime/src/lib.rs index 7b1617df7a19..86125e09de89 100644 --- a/polkadot/runtime/test-runtime/src/lib.rs +++ b/polkadot/runtime/test-runtime/src/lib.rs @@ -343,6 +343,7 @@ impl pallet_staking::Config for Runtime { type BondingDuration = BondingDuration; type SlashDeferDuration = SlashDeferDuration; type AdminOrigin = frame_system::EnsureNever<()>; + type StakingAdminOrigin = EitherOf, StakingAdmin>; type SessionInterface = Self; type EraPayout = pallet_staking::ConvertCurve; type MaxExposurePageSize = MaxExposurePageSize; From 87cf4c2c4229aadd2f663c16bae36d6adaaba443 Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Wed, 6 Dec 2023 09:47:39 +0700 Subject: [PATCH 59/74] feedback --- substrate/frame/staking/src/tests.rs | 36 ++++++++++++++-------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/substrate/frame/staking/src/tests.rs b/substrate/frame/staking/src/tests.rs index b613e8c70e6a..034f8a885a56 100644 --- a/substrate/frame/staking/src/tests.rs +++ b/substrate/frame/staking/src/tests.rs @@ -6876,20 +6876,20 @@ mod ledger { let start = 1001; let mut controllers: Vec<_> = vec![]; for n in start..(start + MaxControllersInDeprecationBatch::get()).into() { - let ctlr: u64 = n.into(); + let ctrl: u64 = n.into(); let stash: u64 = (n + 10000).into(); Ledger::::insert( - ctlr, + ctrl, StakingLedger { controller: None, - total: (10 + ctlr).into(), - active: (10 + ctlr).into(), + total: (10 + ctrl).into(), + active: (10 + ctrl).into(), ..StakingLedger::default_from(stash) }, ); - Bonded::::insert(stash, ctlr); - controllers.push(ctlr); + Bonded::::insert(stash, ctrl); + controllers.push(ctrl); } // When: @@ -6921,11 +6921,11 @@ mod ledger { // Then: for n in start..(start + MaxControllersInDeprecationBatch::get()).into() { - let ctlr: u64 = n.into(); + let ctrl: u64 = n.into(); let stash: u64 = (n + 10000).into(); // Ledger no longer keyed by controller. - assert_eq!(Ledger::::get(ctlr), None); + assert_eq!(Ledger::::get(ctrl), None); // Bonded now maps to the stash. assert_eq!(Bonded::::get(stash), Some(stash)); @@ -6934,8 +6934,8 @@ mod ledger { assert_eq!(ledger_updated.stash, stash); // Check `active` and `total` values match the original ledger set by controller. - assert_eq!(ledger_updated.active, (10 + ctlr).into()); - assert_eq!(ledger_updated.total, (10 + ctlr).into()); + assert_eq!(ledger_updated.active, (10 + ctrl).into()); + assert_eq!(ledger_updated.total, (10 + ctrl).into()); } }) } @@ -6948,17 +6948,17 @@ mod ledger { let start = 1001; let mut controllers: Vec<_> = vec![]; for n in start..(start + MaxControllersInDeprecationBatch::get()).into() { - let ctlr: u64 = n.into(); + let ctrl: u64 = n.into(); // Only half of entries are unique pairs. - let stash: u64 = if n % 2 == 0 { (n + 10000).into() } else { ctlr }; + let stash: u64 = if n % 2 == 0 { (n + 10000).into() } else { ctrl }; Ledger::::insert( - ctlr, + ctrl, StakingLedger { controller: None, ..StakingLedger::default_from(stash) }, ); - Bonded::::insert(stash, ctlr); - controllers.push(ctlr); + Bonded::::insert(stash, ctrl); + controllers.push(ctrl); } // When: @@ -6979,12 +6979,12 @@ mod ledger { for n in start..(start + MaxControllersInDeprecationBatch::get()).into() { let unique_pair = n % 2 == 0; - let ctlr: u64 = n.into(); - let stash: u64 = if unique_pair { (n + 10000).into() } else { ctlr }; + let ctrl: u64 = n.into(); + let stash: u64 = if unique_pair { (n + 10000).into() } else { ctrl }; // Side effect of migration for unique pair. if unique_pair { - assert_eq!(Ledger::::get(ctlr), None); + assert_eq!(Ledger::::get(ctrl), None); } // Bonded maps to the stash. assert_eq!(Bonded::::get(stash), Some(stash)); From ba6e84aab2c02d39c4972b4b8181929c5d8223d3 Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Wed, 6 Dec 2023 09:47:49 +0700 Subject: [PATCH 60/74] add DeprecationOrigin --- polkadot/runtime/test-runtime/src/lib.rs | 2 +- polkadot/runtime/westend/src/lib.rs | 1 + substrate/bin/node/runtime/src/lib.rs | 1 + .../test-staking-e2e/src/mock.rs | 1 + substrate/frame/fast-unstake/src/mock.rs | 1 + substrate/frame/nomination-pools/benchmarking/src/mock.rs | 1 + substrate/frame/nomination-pools/test-staking/src/mock.rs | 1 + substrate/frame/staking/src/mock.rs | 1 + substrate/frame/staking/src/pallet/mod.rs | 5 ++++- 9 files changed, 12 insertions(+), 2 deletions(-) diff --git a/polkadot/runtime/test-runtime/src/lib.rs b/polkadot/runtime/test-runtime/src/lib.rs index 86125e09de89..f5e51da70285 100644 --- a/polkadot/runtime/test-runtime/src/lib.rs +++ b/polkadot/runtime/test-runtime/src/lib.rs @@ -343,7 +343,7 @@ impl pallet_staking::Config for Runtime { type BondingDuration = BondingDuration; type SlashDeferDuration = SlashDeferDuration; type AdminOrigin = frame_system::EnsureNever<()>; - type StakingAdminOrigin = EitherOf, StakingAdmin>; + type DeprecationOrigin = EitherOf, StakingAdmin>; type SessionInterface = Self; type EraPayout = pallet_staking::ConvertCurve; type MaxExposurePageSize = MaxExposurePageSize; diff --git a/polkadot/runtime/westend/src/lib.rs b/polkadot/runtime/westend/src/lib.rs index e3416a00f977..a678a33c3b24 100644 --- a/polkadot/runtime/westend/src/lib.rs +++ b/polkadot/runtime/westend/src/lib.rs @@ -689,6 +689,7 @@ impl pallet_staking::Config for Runtime { type BondingDuration = BondingDuration; type SlashDeferDuration = SlashDeferDuration; type AdminOrigin = EnsureRoot; + type DeprecationOrigin = EitherOf, StakingAdmin>; type SessionInterface = Self; type EraPayout = pallet_staking::ConvertCurve; type MaxExposurePageSize = MaxExposurePageSize; diff --git a/substrate/bin/node/runtime/src/lib.rs b/substrate/bin/node/runtime/src/lib.rs index c6cc663772d9..b4400b8094ce 100644 --- a/substrate/bin/node/runtime/src/lib.rs +++ b/substrate/bin/node/runtime/src/lib.rs @@ -658,6 +658,7 @@ impl pallet_staking::Config for Runtime { EnsureRoot, pallet_collective::EnsureProportionAtLeast, >; + type DeprecationOrigin = EnsureRoot; type SessionInterface = Self; type EraPayout = pallet_staking::ConvertCurve; type NextNewSession = Session; diff --git a/substrate/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs b/substrate/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs index ecb2ae435b8c..ea0cf7e3294b 100644 --- a/substrate/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs +++ b/substrate/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs @@ -265,6 +265,7 @@ impl pallet_staking::Config for Runtime { type BondingDuration = BondingDuration; type SlashDeferDuration = SlashDeferDuration; type AdminOrigin = EnsureRoot; // root can cancel slashes + type DeprecationOrigin = EnsureRoot; type SessionInterface = Self; type EraPayout = (); type NextNewSession = Session; diff --git a/substrate/frame/fast-unstake/src/mock.rs b/substrate/frame/fast-unstake/src/mock.rs index f9326919fd3e..8e2333e61179 100644 --- a/substrate/frame/fast-unstake/src/mock.rs +++ b/substrate/frame/fast-unstake/src/mock.rs @@ -129,6 +129,7 @@ impl pallet_staking::Config for Runtime { type SessionsPerEra = (); type SlashDeferDuration = (); type AdminOrigin = frame_system::EnsureRoot; + type DeprecationOrigin = EnsureRoot; type BondingDuration = BondingDuration; type SessionInterface = (); type EraPayout = pallet_staking::ConvertCurve; diff --git a/substrate/frame/nomination-pools/benchmarking/src/mock.rs b/substrate/frame/nomination-pools/benchmarking/src/mock.rs index c58a66f6163a..20a60625090b 100644 --- a/substrate/frame/nomination-pools/benchmarking/src/mock.rs +++ b/substrate/frame/nomination-pools/benchmarking/src/mock.rs @@ -107,6 +107,7 @@ impl pallet_staking::Config for Runtime { type SessionsPerEra = (); type SlashDeferDuration = (); type AdminOrigin = frame_system::EnsureRoot; + type DeprecationOrigin = frame_system::EnsureRoot; type BondingDuration = ConstU32<3>; type SessionInterface = (); type EraPayout = pallet_staking::ConvertCurve; diff --git a/substrate/frame/nomination-pools/test-staking/src/mock.rs b/substrate/frame/nomination-pools/test-staking/src/mock.rs index 491cd6191619..09c4c6882462 100644 --- a/substrate/frame/nomination-pools/test-staking/src/mock.rs +++ b/substrate/frame/nomination-pools/test-staking/src/mock.rs @@ -121,6 +121,7 @@ impl pallet_staking::Config for Runtime { type SessionsPerEra = (); type SlashDeferDuration = (); type AdminOrigin = frame_system::EnsureRoot; + type DeprecationOrigin = frame_system::EnsureRoot; type BondingDuration = BondingDuration; type SessionInterface = (); type EraPayout = pallet_staking::ConvertCurve; diff --git a/substrate/frame/staking/src/mock.rs b/substrate/frame/staking/src/mock.rs index 5332dbfdd5b2..c51d4cad6142 100644 --- a/substrate/frame/staking/src/mock.rs +++ b/substrate/frame/staking/src/mock.rs @@ -303,6 +303,7 @@ impl crate::pallet::pallet::Config for Test { type SessionsPerEra = SessionsPerEra; type SlashDeferDuration = SlashDeferDuration; type AdminOrigin = EnsureOneOrRoot; + type DeprecationOrigin = EnsureOneOrRoot; type BondingDuration = BondingDuration; type SessionInterface = Self; type EraPayout = ConvertCurve; diff --git a/substrate/frame/staking/src/pallet/mod.rs b/substrate/frame/staking/src/pallet/mod.rs index 0e6c608128ff..5c10bbaa87d6 100644 --- a/substrate/frame/staking/src/pallet/mod.rs +++ b/substrate/frame/staking/src/pallet/mod.rs @@ -172,6 +172,9 @@ pub mod pallet { /// issuance. type Reward: OnUnbalanced>; + /// Origin from which staking admin calls must come. + type DeprecationOrigin: EnsureOrigin; + /// Number of sessions per era. #[pallet::constant] type SessionsPerEra: Get; @@ -1936,7 +1939,7 @@ pub mod pallet { origin: OriginFor, controllers: BoundedVec, ) -> DispatchResultWithPostInfo { - ensure_root(origin)?; + T::DeprecationOrigin::ensure_origin(origin)?; // Ignore controllers that do not exist or are already the same as stash. let filtered_batch_with_ledger: Vec<_> = controllers From 224861c8251a83f52b9a5cd48fa1daab6012862b Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Wed, 6 Dec 2023 09:51:33 +0700 Subject: [PATCH 61/74] comment --- substrate/frame/staking/src/pallet/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/substrate/frame/staking/src/pallet/mod.rs b/substrate/frame/staking/src/pallet/mod.rs index 5c10bbaa87d6..28a124d532a6 100644 --- a/substrate/frame/staking/src/pallet/mod.rs +++ b/substrate/frame/staking/src/pallet/mod.rs @@ -172,7 +172,7 @@ pub mod pallet { /// issuance. type Reward: OnUnbalanced>; - /// Origin from which staking admin calls must come. + /// Origin from which deprecation calls must come. type DeprecationOrigin: EnsureOrigin; /// Number of sessions per era. From 65b70726233226dbbc78add4c52f49fe432b21d7 Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Wed, 6 Dec 2023 09:56:11 +0700 Subject: [PATCH 62/74] fixes --- substrate/frame/staking/src/benchmarking.rs | 3 ++- substrate/frame/staking/src/pallet/mod.rs | 2 +- substrate/frame/staking/src/tests.rs | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/substrate/frame/staking/src/benchmarking.rs b/substrate/frame/staking/src/benchmarking.rs index becb54a2d37a..abb78b7e3040 100644 --- a/substrate/frame/staking/src/benchmarking.rs +++ b/substrate/frame/staking/src/benchmarking.rs @@ -527,7 +527,8 @@ benchmarks! { } deprecate_controller_batch { - // We pass a dynamic number of controllers to the benchmark, up to `MaxControllersInDeprecationBatch`. + // We pass a dynamic number of controllers to the benchmark, up to + // `MaxControllersInDeprecationBatch`. let i in 0 .. T::MaxControllersInDeprecationBatch::get(); let mut controllers: Vec<_> = vec![]; diff --git a/substrate/frame/staking/src/pallet/mod.rs b/substrate/frame/staking/src/pallet/mod.rs index 28a124d532a6..c02680ffe4c0 100644 --- a/substrate/frame/staking/src/pallet/mod.rs +++ b/substrate/frame/staking/src/pallet/mod.rs @@ -1932,7 +1932,7 @@ pub mod pallet { /// /// Effects will be felt instantly (as soon as this function is completed successfully). /// - /// The dispatch origin must be Root. + /// The dispatch origin must be DeprecationOrigin. #[pallet::call_index(28)] #[pallet::weight(T::WeightInfo::deprecate_controller_batch(controllers.len() as u32))] pub fn deprecate_controller_batch( diff --git a/substrate/frame/staking/src/tests.rs b/substrate/frame/staking/src/tests.rs index 034f8a885a56..a9ef8ab61b21 100644 --- a/substrate/frame/staking/src/tests.rs +++ b/substrate/frame/staking/src/tests.rs @@ -6899,10 +6899,10 @@ mod ledger { ::MaxControllersInDeprecationBatch, > = BoundedVec::try_from(controllers).unwrap(); - // Only Root can sign. + // Only `DeprecationOrigin` can sign. assert_noop!( Staking::deprecate_controller_batch( - RuntimeOrigin::signed(1), + RuntimeOrigin::signed(2), bounded_controllers.clone() ), BadOrigin From 2a47ee81dbdcd1ff335e30d700155d11eea92026 Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Wed, 6 Dec 2023 10:02:56 +0700 Subject: [PATCH 63/74] fix --- polkadot/runtime/test-runtime/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/polkadot/runtime/test-runtime/src/lib.rs b/polkadot/runtime/test-runtime/src/lib.rs index f5e51da70285..75dc261787b8 100644 --- a/polkadot/runtime/test-runtime/src/lib.rs +++ b/polkadot/runtime/test-runtime/src/lib.rs @@ -343,7 +343,7 @@ impl pallet_staking::Config for Runtime { type BondingDuration = BondingDuration; type SlashDeferDuration = SlashDeferDuration; type AdminOrigin = frame_system::EnsureNever<()>; - type DeprecationOrigin = EitherOf, StakingAdmin>; + type DeprecationOrigin = frame_system::EnsureRoot; type SessionInterface = Self; type EraPayout = pallet_staking::ConvertCurve; type MaxExposurePageSize = MaxExposurePageSize; From 4ef7c135082c39579b44edc5e1574726eee740c3 Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Wed, 6 Dec 2023 10:05:31 +0700 Subject: [PATCH 64/74] add DeprecationOrigin to mocks --- substrate/frame/babe/src/mock.rs | 1 + substrate/frame/beefy/src/mock.rs | 1 + substrate/frame/grandpa/src/mock.rs | 1 + substrate/frame/offences/benchmarking/src/mock.rs | 1 + substrate/frame/root-offences/src/mock.rs | 1 + substrate/frame/session/benchmarking/src/mock.rs | 1 + 6 files changed, 6 insertions(+) diff --git a/substrate/frame/babe/src/mock.rs b/substrate/frame/babe/src/mock.rs index 72abbc805db1..611c7b1a0fae 100644 --- a/substrate/frame/babe/src/mock.rs +++ b/substrate/frame/babe/src/mock.rs @@ -171,6 +171,7 @@ impl pallet_staking::Config for Test { type BondingDuration = BondingDuration; type SlashDeferDuration = SlashDeferDuration; type AdminOrigin = frame_system::EnsureRoot; + type DeprecationOrigin = frame_system::EnsureRoot; type SessionInterface = Self; type UnixTime = pallet_timestamp::Pallet; type EraPayout = pallet_staking::ConvertCurve; diff --git a/substrate/frame/beefy/src/mock.rs b/substrate/frame/beefy/src/mock.rs index 8dc30614c33b..0e4178b496b3 100644 --- a/substrate/frame/beefy/src/mock.rs +++ b/substrate/frame/beefy/src/mock.rs @@ -189,6 +189,7 @@ impl pallet_staking::Config for Test { type BondingDuration = BondingDuration; type SlashDeferDuration = (); type AdminOrigin = frame_system::EnsureRoot; + type DeprecationOrigin = frame_system::EnsureRoot; type SessionInterface = Self; type UnixTime = pallet_timestamp::Pallet; type EraPayout = pallet_staking::ConvertCurve; diff --git a/substrate/frame/grandpa/src/mock.rs b/substrate/frame/grandpa/src/mock.rs index f1f51e0b1181..d7885ca61f0c 100644 --- a/substrate/frame/grandpa/src/mock.rs +++ b/substrate/frame/grandpa/src/mock.rs @@ -194,6 +194,7 @@ impl pallet_staking::Config for Test { type BondingDuration = BondingDuration; type SlashDeferDuration = (); type AdminOrigin = frame_system::EnsureRoot; + type DeprecationOrigin = frame_system::EnsureRoot; type SessionInterface = Self; type UnixTime = pallet_timestamp::Pallet; type EraPayout = pallet_staking::ConvertCurve; diff --git a/substrate/frame/offences/benchmarking/src/mock.rs b/substrate/frame/offences/benchmarking/src/mock.rs index 1d642b9b4982..8a780efab6d3 100644 --- a/substrate/frame/offences/benchmarking/src/mock.rs +++ b/substrate/frame/offences/benchmarking/src/mock.rs @@ -173,6 +173,7 @@ impl pallet_staking::Config for Test { type SessionsPerEra = (); type SlashDeferDuration = (); type AdminOrigin = frame_system::EnsureRoot; + type DeprecationOrigin = frame_system::EnsureRoot; type BondingDuration = (); type SessionInterface = Self; type EraPayout = pallet_staking::ConvertCurve; diff --git a/substrate/frame/root-offences/src/mock.rs b/substrate/frame/root-offences/src/mock.rs index c0c83dd08d24..f878775d37f6 100644 --- a/substrate/frame/root-offences/src/mock.rs +++ b/substrate/frame/root-offences/src/mock.rs @@ -176,6 +176,7 @@ impl pallet_staking::Config for Test { type SessionsPerEra = SessionsPerEra; type SlashDeferDuration = SlashDeferDuration; type AdminOrigin = frame_system::EnsureRoot; + type DeprecationOrigin = frame_system::EnsureRoot; type BondingDuration = BondingDuration; type SessionInterface = Self; type EraPayout = pallet_staking::ConvertCurve; diff --git a/substrate/frame/session/benchmarking/src/mock.rs b/substrate/frame/session/benchmarking/src/mock.rs index e1744fa43abb..9c0aa0e3ebaf 100644 --- a/substrate/frame/session/benchmarking/src/mock.rs +++ b/substrate/frame/session/benchmarking/src/mock.rs @@ -170,6 +170,7 @@ impl pallet_staking::Config for Test { type SessionsPerEra = (); type SlashDeferDuration = (); type AdminOrigin = frame_system::EnsureRoot; + type DeprecationOrigin = frame_system::EnsureRoot; type BondingDuration = (); type SessionInterface = Self; type EraPayout = pallet_staking::ConvertCurve; From 3f8846dafea5747638bc9a6cea556990019ba6fe Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Wed, 6 Dec 2023 10:14:10 +0700 Subject: [PATCH 65/74] fix --- substrate/frame/fast-unstake/src/mock.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/substrate/frame/fast-unstake/src/mock.rs b/substrate/frame/fast-unstake/src/mock.rs index 8e2333e61179..93b4791bfd5e 100644 --- a/substrate/frame/fast-unstake/src/mock.rs +++ b/substrate/frame/fast-unstake/src/mock.rs @@ -129,7 +129,7 @@ impl pallet_staking::Config for Runtime { type SessionsPerEra = (); type SlashDeferDuration = (); type AdminOrigin = frame_system::EnsureRoot; - type DeprecationOrigin = EnsureRoot; + type DeprecationOrigin = frame_system::EnsureRoot; type BondingDuration = BondingDuration; type SessionInterface = (); type EraPayout = pallet_staking::ConvertCurve; From efb80320154dd3cc81a0733011321cf194ddd4c7 Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Wed, 6 Dec 2023 10:28:56 +0700 Subject: [PATCH 66/74] remove duplicate --- .../westend/src/weights/pallet_staking.rs | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/polkadot/runtime/westend/src/weights/pallet_staking.rs b/polkadot/runtime/westend/src/weights/pallet_staking.rs index 08cfe48e6f5f..f69a19743f8b 100644 --- a/polkadot/runtime/westend/src/weights/pallet_staking.rs +++ b/polkadot/runtime/westend/src/weights/pallet_staking.rs @@ -794,22 +794,4 @@ impl pallet_staking::WeightInfo for WeightInfo { .saturating_add(Weight::from_parts(0, 0)) .saturating_add(T::DbWeight::get().writes(1)) } - /// Storage: `Staking::Ledger` (r:5900 w:11800) - /// Proof: `Staking::Ledger` (`max_values`: None, `max_size`: Some(1091), added: 3566, mode: `MaxEncodedLen`) - /// Storage: `Staking::Bonded` (r:0 w:5900) - /// Proof: `Staking::Bonded` (`max_values`: None, `max_size`: Some(72), added: 2547, mode: `MaxEncodedLen`) - /// The range of component `i` is `[0, 5900]`. - fn deprecate_controller_batch(i: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `1015 + i * (105 ±0)` - // Estimated: `990 + i * (3566 ±0)` - // Minimum execution time: 2_000_000 picoseconds. - Weight::from_parts(2_000_000, 0) - .saturating_add(Weight::from_parts(0, 990)) - // Standard Error: 17_374 - .saturating_add(Weight::from_parts(11_852_767, 0).saturating_mul(i.into())) - .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(i.into()))) - .saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(i.into()))) - .saturating_add(Weight::from_parts(0, 3566).saturating_mul(i.into())) - } } From d2f49fe2e5b2946a9a00d1ded434a203efa2ebc1 Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Wed, 6 Dec 2023 16:59:42 +0700 Subject: [PATCH 67/74] AdminOrigin gains StakingAdmin --- polkadot/runtime/test-runtime/src/lib.rs | 1 - polkadot/runtime/westend/src/lib.rs | 3 +-- substrate/bin/node/runtime/src/lib.rs | 1 - substrate/frame/beefy/src/mock.rs | 1 - .../test-staking-e2e/src/mock.rs | 1 - substrate/frame/fast-unstake/src/mock.rs | 1 - substrate/frame/grandpa/src/mock.rs | 1 - substrate/frame/nomination-pools/benchmarking/src/mock.rs | 1 - substrate/frame/nomination-pools/test-staking/src/mock.rs | 1 - substrate/frame/offences/benchmarking/src/mock.rs | 1 - substrate/frame/root-offences/src/mock.rs | 1 - substrate/frame/session/benchmarking/src/mock.rs | 1 - substrate/frame/staking/src/mock.rs | 1 - substrate/frame/staking/src/pallet/mod.rs | 4 ++-- substrate/frame/staking/src/tests.rs | 2 +- 15 files changed, 4 insertions(+), 17 deletions(-) diff --git a/polkadot/runtime/test-runtime/src/lib.rs b/polkadot/runtime/test-runtime/src/lib.rs index 75dc261787b8..7b1617df7a19 100644 --- a/polkadot/runtime/test-runtime/src/lib.rs +++ b/polkadot/runtime/test-runtime/src/lib.rs @@ -343,7 +343,6 @@ impl pallet_staking::Config for Runtime { type BondingDuration = BondingDuration; type SlashDeferDuration = SlashDeferDuration; type AdminOrigin = frame_system::EnsureNever<()>; - type DeprecationOrigin = frame_system::EnsureRoot; type SessionInterface = Self; type EraPayout = pallet_staking::ConvertCurve; type MaxExposurePageSize = MaxExposurePageSize; diff --git a/polkadot/runtime/westend/src/lib.rs b/polkadot/runtime/westend/src/lib.rs index a678a33c3b24..fa584135bdfd 100644 --- a/polkadot/runtime/westend/src/lib.rs +++ b/polkadot/runtime/westend/src/lib.rs @@ -688,8 +688,7 @@ impl pallet_staking::Config for Runtime { type SessionsPerEra = SessionsPerEra; type BondingDuration = BondingDuration; type SlashDeferDuration = SlashDeferDuration; - type AdminOrigin = EnsureRoot; - type DeprecationOrigin = EitherOf, StakingAdmin>; + type AdminOrigin = EitherOf, StakingAdmin>; type SessionInterface = Self; type EraPayout = pallet_staking::ConvertCurve; type MaxExposurePageSize = MaxExposurePageSize; diff --git a/substrate/bin/node/runtime/src/lib.rs b/substrate/bin/node/runtime/src/lib.rs index b4400b8094ce..c6cc663772d9 100644 --- a/substrate/bin/node/runtime/src/lib.rs +++ b/substrate/bin/node/runtime/src/lib.rs @@ -658,7 +658,6 @@ impl pallet_staking::Config for Runtime { EnsureRoot, pallet_collective::EnsureProportionAtLeast, >; - type DeprecationOrigin = EnsureRoot; type SessionInterface = Self; type EraPayout = pallet_staking::ConvertCurve; type NextNewSession = Session; diff --git a/substrate/frame/beefy/src/mock.rs b/substrate/frame/beefy/src/mock.rs index 0e4178b496b3..8dc30614c33b 100644 --- a/substrate/frame/beefy/src/mock.rs +++ b/substrate/frame/beefy/src/mock.rs @@ -189,7 +189,6 @@ impl pallet_staking::Config for Test { type BondingDuration = BondingDuration; type SlashDeferDuration = (); type AdminOrigin = frame_system::EnsureRoot; - type DeprecationOrigin = frame_system::EnsureRoot; type SessionInterface = Self; type UnixTime = pallet_timestamp::Pallet; type EraPayout = pallet_staking::ConvertCurve; diff --git a/substrate/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs b/substrate/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs index ea0cf7e3294b..ecb2ae435b8c 100644 --- a/substrate/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs +++ b/substrate/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs @@ -265,7 +265,6 @@ impl pallet_staking::Config for Runtime { type BondingDuration = BondingDuration; type SlashDeferDuration = SlashDeferDuration; type AdminOrigin = EnsureRoot; // root can cancel slashes - type DeprecationOrigin = EnsureRoot; type SessionInterface = Self; type EraPayout = (); type NextNewSession = Session; diff --git a/substrate/frame/fast-unstake/src/mock.rs b/substrate/frame/fast-unstake/src/mock.rs index 93b4791bfd5e..f9326919fd3e 100644 --- a/substrate/frame/fast-unstake/src/mock.rs +++ b/substrate/frame/fast-unstake/src/mock.rs @@ -129,7 +129,6 @@ impl pallet_staking::Config for Runtime { type SessionsPerEra = (); type SlashDeferDuration = (); type AdminOrigin = frame_system::EnsureRoot; - type DeprecationOrigin = frame_system::EnsureRoot; type BondingDuration = BondingDuration; type SessionInterface = (); type EraPayout = pallet_staking::ConvertCurve; diff --git a/substrate/frame/grandpa/src/mock.rs b/substrate/frame/grandpa/src/mock.rs index d7885ca61f0c..f1f51e0b1181 100644 --- a/substrate/frame/grandpa/src/mock.rs +++ b/substrate/frame/grandpa/src/mock.rs @@ -194,7 +194,6 @@ impl pallet_staking::Config for Test { type BondingDuration = BondingDuration; type SlashDeferDuration = (); type AdminOrigin = frame_system::EnsureRoot; - type DeprecationOrigin = frame_system::EnsureRoot; type SessionInterface = Self; type UnixTime = pallet_timestamp::Pallet; type EraPayout = pallet_staking::ConvertCurve; diff --git a/substrate/frame/nomination-pools/benchmarking/src/mock.rs b/substrate/frame/nomination-pools/benchmarking/src/mock.rs index 20a60625090b..c58a66f6163a 100644 --- a/substrate/frame/nomination-pools/benchmarking/src/mock.rs +++ b/substrate/frame/nomination-pools/benchmarking/src/mock.rs @@ -107,7 +107,6 @@ impl pallet_staking::Config for Runtime { type SessionsPerEra = (); type SlashDeferDuration = (); type AdminOrigin = frame_system::EnsureRoot; - type DeprecationOrigin = frame_system::EnsureRoot; type BondingDuration = ConstU32<3>; type SessionInterface = (); type EraPayout = pallet_staking::ConvertCurve; diff --git a/substrate/frame/nomination-pools/test-staking/src/mock.rs b/substrate/frame/nomination-pools/test-staking/src/mock.rs index 09c4c6882462..491cd6191619 100644 --- a/substrate/frame/nomination-pools/test-staking/src/mock.rs +++ b/substrate/frame/nomination-pools/test-staking/src/mock.rs @@ -121,7 +121,6 @@ impl pallet_staking::Config for Runtime { type SessionsPerEra = (); type SlashDeferDuration = (); type AdminOrigin = frame_system::EnsureRoot; - type DeprecationOrigin = frame_system::EnsureRoot; type BondingDuration = BondingDuration; type SessionInterface = (); type EraPayout = pallet_staking::ConvertCurve; diff --git a/substrate/frame/offences/benchmarking/src/mock.rs b/substrate/frame/offences/benchmarking/src/mock.rs index 8a780efab6d3..1d642b9b4982 100644 --- a/substrate/frame/offences/benchmarking/src/mock.rs +++ b/substrate/frame/offences/benchmarking/src/mock.rs @@ -173,7 +173,6 @@ impl pallet_staking::Config for Test { type SessionsPerEra = (); type SlashDeferDuration = (); type AdminOrigin = frame_system::EnsureRoot; - type DeprecationOrigin = frame_system::EnsureRoot; type BondingDuration = (); type SessionInterface = Self; type EraPayout = pallet_staking::ConvertCurve; diff --git a/substrate/frame/root-offences/src/mock.rs b/substrate/frame/root-offences/src/mock.rs index f878775d37f6..c0c83dd08d24 100644 --- a/substrate/frame/root-offences/src/mock.rs +++ b/substrate/frame/root-offences/src/mock.rs @@ -176,7 +176,6 @@ impl pallet_staking::Config for Test { type SessionsPerEra = SessionsPerEra; type SlashDeferDuration = SlashDeferDuration; type AdminOrigin = frame_system::EnsureRoot; - type DeprecationOrigin = frame_system::EnsureRoot; type BondingDuration = BondingDuration; type SessionInterface = Self; type EraPayout = pallet_staking::ConvertCurve; diff --git a/substrate/frame/session/benchmarking/src/mock.rs b/substrate/frame/session/benchmarking/src/mock.rs index 9c0aa0e3ebaf..e1744fa43abb 100644 --- a/substrate/frame/session/benchmarking/src/mock.rs +++ b/substrate/frame/session/benchmarking/src/mock.rs @@ -170,7 +170,6 @@ impl pallet_staking::Config for Test { type SessionsPerEra = (); type SlashDeferDuration = (); type AdminOrigin = frame_system::EnsureRoot; - type DeprecationOrigin = frame_system::EnsureRoot; type BondingDuration = (); type SessionInterface = Self; type EraPayout = pallet_staking::ConvertCurve; diff --git a/substrate/frame/staking/src/mock.rs b/substrate/frame/staking/src/mock.rs index c51d4cad6142..5332dbfdd5b2 100644 --- a/substrate/frame/staking/src/mock.rs +++ b/substrate/frame/staking/src/mock.rs @@ -303,7 +303,6 @@ impl crate::pallet::pallet::Config for Test { type SessionsPerEra = SessionsPerEra; type SlashDeferDuration = SlashDeferDuration; type AdminOrigin = EnsureOneOrRoot; - type DeprecationOrigin = EnsureOneOrRoot; type BondingDuration = BondingDuration; type SessionInterface = Self; type EraPayout = ConvertCurve; diff --git a/substrate/frame/staking/src/pallet/mod.rs b/substrate/frame/staking/src/pallet/mod.rs index c02680ffe4c0..4be6c5ba9181 100644 --- a/substrate/frame/staking/src/pallet/mod.rs +++ b/substrate/frame/staking/src/pallet/mod.rs @@ -1932,14 +1932,14 @@ pub mod pallet { /// /// Effects will be felt instantly (as soon as this function is completed successfully). /// - /// The dispatch origin must be DeprecationOrigin. + /// The dispatch origin must be AdminOrigin. #[pallet::call_index(28)] #[pallet::weight(T::WeightInfo::deprecate_controller_batch(controllers.len() as u32))] pub fn deprecate_controller_batch( origin: OriginFor, controllers: BoundedVec, ) -> DispatchResultWithPostInfo { - T::DeprecationOrigin::ensure_origin(origin)?; + T::AdminOrigin::ensure_origin(origin)?; // Ignore controllers that do not exist or are already the same as stash. let filtered_batch_with_ledger: Vec<_> = controllers diff --git a/substrate/frame/staking/src/tests.rs b/substrate/frame/staking/src/tests.rs index a9ef8ab61b21..f61c444be27c 100644 --- a/substrate/frame/staking/src/tests.rs +++ b/substrate/frame/staking/src/tests.rs @@ -6899,7 +6899,7 @@ mod ledger { ::MaxControllersInDeprecationBatch, > = BoundedVec::try_from(controllers).unwrap(); - // Only `DeprecationOrigin` can sign. + // Only `AdminOrigin` can sign. assert_noop!( Staking::deprecate_controller_batch( RuntimeOrigin::signed(2), From eef836044bf38b4aa169949f09fedee84c527899 Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Wed, 6 Dec 2023 17:04:37 +0700 Subject: [PATCH 68/74] rm DeprecationOrigin --- substrate/frame/staking/src/pallet/mod.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/substrate/frame/staking/src/pallet/mod.rs b/substrate/frame/staking/src/pallet/mod.rs index 4be6c5ba9181..e1e7f68dc6e9 100644 --- a/substrate/frame/staking/src/pallet/mod.rs +++ b/substrate/frame/staking/src/pallet/mod.rs @@ -172,9 +172,6 @@ pub mod pallet { /// issuance. type Reward: OnUnbalanced>; - /// Origin from which deprecation calls must come. - type DeprecationOrigin: EnsureOrigin; - /// Number of sessions per era. #[pallet::constant] type SessionsPerEra: Get; From 04833df5e5aca4e530b3a5bb07ee054914831ebf Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Wed, 6 Dec 2023 17:15:12 +0700 Subject: [PATCH 69/74] rm DeprecationOrigin --- substrate/frame/babe/src/mock.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/substrate/frame/babe/src/mock.rs b/substrate/frame/babe/src/mock.rs index 611c7b1a0fae..72abbc805db1 100644 --- a/substrate/frame/babe/src/mock.rs +++ b/substrate/frame/babe/src/mock.rs @@ -171,7 +171,6 @@ impl pallet_staking::Config for Test { type BondingDuration = BondingDuration; type SlashDeferDuration = SlashDeferDuration; type AdminOrigin = frame_system::EnsureRoot; - type DeprecationOrigin = frame_system::EnsureRoot; type SessionInterface = Self; type UnixTime = pallet_timestamp::Pallet; type EraPayout = pallet_staking::ConvertCurve; From 0d710055676c0c69aabccde50f8200e3e856efca Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Sun, 10 Dec 2023 11:14:41 +0700 Subject: [PATCH 70/74] skip deprecation if still Controller payee --- substrate/frame/staking/src/pallet/mod.rs | 9 ++- substrate/frame/staking/src/tests.rs | 87 ++++++++++++++++++----- 2 files changed, 76 insertions(+), 20 deletions(-) diff --git a/substrate/frame/staking/src/pallet/mod.rs b/substrate/frame/staking/src/pallet/mod.rs index e1e7f68dc6e9..189182a4062b 100644 --- a/substrate/frame/staking/src/pallet/mod.rs +++ b/substrate/frame/staking/src/pallet/mod.rs @@ -1944,7 +1944,14 @@ pub mod pallet { .filter_map(|controller| { let ledger = Self::ledger(StakingAccount::Controller(controller.clone())); ledger.ok().map_or(None, |ledger| { - if ledger.stash != *controller { + // If the controller `RewardDestination` is still the deprecated + // `Controller` variant, skip deprecating this account. + let payee_deprecated = Payee::::get(&ledger.stash) == { + #[allow(deprecated)] + RewardDestination::Controller + }; + + if ledger.stash != *controller && !payee_deprecated { Some((controller.clone(), ledger)) } else { None diff --git a/substrate/frame/staking/src/tests.rs b/substrate/frame/staking/src/tests.rs index f61c444be27c..0e9be70ee7d2 100644 --- a/substrate/frame/staking/src/tests.rs +++ b/substrate/frame/staking/src/tests.rs @@ -6206,7 +6206,7 @@ fn proportional_ledger_slash_works() { #[test] fn reducing_max_unlocking_chunks_abrupt() { // Concern is on validators only - // By Default 11, 10 are stash and ctrl and 21,20 + // By Default 11, 10 are stash and ctlr and 21,20 ExtBuilder::default().build_and_execute(|| { // given a staker at era=10 and MaxUnlockChunks set to 2 MaxUnlockingChunks::set(2); @@ -6876,20 +6876,22 @@ mod ledger { let start = 1001; let mut controllers: Vec<_> = vec![]; for n in start..(start + MaxControllersInDeprecationBatch::get()).into() { - let ctrl: u64 = n.into(); + let ctlr: u64 = n.into(); let stash: u64 = (n + 10000).into(); Ledger::::insert( - ctrl, + ctlr, StakingLedger { controller: None, - total: (10 + ctrl).into(), - active: (10 + ctrl).into(), + total: (10 + ctlr).into(), + active: (10 + ctlr).into(), ..StakingLedger::default_from(stash) }, ); - Bonded::::insert(stash, ctrl); - controllers.push(ctrl); + Bonded::::insert(stash, ctlr); + Payee::::insert(stash, RewardDestination::Staked); + + controllers.push(ctlr); } // When: @@ -6921,11 +6923,11 @@ mod ledger { // Then: for n in start..(start + MaxControllersInDeprecationBatch::get()).into() { - let ctrl: u64 = n.into(); + let ctlr: u64 = n.into(); let stash: u64 = (n + 10000).into(); // Ledger no longer keyed by controller. - assert_eq!(Ledger::::get(ctrl), None); + assert_eq!(Ledger::::get(ctlr), None); // Bonded now maps to the stash. assert_eq!(Bonded::::get(stash), Some(stash)); @@ -6934,8 +6936,8 @@ mod ledger { assert_eq!(ledger_updated.stash, stash); // Check `active` and `total` values match the original ledger set by controller. - assert_eq!(ledger_updated.active, (10 + ctrl).into()); - assert_eq!(ledger_updated.total, (10 + ctrl).into()); + assert_eq!(ledger_updated.active, (10 + ctlr).into()); + assert_eq!(ledger_updated.total, (10 + ctlr).into()); } }) } @@ -6948,17 +6950,19 @@ mod ledger { let start = 1001; let mut controllers: Vec<_> = vec![]; for n in start..(start + MaxControllersInDeprecationBatch::get()).into() { - let ctrl: u64 = n.into(); + let ctlr: u64 = n.into(); // Only half of entries are unique pairs. - let stash: u64 = if n % 2 == 0 { (n + 10000).into() } else { ctrl }; + let stash: u64 = if n % 2 == 0 { (n + 10000).into() } else { ctlr }; Ledger::::insert( - ctrl, + ctlr, StakingLedger { controller: None, ..StakingLedger::default_from(stash) }, ); - Bonded::::insert(stash, ctrl); - controllers.push(ctrl); + Bonded::::insert(stash, ctlr); + Payee::::insert(stash, RewardDestination::Staked); + + controllers.push(ctlr); } // When: @@ -6979,12 +6983,12 @@ mod ledger { for n in start..(start + MaxControllersInDeprecationBatch::get()).into() { let unique_pair = n % 2 == 0; - let ctrl: u64 = n.into(); - let stash: u64 = if unique_pair { (n + 10000).into() } else { ctrl }; + let ctlr: u64 = n.into(); + let stash: u64 = if unique_pair { (n + 10000).into() } else { ctlr }; // Side effect of migration for unique pair. if unique_pair { - assert_eq!(Ledger::::get(ctrl), None); + assert_eq!(Ledger::::get(ctlr), None); } // Bonded maps to the stash. assert_eq!(Bonded::::get(stash), Some(stash)); @@ -6995,4 +6999,49 @@ mod ledger { } }) } + + #[test] + fn deprecate_controller_batch_skips_unmigrated_controller_payees() { + ExtBuilder::default().build_and_execute(|| { + // Given: + + let stash: u64 = 1000; + let ctlr: u64 = 1001; + + Ledger::::insert( + ctlr, + StakingLedger { controller: None, ..StakingLedger::default_from(stash) }, + ); + Bonded::::insert(stash, ctlr); + #[allow(deprecated)] + Payee::::insert(stash, RewardDestination::Controller); + + // When: + + let bounded_controllers: BoundedVec< + _, + ::MaxControllersInDeprecationBatch, + > = BoundedVec::try_from(vec![ctlr]).unwrap(); + + let result = + Staking::deprecate_controller_batch(RuntimeOrigin::root(), bounded_controllers); + assert_ok!(result); + assert_eq!( + result.unwrap().actual_weight.unwrap(), + ::WeightInfo::deprecate_controller_batch(1 as u32) + ); + + // Then: + + // Esure deprecation did not happen. + assert_eq!(Ledger::::get(ctlr).is_some(), true); + + // Bonded still keyed by controller. + assert_eq!(Bonded::::get(stash), Some(ctlr)); + + // Ledger is still keyed by controller. + let ledger_updated = Ledger::::get(ctlr).unwrap(); + assert_eq!(ledger_updated.stash, stash); + }) + } } From 84daf1bbdc4b5d99ddf9adfbff1db98aca651cb5 Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Sun, 10 Dec 2023 08:02:20 +0000 Subject: [PATCH 71/74] ".git/.scripts/commands/bench/bench.sh" --subcommand=runtime --runtime=westend --target_dir=polkadot --pallet=pallet_staking --- .../westend/src/weights/pallet_staking.rs | 200 +++++++++--------- 1 file changed, 101 insertions(+), 99 deletions(-) diff --git a/polkadot/runtime/westend/src/weights/pallet_staking.rs b/polkadot/runtime/westend/src/weights/pallet_staking.rs index f69a19743f8b..1ecd44747ef5 100644 --- a/polkadot/runtime/westend/src/weights/pallet_staking.rs +++ b/polkadot/runtime/westend/src/weights/pallet_staking.rs @@ -17,9 +17,9 @@ //! Autogenerated weights for `pallet_staking` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-12-04, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-12-10, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `runner-r43aesjn-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` +//! HOSTNAME: `runner-itmxxexx-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` //! WASM-EXECUTION: `Compiled`, CHAIN: `Some("westend-dev")`, DB CACHE: 1024 // Executed Command: @@ -62,8 +62,8 @@ impl pallet_staking::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `894` // Estimated: `4764` - // Minimum execution time: 38_131_000 picoseconds. - Weight::from_parts(39_750_000, 0) + // Minimum execution time: 38_316_000 picoseconds. + Weight::from_parts(40_022_000, 0) .saturating_add(Weight::from_parts(0, 4764)) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(4)) @@ -84,8 +84,8 @@ impl pallet_staking::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `1921` // Estimated: `8877` - // Minimum execution time: 81_673_000 picoseconds. - Weight::from_parts(84_229_000, 0) + // Minimum execution time: 81_027_000 picoseconds. + Weight::from_parts(83_964_000, 0) .saturating_add(Weight::from_parts(0, 8877)) .saturating_add(T::DbWeight::get().reads(9)) .saturating_add(T::DbWeight::get().writes(7)) @@ -112,8 +112,8 @@ impl pallet_staking::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `2128` // Estimated: `8877` - // Minimum execution time: 85_412_000 picoseconds. - Weight::from_parts(87_733_000, 0) + // Minimum execution time: 85_585_000 picoseconds. + Weight::from_parts(87_256_000, 0) .saturating_add(Weight::from_parts(0, 8877)) .saturating_add(T::DbWeight::get().reads(12)) .saturating_add(T::DbWeight::get().writes(7)) @@ -133,11 +133,11 @@ impl pallet_staking::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `1075` // Estimated: `4764` - // Minimum execution time: 39_818_000 picoseconds. - Weight::from_parts(41_316_192, 0) + // Minimum execution time: 39_520_000 picoseconds. + Weight::from_parts(41_551_548, 0) .saturating_add(Weight::from_parts(0, 4764)) - // Standard Error: 865 - .saturating_add(Weight::from_parts(46_320, 0).saturating_mul(s.into())) + // Standard Error: 1_094 + .saturating_add(Weight::from_parts(50_426, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -174,11 +174,11 @@ impl pallet_staking::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `2127 + s * (4 ±0)` // Estimated: `6248 + s * (4 ±0)` - // Minimum execution time: 81_972_000 picoseconds. - Weight::from_parts(89_744_685, 0) + // Minimum execution time: 82_915_000 picoseconds. + Weight::from_parts(89_597_160, 0) .saturating_add(Weight::from_parts(0, 6248)) - // Standard Error: 3_956 - .saturating_add(Weight::from_parts(1_272_172, 0).saturating_mul(s.into())) + // Standard Error: 3_146 + .saturating_add(Weight::from_parts(1_228_061, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(13)) .saturating_add(T::DbWeight::get().writes(11)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(s.into()))) @@ -210,8 +210,8 @@ impl pallet_staking::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `1301` // Estimated: `4556` - // Minimum execution time: 48_774_000 picoseconds. - Weight::from_parts(50_515_000, 0) + // Minimum execution time: 48_070_000 picoseconds. + Weight::from_parts(49_226_000, 0) .saturating_add(Weight::from_parts(0, 4556)) .saturating_add(T::DbWeight::get().reads(11)) .saturating_add(T::DbWeight::get().writes(5)) @@ -225,11 +225,11 @@ impl pallet_staking::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `1243 + k * (569 ±0)` // Estimated: `4556 + k * (3033 ±0)` - // Minimum execution time: 28_844_000 picoseconds. - Weight::from_parts(26_928_199, 0) + // Minimum execution time: 29_140_000 picoseconds. + Weight::from_parts(30_225_579, 0) .saturating_add(Weight::from_parts(0, 4556)) - // Standard Error: 10_206 - .saturating_add(Weight::from_parts(6_757_218, 0).saturating_mul(k.into())) + // Standard Error: 5_394 + .saturating_add(Weight::from_parts(6_401_367, 0).saturating_mul(k.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(k.into()))) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(k.into()))) @@ -262,11 +262,11 @@ impl pallet_staking::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `1797 + n * (102 ±0)` // Estimated: `6248 + n * (2520 ±0)` - // Minimum execution time: 59_414_000 picoseconds. - Weight::from_parts(57_811_923, 0) + // Minimum execution time: 59_287_000 picoseconds. + Weight::from_parts(58_285_052, 0) .saturating_add(Weight::from_parts(0, 6248)) - // Standard Error: 18_178 - .saturating_add(Weight::from_parts(3_948_815, 0).saturating_mul(n.into())) + // Standard Error: 14_556 + .saturating_add(Weight::from_parts(3_863_008, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(12)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes(6)) @@ -290,8 +290,8 @@ impl pallet_staking::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `1581` // Estimated: `6248` - // Minimum execution time: 50_272_000 picoseconds. - Weight::from_parts(52_124_000, 0) + // Minimum execution time: 51_035_000 picoseconds. + Weight::from_parts(52_163_000, 0) .saturating_add(Weight::from_parts(0, 6248)) .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().writes(6)) @@ -306,8 +306,8 @@ impl pallet_staking::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `865` // Estimated: `4556` - // Minimum execution time: 15_822_000 picoseconds. - Weight::from_parts(16_429_000, 0) + // Minimum execution time: 15_809_000 picoseconds. + Weight::from_parts(16_451_000, 0) .saturating_add(Weight::from_parts(0, 4556)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) @@ -322,8 +322,8 @@ impl pallet_staking::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `932` // Estimated: `4556` - // Minimum execution time: 21_657_000 picoseconds. - Weight::from_parts(22_400_000, 0) + // Minimum execution time: 21_695_000 picoseconds. + Weight::from_parts(22_351_000, 0) .saturating_add(Weight::from_parts(0, 4556)) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(1)) @@ -336,8 +336,8 @@ impl pallet_staking::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `865` // Estimated: `4556` - // Minimum execution time: 18_721_000 picoseconds. - Weight::from_parts(19_168_000, 0) + // Minimum execution time: 18_548_000 picoseconds. + Weight::from_parts(19_205_000, 0) .saturating_add(Weight::from_parts(0, 4556)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(3)) @@ -348,8 +348,8 @@ impl pallet_staking::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_110_000 picoseconds. - Weight::from_parts(2_250_000, 0) + // Minimum execution time: 2_193_000 picoseconds. + Weight::from_parts(2_408_000, 0) .saturating_add(Weight::from_parts(0, 0)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -359,8 +359,8 @@ impl pallet_staking::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_283_000 picoseconds. - Weight::from_parts(7_716_000, 0) + // Minimum execution time: 7_475_000 picoseconds. + Weight::from_parts(7_874_000, 0) .saturating_add(Weight::from_parts(0, 0)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -370,8 +370,8 @@ impl pallet_staking::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_356_000 picoseconds. - Weight::from_parts(7_773_000, 0) + // Minimum execution time: 7_393_000 picoseconds. + Weight::from_parts(7_643_000, 0) .saturating_add(Weight::from_parts(0, 0)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -381,8 +381,8 @@ impl pallet_staking::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_309_000 picoseconds. - Weight::from_parts(7_605_000, 0) + // Minimum execution time: 7_474_000 picoseconds. + Weight::from_parts(7_814_000, 0) .saturating_add(Weight::from_parts(0, 0)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -393,28 +393,30 @@ impl pallet_staking::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_319_000 picoseconds. - Weight::from_parts(2_597_614, 0) + // Minimum execution time: 2_358_000 picoseconds. + Weight::from_parts(2_589_423, 0) .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 77 - .saturating_add(Weight::from_parts(12_005, 0).saturating_mul(v.into())) + // Standard Error: 81 + .saturating_add(Weight::from_parts(13_612, 0).saturating_mul(v.into())) .saturating_add(T::DbWeight::get().writes(1)) } /// Storage: `Staking::Ledger` (r:751 w:1502) /// Proof: `Staking::Ledger` (`max_values`: None, `max_size`: Some(1091), added: 3566, mode: `MaxEncodedLen`) + /// Storage: `Staking::Payee` (r:751 w:0) + /// Proof: `Staking::Payee` (`max_values`: None, `max_size`: Some(73), added: 2548, mode: `MaxEncodedLen`) /// Storage: `Staking::Bonded` (r:0 w:751) /// Proof: `Staking::Bonded` (`max_values`: None, `max_size`: Some(72), added: 2547, mode: `MaxEncodedLen`) /// The range of component `i` is `[0, 751]`. fn deprecate_controller_batch(i: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `670 + i * (101 ±0)` + // Measured: `668 + i * (148 ±0)` // Estimated: `990 + i * (3566 ±0)` - // Minimum execution time: 1_757_000 picoseconds. - Weight::from_parts(1_852_000, 0) + // Minimum execution time: 1_934_000 picoseconds. + Weight::from_parts(2_070_000, 0) .saturating_add(Weight::from_parts(0, 990)) - // Standard Error: 13_274 - .saturating_add(Weight::from_parts(9_581_951, 0).saturating_mul(i.into())) - .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(i.into()))) + // Standard Error: 19_129 + .saturating_add(Weight::from_parts(13_231_580, 0).saturating_mul(i.into())) + .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(i.into()))) .saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(i.into()))) .saturating_add(Weight::from_parts(0, 3566).saturating_mul(i.into())) } @@ -451,11 +453,11 @@ impl pallet_staking::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `2127 + s * (4 ±0)` // Estimated: `6248 + s * (4 ±0)` - // Minimum execution time: 80_758_000 picoseconds. - Weight::from_parts(87_211_938, 0) + // Minimum execution time: 80_290_000 picoseconds. + Weight::from_parts(87_901_664, 0) .saturating_add(Weight::from_parts(0, 6248)) - // Standard Error: 3_191 - .saturating_add(Weight::from_parts(1_212_350, 0).saturating_mul(s.into())) + // Standard Error: 2_960 + .saturating_add(Weight::from_parts(1_195_050, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(13)) .saturating_add(T::DbWeight::get().writes(12)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(s.into()))) @@ -468,11 +470,11 @@ impl pallet_staking::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `66639` // Estimated: `70104` - // Minimum execution time: 133_849_000 picoseconds. - Weight::from_parts(1_204_195_716, 0) + // Minimum execution time: 132_682_000 picoseconds. + Weight::from_parts(932_504_297, 0) .saturating_add(Weight::from_parts(0, 70104)) - // Standard Error: 77_028 - .saturating_add(Weight::from_parts(6_462_199, 0).saturating_mul(s.into())) + // Standard Error: 57_593 + .saturating_add(Weight::from_parts(4_829_705, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -509,11 +511,11 @@ impl pallet_staking::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `8249 + n * (396 ±0)` // Estimated: `10779 + n * (3774 ±3)` - // Minimum execution time: 130_738_000 picoseconds. - Weight::from_parts(177_263_167, 0) + // Minimum execution time: 129_091_000 picoseconds. + Weight::from_parts(166_186_167, 0) .saturating_add(Weight::from_parts(0, 10779)) - // Standard Error: 57_605 - .saturating_add(Weight::from_parts(42_162_920, 0).saturating_mul(n.into())) + // Standard Error: 36_242 + .saturating_add(Weight::from_parts(40_467_481, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(14)) .saturating_add(T::DbWeight::get().reads((6_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes(4)) @@ -537,11 +539,11 @@ impl pallet_staking::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `1922 + l * (5 ±0)` // Estimated: `8877` - // Minimum execution time: 77_417_000 picoseconds. - Weight::from_parts(79_886_333, 0) + // Minimum execution time: 77_461_000 picoseconds. + Weight::from_parts(80_118_021, 0) .saturating_add(Weight::from_parts(0, 8877)) - // Standard Error: 4_437 - .saturating_add(Weight::from_parts(57_506, 0).saturating_mul(l.into())) + // Standard Error: 4_343 + .saturating_add(Weight::from_parts(59_113, 0).saturating_mul(l.into())) .saturating_add(T::DbWeight::get().reads(9)) .saturating_add(T::DbWeight::get().writes(7)) } @@ -576,11 +578,11 @@ impl pallet_staking::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `2127 + s * (4 ±0)` // Estimated: `6248 + s * (4 ±0)` - // Minimum execution time: 89_339_000 picoseconds. - Weight::from_parts(92_298_354, 0) + // Minimum execution time: 89_366_000 picoseconds. + Weight::from_parts(91_964_557, 0) .saturating_add(Weight::from_parts(0, 6248)) - // Standard Error: 3_468 - .saturating_add(Weight::from_parts(1_211_827, 0).saturating_mul(s.into())) + // Standard Error: 2_799 + .saturating_add(Weight::from_parts(1_206_123, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(12)) .saturating_add(T::DbWeight::get().writes(11)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(s.into()))) @@ -625,14 +627,14 @@ impl pallet_staking::WeightInfo for WeightInfo { fn new_era(v: u32, n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0 + n * (716 ±0) + v * (3594 ±0)` - // Estimated: `456136 + n * (3566 ±0) + v * (3566 ±0)` - // Minimum execution time: 524_072_000 picoseconds. - Weight::from_parts(530_854_000, 0) + // Estimated: `456136 + n * (3566 ±4) + v * (3566 ±40)` + // Minimum execution time: 520_430_000 picoseconds. + Weight::from_parts(527_125_000, 0) .saturating_add(Weight::from_parts(0, 456136)) - // Standard Error: 2_163_307 - .saturating_add(Weight::from_parts(70_082_102, 0).saturating_mul(v.into())) - // Standard Error: 215_561 - .saturating_add(Weight::from_parts(19_364_205, 0).saturating_mul(n.into())) + // Standard Error: 1_974_092 + .saturating_add(Weight::from_parts(64_885_491, 0).saturating_mul(v.into())) + // Standard Error: 196_707 + .saturating_add(Weight::from_parts(18_100_326, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(184)) .saturating_add(T::DbWeight::get().reads((5_u64).saturating_mul(v.into()))) .saturating_add(T::DbWeight::get().reads((4_u64).saturating_mul(n.into()))) @@ -663,13 +665,13 @@ impl pallet_staking::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `3108 + n * (907 ±0) + v * (391 ±0)` // Estimated: `456136 + n * (3566 ±0) + v * (3566 ±0)` - // Minimum execution time: 35_973_199_000 picoseconds. - Weight::from_parts(37_068_877_000, 0) + // Minimum execution time: 33_917_323_000 picoseconds. + Weight::from_parts(34_173_565_000, 0) .saturating_add(Weight::from_parts(0, 456136)) - // Standard Error: 417_905 - .saturating_add(Weight::from_parts(5_666_298, 0).saturating_mul(v.into())) - // Standard Error: 417_905 - .saturating_add(Weight::from_parts(4_689_560, 0).saturating_mul(n.into())) + // Standard Error: 367_135 + .saturating_add(Weight::from_parts(4_696_840, 0).saturating_mul(v.into())) + // Standard Error: 367_135 + .saturating_add(Weight::from_parts(3_889_075, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(179)) .saturating_add(T::DbWeight::get().reads((5_u64).saturating_mul(v.into()))) .saturating_add(T::DbWeight::get().reads((4_u64).saturating_mul(n.into()))) @@ -686,11 +688,11 @@ impl pallet_staking::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `946 + v * (50 ±0)` // Estimated: `3510 + v * (2520 ±0)` - // Minimum execution time: 2_515_600_000 picoseconds. - Weight::from_parts(83_484_440, 0) + // Minimum execution time: 2_447_197_000 picoseconds. + Weight::from_parts(13_003_614, 0) .saturating_add(Weight::from_parts(0, 3510)) - // Standard Error: 15_899 - .saturating_add(Weight::from_parts(5_080_559, 0).saturating_mul(v.into())) + // Standard Error: 9_738 + .saturating_add(Weight::from_parts(4_953_442, 0).saturating_mul(v.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(v.into()))) .saturating_add(Weight::from_parts(0, 2520).saturating_mul(v.into())) @@ -711,8 +713,8 @@ impl pallet_staking::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_663_000 picoseconds. - Weight::from_parts(3_970_000, 0) + // Minimum execution time: 3_714_000 picoseconds. + Weight::from_parts(3_956_000, 0) .saturating_add(Weight::from_parts(0, 0)) .saturating_add(T::DbWeight::get().writes(6)) } @@ -732,8 +734,8 @@ impl pallet_staking::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_362_000 picoseconds. - Weight::from_parts(3_549_000, 0) + // Minimum execution time: 3_361_000 picoseconds. + Weight::from_parts(3_632_000, 0) .saturating_add(Weight::from_parts(0, 0)) .saturating_add(T::DbWeight::get().writes(6)) } @@ -763,8 +765,8 @@ impl pallet_staking::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `1870` // Estimated: `6248` - // Minimum execution time: 66_875_000 picoseconds. - Weight::from_parts(68_380_000, 0) + // Minimum execution time: 65_329_000 picoseconds. + Weight::from_parts(67_247_000, 0) .saturating_add(Weight::from_parts(0, 6248)) .saturating_add(T::DbWeight::get().reads(12)) .saturating_add(T::DbWeight::get().writes(6)) @@ -777,8 +779,8 @@ impl pallet_staking::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `658` // Estimated: `3510` - // Minimum execution time: 11_377_000 picoseconds. - Weight::from_parts(12_038_000, 0) + // Minimum execution time: 11_760_000 picoseconds. + Weight::from_parts(12_095_000, 0) .saturating_add(Weight::from_parts(0, 3510)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) @@ -789,8 +791,8 @@ impl pallet_staking::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_272_000 picoseconds. - Weight::from_parts(2_341_000, 0) + // Minimum execution time: 2_256_000 picoseconds. + Weight::from_parts(2_378_000, 0) .saturating_add(Weight::from_parts(0, 0)) .saturating_add(T::DbWeight::get().writes(1)) } From 5b5dc1abc11f52bac9b1ad3c8154b8c6849b0793 Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Sun, 10 Dec 2023 08:18:07 +0000 Subject: [PATCH 72/74] ".git/.scripts/commands/bench/bench.sh" --subcommand=pallet --runtime=dev --target_dir=substrate --pallet=pallet_staking --- substrate/frame/staking/src/weights.rs | 392 +++++++++++++------------ 1 file changed, 198 insertions(+), 194 deletions(-) diff --git a/substrate/frame/staking/src/weights.rs b/substrate/frame/staking/src/weights.rs index 4d986db5408d..7c9a05001640 100644 --- a/substrate/frame/staking/src/weights.rs +++ b/substrate/frame/staking/src/weights.rs @@ -18,9 +18,9 @@ //! Autogenerated weights for `pallet_staking` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-12-04, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-12-10, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `runner-r43aesjn-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` +//! HOSTNAME: `runner-itmxxexx-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` //! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` // Executed Command: @@ -99,8 +99,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `927` // Estimated: `4764` - // Minimum execution time: 42_189_000 picoseconds. - Weight::from_parts(43_771_000, 4764) + // Minimum execution time: 42_491_000 picoseconds. + Weight::from_parts(44_026_000, 4764) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -120,8 +120,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `1990` // Estimated: `8877` - // Minimum execution time: 86_677_000 picoseconds. - Weight::from_parts(89_437_000, 8877) + // Minimum execution time: 88_756_000 picoseconds. + Weight::from_parts(91_000_000, 8877) .saturating_add(T::DbWeight::get().reads(9_u64)) .saturating_add(T::DbWeight::get().writes(7_u64)) } @@ -147,8 +147,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `2195` // Estimated: `8877` - // Minimum execution time: 90_824_000 picoseconds. - Weight::from_parts(92_907_000, 8877) + // Minimum execution time: 91_331_000 picoseconds. + Weight::from_parts(94_781_000, 8877) .saturating_add(T::DbWeight::get().reads(12_u64)) .saturating_add(T::DbWeight::get().writes(7_u64)) } @@ -167,10 +167,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `1115` // Estimated: `4764` - // Minimum execution time: 42_837_000 picoseconds. - Weight::from_parts(44_269_425, 4764) - // Standard Error: 817 - .saturating_add(Weight::from_parts(43_253, 0).saturating_mul(s.into())) + // Minimum execution time: 42_495_000 picoseconds. + Weight::from_parts(44_189_470, 4764) + // Standard Error: 1_389 + .saturating_add(Weight::from_parts(47_484, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -207,10 +207,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `2196 + s * (4 ±0)` // Estimated: `6248 + s * (4 ±0)` - // Minimum execution time: 87_194_000 picoseconds. - Weight::from_parts(95_999_434, 6248) - // Standard Error: 3_674 - .saturating_add(Weight::from_parts(1_320_100, 0).saturating_mul(s.into())) + // Minimum execution time: 89_004_000 picoseconds. + Weight::from_parts(96_677_570, 6248) + // Standard Error: 4_635 + .saturating_add(Weight::from_parts(1_387_718, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(13_u64)) .saturating_add(T::DbWeight::get().writes(11_u64)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(s.into()))) @@ -242,8 +242,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `1372` // Estimated: `4556` - // Minimum execution time: 51_574_000 picoseconds. - Weight::from_parts(54_444_000, 4556) + // Minimum execution time: 51_532_000 picoseconds. + Weight::from_parts(53_308_000, 4556) .saturating_add(T::DbWeight::get().reads(11_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } @@ -256,10 +256,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `1280 + k * (569 ±0)` // Estimated: `4556 + k * (3033 ±0)` - // Minimum execution time: 28_579_000 picoseconds. - Weight::from_parts(31_179_862, 4556) - // Standard Error: 7_307 - .saturating_add(Weight::from_parts(6_198_340, 0).saturating_mul(k.into())) + // Minimum execution time: 28_955_000 picoseconds. + Weight::from_parts(29_609_869, 4556) + // Standard Error: 6_793 + .saturating_add(Weight::from_parts(6_412_124, 0).saturating_mul(k.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(k.into()))) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(k.into()))) @@ -292,10 +292,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `1866 + n * (102 ±0)` // Estimated: `6248 + n * (2520 ±0)` - // Minimum execution time: 62_856_000 picoseconds. - Weight::from_parts(60_783_406, 6248) - // Standard Error: 13_888 - .saturating_add(Weight::from_parts(3_953_896, 0).saturating_mul(n.into())) + // Minimum execution time: 64_080_000 picoseconds. + Weight::from_parts(61_985_382, 6248) + // Standard Error: 13_320 + .saturating_add(Weight::from_parts(4_030_513, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(12_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes(6_u64)) @@ -319,8 +319,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `1650` // Estimated: `6248` - // Minimum execution time: 53_408_000 picoseconds. - Weight::from_parts(54_715_000, 6248) + // Minimum execution time: 54_194_000 picoseconds. + Weight::from_parts(55_578_000, 6248) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(6_u64)) } @@ -334,8 +334,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `902` // Estimated: `4556` - // Minimum execution time: 16_708_000 picoseconds. - Weight::from_parts(17_177_000, 4556) + // Minimum execution time: 16_597_000 picoseconds. + Weight::from_parts(16_980_000, 4556) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -349,8 +349,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `969` // Estimated: `4556` - // Minimum execution time: 20_516_000 picoseconds. - Weight::from_parts(21_240_000, 4556) + // Minimum execution time: 20_626_000 picoseconds. + Weight::from_parts(21_242_000, 4556) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -362,8 +362,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `902` // Estimated: `4556` - // Minimum execution time: 19_514_000 picoseconds. - Weight::from_parts(20_519_000, 4556) + // Minimum execution time: 19_972_000 picoseconds. + Weight::from_parts(20_470_000, 4556) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -373,8 +373,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_477_000 picoseconds. - Weight::from_parts(2_792_000, 0) + // Minimum execution time: 2_571_000 picoseconds. + Weight::from_parts(2_720_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: `Staking::ForceEra` (r:0 w:1) @@ -383,8 +383,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_917_000 picoseconds. - Weight::from_parts(8_342_000, 0) + // Minimum execution time: 8_056_000 picoseconds. + Weight::from_parts(8_413_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: `Staking::ForceEra` (r:0 w:1) @@ -393,8 +393,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 8_212_000 picoseconds. - Weight::from_parts(8_506_000, 0) + // Minimum execution time: 8_162_000 picoseconds. + Weight::from_parts(8_497_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: `Staking::ForceEra` (r:0 w:1) @@ -403,8 +403,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 8_052_000 picoseconds. - Weight::from_parts(8_405_000, 0) + // Minimum execution time: 8_320_000 picoseconds. + Weight::from_parts(8_564_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: `Staking::Invulnerables` (r:0 w:1) @@ -414,26 +414,28 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_676_000 picoseconds. - Weight::from_parts(3_288_767, 0) - // Standard Error: 69 - .saturating_add(Weight::from_parts(11_426, 0).saturating_mul(v.into())) + // Minimum execution time: 2_470_000 picoseconds. + Weight::from_parts(3_110_242, 0) + // Standard Error: 63 + .saturating_add(Weight::from_parts(11_786, 0).saturating_mul(v.into())) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: `Staking::Ledger` (r:5900 w:11800) /// Proof: `Staking::Ledger` (`max_values`: None, `max_size`: Some(1091), added: 3566, mode: `MaxEncodedLen`) + /// Storage: `Staking::Payee` (r:5900 w:0) + /// Proof: `Staking::Payee` (`max_values`: None, `max_size`: Some(73), added: 2548, mode: `MaxEncodedLen`) /// Storage: `Staking::Bonded` (r:0 w:5900) /// Proof: `Staking::Bonded` (`max_values`: None, `max_size`: Some(72), added: 2547, mode: `MaxEncodedLen`) /// The range of component `i` is `[0, 5900]`. fn deprecate_controller_batch(i: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1015 + i * (105 ±0)` + // Measured: `1356 + i * (151 ±0)` // Estimated: `990 + i * (3566 ±0)` - // Minimum execution time: 2_104_000 picoseconds. - Weight::from_parts(2_155_000, 990) - // Standard Error: 22_751 - .saturating_add(Weight::from_parts(11_460_237, 0).saturating_mul(i.into())) - .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(i.into()))) + // Minimum execution time: 2_101_000 picoseconds. + Weight::from_parts(2_238_000, 990) + // Standard Error: 56_753 + .saturating_add(Weight::from_parts(18_404_902, 0).saturating_mul(i.into())) + .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(i.into()))) .saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(i.into()))) .saturating_add(Weight::from_parts(0, 3566).saturating_mul(i.into())) } @@ -470,10 +472,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `2196 + s * (4 ±0)` // Estimated: `6248 + s * (4 ±0)` - // Minimum execution time: 85_268_000 picoseconds. - Weight::from_parts(93_698_590, 6248) - // Standard Error: 3_793 - .saturating_add(Weight::from_parts(1_323_467, 0).saturating_mul(s.into())) + // Minimum execution time: 86_765_000 picoseconds. + Weight::from_parts(95_173_565, 6248) + // Standard Error: 4_596 + .saturating_add(Weight::from_parts(1_354_849, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(13_u64)) .saturating_add(T::DbWeight::get().writes(12_u64)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(s.into()))) @@ -486,10 +488,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `66672` // Estimated: `70137` - // Minimum execution time: 103_919_000 picoseconds. - Weight::from_parts(1_163_897_466, 70137) - // Standard Error: 76_813 - .saturating_add(Weight::from_parts(6_482_249, 0).saturating_mul(s.into())) + // Minimum execution time: 104_490_000 picoseconds. + Weight::from_parts(1_162_956_951, 70137) + // Standard Error: 76_760 + .saturating_add(Weight::from_parts(6_485_569, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -526,10 +528,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `33297 + n * (377 ±0)` // Estimated: `30944 + n * (3774 ±0)` - // Minimum execution time: 141_186_000 picoseconds. - Weight::from_parts(170_953_387, 30944) - // Standard Error: 32_141 - .saturating_add(Weight::from_parts(45_316_107, 0).saturating_mul(n.into())) + // Minimum execution time: 144_790_000 picoseconds. + Weight::from_parts(36_764_791, 30944) + // Standard Error: 89_592 + .saturating_add(Weight::from_parts(49_620_105, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(14_u64)) .saturating_add(T::DbWeight::get().reads((6_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes(4_u64)) @@ -553,10 +555,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `1991 + l * (7 ±0)` // Estimated: `8877` - // Minimum execution time: 80_676_000 picoseconds. - Weight::from_parts(83_786_705, 8877) - // Standard Error: 4_547 - .saturating_add(Weight::from_parts(79_908, 0).saturating_mul(l.into())) + // Minimum execution time: 81_768_000 picoseconds. + Weight::from_parts(85_332_982, 8877) + // Standard Error: 5_380 + .saturating_add(Weight::from_parts(70_298, 0).saturating_mul(l.into())) .saturating_add(T::DbWeight::get().reads(9_u64)) .saturating_add(T::DbWeight::get().writes(7_u64)) } @@ -591,10 +593,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `2196 + s * (4 ±0)` // Estimated: `6248 + s * (4 ±0)` - // Minimum execution time: 94_239_000 picoseconds. - Weight::from_parts(98_128_278, 6248) - // Standard Error: 3_345 - .saturating_add(Weight::from_parts(1_323_942, 0).saturating_mul(s.into())) + // Minimum execution time: 96_123_000 picoseconds. + Weight::from_parts(100_278_672, 6248) + // Standard Error: 3_487 + .saturating_add(Weight::from_parts(1_326_503, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(12_u64)) .saturating_add(T::DbWeight::get().writes(11_u64)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(s.into()))) @@ -640,12 +642,12 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0 + n * (720 ±0) + v * (3598 ±0)` // Estimated: `512390 + n * (3566 ±0) + v * (3566 ±0)` - // Minimum execution time: 561_749_000 picoseconds. - Weight::from_parts(565_657_000, 512390) - // Standard Error: 2_021_729 - .saturating_add(Weight::from_parts(67_864_146, 0).saturating_mul(v.into())) - // Standard Error: 201_454 - .saturating_add(Weight::from_parts(18_172_710, 0).saturating_mul(n.into())) + // Minimum execution time: 572_893_000 picoseconds. + Weight::from_parts(578_010_000, 512390) + // Standard Error: 2_094_268 + .saturating_add(Weight::from_parts(68_419_710, 0).saturating_mul(v.into())) + // Standard Error: 208_682 + .saturating_add(Weight::from_parts(18_826_175, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(206_u64)) .saturating_add(T::DbWeight::get().reads((5_u64).saturating_mul(v.into()))) .saturating_add(T::DbWeight::get().reads((4_u64).saturating_mul(n.into()))) @@ -676,12 +678,12 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `3175 + n * (911 ±0) + v * (395 ±0)` // Estimated: `512390 + n * (3566 ±0) + v * (3566 ±0)` - // Minimum execution time: 32_858_623_000 picoseconds. - Weight::from_parts(32_996_593_000, 512390) - // Standard Error: 356_817 - .saturating_add(Weight::from_parts(5_152_745, 0).saturating_mul(v.into())) - // Standard Error: 356_817 - .saturating_add(Weight::from_parts(3_183_518, 0).saturating_mul(n.into())) + // Minimum execution time: 33_836_205_000 picoseconds. + Weight::from_parts(34_210_443_000, 512390) + // Standard Error: 441_692 + .saturating_add(Weight::from_parts(6_122_533, 0).saturating_mul(v.into())) + // Standard Error: 441_692 + .saturating_add(Weight::from_parts(4_418_264, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(201_u64)) .saturating_add(T::DbWeight::get().reads((5_u64).saturating_mul(v.into()))) .saturating_add(T::DbWeight::get().reads((4_u64).saturating_mul(n.into()))) @@ -698,10 +700,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `979 + v * (50 ±0)` // Estimated: `3510 + v * (2520 ±0)` - // Minimum execution time: 2_433_720_000 picoseconds. - Weight::from_parts(108_144_707, 3510) - // Standard Error: 6_825 - .saturating_add(Weight::from_parts(4_664_777, 0).saturating_mul(v.into())) + // Minimum execution time: 2_454_689_000 picoseconds. + Weight::from_parts(161_771_064, 3510) + // Standard Error: 31_022 + .saturating_add(Weight::from_parts(4_820_158, 0).saturating_mul(v.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(v.into()))) .saturating_add(Weight::from_parts(0, 2520).saturating_mul(v.into())) @@ -722,8 +724,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 5_259_000 picoseconds. - Weight::from_parts(5_726_000, 0) + // Minimum execution time: 5_073_000 picoseconds. + Weight::from_parts(5_452_000, 0) .saturating_add(T::DbWeight::get().writes(6_u64)) } /// Storage: `Staking::MinCommission` (r:0 w:1) @@ -742,8 +744,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 4_772_000 picoseconds. - Weight::from_parts(4_960_000, 0) + // Minimum execution time: 4_465_000 picoseconds. + Weight::from_parts(4_832_000, 0) .saturating_add(T::DbWeight::get().writes(6_u64)) } /// Storage: `Staking::Bonded` (r:1 w:0) @@ -772,8 +774,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `1939` // Estimated: `6248` - // Minimum execution time: 69_269_000 picoseconds. - Weight::from_parts(71_478_000, 6248) + // Minimum execution time: 71_239_000 picoseconds. + Weight::from_parts(74_649_000, 6248) .saturating_add(T::DbWeight::get().reads(12_u64)) .saturating_add(T::DbWeight::get().writes(6_u64)) } @@ -785,8 +787,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `691` // Estimated: `3510` - // Minimum execution time: 12_436_000 picoseconds. - Weight::from_parts(12_749_000, 3510) + // Minimum execution time: 12_525_000 picoseconds. + Weight::from_parts(13_126_000, 3510) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -796,8 +798,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_073_000 picoseconds. - Weight::from_parts(3_240_000, 0) + // Minimum execution time: 2_918_000 picoseconds. + Weight::from_parts(3_176_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } } @@ -818,8 +820,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `927` // Estimated: `4764` - // Minimum execution time: 42_189_000 picoseconds. - Weight::from_parts(43_771_000, 4764) + // Minimum execution time: 42_491_000 picoseconds. + Weight::from_parts(44_026_000, 4764) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -839,8 +841,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1990` // Estimated: `8877` - // Minimum execution time: 86_677_000 picoseconds. - Weight::from_parts(89_437_000, 8877) + // Minimum execution time: 88_756_000 picoseconds. + Weight::from_parts(91_000_000, 8877) .saturating_add(RocksDbWeight::get().reads(9_u64)) .saturating_add(RocksDbWeight::get().writes(7_u64)) } @@ -866,8 +868,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `2195` // Estimated: `8877` - // Minimum execution time: 90_824_000 picoseconds. - Weight::from_parts(92_907_000, 8877) + // Minimum execution time: 91_331_000 picoseconds. + Weight::from_parts(94_781_000, 8877) .saturating_add(RocksDbWeight::get().reads(12_u64)) .saturating_add(RocksDbWeight::get().writes(7_u64)) } @@ -886,10 +888,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1115` // Estimated: `4764` - // Minimum execution time: 42_837_000 picoseconds. - Weight::from_parts(44_269_425, 4764) - // Standard Error: 817 - .saturating_add(Weight::from_parts(43_253, 0).saturating_mul(s.into())) + // Minimum execution time: 42_495_000 picoseconds. + Weight::from_parts(44_189_470, 4764) + // Standard Error: 1_389 + .saturating_add(Weight::from_parts(47_484, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -926,10 +928,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `2196 + s * (4 ±0)` // Estimated: `6248 + s * (4 ±0)` - // Minimum execution time: 87_194_000 picoseconds. - Weight::from_parts(95_999_434, 6248) - // Standard Error: 3_674 - .saturating_add(Weight::from_parts(1_320_100, 0).saturating_mul(s.into())) + // Minimum execution time: 89_004_000 picoseconds. + Weight::from_parts(96_677_570, 6248) + // Standard Error: 4_635 + .saturating_add(Weight::from_parts(1_387_718, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(13_u64)) .saturating_add(RocksDbWeight::get().writes(11_u64)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(s.into()))) @@ -961,8 +963,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1372` // Estimated: `4556` - // Minimum execution time: 51_574_000 picoseconds. - Weight::from_parts(54_444_000, 4556) + // Minimum execution time: 51_532_000 picoseconds. + Weight::from_parts(53_308_000, 4556) .saturating_add(RocksDbWeight::get().reads(11_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) } @@ -975,10 +977,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1280 + k * (569 ±0)` // Estimated: `4556 + k * (3033 ±0)` - // Minimum execution time: 28_579_000 picoseconds. - Weight::from_parts(31_179_862, 4556) - // Standard Error: 7_307 - .saturating_add(Weight::from_parts(6_198_340, 0).saturating_mul(k.into())) + // Minimum execution time: 28_955_000 picoseconds. + Weight::from_parts(29_609_869, 4556) + // Standard Error: 6_793 + .saturating_add(Weight::from_parts(6_412_124, 0).saturating_mul(k.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(k.into()))) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(k.into()))) @@ -1011,10 +1013,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1866 + n * (102 ±0)` // Estimated: `6248 + n * (2520 ±0)` - // Minimum execution time: 62_856_000 picoseconds. - Weight::from_parts(60_783_406, 6248) - // Standard Error: 13_888 - .saturating_add(Weight::from_parts(3_953_896, 0).saturating_mul(n.into())) + // Minimum execution time: 64_080_000 picoseconds. + Weight::from_parts(61_985_382, 6248) + // Standard Error: 13_320 + .saturating_add(Weight::from_parts(4_030_513, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(12_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(n.into()))) .saturating_add(RocksDbWeight::get().writes(6_u64)) @@ -1038,8 +1040,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1650` // Estimated: `6248` - // Minimum execution time: 53_408_000 picoseconds. - Weight::from_parts(54_715_000, 6248) + // Minimum execution time: 54_194_000 picoseconds. + Weight::from_parts(55_578_000, 6248) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(6_u64)) } @@ -1053,8 +1055,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `902` // Estimated: `4556` - // Minimum execution time: 16_708_000 picoseconds. - Weight::from_parts(17_177_000, 4556) + // Minimum execution time: 16_597_000 picoseconds. + Weight::from_parts(16_980_000, 4556) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1068,8 +1070,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `969` // Estimated: `4556` - // Minimum execution time: 20_516_000 picoseconds. - Weight::from_parts(21_240_000, 4556) + // Minimum execution time: 20_626_000 picoseconds. + Weight::from_parts(21_242_000, 4556) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1081,8 +1083,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `902` // Estimated: `4556` - // Minimum execution time: 19_514_000 picoseconds. - Weight::from_parts(20_519_000, 4556) + // Minimum execution time: 19_972_000 picoseconds. + Weight::from_parts(20_470_000, 4556) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -1092,8 +1094,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_477_000 picoseconds. - Weight::from_parts(2_792_000, 0) + // Minimum execution time: 2_571_000 picoseconds. + Weight::from_parts(2_720_000, 0) .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: `Staking::ForceEra` (r:0 w:1) @@ -1102,8 +1104,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_917_000 picoseconds. - Weight::from_parts(8_342_000, 0) + // Minimum execution time: 8_056_000 picoseconds. + Weight::from_parts(8_413_000, 0) .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: `Staking::ForceEra` (r:0 w:1) @@ -1112,8 +1114,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 8_212_000 picoseconds. - Weight::from_parts(8_506_000, 0) + // Minimum execution time: 8_162_000 picoseconds. + Weight::from_parts(8_497_000, 0) .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: `Staking::ForceEra` (r:0 w:1) @@ -1122,8 +1124,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 8_052_000 picoseconds. - Weight::from_parts(8_405_000, 0) + // Minimum execution time: 8_320_000 picoseconds. + Weight::from_parts(8_564_000, 0) .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: `Staking::Invulnerables` (r:0 w:1) @@ -1133,26 +1135,28 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_676_000 picoseconds. - Weight::from_parts(3_288_767, 0) - // Standard Error: 69 - .saturating_add(Weight::from_parts(11_426, 0).saturating_mul(v.into())) + // Minimum execution time: 2_470_000 picoseconds. + Weight::from_parts(3_110_242, 0) + // Standard Error: 63 + .saturating_add(Weight::from_parts(11_786, 0).saturating_mul(v.into())) .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: `Staking::Ledger` (r:5900 w:11800) /// Proof: `Staking::Ledger` (`max_values`: None, `max_size`: Some(1091), added: 3566, mode: `MaxEncodedLen`) + /// Storage: `Staking::Payee` (r:5900 w:0) + /// Proof: `Staking::Payee` (`max_values`: None, `max_size`: Some(73), added: 2548, mode: `MaxEncodedLen`) /// Storage: `Staking::Bonded` (r:0 w:5900) /// Proof: `Staking::Bonded` (`max_values`: None, `max_size`: Some(72), added: 2547, mode: `MaxEncodedLen`) /// The range of component `i` is `[0, 5900]`. fn deprecate_controller_batch(i: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1015 + i * (105 ±0)` + // Measured: `1356 + i * (151 ±0)` // Estimated: `990 + i * (3566 ±0)` - // Minimum execution time: 2_104_000 picoseconds. - Weight::from_parts(2_155_000, 990) - // Standard Error: 22_751 - .saturating_add(Weight::from_parts(11_460_237, 0).saturating_mul(i.into())) - .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(i.into()))) + // Minimum execution time: 2_101_000 picoseconds. + Weight::from_parts(2_238_000, 990) + // Standard Error: 56_753 + .saturating_add(Weight::from_parts(18_404_902, 0).saturating_mul(i.into())) + .saturating_add(RocksDbWeight::get().reads((2_u64).saturating_mul(i.into()))) .saturating_add(RocksDbWeight::get().writes((3_u64).saturating_mul(i.into()))) .saturating_add(Weight::from_parts(0, 3566).saturating_mul(i.into())) } @@ -1189,10 +1193,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `2196 + s * (4 ±0)` // Estimated: `6248 + s * (4 ±0)` - // Minimum execution time: 85_268_000 picoseconds. - Weight::from_parts(93_698_590, 6248) - // Standard Error: 3_793 - .saturating_add(Weight::from_parts(1_323_467, 0).saturating_mul(s.into())) + // Minimum execution time: 86_765_000 picoseconds. + Weight::from_parts(95_173_565, 6248) + // Standard Error: 4_596 + .saturating_add(Weight::from_parts(1_354_849, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(13_u64)) .saturating_add(RocksDbWeight::get().writes(12_u64)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(s.into()))) @@ -1205,10 +1209,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `66672` // Estimated: `70137` - // Minimum execution time: 103_919_000 picoseconds. - Weight::from_parts(1_163_897_466, 70137) - // Standard Error: 76_813 - .saturating_add(Weight::from_parts(6_482_249, 0).saturating_mul(s.into())) + // Minimum execution time: 104_490_000 picoseconds. + Weight::from_parts(1_162_956_951, 70137) + // Standard Error: 76_760 + .saturating_add(Weight::from_parts(6_485_569, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1245,10 +1249,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `33297 + n * (377 ±0)` // Estimated: `30944 + n * (3774 ±0)` - // Minimum execution time: 141_186_000 picoseconds. - Weight::from_parts(170_953_387, 30944) - // Standard Error: 32_141 - .saturating_add(Weight::from_parts(45_316_107, 0).saturating_mul(n.into())) + // Minimum execution time: 144_790_000 picoseconds. + Weight::from_parts(36_764_791, 30944) + // Standard Error: 89_592 + .saturating_add(Weight::from_parts(49_620_105, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(14_u64)) .saturating_add(RocksDbWeight::get().reads((6_u64).saturating_mul(n.into()))) .saturating_add(RocksDbWeight::get().writes(4_u64)) @@ -1272,10 +1276,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1991 + l * (7 ±0)` // Estimated: `8877` - // Minimum execution time: 80_676_000 picoseconds. - Weight::from_parts(83_786_705, 8877) - // Standard Error: 4_547 - .saturating_add(Weight::from_parts(79_908, 0).saturating_mul(l.into())) + // Minimum execution time: 81_768_000 picoseconds. + Weight::from_parts(85_332_982, 8877) + // Standard Error: 5_380 + .saturating_add(Weight::from_parts(70_298, 0).saturating_mul(l.into())) .saturating_add(RocksDbWeight::get().reads(9_u64)) .saturating_add(RocksDbWeight::get().writes(7_u64)) } @@ -1310,10 +1314,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `2196 + s * (4 ±0)` // Estimated: `6248 + s * (4 ±0)` - // Minimum execution time: 94_239_000 picoseconds. - Weight::from_parts(98_128_278, 6248) - // Standard Error: 3_345 - .saturating_add(Weight::from_parts(1_323_942, 0).saturating_mul(s.into())) + // Minimum execution time: 96_123_000 picoseconds. + Weight::from_parts(100_278_672, 6248) + // Standard Error: 3_487 + .saturating_add(Weight::from_parts(1_326_503, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(12_u64)) .saturating_add(RocksDbWeight::get().writes(11_u64)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(s.into()))) @@ -1359,12 +1363,12 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0 + n * (720 ±0) + v * (3598 ±0)` // Estimated: `512390 + n * (3566 ±0) + v * (3566 ±0)` - // Minimum execution time: 561_749_000 picoseconds. - Weight::from_parts(565_657_000, 512390) - // Standard Error: 2_021_729 - .saturating_add(Weight::from_parts(67_864_146, 0).saturating_mul(v.into())) - // Standard Error: 201_454 - .saturating_add(Weight::from_parts(18_172_710, 0).saturating_mul(n.into())) + // Minimum execution time: 572_893_000 picoseconds. + Weight::from_parts(578_010_000, 512390) + // Standard Error: 2_094_268 + .saturating_add(Weight::from_parts(68_419_710, 0).saturating_mul(v.into())) + // Standard Error: 208_682 + .saturating_add(Weight::from_parts(18_826_175, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(206_u64)) .saturating_add(RocksDbWeight::get().reads((5_u64).saturating_mul(v.into()))) .saturating_add(RocksDbWeight::get().reads((4_u64).saturating_mul(n.into()))) @@ -1395,12 +1399,12 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `3175 + n * (911 ±0) + v * (395 ±0)` // Estimated: `512390 + n * (3566 ±0) + v * (3566 ±0)` - // Minimum execution time: 32_858_623_000 picoseconds. - Weight::from_parts(32_996_593_000, 512390) - // Standard Error: 356_817 - .saturating_add(Weight::from_parts(5_152_745, 0).saturating_mul(v.into())) - // Standard Error: 356_817 - .saturating_add(Weight::from_parts(3_183_518, 0).saturating_mul(n.into())) + // Minimum execution time: 33_836_205_000 picoseconds. + Weight::from_parts(34_210_443_000, 512390) + // Standard Error: 441_692 + .saturating_add(Weight::from_parts(6_122_533, 0).saturating_mul(v.into())) + // Standard Error: 441_692 + .saturating_add(Weight::from_parts(4_418_264, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(201_u64)) .saturating_add(RocksDbWeight::get().reads((5_u64).saturating_mul(v.into()))) .saturating_add(RocksDbWeight::get().reads((4_u64).saturating_mul(n.into()))) @@ -1417,10 +1421,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `979 + v * (50 ±0)` // Estimated: `3510 + v * (2520 ±0)` - // Minimum execution time: 2_433_720_000 picoseconds. - Weight::from_parts(108_144_707, 3510) - // Standard Error: 6_825 - .saturating_add(Weight::from_parts(4_664_777, 0).saturating_mul(v.into())) + // Minimum execution time: 2_454_689_000 picoseconds. + Weight::from_parts(161_771_064, 3510) + // Standard Error: 31_022 + .saturating_add(Weight::from_parts(4_820_158, 0).saturating_mul(v.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(v.into()))) .saturating_add(Weight::from_parts(0, 2520).saturating_mul(v.into())) @@ -1441,8 +1445,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 5_259_000 picoseconds. - Weight::from_parts(5_726_000, 0) + // Minimum execution time: 5_073_000 picoseconds. + Weight::from_parts(5_452_000, 0) .saturating_add(RocksDbWeight::get().writes(6_u64)) } /// Storage: `Staking::MinCommission` (r:0 w:1) @@ -1461,8 +1465,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 4_772_000 picoseconds. - Weight::from_parts(4_960_000, 0) + // Minimum execution time: 4_465_000 picoseconds. + Weight::from_parts(4_832_000, 0) .saturating_add(RocksDbWeight::get().writes(6_u64)) } /// Storage: `Staking::Bonded` (r:1 w:0) @@ -1491,8 +1495,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1939` // Estimated: `6248` - // Minimum execution time: 69_269_000 picoseconds. - Weight::from_parts(71_478_000, 6248) + // Minimum execution time: 71_239_000 picoseconds. + Weight::from_parts(74_649_000, 6248) .saturating_add(RocksDbWeight::get().reads(12_u64)) .saturating_add(RocksDbWeight::get().writes(6_u64)) } @@ -1504,8 +1508,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `691` // Estimated: `3510` - // Minimum execution time: 12_436_000 picoseconds. - Weight::from_parts(12_749_000, 3510) + // Minimum execution time: 12_525_000 picoseconds. + Weight::from_parts(13_126_000, 3510) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1515,8 +1519,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_073_000 picoseconds. - Weight::from_parts(3_240_000, 0) + // Minimum execution time: 2_918_000 picoseconds. + Weight::from_parts(3_176_000, 0) .saturating_add(RocksDbWeight::get().writes(1_u64)) } } From bbcefc320547a706ad647bac1434e935729810d9 Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Tue, 12 Dec 2023 11:14:48 +0700 Subject: [PATCH 73/74] Update substrate/frame/staking/src/pallet/mod.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Gonçalo Pestana --- substrate/frame/staking/src/pallet/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/substrate/frame/staking/src/pallet/mod.rs b/substrate/frame/staking/src/pallet/mod.rs index 189182a4062b..df7c44597f41 100644 --- a/substrate/frame/staking/src/pallet/mod.rs +++ b/substrate/frame/staking/src/pallet/mod.rs @@ -1929,7 +1929,7 @@ pub mod pallet { /// /// Effects will be felt instantly (as soon as this function is completed successfully). /// - /// The dispatch origin must be AdminOrigin. + /// The dispatch origin must be [`T::AdminOrigin`]. #[pallet::call_index(28)] #[pallet::weight(T::WeightInfo::deprecate_controller_batch(controllers.len() as u32))] pub fn deprecate_controller_batch( From 9aa3af17bdf2827fd34a6c0a21b59c68fab86abe Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Tue, 12 Dec 2023 12:21:32 +0700 Subject: [PATCH 74/74] fix rustdoc --- substrate/frame/staking/src/pallet/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/substrate/frame/staking/src/pallet/mod.rs b/substrate/frame/staking/src/pallet/mod.rs index df7c44597f41..b914545a76b9 100644 --- a/substrate/frame/staking/src/pallet/mod.rs +++ b/substrate/frame/staking/src/pallet/mod.rs @@ -1929,7 +1929,7 @@ pub mod pallet { /// /// Effects will be felt instantly (as soon as this function is completed successfully). /// - /// The dispatch origin must be [`T::AdminOrigin`]. + /// The dispatch origin must be `T::AdminOrigin`. #[pallet::call_index(28)] #[pallet::weight(T::WeightInfo::deprecate_controller_batch(controllers.len() as u32))] pub fn deprecate_controller_batch(