mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 04:41:03 +00:00
Add Ability to Add/Remove Invulnerable Collators (#2596)
* 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 <git@kchr.de> * 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 <git@kchr.de> Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
authors = ["Anonymous"]
|
||||
description = "Simple staking pallet with a fixed stake."
|
||||
authors = ["Parity Technologies <admin@parity.io>"]
|
||||
description = "Simple pallet to select collators for a parachain."
|
||||
edition = "2021"
|
||||
homepage = "https://substrate.io"
|
||||
license = "Apache-2.0"
|
||||
|
||||
@@ -110,17 +110,61 @@ benchmarks! {
|
||||
where_clause { where T: pallet_authorship::Config + session::Config }
|
||||
|
||||
set_invulnerables {
|
||||
let b in 1 .. T::MaxInvulnerables::get();
|
||||
let new_invulnerables = register_validators::<T>(b);
|
||||
let origin =
|
||||
T::UpdateOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?;
|
||||
let b in 1 .. T::MaxInvulnerables::get();
|
||||
let new_invulnerables = register_validators::<T>(b);
|
||||
let mut sorted_new_invulnerables = new_invulnerables.clone();
|
||||
sorted_new_invulnerables.sort();
|
||||
}: {
|
||||
assert_ok!(
|
||||
// call the function with the unsorted list
|
||||
<CollatorSelection<T>>::set_invulnerables(origin, new_invulnerables.clone())
|
||||
);
|
||||
}
|
||||
verify {
|
||||
assert_last_event::<T>(Event::NewInvulnerables{invulnerables: new_invulnerables}.into());
|
||||
// assert that it comes out sorted
|
||||
assert_last_event::<T>(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::<T>(b);
|
||||
invulnerables.sort();
|
||||
let invulnerables: frame_support::BoundedVec<_, T::MaxInvulnerables> = frame_support::BoundedVec::try_from(invulnerables).unwrap();
|
||||
<Invulnerables<T>>::put(invulnerables);
|
||||
|
||||
// now let's set up a new one to add
|
||||
let (new, keys) = validator::<T>(b + 1);
|
||||
<session::Pallet<T>>::set_keys(RawOrigin::Signed(new.clone()).into(), keys, Vec::new()).unwrap();
|
||||
}: {
|
||||
assert_ok!(
|
||||
<CollatorSelection<T>>::add_invulnerable(origin, new.clone())
|
||||
);
|
||||
}
|
||||
verify {
|
||||
assert_last_event::<T>(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::<T>(b);
|
||||
invulnerables.sort();
|
||||
let invulnerables: frame_support::BoundedVec<_, T::MaxInvulnerables> = frame_support::BoundedVec::try_from(invulnerables).unwrap();
|
||||
<Invulnerables<T>>::put(invulnerables);
|
||||
let to_remove = <Invulnerables<T>>::get().first().unwrap().clone();
|
||||
}: {
|
||||
assert_ok!(
|
||||
<CollatorSelection<T>>::remove_invulnerable(origin, to_remove.clone())
|
||||
);
|
||||
}
|
||||
verify {
|
||||
assert_last_event::<T>(Event::InvulnerableRemoved{account_id: to_remove}.into());
|
||||
}
|
||||
|
||||
set_desired_candidates {
|
||||
|
||||
@@ -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<T> =
|
||||
<<T as Config>::Currency as Currency<<T as SystemConfig>::AccountId>>::Balance;
|
||||
|
||||
@@ -165,9 +171,10 @@ pub mod pallet {
|
||||
}
|
||||
|
||||
#[pallet::pallet]
|
||||
#[pallet::storage_version(STORAGE_VERSION)]
|
||||
pub struct Pallet<T>(_);
|
||||
|
||||
/// The invulnerable, fixed collators.
|
||||
/// The invulnerable, permissioned collators. This list must be sorted.
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn invulnerables)]
|
||||
pub type Invulnerables<T: Config> =
|
||||
@@ -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();
|
||||
|
||||
<DesiredCandidates<T>>::put(self.desired_candidates);
|
||||
<CandidacyBond<T>>::put(self.candidacy_bond);
|
||||
<Invulnerables<T>>::put(bounded_invulnerables);
|
||||
@@ -239,35 +248,41 @@ pub mod pallet {
|
||||
#[pallet::event]
|
||||
#[pallet::generate_deposit(pub(super) fn deposit_event)]
|
||||
pub enum Event<T: Config> {
|
||||
/// New Invulnerables were set.
|
||||
NewInvulnerables { invulnerables: Vec<T::AccountId> },
|
||||
/// 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<T> },
|
||||
/// A new candidate joined.
|
||||
CandidateAdded { account_id: T::AccountId, deposit: BalanceOf<T> },
|
||||
/// A candidate was removed.
|
||||
CandidateRemoved { account_id: T::AccountId },
|
||||
}
|
||||
|
||||
// Errors inform users that something went wrong.
|
||||
#[pallet::error]
|
||||
pub enum Error<T> {
|
||||
/// 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<T::AccountId>,
|
||||
) -> 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::<T>::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();
|
||||
|
||||
<Invulnerables<T>>::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<T>, 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::<T>::NoAssociatedValidatorId)?;
|
||||
ensure!(
|
||||
T::ValidatorRegistration::is_registered(&validator_key),
|
||||
Error::<T>::ValidatorNotRegistered
|
||||
);
|
||||
|
||||
<Invulnerables<T>>::try_mutate(|invulnerables| -> DispatchResult {
|
||||
match invulnerables.binary_search(&who) {
|
||||
Ok(_) => return Err(Error::<T>::AlreadyInvulnerable)?,
|
||||
Err(pos) => invulnerables
|
||||
.try_insert(pos, who.clone())
|
||||
.map_err(|_| Error::<T>::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<T>, who: T::AccountId) -> DispatchResult {
|
||||
T::UpdateOrigin::ensure_origin(origin)?;
|
||||
|
||||
<Invulnerables<T>>::try_mutate(|invulnerables| -> DispatchResult {
|
||||
let pos =
|
||||
invulnerables.binary_search(&who).map_err(|_| Error::<T>::NotInvulnerable)?;
|
||||
invulnerables.remove(pos);
|
||||
Ok(())
|
||||
})?;
|
||||
|
||||
Self::deposit_event(Event::InvulnerableRemoved { account_id: who });
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Config> Pallet<T> {
|
||||
|
||||
@@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! 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<T>(sp_std::marker::PhantomData<T>);
|
||||
impl<T: Config> OnRuntimeUpgrade for MigrateToV1<T> {
|
||||
fn on_runtime_upgrade() -> Weight {
|
||||
let onchain_version = Pallet::<T>::on_chain_storage_version();
|
||||
if onchain_version == 0 {
|
||||
let invulnerables_len = Invulnerables::<T>::get().to_vec().len();
|
||||
<Invulnerables<T>>::mutate(|invulnerables| {
|
||||
invulnerables.sort();
|
||||
});
|
||||
|
||||
StorageVersion::new(1).put::<Pallet<T>>();
|
||||
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<Vec<u8>, sp_runtime::DispatchError> {
|
||||
let number_of_invulnerables = Invulnerables::<T>::get().to_vec().len();
|
||||
Ok((number_of_invulnerables as u32).encode())
|
||||
}
|
||||
|
||||
#[cfg(feature = "try-runtime")]
|
||||
fn post_upgrade(number_of_invulnerables: Vec<u8>) -> Result<(), sp_runtime::DispatchError> {
|
||||
let stored_invulnerables = Invulnerables::<T>::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::<T>::on_chain_storage_version();
|
||||
frame_support::ensure!(onchain_version >= 1, "must_upgrade");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -195,7 +195,7 @@ parameter_types! {
|
||||
pub struct IsRegistered;
|
||||
impl ValidatorRegistration<u64> 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::<Test>().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
|
||||
|
||||
@@ -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::<Test>::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::<Test>::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::<Test>::TooManyInvulnerables
|
||||
);
|
||||
}
|
||||
}
|
||||
let expected: Vec<u64> = (1..=20).collect();
|
||||
assert_eq!(CollatorSelection::invulnerables(), expected);
|
||||
|
||||
// Cannot set too many Invulnerables
|
||||
let too_many_invulnerables: Vec<u64> = (1..=21).collect();
|
||||
assert_noop!(
|
||||
CollatorSelection::set_invulnerables(
|
||||
RuntimeOrigin::signed(RootAccount::get()),
|
||||
too_many_invulnerables
|
||||
),
|
||||
Error::<Test>::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::<Test>::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::<Test>::ValidatorNotRegistered
|
||||
);
|
||||
})
|
||||
|
||||
@@ -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<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
||||
.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))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -768,7 +768,7 @@ pub type UncheckedExtrinsic =
|
||||
/// Extrinsic type that has already been checked.
|
||||
pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, RuntimeCall, SignedExtra>;
|
||||
/// Migrations to apply on runtime upgrade.
|
||||
pub type Migrations = ();
|
||||
pub type Migrations = (pallet_collator_selection::migration::v1::MigrateToV1<Runtime>,);
|
||||
|
||||
/// Executive: handles dispatch to the various modules.
|
||||
pub type Executive = frame_executive::Executive<
|
||||
|
||||
@@ -147,6 +147,39 @@ impl<T: frame_system::Config> 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)
|
||||
|
||||
@@ -209,7 +209,9 @@ impl Contains<RuntimeCall> 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(..) |
|
||||
|
||||
@@ -779,7 +779,7 @@ pub type UncheckedExtrinsic =
|
||||
/// Extrinsic type that has already been checked.
|
||||
pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, RuntimeCall, SignedExtra>;
|
||||
/// Migrations to apply on runtime upgrade.
|
||||
pub type Migrations = ();
|
||||
pub type Migrations = (pallet_collator_selection::migration::v1::MigrateToV1<Runtime>,);
|
||||
|
||||
/// Executive: handles dispatch to the various modules.
|
||||
pub type Executive = frame_executive::Executive<
|
||||
|
||||
@@ -147,6 +147,39 @@ impl<T: frame_system::Config> 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)
|
||||
|
||||
@@ -212,7 +212,9 @@ impl Contains<RuntimeCall> 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(..) |
|
||||
|
||||
@@ -764,7 +764,12 @@ pub type UncheckedExtrinsic =
|
||||
generic::UncheckedExtrinsic<Address, RuntimeCall, Signature, SignedExtra>;
|
||||
|
||||
/// Migrations to apply on runtime upgrade.
|
||||
pub type Migrations = ();
|
||||
pub type Migrations = (
|
||||
// v9420
|
||||
pallet_nfts::migration::v1::MigrateToV1<Runtime>,
|
||||
// unreleased
|
||||
pallet_collator_selection::migration::v1::MigrateToV1<Runtime>,
|
||||
);
|
||||
|
||||
/// Executive: handles dispatch to the various modules.
|
||||
pub type Executive = frame_executive::Executive<
|
||||
|
||||
@@ -147,6 +147,39 @@ impl<T: frame_system::Config> 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)
|
||||
|
||||
@@ -204,7 +204,9 @@ impl Contains<RuntimeCall> 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(..) |
|
||||
|
||||
@@ -108,6 +108,9 @@ pub type UncheckedExtrinsic =
|
||||
/// Extrinsic type that has already been checked.
|
||||
pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, RuntimeCall, SignedExtra>;
|
||||
|
||||
/// Migrations to apply on runtime upgrade.
|
||||
pub type Migrations = (pallet_collator_selection::migration::v1::MigrateToV1<Runtime>,);
|
||||
|
||||
/// 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>,
|
||||
Runtime,
|
||||
AllPalletsWithSystem,
|
||||
Migrations,
|
||||
>;
|
||||
|
||||
impl_opaque_keys! {
|
||||
|
||||
+33
@@ -147,6 +147,39 @@ impl<T: frame_system::Config> 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)
|
||||
|
||||
@@ -142,7 +142,9 @@ impl Contains<RuntimeCall> 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(..) |
|
||||
|
||||
@@ -108,6 +108,9 @@ pub type UncheckedExtrinsic =
|
||||
/// Extrinsic type that has already been checked.
|
||||
pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, RuntimeCall, SignedExtra>;
|
||||
|
||||
/// Migrations to apply on runtime upgrade.
|
||||
pub type Migrations = (pallet_collator_selection::migration::v1::MigrateToV1<Runtime>,);
|
||||
|
||||
/// 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>,
|
||||
Runtime,
|
||||
AllPalletsWithSystem,
|
||||
Migrations,
|
||||
>;
|
||||
|
||||
impl_opaque_keys! {
|
||||
|
||||
+33
@@ -147,6 +147,39 @@ impl<T: frame_system::Config> 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)
|
||||
|
||||
@@ -145,7 +145,9 @@ impl Contains<RuntimeCall> 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(..) |
|
||||
|
||||
@@ -122,6 +122,9 @@ pub type SignedExtra = (
|
||||
pub type UncheckedExtrinsic =
|
||||
generic::UncheckedExtrinsic<Address, RuntimeCall, Signature, SignedExtra>;
|
||||
|
||||
/// Migrations to apply on runtime upgrade.
|
||||
pub type Migrations = (pallet_collator_selection::migration::v1::MigrateToV1<Runtime>,);
|
||||
|
||||
/// 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>,
|
||||
Runtime,
|
||||
AllPalletsWithSystem,
|
||||
Migrations,
|
||||
>;
|
||||
|
||||
impl_opaque_keys! {
|
||||
|
||||
+33
@@ -147,6 +147,39 @@ impl<T: frame_system::Config> 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)
|
||||
|
||||
@@ -178,7 +178,9 @@ impl Contains<RuntimeCall> 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(..) |
|
||||
|
||||
@@ -627,7 +627,12 @@ pub type UncheckedExtrinsic =
|
||||
pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, RuntimeCall, SignedExtra>;
|
||||
// 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<Runtime, FellowshipCollectiveInstance>;
|
||||
type Migrations = (
|
||||
// v9420
|
||||
import_kusama_fellowship::Migration<Runtime, FellowshipCollectiveInstance>,
|
||||
// unreleased
|
||||
pallet_collator_selection::migration::v1::MigrateToV1<Runtime>,
|
||||
);
|
||||
|
||||
/// Executive: handles dispatch to the various modules.
|
||||
pub type Executive = frame_executive::Executive<
|
||||
|
||||
+33
@@ -147,6 +147,39 @@ impl<T: frame_system::Config> 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)
|
||||
|
||||
@@ -153,7 +153,9 @@ impl Contains<RuntimeCall> 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(..) |
|
||||
|
||||
@@ -95,7 +95,10 @@ pub type SignedExtra = (
|
||||
pub type UncheckedExtrinsic =
|
||||
generic::UncheckedExtrinsic<Address, RuntimeCall, Signature, SignedExtra>;
|
||||
|
||||
pub type Migrations = (pallet_contracts::Migration<Runtime>,);
|
||||
pub type Migrations = (
|
||||
pallet_contracts::Migration<Runtime>,
|
||||
pallet_collator_selection::migration::v1::MigrateToV1<Runtime>,
|
||||
);
|
||||
|
||||
type EventRecord = frame_system::EventRecord<
|
||||
<Runtime as frame_system::Config>::RuntimeEvent,
|
||||
|
||||
@@ -123,8 +123,10 @@ pub type SignedExtra = (
|
||||
pub type UncheckedExtrinsic =
|
||||
generic::UncheckedExtrinsic<Address, RuntimeCall, Signature, SignedExtra>;
|
||||
|
||||
pub type Migrations =
|
||||
(pallet_balances::migration::MigrateToTrackInactive<Runtime, xcm_config::CheckingAccount>,);
|
||||
pub type Migrations = (
|
||||
pallet_balances::migration::MigrateToTrackInactive<Runtime, xcm_config::CheckingAccount>,
|
||||
pallet_collator_selection::migration::v1::MigrateToV1<Runtime>,
|
||||
);
|
||||
|
||||
/// Executive: handles dispatch to the various modules.
|
||||
pub type Executive = frame_executive::Executive<
|
||||
|
||||
Reference in New Issue
Block a user