From abccfae5f24b4ced2b3802fa2665c3e79cdb62a9 Mon Sep 17 00:00:00 2001 From: joe petrowski <25483142+joepetrowski@users.noreply.github.com> Date: Mon, 29 May 2023 15:03:48 +0200 Subject: [PATCH] Add Ability to Add/Remove Invulnerable Collators (#2596) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add add and remove invulnerable dispatchables * add migration * fix benchmarking code * add weights * add migration to runtimes * clippy * pass SafeCallFilter * make try-runtime work * typos Co-authored-by: Ankan <10196091+Ank4n@users.noreply.github.com> * better insert and added test * fix try-runtime update * Apply suggestions from code review Co-authored-by: Bastian Köcher * Update pallets/collator-selection/src/migration.rs * check events in test * Update pallets/collator-selection/src/migration.rs Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * just dispatchresult * only sp_std for try-runtime --------- Co-authored-by: Ankan <10196091+Ank4n@users.noreply.github.com> Co-authored-by: Bastian Köcher Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> --- pallets/collator-selection/Cargo.toml | 4 +- .../collator-selection/src/benchmarking.rs | 48 +++++- pallets/collator-selection/src/lib.rs | 100 +++++++++++-- pallets/collator-selection/src/migration.rs | 91 ++++++++++++ pallets/collator-selection/src/mock.rs | 4 +- pallets/collator-selection/src/tests.rs | 137 +++++++++++++++++- pallets/collator-selection/src/weights.rs | 68 +++++++++ .../runtimes/assets/statemine/src/lib.rs | 2 +- .../src/weights/pallet_collator_selection.rs | 33 +++++ .../assets/statemine/src/xcm_config.rs | 4 +- .../runtimes/assets/statemint/src/lib.rs | 2 +- .../src/weights/pallet_collator_selection.rs | 33 +++++ .../assets/statemint/src/xcm_config.rs | 4 +- .../runtimes/assets/westmint/src/lib.rs | 7 +- .../src/weights/pallet_collator_selection.rs | 33 +++++ .../assets/westmint/src/xcm_config.rs | 4 +- .../bridge-hubs/bridge-hub-kusama/src/lib.rs | 4 + .../src/weights/pallet_collator_selection.rs | 33 +++++ .../bridge-hub-kusama/src/xcm_config.rs | 4 +- .../bridge-hub-polkadot/src/lib.rs | 4 + .../src/weights/pallet_collator_selection.rs | 33 +++++ .../bridge-hub-polkadot/src/xcm_config.rs | 4 +- .../bridge-hubs/bridge-hub-rococo/src/lib.rs | 4 + .../src/weights/pallet_collator_selection.rs | 33 +++++ .../bridge-hub-rococo/src/xcm_config.rs | 4 +- .../collectives-polkadot/src/lib.rs | 7 +- .../src/weights/pallet_collator_selection.rs | 33 +++++ .../collectives-polkadot/src/xcm_config.rs | 4 +- .../contracts/contracts-rococo/src/lib.rs | 5 +- parachains/runtimes/testing/penpal/src/lib.rs | 6 +- 30 files changed, 712 insertions(+), 40 deletions(-) create mode 100644 pallets/collator-selection/src/migration.rs diff --git a/pallets/collator-selection/Cargo.toml b/pallets/collator-selection/Cargo.toml index 9ff4d2eb5e6..f3bec9567cd 100644 --- a/pallets/collator-selection/Cargo.toml +++ b/pallets/collator-selection/Cargo.toml @@ -1,6 +1,6 @@ [package] -authors = ["Anonymous"] -description = "Simple staking pallet with a fixed stake." +authors = ["Parity Technologies "] +description = "Simple pallet to select collators for a parachain." edition = "2021" homepage = "https://substrate.io" license = "Apache-2.0" diff --git a/pallets/collator-selection/src/benchmarking.rs b/pallets/collator-selection/src/benchmarking.rs index 6b386f7d697..63c9561e7dd 100644 --- a/pallets/collator-selection/src/benchmarking.rs +++ b/pallets/collator-selection/src/benchmarking.rs @@ -110,17 +110,61 @@ benchmarks! { where_clause { where T: pallet_authorship::Config + session::Config } set_invulnerables { + let origin = + T::UpdateOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; let b in 1 .. T::MaxInvulnerables::get(); let new_invulnerables = register_validators::(b); + let mut sorted_new_invulnerables = new_invulnerables.clone(); + sorted_new_invulnerables.sort(); + }: { + assert_ok!( + // call the function with the unsorted list + >::set_invulnerables(origin, new_invulnerables.clone()) + ); + } + verify { + // assert that it comes out sorted + assert_last_event::(Event::NewInvulnerables{invulnerables: sorted_new_invulnerables}.into()); + } + + add_invulnerable { let origin = T::UpdateOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; + // we're going to add one, so need one less than max set as invulnerables to start + let b in 1 .. T::MaxInvulnerables::get() - 1; + let mut invulnerables = register_validators::(b); + invulnerables.sort(); + let invulnerables: frame_support::BoundedVec<_, T::MaxInvulnerables> = frame_support::BoundedVec::try_from(invulnerables).unwrap(); + >::put(invulnerables); + + // now let's set up a new one to add + let (new, keys) = validator::(b + 1); + >::set_keys(RawOrigin::Signed(new.clone()).into(), keys, Vec::new()).unwrap(); }: { assert_ok!( - >::set_invulnerables(origin, new_invulnerables.clone()) + >::add_invulnerable(origin, new.clone()) + ); + } + verify { + assert_last_event::(Event::InvulnerableAdded{account_id: new}.into()); + } + + remove_invulnerable { + let origin = + T::UpdateOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; + let b in 1 .. T::MaxInvulnerables::get(); + let mut invulnerables = register_validators::(b); + invulnerables.sort(); + let invulnerables: frame_support::BoundedVec<_, T::MaxInvulnerables> = frame_support::BoundedVec::try_from(invulnerables).unwrap(); + >::put(invulnerables); + let to_remove = >::get().first().unwrap().clone(); + }: { + assert_ok!( + >::remove_invulnerable(origin, to_remove.clone()) ); } verify { - assert_last_event::(Event::NewInvulnerables{invulnerables: new_invulnerables}.into()); + assert_last_event::(Event::InvulnerableRemoved{account_id: to_remove}.into()); } set_desired_candidates { diff --git a/pallets/collator-selection/src/lib.rs b/pallets/collator-selection/src/lib.rs index 5983ac5cc3a..daccc4ce93c 100644 --- a/pallets/collator-selection/src/lib.rs +++ b/pallets/collator-selection/src/lib.rs @@ -70,8 +70,11 @@ mod tests; #[cfg(feature = "runtime-benchmarks")] mod benchmarking; +pub mod migration; pub mod weights; +const LOG_TARGET: &str = "runtime::collator-selection"; + #[frame_support::pallet] pub mod pallet { pub use crate::weights::WeightInfo; @@ -95,6 +98,9 @@ pub mod pallet { use sp_runtime::traits::Convert; use sp_staking::SessionIndex; + /// The current storage version. + const STORAGE_VERSION: StorageVersion = StorageVersion::new(1); + type BalanceOf = <::Currency as Currency<::AccountId>>::Balance; @@ -165,9 +171,10 @@ pub mod pallet { } #[pallet::pallet] + #[pallet::storage_version(STORAGE_VERSION)] pub struct Pallet(_); - /// The invulnerable, fixed collators. + /// The invulnerable, permissioned collators. This list must be sorted. #[pallet::storage] #[pallet::getter(fn invulnerables)] pub type Invulnerables = @@ -222,7 +229,7 @@ pub mod pallet { "duplicate invulnerables in genesis." ); - let bounded_invulnerables = + let mut bounded_invulnerables = BoundedVec::<_, T::MaxInvulnerables>::try_from(self.invulnerables.clone()) .expect("genesis invulnerables are more than T::MaxInvulnerables"); assert!( @@ -230,6 +237,8 @@ pub mod pallet { "genesis desired_candidates are more than T::MaxCandidates", ); + bounded_invulnerables.sort(); + >::put(self.desired_candidates); >::put(self.candidacy_bond); >::put(bounded_invulnerables); @@ -239,35 +248,41 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] pub enum Event { + /// New Invulnerables were set. NewInvulnerables { invulnerables: Vec }, + /// A new Invulnerable was added. + InvulnerableAdded { account_id: T::AccountId }, + /// An Invulnerable was removed. + InvulnerableRemoved { account_id: T::AccountId }, + /// The number of desired candidates was set. NewDesiredCandidates { desired_candidates: u32 }, + /// The candidacy bond was set. NewCandidacyBond { bond_amount: BalanceOf }, + /// A new candidate joined. CandidateAdded { account_id: T::AccountId, deposit: BalanceOf }, + /// A candidate was removed. CandidateRemoved { account_id: T::AccountId }, } - // Errors inform users that something went wrong. #[pallet::error] pub enum Error { - /// Too many candidates + /// The pallet has too many candidates. TooManyCandidates, - /// Too few candidates + /// Leaving would result in too few candidates. TooFewCandidates, - /// Unknown error - Unknown, - /// Permission issue - Permission, - /// User is already a candidate + /// Account is already a candidate. AlreadyCandidate, - /// User is not a candidate + /// Account is not a candidate. NotCandidate, - /// Too many invulnerables + /// There are too many Invulnerables. TooManyInvulnerables, - /// User is already an Invulnerable + /// Account is already an Invulnerable. AlreadyInvulnerable, - /// Account has no associated validator ID + /// Account is not an Invulnerable. + NotInvulnerable, + /// Account has no associated validator ID. NoAssociatedValidatorId, - /// Validator ID is not yet registered + /// Validator ID is not yet registered. ValidatorNotRegistered, } @@ -284,7 +299,7 @@ pub mod pallet { new: Vec, ) -> DispatchResultWithPostInfo { T::UpdateOrigin::ensure_origin(origin)?; - let bounded_invulnerables = BoundedVec::<_, T::MaxInvulnerables>::try_from(new) + let mut bounded_invulnerables = BoundedVec::<_, T::MaxInvulnerables>::try_from(new) .map_err(|_| Error::::TooManyInvulnerables)?; // check if the invulnerables have associated validator keys before they are set @@ -297,6 +312,9 @@ pub mod pallet { ); } + // Invulnerables must be sorted for removal. + bounded_invulnerables.sort(); + >::put(&bounded_invulnerables); Self::deposit_event(Event::NewInvulnerables { invulnerables: bounded_invulnerables.to_vec(), @@ -398,6 +416,56 @@ pub mod pallet { Ok(Some(T::WeightInfo::leave_intent(current_count as u32)).into()) } + + /// Add a new account `who` to the list of `Invulnerables` collators. + /// + /// The origin for this call must be the `UpdateOrigin`. + #[pallet::call_index(5)] + #[pallet::weight(T::WeightInfo::add_invulnerable(T::MaxInvulnerables::get() - 1))] + pub fn add_invulnerable(origin: OriginFor, who: T::AccountId) -> DispatchResult { + T::UpdateOrigin::ensure_origin(origin)?; + + // ensure `who` has registered a validator key + let validator_key = T::ValidatorIdOf::convert(who.clone()) + .ok_or(Error::::NoAssociatedValidatorId)?; + ensure!( + T::ValidatorRegistration::is_registered(&validator_key), + Error::::ValidatorNotRegistered + ); + + >::try_mutate(|invulnerables| -> DispatchResult { + match invulnerables.binary_search(&who) { + Ok(_) => return Err(Error::::AlreadyInvulnerable)?, + Err(pos) => invulnerables + .try_insert(pos, who.clone()) + .map_err(|_| Error::::TooManyInvulnerables)?, + } + Ok(()) + })?; + + Self::deposit_event(Event::InvulnerableAdded { account_id: who }); + Ok(()) + } + + /// Remove an account `who` from the list of `Invulnerables` collators. `Invulnerables` must + /// be sorted. + /// + /// The origin for this call must be the `UpdateOrigin`. + #[pallet::call_index(6)] + #[pallet::weight(T::WeightInfo::remove_invulnerable(T::MaxInvulnerables::get()))] + pub fn remove_invulnerable(origin: OriginFor, who: T::AccountId) -> DispatchResult { + T::UpdateOrigin::ensure_origin(origin)?; + + >::try_mutate(|invulnerables| -> DispatchResult { + let pos = + invulnerables.binary_search(&who).map_err(|_| Error::::NotInvulnerable)?; + invulnerables.remove(pos); + Ok(()) + })?; + + Self::deposit_event(Event::InvulnerableRemoved { account_id: who }); + Ok(()) + } } impl Pallet { diff --git a/pallets/collator-selection/src/migration.rs b/pallets/collator-selection/src/migration.rs new file mode 100644 index 00000000000..e26d9f08b5b --- /dev/null +++ b/pallets/collator-selection/src/migration.rs @@ -0,0 +1,91 @@ +// Copyright Parity Technologies (UK) Ltd. +// This file is part of Polkadot. + +// Polkadot is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Polkadot is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Polkadot. If not, see . + +//! A module that is responsible for migration of storage for Collator Selection. + +use super::*; +use frame_support::{log, traits::OnRuntimeUpgrade}; + +/// Version 1 Migration +/// This migration ensures that any existing `Invulnerables` storage lists are sorted. +pub mod v1 { + use super::*; + use frame_support::pallet_prelude::*; + #[cfg(feature = "try-runtime")] + use sp_std::prelude::*; + + pub struct MigrateToV1(sp_std::marker::PhantomData); + impl OnRuntimeUpgrade for MigrateToV1 { + fn on_runtime_upgrade() -> Weight { + let onchain_version = Pallet::::on_chain_storage_version(); + if onchain_version == 0 { + let invulnerables_len = Invulnerables::::get().to_vec().len(); + >::mutate(|invulnerables| { + invulnerables.sort(); + }); + + StorageVersion::new(1).put::>(); + log::info!( + target: LOG_TARGET, + "Sorted {} Invulnerables, upgraded storage to version 1", + invulnerables_len, + ); + // Similar complexity to `set_invulnerables` (put storage value) + // Plus 1 read for length, 1 read for `onchain_version`, 1 write to put version + T::WeightInfo::set_invulnerables(invulnerables_len as u32) + .saturating_add(T::DbWeight::get().reads_writes(2, 1)) + } else { + log::info!( + target: LOG_TARGET, + "Migration did not execute. This probably should be removed" + ); + T::DbWeight::get().reads(1) + } + } + + #[cfg(feature = "try-runtime")] + fn pre_upgrade() -> Result, sp_runtime::DispatchError> { + let number_of_invulnerables = Invulnerables::::get().to_vec().len(); + Ok((number_of_invulnerables as u32).encode()) + } + + #[cfg(feature = "try-runtime")] + fn post_upgrade(number_of_invulnerables: Vec) -> Result<(), sp_runtime::DispatchError> { + let stored_invulnerables = Invulnerables::::get().to_vec(); + let mut sorted_invulnerables = stored_invulnerables.clone(); + sorted_invulnerables.sort(); + assert_eq!( + stored_invulnerables, sorted_invulnerables, + "after migration, the stored invulnerables should be sorted" + ); + + let number_of_invulnerables: u32 = Decode::decode( + &mut number_of_invulnerables.as_slice(), + ) + .expect("the state parameter should be something that was generated by pre_upgrade"); + let stored_invulnerables_len = stored_invulnerables.len() as u32; + assert_eq!( + number_of_invulnerables, stored_invulnerables_len, + "after migration, there should be the same number of invulnerables" + ); + + let onchain_version = Pallet::::on_chain_storage_version(); + frame_support::ensure!(onchain_version >= 1, "must_upgrade"); + + Ok(()) + } + } +} diff --git a/pallets/collator-selection/src/mock.rs b/pallets/collator-selection/src/mock.rs index ef2bdc81746..d7b9c2bf74d 100644 --- a/pallets/collator-selection/src/mock.rs +++ b/pallets/collator-selection/src/mock.rs @@ -195,7 +195,7 @@ parameter_types! { pub struct IsRegistered; impl ValidatorRegistration for IsRegistered { fn is_registered(id: &u64) -> bool { - *id != 7u64 + *id != 42u64 } } @@ -217,7 +217,7 @@ impl Config for Test { pub fn new_test_ext() -> sp_io::TestExternalities { sp_tracing::try_init_simple(); let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); - let invulnerables = vec![1, 2]; + let invulnerables = vec![2, 1]; // unsorted let balances = vec![(1, 100), (2, 100), (3, 100), (4, 100), (5, 100)]; let keys = balances diff --git a/pallets/collator-selection/src/tests.rs b/pallets/collator-selection/src/tests.rs index 0ae3e3d5a18..9014b6eff65 100644 --- a/pallets/collator-selection/src/tests.rs +++ b/pallets/collator-selection/src/tests.rs @@ -20,7 +20,7 @@ use frame_support::{ traits::{Currency, GenesisBuild, OnInitialize}, }; use pallet_balances::Error as BalancesError; -use sp_runtime::traits::BadOrigin; +use sp_runtime::{testing::UintAuthorityId, traits::BadOrigin}; #[test] fn basic_setup_works() { @@ -29,6 +29,7 @@ fn basic_setup_works() { assert_eq!(CollatorSelection::candidacy_bond(), 10); assert!(CollatorSelection::candidates().is_empty()); + // genesis should sort input assert_eq!(CollatorSelection::invulnerables(), vec![1, 2]); }); } @@ -36,11 +37,12 @@ fn basic_setup_works() { #[test] fn it_should_set_invulnerables() { new_test_ext().execute_with(|| { - let new_set = vec![1, 2, 3, 4]; + let mut new_set = vec![1, 4, 3, 2]; assert_ok!(CollatorSelection::set_invulnerables( RuntimeOrigin::signed(RootAccount::get()), new_set.clone() )); + new_set.sort(); assert_eq!(CollatorSelection::invulnerables(), new_set); // cannot set with non-root. @@ -50,7 +52,7 @@ fn it_should_set_invulnerables() { ); // cannot set invulnerables without associated validator keys - let invulnerables = vec![7]; + let invulnerables = vec![42]; assert_noop!( CollatorSelection::set_invulnerables( RuntimeOrigin::signed(RootAccount::get()), @@ -61,6 +63,133 @@ fn it_should_set_invulnerables() { }); } +#[test] +fn add_invulnerable_works() { + new_test_ext().execute_with(|| { + initialize_to_block(1); + assert_eq!(CollatorSelection::invulnerables(), vec![1, 2]); + let new = 3; + + // function runs + assert_ok!(CollatorSelection::add_invulnerable( + RuntimeOrigin::signed(RootAccount::get()), + new + )); + + System::assert_last_event(RuntimeEvent::CollatorSelection( + crate::Event::InvulnerableAdded { account_id: new }, + )); + + // same element cannot be added more than once + assert_noop!( + CollatorSelection::add_invulnerable(RuntimeOrigin::signed(RootAccount::get()), new), + Error::::AlreadyInvulnerable + ); + + // new element is now part of the invulnerables list + assert!(CollatorSelection::invulnerables().to_vec().contains(&new)); + + // cannot add with non-root + assert_noop!(CollatorSelection::add_invulnerable(RuntimeOrigin::signed(1), new), BadOrigin); + + // cannot add invulnerable without associated validator keys + let not_validator = 42; + assert_noop!( + CollatorSelection::add_invulnerable( + RuntimeOrigin::signed(RootAccount::get()), + not_validator + ), + Error::::ValidatorNotRegistered + ); + }); +} + +#[test] +fn invulnerable_limit_works() { + new_test_ext().execute_with(|| { + assert_eq!(CollatorSelection::invulnerables(), vec![1, 2]); + + // MaxInvulnerables: u32 = 20 + for ii in 3..=21 { + // only keys were registered in mock for 1 to 5 + if ii > 5 { + Balances::make_free_balance_be(&ii, 100); + let key = MockSessionKeys { aura: UintAuthorityId(ii) }; + Session::set_keys(RuntimeOrigin::signed(ii).into(), key, Vec::new()).unwrap(); + } + assert_eq!(Balances::free_balance(ii), 100); + if ii < 21 { + assert_ok!(CollatorSelection::add_invulnerable( + RuntimeOrigin::signed(RootAccount::get()), + ii + )); + } else { + assert_noop!( + CollatorSelection::add_invulnerable( + RuntimeOrigin::signed(RootAccount::get()), + ii + ), + Error::::TooManyInvulnerables + ); + } + } + let expected: Vec = (1..=20).collect(); + assert_eq!(CollatorSelection::invulnerables(), expected); + + // Cannot set too many Invulnerables + let too_many_invulnerables: Vec = (1..=21).collect(); + assert_noop!( + CollatorSelection::set_invulnerables( + RuntimeOrigin::signed(RootAccount::get()), + too_many_invulnerables + ), + Error::::TooManyInvulnerables + ); + assert_eq!(CollatorSelection::invulnerables(), expected); + }); +} + +#[test] +fn remove_invulnerable_works() { + new_test_ext().execute_with(|| { + initialize_to_block(1); + assert_eq!(CollatorSelection::invulnerables(), vec![1, 2]); + + assert_ok!(CollatorSelection::add_invulnerable( + RuntimeOrigin::signed(RootAccount::get()), + 4 + )); + assert_ok!(CollatorSelection::add_invulnerable( + RuntimeOrigin::signed(RootAccount::get()), + 3 + )); + + assert_eq!(CollatorSelection::invulnerables(), vec![1, 2, 3, 4]); + + assert_ok!(CollatorSelection::remove_invulnerable( + RuntimeOrigin::signed(RootAccount::get()), + 2 + )); + + System::assert_last_event(RuntimeEvent::CollatorSelection( + crate::Event::InvulnerableRemoved { account_id: 2 }, + )); + assert_eq!(CollatorSelection::invulnerables(), vec![1, 3, 4]); + + // cannot remove invulnerable not in the list + assert_noop!( + CollatorSelection::remove_invulnerable(RuntimeOrigin::signed(RootAccount::get()), 2), + Error::::NotInvulnerable + ); + + // cannot remove without privilege + assert_noop!( + CollatorSelection::remove_invulnerable(RuntimeOrigin::signed(1), 3), + BadOrigin + ); + }); +} + #[test] fn set_desired_candidates_works() { new_test_ext().execute_with(|| { @@ -157,7 +286,7 @@ fn cannot_register_as_candidate_if_keys_not_registered() { new_test_ext().execute_with(|| { // can't 7 because keys not registered. assert_noop!( - CollatorSelection::register_as_candidate(RuntimeOrigin::signed(7)), + CollatorSelection::register_as_candidate(RuntimeOrigin::signed(42)), Error::::ValidatorNotRegistered ); }) diff --git a/pallets/collator-selection/src/weights.rs b/pallets/collator-selection/src/weights.rs index 874cec8ae36..6b02d28d673 100644 --- a/pallets/collator-selection/src/weights.rs +++ b/pallets/collator-selection/src/weights.rs @@ -27,6 +27,8 @@ use sp_std::marker::PhantomData; // The weight info trait for `pallet_collator_selection`. pub trait WeightInfo { fn set_invulnerables(_b: u32) -> Weight; + fn add_invulnerable(_b: u32) -> Weight; + fn remove_invulnerable(_b: u32) -> Weight; fn set_desired_candidates() -> Weight; fn set_candidacy_bond() -> Weight; fn register_as_candidate(_c: u32) -> Weight; @@ -80,6 +82,39 @@ impl WeightInfo for SubstrateWeight { .saturating_add(T::DbWeight::get().writes(2_u64.saturating_mul(r as u64))) .saturating_add(T::DbWeight::get().writes(2_u64.saturating_mul(c as u64))) } + /// Storage: CollatorSelection Invulnerables (r:1 w:1) + /// Proof: CollatorSelection Invulnerables (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: Session NextKeys (r:1 w:0) + /// Proof Skipped: Session NextKeys (max_values: None, max_size: None, mode: Measured) + /// The range of component `b` is `[1, 99]`. + fn add_invulnerable(b: u32) -> Weight { + // Proof Size summary in bytes: + // Measured: `581 + b * (37 ±0)` + // Estimated: `4687 + b * (37 ±0)` + // Minimum execution time: 269_126_000 picoseconds. + Weight::from_parts(286_711_880, 0) + .saturating_add(Weight::from_parts(0, 4687)) + // Standard Error: 22_887 + .saturating_add(Weight::from_parts(813_399, 0).saturating_mul(b.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) + .saturating_add(Weight::from_parts(0, 37).saturating_mul(b.into())) + } + /// Storage: CollatorSelection Invulnerables (r:1 w:1) + /// Proof: CollatorSelection Invulnerables (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// The range of component `b` is `[1, 100]`. + fn remove_invulnerable(b: u32) -> Weight { + // Proof Size summary in bytes: + // Measured: `119 + b * (32 ±0)` + // Estimated: `4687` + // Minimum execution time: 183_054_000 picoseconds. + Weight::from_parts(197_205_427, 0) + .saturating_add(Weight::from_parts(0, 4687)) + // Standard Error: 13_533 + .saturating_add(Weight::from_parts(376_231, 0).saturating_mul(b.into())) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } } // For backwards compatibility and tests @@ -126,4 +161,37 @@ impl WeightInfo for () { .saturating_add(RocksDbWeight::get().writes(2_u64.saturating_mul(r as u64))) .saturating_add(RocksDbWeight::get().writes(2_u64.saturating_mul(c as u64))) } + /// Storage: CollatorSelection Invulnerables (r:1 w:1) + /// Proof: CollatorSelection Invulnerables (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: Session NextKeys (r:1 w:0) + /// Proof Skipped: Session NextKeys (max_values: None, max_size: None, mode: Measured) + /// The range of component `b` is `[1, 99]`. + fn add_invulnerable(b: u32) -> Weight { + // Proof Size summary in bytes: + // Measured: `581 + b * (37 ±0)` + // Estimated: `4687 + b * (37 ±0)` + // Minimum execution time: 269_126_000 picoseconds. + Weight::from_parts(286_711_880, 0) + .saturating_add(Weight::from_parts(0, 4687)) + // Standard Error: 22_887 + .saturating_add(Weight::from_parts(813_399, 0).saturating_mul(b.into())) + .saturating_add(RocksDbWeight::get().reads(2)) + .saturating_add(RocksDbWeight::get().writes(1)) + .saturating_add(Weight::from_parts(0, 37).saturating_mul(b.into())) + } + /// Storage: CollatorSelection Invulnerables (r:1 w:1) + /// Proof: CollatorSelection Invulnerables (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// The range of component `b` is `[1, 100]`. + fn remove_invulnerable(b: u32) -> Weight { + // Proof Size summary in bytes: + // Measured: `119 + b * (32 ±0)` + // Estimated: `4687` + // Minimum execution time: 183_054_000 picoseconds. + Weight::from_parts(197_205_427, 0) + .saturating_add(Weight::from_parts(0, 4687)) + // Standard Error: 13_533 + .saturating_add(Weight::from_parts(376_231, 0).saturating_mul(b.into())) + .saturating_add(RocksDbWeight::get().reads(1)) + .saturating_add(RocksDbWeight::get().writes(1)) + } } diff --git a/parachains/runtimes/assets/statemine/src/lib.rs b/parachains/runtimes/assets/statemine/src/lib.rs index 4e06604aaf5..e1f9fbe3dc2 100644 --- a/parachains/runtimes/assets/statemine/src/lib.rs +++ b/parachains/runtimes/assets/statemine/src/lib.rs @@ -768,7 +768,7 @@ pub type UncheckedExtrinsic = /// Extrinsic type that has already been checked. pub type CheckedExtrinsic = generic::CheckedExtrinsic; /// Migrations to apply on runtime upgrade. -pub type Migrations = (); +pub type Migrations = (pallet_collator_selection::migration::v1::MigrateToV1,); /// Executive: handles dispatch to the various modules. pub type Executive = frame_executive::Executive< diff --git a/parachains/runtimes/assets/statemine/src/weights/pallet_collator_selection.rs b/parachains/runtimes/assets/statemine/src/weights/pallet_collator_selection.rs index b3a9fa52bd8..7c518a45ddf 100644 --- a/parachains/runtimes/assets/statemine/src/weights/pallet_collator_selection.rs +++ b/parachains/runtimes/assets/statemine/src/weights/pallet_collator_selection.rs @@ -147,6 +147,39 @@ impl pallet_collator_selection::WeightInfo for WeightIn .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(4)) } + /// Storage: CollatorSelection Invulnerables (r:1 w:1) + /// Proof: CollatorSelection Invulnerables (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: Session NextKeys (r:1 w:0) + /// Proof Skipped: Session NextKeys (max_values: None, max_size: None, mode: Measured) + /// The range of component `b` is `[1, 99]`. + fn add_invulnerable(b: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `581 + b * (37 ±0)` + // Estimated: `4687 + b * (37 ±0)` + // Minimum execution time: 269_126_000 picoseconds. + Weight::from_parts(286_711_880, 0) + .saturating_add(Weight::from_parts(0, 4687)) + // Standard Error: 22_887 + .saturating_add(Weight::from_parts(813_399, 0).saturating_mul(b.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) + .saturating_add(Weight::from_parts(0, 37).saturating_mul(b.into())) + } + /// Storage: CollatorSelection Invulnerables (r:1 w:1) + /// Proof: CollatorSelection Invulnerables (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// The range of component `b` is `[1, 100]`. + fn remove_invulnerable(b: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `119 + b * (32 ±0)` + // Estimated: `4687` + // Minimum execution time: 183_054_000 picoseconds. + Weight::from_parts(197_205_427, 0) + .saturating_add(Weight::from_parts(0, 4687)) + // Standard Error: 13_533 + .saturating_add(Weight::from_parts(376_231, 0).saturating_mul(b.into())) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } /// Storage: CollatorSelection Candidates (r:1 w:0) /// Proof: CollatorSelection Candidates (max_values: Some(1), max_size: Some(48002), added: 48497, mode: MaxEncodedLen) /// Storage: CollatorSelection LastAuthoredBlock (r:999 w:0) diff --git a/parachains/runtimes/assets/statemine/src/xcm_config.rs b/parachains/runtimes/assets/statemine/src/xcm_config.rs index 0ef469d2b31..3ce1058ab35 100644 --- a/parachains/runtimes/assets/statemine/src/xcm_config.rs +++ b/parachains/runtimes/assets/statemine/src/xcm_config.rs @@ -209,7 +209,9 @@ impl Contains for SafeCallFilter { pallet_collator_selection::Call::set_candidacy_bond { .. } | pallet_collator_selection::Call::register_as_candidate { .. } | pallet_collator_selection::Call::leave_intent { .. } | - pallet_collator_selection::Call::set_invulnerables { .. }, + pallet_collator_selection::Call::set_invulnerables { .. } | + pallet_collator_selection::Call::add_invulnerable { .. } | + pallet_collator_selection::Call::remove_invulnerable { .. }, ) | RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | RuntimeCall::XcmpQueue(..) | RuntimeCall::DmpQueue(..) | diff --git a/parachains/runtimes/assets/statemint/src/lib.rs b/parachains/runtimes/assets/statemint/src/lib.rs index f9a8b96a309..518fb3c4cab 100644 --- a/parachains/runtimes/assets/statemint/src/lib.rs +++ b/parachains/runtimes/assets/statemint/src/lib.rs @@ -779,7 +779,7 @@ pub type UncheckedExtrinsic = /// Extrinsic type that has already been checked. pub type CheckedExtrinsic = generic::CheckedExtrinsic; /// Migrations to apply on runtime upgrade. -pub type Migrations = (); +pub type Migrations = (pallet_collator_selection::migration::v1::MigrateToV1,); /// Executive: handles dispatch to the various modules. pub type Executive = frame_executive::Executive< diff --git a/parachains/runtimes/assets/statemint/src/weights/pallet_collator_selection.rs b/parachains/runtimes/assets/statemint/src/weights/pallet_collator_selection.rs index d18f3072c3d..37c59255469 100644 --- a/parachains/runtimes/assets/statemint/src/weights/pallet_collator_selection.rs +++ b/parachains/runtimes/assets/statemint/src/weights/pallet_collator_selection.rs @@ -147,6 +147,39 @@ impl pallet_collator_selection::WeightInfo for WeightIn .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(4)) } + /// Storage: CollatorSelection Invulnerables (r:1 w:1) + /// Proof: CollatorSelection Invulnerables (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: Session NextKeys (r:1 w:0) + /// Proof Skipped: Session NextKeys (max_values: None, max_size: None, mode: Measured) + /// The range of component `b` is `[1, 99]`. + fn add_invulnerable(b: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `581 + b * (37 ±0)` + // Estimated: `4687 + b * (37 ±0)` + // Minimum execution time: 269_126_000 picoseconds. + Weight::from_parts(286_711_880, 0) + .saturating_add(Weight::from_parts(0, 4687)) + // Standard Error: 22_887 + .saturating_add(Weight::from_parts(813_399, 0).saturating_mul(b.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) + .saturating_add(Weight::from_parts(0, 37).saturating_mul(b.into())) + } + /// Storage: CollatorSelection Invulnerables (r:1 w:1) + /// Proof: CollatorSelection Invulnerables (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// The range of component `b` is `[1, 100]`. + fn remove_invulnerable(b: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `119 + b * (32 ±0)` + // Estimated: `4687` + // Minimum execution time: 183_054_000 picoseconds. + Weight::from_parts(197_205_427, 0) + .saturating_add(Weight::from_parts(0, 4687)) + // Standard Error: 13_533 + .saturating_add(Weight::from_parts(376_231, 0).saturating_mul(b.into())) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } /// Storage: CollatorSelection Candidates (r:1 w:0) /// Proof: CollatorSelection Candidates (max_values: Some(1), max_size: Some(48002), added: 48497, mode: MaxEncodedLen) /// Storage: CollatorSelection LastAuthoredBlock (r:999 w:0) diff --git a/parachains/runtimes/assets/statemint/src/xcm_config.rs b/parachains/runtimes/assets/statemint/src/xcm_config.rs index ba2862742c1..82414a20a4b 100644 --- a/parachains/runtimes/assets/statemint/src/xcm_config.rs +++ b/parachains/runtimes/assets/statemint/src/xcm_config.rs @@ -212,7 +212,9 @@ impl Contains for SafeCallFilter { pallet_collator_selection::Call::set_candidacy_bond { .. } | pallet_collator_selection::Call::register_as_candidate { .. } | pallet_collator_selection::Call::leave_intent { .. } | - pallet_collator_selection::Call::set_invulnerables { .. }, + pallet_collator_selection::Call::set_invulnerables { .. } | + pallet_collator_selection::Call::add_invulnerable { .. } | + pallet_collator_selection::Call::remove_invulnerable { .. }, ) | RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | RuntimeCall::XcmpQueue(..) | RuntimeCall::DmpQueue(..) | diff --git a/parachains/runtimes/assets/westmint/src/lib.rs b/parachains/runtimes/assets/westmint/src/lib.rs index 4e72394636c..b988d9b6d34 100644 --- a/parachains/runtimes/assets/westmint/src/lib.rs +++ b/parachains/runtimes/assets/westmint/src/lib.rs @@ -764,7 +764,12 @@ pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; /// Migrations to apply on runtime upgrade. -pub type Migrations = (); +pub type Migrations = ( + // v9420 + pallet_nfts::migration::v1::MigrateToV1, + // unreleased + pallet_collator_selection::migration::v1::MigrateToV1, +); /// Executive: handles dispatch to the various modules. pub type Executive = frame_executive::Executive< diff --git a/parachains/runtimes/assets/westmint/src/weights/pallet_collator_selection.rs b/parachains/runtimes/assets/westmint/src/weights/pallet_collator_selection.rs index 5e7b72e9cd8..8b157d96d76 100644 --- a/parachains/runtimes/assets/westmint/src/weights/pallet_collator_selection.rs +++ b/parachains/runtimes/assets/westmint/src/weights/pallet_collator_selection.rs @@ -147,6 +147,39 @@ impl pallet_collator_selection::WeightInfo for WeightIn .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(4)) } + /// Storage: CollatorSelection Invulnerables (r:1 w:1) + /// Proof: CollatorSelection Invulnerables (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: Session NextKeys (r:1 w:0) + /// Proof Skipped: Session NextKeys (max_values: None, max_size: None, mode: Measured) + /// The range of component `b` is `[1, 99]`. + fn add_invulnerable(b: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `581 + b * (37 ±0)` + // Estimated: `4687 + b * (37 ±0)` + // Minimum execution time: 269_126_000 picoseconds. + Weight::from_parts(286_711_880, 0) + .saturating_add(Weight::from_parts(0, 4687)) + // Standard Error: 22_887 + .saturating_add(Weight::from_parts(813_399, 0).saturating_mul(b.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) + .saturating_add(Weight::from_parts(0, 37).saturating_mul(b.into())) + } + /// Storage: CollatorSelection Invulnerables (r:1 w:1) + /// Proof: CollatorSelection Invulnerables (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// The range of component `b` is `[1, 100]`. + fn remove_invulnerable(b: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `119 + b * (32 ±0)` + // Estimated: `4687` + // Minimum execution time: 183_054_000 picoseconds. + Weight::from_parts(197_205_427, 0) + .saturating_add(Weight::from_parts(0, 4687)) + // Standard Error: 13_533 + .saturating_add(Weight::from_parts(376_231, 0).saturating_mul(b.into())) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } /// Storage: CollatorSelection Candidates (r:1 w:0) /// Proof: CollatorSelection Candidates (max_values: Some(1), max_size: Some(48002), added: 48497, mode: MaxEncodedLen) /// Storage: CollatorSelection LastAuthoredBlock (r:999 w:0) diff --git a/parachains/runtimes/assets/westmint/src/xcm_config.rs b/parachains/runtimes/assets/westmint/src/xcm_config.rs index 33c8e487054..a4dc99df33f 100644 --- a/parachains/runtimes/assets/westmint/src/xcm_config.rs +++ b/parachains/runtimes/assets/westmint/src/xcm_config.rs @@ -204,7 +204,9 @@ impl Contains for SafeCallFilter { pallet_collator_selection::Call::set_candidacy_bond { .. } | pallet_collator_selection::Call::register_as_candidate { .. } | pallet_collator_selection::Call::leave_intent { .. } | - pallet_collator_selection::Call::set_invulnerables { .. }, + pallet_collator_selection::Call::set_invulnerables { .. } | + pallet_collator_selection::Call::add_invulnerable { .. } | + pallet_collator_selection::Call::remove_invulnerable { .. }, ) | RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | RuntimeCall::XcmpQueue(..) | RuntimeCall::DmpQueue(..) | diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs index b003c58ffb6..86964af6ced 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs @@ -108,6 +108,9 @@ pub type UncheckedExtrinsic = /// Extrinsic type that has already been checked. pub type CheckedExtrinsic = generic::CheckedExtrinsic; +/// Migrations to apply on runtime upgrade. +pub type Migrations = (pallet_collator_selection::migration::v1::MigrateToV1,); + /// Executive: handles dispatch to the various modules. pub type Executive = frame_executive::Executive< Runtime, @@ -115,6 +118,7 @@ pub type Executive = frame_executive::Executive< frame_system::ChainContext, Runtime, AllPalletsWithSystem, + Migrations, >; impl_opaque_keys! { diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/pallet_collator_selection.rs b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/pallet_collator_selection.rs index 8a49dd2eb07..1d48699a2e8 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/pallet_collator_selection.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/pallet_collator_selection.rs @@ -147,6 +147,39 @@ impl pallet_collator_selection::WeightInfo for WeightIn .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(4)) } + /// Storage: CollatorSelection Invulnerables (r:1 w:1) + /// Proof: CollatorSelection Invulnerables (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: Session NextKeys (r:1 w:0) + /// Proof Skipped: Session NextKeys (max_values: None, max_size: None, mode: Measured) + /// The range of component `b` is `[1, 99]`. + fn add_invulnerable(b: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `581 + b * (37 ±0)` + // Estimated: `4687 + b * (37 ±0)` + // Minimum execution time: 269_126_000 picoseconds. + Weight::from_parts(286_711_880, 0) + .saturating_add(Weight::from_parts(0, 4687)) + // Standard Error: 22_887 + .saturating_add(Weight::from_parts(813_399, 0).saturating_mul(b.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) + .saturating_add(Weight::from_parts(0, 37).saturating_mul(b.into())) + } + /// Storage: CollatorSelection Invulnerables (r:1 w:1) + /// Proof: CollatorSelection Invulnerables (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// The range of component `b` is `[1, 100]`. + fn remove_invulnerable(b: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `119 + b * (32 ±0)` + // Estimated: `4687` + // Minimum execution time: 183_054_000 picoseconds. + Weight::from_parts(197_205_427, 0) + .saturating_add(Weight::from_parts(0, 4687)) + // Standard Error: 13_533 + .saturating_add(Weight::from_parts(376_231, 0).saturating_mul(b.into())) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } /// Storage: CollatorSelection Candidates (r:1 w:0) /// Proof: CollatorSelection Candidates (max_values: Some(1), max_size: Some(48002), added: 48497, mode: MaxEncodedLen) /// Storage: CollatorSelection LastAuthoredBlock (r:999 w:0) diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs index 6f9c1542423..ed72909f0cb 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs @@ -142,7 +142,9 @@ impl Contains for SafeCallFilter { pallet_collator_selection::Call::set_candidacy_bond { .. } | pallet_collator_selection::Call::register_as_candidate { .. } | pallet_collator_selection::Call::leave_intent { .. } | - pallet_collator_selection::Call::set_invulnerables { .. }, + pallet_collator_selection::Call::set_invulnerables { .. } | + pallet_collator_selection::Call::add_invulnerable { .. } | + pallet_collator_selection::Call::remove_invulnerable { .. }, ) | RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | RuntimeCall::XcmpQueue(..) | RuntimeCall::DmpQueue(..) | diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/lib.rs b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/lib.rs index 5913df282d7..fd284576da0 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/lib.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/lib.rs @@ -108,6 +108,9 @@ pub type UncheckedExtrinsic = /// Extrinsic type that has already been checked. pub type CheckedExtrinsic = generic::CheckedExtrinsic; +/// Migrations to apply on runtime upgrade. +pub type Migrations = (pallet_collator_selection::migration::v1::MigrateToV1,); + /// Executive: handles dispatch to the various modules. pub type Executive = frame_executive::Executive< Runtime, @@ -115,6 +118,7 @@ pub type Executive = frame_executive::Executive< frame_system::ChainContext, Runtime, AllPalletsWithSystem, + Migrations, >; impl_opaque_keys! { diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/pallet_collator_selection.rs b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/pallet_collator_selection.rs index cac72598bd3..bae3a058100 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/pallet_collator_selection.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/pallet_collator_selection.rs @@ -147,6 +147,39 @@ impl pallet_collator_selection::WeightInfo for WeightIn .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(4)) } + /// Storage: CollatorSelection Invulnerables (r:1 w:1) + /// Proof: CollatorSelection Invulnerables (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: Session NextKeys (r:1 w:0) + /// Proof Skipped: Session NextKeys (max_values: None, max_size: None, mode: Measured) + /// The range of component `b` is `[1, 99]`. + fn add_invulnerable(b: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `581 + b * (37 ±0)` + // Estimated: `4687 + b * (37 ±0)` + // Minimum execution time: 269_126_000 picoseconds. + Weight::from_parts(286_711_880, 0) + .saturating_add(Weight::from_parts(0, 4687)) + // Standard Error: 22_887 + .saturating_add(Weight::from_parts(813_399, 0).saturating_mul(b.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) + .saturating_add(Weight::from_parts(0, 37).saturating_mul(b.into())) + } + /// Storage: CollatorSelection Invulnerables (r:1 w:1) + /// Proof: CollatorSelection Invulnerables (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// The range of component `b` is `[1, 100]`. + fn remove_invulnerable(b: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `119 + b * (32 ±0)` + // Estimated: `4687` + // Minimum execution time: 183_054_000 picoseconds. + Weight::from_parts(197_205_427, 0) + .saturating_add(Weight::from_parts(0, 4687)) + // Standard Error: 13_533 + .saturating_add(Weight::from_parts(376_231, 0).saturating_mul(b.into())) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } /// Storage: CollatorSelection Candidates (r:1 w:0) /// Proof: CollatorSelection Candidates (max_values: Some(1), max_size: Some(48002), added: 48497, mode: MaxEncodedLen) /// Storage: CollatorSelection LastAuthoredBlock (r:999 w:0) diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs index e2bf2dd4a95..804c7455b5a 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs @@ -145,7 +145,9 @@ impl Contains for SafeCallFilter { pallet_collator_selection::Call::set_candidacy_bond { .. } | pallet_collator_selection::Call::register_as_candidate { .. } | pallet_collator_selection::Call::leave_intent { .. } | - pallet_collator_selection::Call::set_invulnerables { .. }, + pallet_collator_selection::Call::set_invulnerables { .. } | + pallet_collator_selection::Call::add_invulnerable { .. } | + pallet_collator_selection::Call::remove_invulnerable { .. }, ) | RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | RuntimeCall::XcmpQueue(..) | RuntimeCall::DmpQueue(..) | diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs index b0f32c72fcf..ef645b93b55 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs @@ -122,6 +122,9 @@ pub type SignedExtra = ( pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; +/// Migrations to apply on runtime upgrade. +pub type Migrations = (pallet_collator_selection::migration::v1::MigrateToV1,); + /// Executive: handles dispatch to the various modules. pub type Executive = frame_executive::Executive< Runtime, @@ -129,6 +132,7 @@ pub type Executive = frame_executive::Executive< frame_system::ChainContext, Runtime, AllPalletsWithSystem, + Migrations, >; impl_opaque_keys! { diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_collator_selection.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_collator_selection.rs index 175d98504ad..b66a8635e40 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_collator_selection.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_collator_selection.rs @@ -147,6 +147,39 @@ impl pallet_collator_selection::WeightInfo for WeightIn .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(4)) } + /// Storage: CollatorSelection Invulnerables (r:1 w:1) + /// Proof: CollatorSelection Invulnerables (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: Session NextKeys (r:1 w:0) + /// Proof Skipped: Session NextKeys (max_values: None, max_size: None, mode: Measured) + /// The range of component `b` is `[1, 99]`. + fn add_invulnerable(b: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `581 + b * (37 ±0)` + // Estimated: `4687 + b * (37 ±0)` + // Minimum execution time: 269_126_000 picoseconds. + Weight::from_parts(286_711_880, 0) + .saturating_add(Weight::from_parts(0, 4687)) + // Standard Error: 22_887 + .saturating_add(Weight::from_parts(813_399, 0).saturating_mul(b.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) + .saturating_add(Weight::from_parts(0, 37).saturating_mul(b.into())) + } + /// Storage: CollatorSelection Invulnerables (r:1 w:1) + /// Proof: CollatorSelection Invulnerables (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// The range of component `b` is `[1, 100]`. + fn remove_invulnerable(b: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `119 + b * (32 ±0)` + // Estimated: `4687` + // Minimum execution time: 183_054_000 picoseconds. + Weight::from_parts(197_205_427, 0) + .saturating_add(Weight::from_parts(0, 4687)) + // Standard Error: 13_533 + .saturating_add(Weight::from_parts(376_231, 0).saturating_mul(b.into())) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } /// Storage: CollatorSelection Candidates (r:1 w:0) /// Proof: CollatorSelection Candidates (max_values: Some(1), max_size: Some(48002), added: 48497, mode: MaxEncodedLen) /// Storage: CollatorSelection LastAuthoredBlock (r:999 w:0) diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs index a08f2f7c426..371af54797b 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs @@ -178,7 +178,9 @@ impl Contains for SafeCallFilter { pallet_collator_selection::Call::set_candidacy_bond { .. } | pallet_collator_selection::Call::register_as_candidate { .. } | pallet_collator_selection::Call::leave_intent { .. } | - pallet_collator_selection::Call::set_invulnerables { .. }, + pallet_collator_selection::Call::set_invulnerables { .. } | + pallet_collator_selection::Call::add_invulnerable { .. } | + pallet_collator_selection::Call::remove_invulnerable { .. }, ) | RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | RuntimeCall::XcmpQueue(..) | RuntimeCall::DmpQueue(..) | diff --git a/parachains/runtimes/collectives/collectives-polkadot/src/lib.rs b/parachains/runtimes/collectives/collectives-polkadot/src/lib.rs index 493fa611fe2..3aed385e404 100644 --- a/parachains/runtimes/collectives/collectives-polkadot/src/lib.rs +++ b/parachains/runtimes/collectives/collectives-polkadot/src/lib.rs @@ -627,7 +627,12 @@ pub type UncheckedExtrinsic = pub type CheckedExtrinsic = generic::CheckedExtrinsic; // All migrations executed on runtime upgrade as a nested tuple of types implementing // `OnRuntimeUpgrade`. Included migrations must be idempotent. -type Migrations = import_kusama_fellowship::Migration; +type Migrations = ( + // v9420 + import_kusama_fellowship::Migration, + // unreleased + pallet_collator_selection::migration::v1::MigrateToV1, +); /// Executive: handles dispatch to the various modules. pub type Executive = frame_executive::Executive< diff --git a/parachains/runtimes/collectives/collectives-polkadot/src/weights/pallet_collator_selection.rs b/parachains/runtimes/collectives/collectives-polkadot/src/weights/pallet_collator_selection.rs index 3eee2a2014e..73961b722fa 100644 --- a/parachains/runtimes/collectives/collectives-polkadot/src/weights/pallet_collator_selection.rs +++ b/parachains/runtimes/collectives/collectives-polkadot/src/weights/pallet_collator_selection.rs @@ -147,6 +147,39 @@ impl pallet_collator_selection::WeightInfo for WeightIn .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(4)) } + /// Storage: CollatorSelection Invulnerables (r:1 w:1) + /// Proof: CollatorSelection Invulnerables (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: Session NextKeys (r:1 w:0) + /// Proof Skipped: Session NextKeys (max_values: None, max_size: None, mode: Measured) + /// The range of component `b` is `[1, 99]`. + fn add_invulnerable(b: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `581 + b * (37 ±0)` + // Estimated: `4687 + b * (37 ±0)` + // Minimum execution time: 269_126_000 picoseconds. + Weight::from_parts(286_711_880, 0) + .saturating_add(Weight::from_parts(0, 4687)) + // Standard Error: 22_887 + .saturating_add(Weight::from_parts(813_399, 0).saturating_mul(b.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) + .saturating_add(Weight::from_parts(0, 37).saturating_mul(b.into())) + } + /// Storage: CollatorSelection Invulnerables (r:1 w:1) + /// Proof: CollatorSelection Invulnerables (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// The range of component `b` is `[1, 100]`. + fn remove_invulnerable(b: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `119 + b * (32 ±0)` + // Estimated: `4687` + // Minimum execution time: 183_054_000 picoseconds. + Weight::from_parts(197_205_427, 0) + .saturating_add(Weight::from_parts(0, 4687)) + // Standard Error: 13_533 + .saturating_add(Weight::from_parts(376_231, 0).saturating_mul(b.into())) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } /// Storage: CollatorSelection Candidates (r:1 w:0) /// Proof: CollatorSelection Candidates (max_values: Some(1), max_size: Some(48002), added: 48497, mode: MaxEncodedLen) /// Storage: CollatorSelection LastAuthoredBlock (r:999 w:0) diff --git a/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs b/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs index c8571ebc6f2..406209a4a4c 100644 --- a/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs +++ b/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs @@ -153,7 +153,9 @@ impl Contains for SafeCallFilter { pallet_collator_selection::Call::set_candidacy_bond { .. } | pallet_collator_selection::Call::register_as_candidate { .. } | pallet_collator_selection::Call::leave_intent { .. } | - pallet_collator_selection::Call::set_invulnerables { .. }, + pallet_collator_selection::Call::set_invulnerables { .. } | + pallet_collator_selection::Call::add_invulnerable { .. } | + pallet_collator_selection::Call::remove_invulnerable { .. }, ) | RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | RuntimeCall::PolkadotXcm(pallet_xcm::Call::force_xcm_version { .. }) | RuntimeCall::XcmpQueue(..) | diff --git a/parachains/runtimes/contracts/contracts-rococo/src/lib.rs b/parachains/runtimes/contracts/contracts-rococo/src/lib.rs index cbdbd5500b6..d90c60990c4 100644 --- a/parachains/runtimes/contracts/contracts-rococo/src/lib.rs +++ b/parachains/runtimes/contracts/contracts-rococo/src/lib.rs @@ -95,7 +95,10 @@ pub type SignedExtra = ( pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; -pub type Migrations = (pallet_contracts::Migration,); +pub type Migrations = ( + pallet_contracts::Migration, + pallet_collator_selection::migration::v1::MigrateToV1, +); type EventRecord = frame_system::EventRecord< ::RuntimeEvent, diff --git a/parachains/runtimes/testing/penpal/src/lib.rs b/parachains/runtimes/testing/penpal/src/lib.rs index 01b9654006d..8ba89c803ce 100644 --- a/parachains/runtimes/testing/penpal/src/lib.rs +++ b/parachains/runtimes/testing/penpal/src/lib.rs @@ -123,8 +123,10 @@ pub type SignedExtra = ( pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; -pub type Migrations = - (pallet_balances::migration::MigrateToTrackInactive,); +pub type Migrations = ( + pallet_balances::migration::MigrateToTrackInactive, + pallet_collator_selection::migration::v1::MigrateToV1, +); /// Executive: handles dispatch to the various modules. pub type Executive = frame_executive::Executive<