difftreelog
feat(configuration) benchmarks
in: master
15 files changed
Cargo.lockdiffbeforeafterboth--- a/Cargo.lock
+++ b/Cargo.lock
@@ -5846,6 +5846,7 @@
version = "0.1.2"
dependencies = [
"fp-evm",
+ "frame-benchmarking",
"frame-support",
"frame-system",
"parity-scale-codec 3.2.1",
Makefilediffbeforeafterboth--- a/Makefile
+++ b/Makefile
@@ -89,6 +89,10 @@
bench-evm-migration:
make _bench PALLET=evm-migration
+.PHONY: bench-configuration
+bench-configuration:
+ make _bench PALLET=configuration
+
.PHONY: bench-common
bench-common:
make _bench PALLET=common
@@ -143,4 +147,4 @@
.PHONY: bench
# Disabled: bench-scheduler, bench-rmrk-core, bench-rmrk-equip
-bench: bench-evm-migration bench-unique bench-structure bench-fungible bench-refungible bench-nonfungible bench-foreign-assets bench-collator-selection bench-identity
+bench: bench-evm-migration bench-unique bench-structure bench-fungible bench-refungible bench-nonfungible bench-configuration bench-foreign-assets bench-collator-selection bench-identity
pallets/collator-selection/src/benchmarking.rsdiffbeforeafterboth--- a/pallets/collator-selection/src/benchmarking.rs
+++ b/pallets/collator-selection/src/benchmarking.rs
@@ -52,9 +52,6 @@
};
use sp_std::prelude::*;
-/*pub type BalanceOf<T> =
-<<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance;*/
-
const SEED: u32 = 0;
// TODO: remove if this is given in substrate commit.
@@ -116,14 +113,24 @@
validators.into_iter().map(|(who, _)| who).collect()
}
+fn register_invulnerables<T: Config + configuration::Config>(count: u32) {
+ let candidates = (0..count)
+ .map(|c| account("candidate", c, SEED))
+ .collect::<Vec<_>>();
+
+ for who in candidates {
+ <CollatorSelection<T>>::add_invulnerable(T::UpdateOrigin::successful_origin(), who).unwrap();
+ }
+}
+
fn register_candidates<T: Config + configuration::Config>(count: u32) {
let candidates = (0..count)
.map(|c| account("candidate", c, SEED))
.collect::<Vec<_>>();
- assert!(
+ /*assert!(
<LicenseBond<T>>::get() > 0u32.into(),
"Bond cannot be zero!"
- );
+ );*/
for who in candidates {
T::Currency::make_free_balance_be(&who, <LicenseBond<T>>::get() * 2u32.into());
@@ -132,16 +139,45 @@
}
}
+fn get_licenses<T: Config + configuration::Config>(count: u32) {
+ let candidates = (0..count)
+ .map(|c| account("candidate", c, SEED))
+ .collect::<Vec<_>>();
+ /*assert!(
+ <LicenseBond<T>>::get() > 0u32.into(),
+ "Bond cannot be zero!"
+ );*/
+
+ for who in candidates {
+ T::Currency::make_free_balance_be(&who, <LicenseBond<T>>::get() * 2u32.into());
+ <CollatorSelection<T>>::get_license(RawOrigin::Signed(who.clone()).into()).unwrap();
+ }
+}
+
benchmarks! {
where_clause { where T: pallet_authorship::Config + session::Config + configuration::Config }
add_invulnerable {
- let b in 1 .. T::MaxCollators::get();
- let new_invulnerable = register_validators::<T>(b)[0].clone();
- let origin = T::UpdateOrigin::successful_origin();
+ let b in 1 .. T::MaxCollators::get() - 3;
+ register_validators::<T>(b);
+ register_invulnerables::<T>(b);
+
+ // log::info!("{} {}", <Invulnerables<T>>::get().len(), b);
+
+ let new_invulnerable: T::AccountId = whitelisted_caller();
+ let bond: BalanceOf<T> = T::Currency::minimum_balance() * 2u32.into();
+ T::Currency::make_free_balance_be(&new_invulnerable, bond.clone());
+
+ <session::Pallet<T>>::set_keys(
+ RawOrigin::Signed(new_invulnerable.clone()).into(),
+ keys::<T>(b + 1),
+ Vec::new()
+ ).unwrap();
+
+ let root_origin = T::UpdateOrigin::successful_origin();
}: {
assert_ok!(
- <CollatorSelection<T>>::add_invulnerable(origin, new_invulnerable.clone())
+ <CollatorSelection<T>>::add_invulnerable(root_origin, new_invulnerable.clone())
);
}
verify {
@@ -150,52 +186,28 @@
remove_invulnerable {
let b in 1 .. T::MaxCollators::get();
- let new_invulnerable = register_validators::<T>(b)[0].clone();
- let origin = T::UpdateOrigin::successful_origin();
- assert_ok!(
- <CollatorSelection<T>>::add_invulnerable(origin.clone(), new_invulnerable.clone())
- );
- }: {
- assert_ok!(
- <CollatorSelection<T>>::remove_invulnerable(origin, new_invulnerable.clone())
- );
- }
- verify {
- assert_last_event::<T>(Event::InvulnerableRemoved{invulnerable: new_invulnerable}.into());
- }
+ register_validators::<T>(b);
+ register_invulnerables::<T>(b);
- /*set_desired_collators {
- let max: u32 = 999;
- let origin = T::UpdateOrigin::successful_origin();
+ let root_origin = T::UpdateOrigin::successful_origin();
+ let leaving = <Invulnerables<T>>::get().last().unwrap().clone();
+ whitelist!(leaving);
}: {
assert_ok!(
- <CollatorSelection<T>>::set_desired_collators(origin, max.clone())
+ <CollatorSelection<T>>::remove_invulnerable(root_origin, leaving.clone())
);
}
verify {
- assert_last_event::<T>(Event::NewDesiredCollators{desired_collators: max}.into());
+ assert_last_event::<T>(Event::InvulnerableRemoved{invulnerable: leaving}.into());
}
- set_license_bond {
- let bond_amount: BalanceOf<T> = T::Currency::minimum_balance() * 10u32.into();
- let origin = T::UpdateOrigin::successful_origin();
- }: {
- assert_ok!(
- <CollatorSelection<T>>::set_license_bond(origin, bond_amount.clone())
- );
- }
- verify {
- assert_last_event::<T>(Event::NewLicenseBond{bond_amount}.into());
- }*/
-
get_license {
let c in 1 .. T::MaxCollators::get();
<LicenseBond<T>>::put(T::Currency::minimum_balance());
- <DesiredCollators<T>>::put(c + 1);
register_validators::<T>(c);
- register_candidates::<T>(c);
+ get_licenses::<T>(c);
let caller: T::AccountId = whitelisted_caller();
let bond: BalanceOf<T> = T::Currency::minimum_balance() * 2u32.into();
@@ -215,10 +227,10 @@
// worst case is when we have all the max-candidate slots filled except one, and we fill that
// one.
onboard {
- let c in 1 .. T::MaxCollators::get();
+ let c in 1 .. 5;
<LicenseBond<T>>::put(T::Currency::minimum_balance());
- <DesiredCollators<T>>::put(c + 1);
+ <DesiredCollators<T>>::put(c + 2);
register_validators::<T>(c);
register_candidates::<T>(c);
@@ -247,7 +259,7 @@
offboard {
let c in 1 .. T::MaxCollators::get();
<LicenseBond<T>>::put(T::Currency::minimum_balance());
- <DesiredCollators<T>>::put(c);
+ <DesiredCollators<T>>::put(c + 2);
register_validators::<T>(c);
register_candidates::<T>(c);
pallets/collator-selection/src/lib.rsdiffbeforeafterboth--- a/pallets/collator-selection/src/lib.rs
+++ b/pallets/collator-selection/src/lib.rs
@@ -285,7 +285,7 @@
impl<T: Config> Pallet<T> {
/// Add a collator to the list of invulnerable (fixed) collators.
#[pallet::call_index(0)]
- #[pallet::weight(T::WeightInfo::add_invulnerable(T::MaxCollators::get()))]
+ #[pallet::weight(<T as Config>::WeightInfo::add_invulnerable(T::MaxCollators::get()))]
pub fn add_invulnerable(
origin: OriginFor<T>,
new: T::AccountId,
@@ -315,7 +315,7 @@
/// Remove a collator from the list of invulnerable (fixed) collators.
#[pallet::call_index(1)]
- #[pallet::weight(T::WeightInfo::remove_invulnerable(T::MaxCollators::get()))]
+ #[pallet::weight(<T as Config>::WeightInfo::remove_invulnerable(T::MaxCollators::get()))]
pub fn remove_invulnerable(
origin: OriginFor<T>,
who: T::AccountId,
@@ -344,7 +344,7 @@
///
/// This call is not available to `Invulnerable` collators.
#[pallet::call_index(2)]
- #[pallet::weight(T::WeightInfo::get_license(T::MaxCollators::get()))]
+ #[pallet::weight(<T as Config>::WeightInfo::get_license(T::MaxCollators::get()))]
pub fn get_license(origin: OriginFor<T>) -> DispatchResultWithPostInfo {
// register_as_candidate
let who = ensure_signed(origin)?;
@@ -377,7 +377,7 @@
///
/// This call is not available to `Invulnerable` collators.
#[pallet::call_index(3)]
- #[pallet::weight(T::WeightInfo::onboard(T::MaxCollators::get()))]
+ #[pallet::weight(<T as Config>::WeightInfo::onboard(T::MaxCollators::get()))]
pub fn onboard(origin: OriginFor<T>) -> DispatchResultWithPostInfo {
// register_as_candidate
let who = ensure_signed(origin)?;
@@ -417,33 +417,36 @@
})?;
Self::deposit_event(Event::CandidateAdded { account_id: who });
- Ok(Some(T::WeightInfo::onboard(current_count as u32)).into())
+ Ok(Some(<T as Config>::WeightInfo::onboard(current_count as u32)).into())
}
/// Deregister `origin` as a collator candidate. Note that the collator can only leave on
/// session change. The license to `onboard` later at any other time will remain.
#[pallet::call_index(4)]
- #[pallet::weight(T::WeightInfo::offboard(T::MaxCollators::get()))]
+ #[pallet::weight(<T as Config>::WeightInfo::offboard(T::MaxCollators::get()))]
pub fn offboard(origin: OriginFor<T>) -> DispatchResultWithPostInfo {
// leave_intent
let who = ensure_signed(origin)?;
let current_count = Self::try_remove_candidate(&who)?;
- Ok(Some(T::WeightInfo::offboard(current_count as u32)).into())
+ Ok(Some(<T as Config>::WeightInfo::offboard(current_count as u32)).into())
}
/// Forfeit `origin`'s own license. The `LicenseBond` will be unreserved immediately.
///
/// This call is not available to `Invulnerable` collators.
#[pallet::call_index(5)]
- #[pallet::weight(T::WeightInfo::release_license(T::MaxCollators::get()))]
+ #[pallet::weight(<T as Config>::WeightInfo::release_license(T::MaxCollators::get()))]
pub fn release_license(origin: OriginFor<T>) -> DispatchResultWithPostInfo {
// leave_intent
let who = ensure_signed(origin)?;
let current_count = Self::try_remove_candidate_and_release_license(&who, false, true)?;
- Ok(Some(T::WeightInfo::release_license(current_count as u32)).into())
+ Ok(Some(<T as Config>::WeightInfo::release_license(
+ current_count as u32,
+ ))
+ .into())
}
/// Force deregister `origin` as a collator candidate as a governing authority, and revoke its license.
@@ -452,7 +455,7 @@
///
/// This call is, of course, not applicable to `Invulnerable` collators.
#[pallet::call_index(6)]
- #[pallet::weight(T::WeightInfo::force_release_license(T::MaxCollators::get()))]
+ #[pallet::weight(<T as Config>::WeightInfo::force_release_license(T::MaxCollators::get()))]
pub fn force_release_license(
origin: OriginFor<T>,
who: T::AccountId,
@@ -462,7 +465,10 @@
let current_count = Self::try_remove_candidate_and_release_license(&who, false, true)?;
- Ok(Some(T::WeightInfo::force_release_license(current_count as u32)).into())
+ Ok(Some(<T as Config>::WeightInfo::force_release_license(
+ current_count as u32,
+ ))
+ .into())
}
}
@@ -599,7 +605,7 @@
<LastAuthoredBlock<T>>::insert(author, frame_system::Pallet::<T>::block_number());
frame_system::Pallet::<T>::register_extra_weight_unchecked(
- T::WeightInfo::note_author(),
+ <T as Config>::WeightInfo::note_author(),
DispatchClass::Mandatory,
);
}
@@ -625,7 +631,10 @@
let result = Self::assemble_collators(active_candidates);
frame_system::Pallet::<T>::register_extra_weight_unchecked(
- T::WeightInfo::new_session(candidates_len_before as u32, removed as u32),
+ <T as Config>::WeightInfo::new_session(
+ candidates_len_before as u32,
+ removed as u32,
+ ),
DispatchClass::Mandatory,
);
Some(result)
pallets/collator-selection/src/mock.rsdiffbeforeafterboth1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617// Original license:18// Copyright (C) 2021 Parity Technologies (UK) Ltd.19// SPDX-License-Identifier: Apache-2.02021// Licensed under the Apache License, Version 2.0 (the "License");22// you may not use this file except in compliance with the License.23// You may obtain a copy of the License at24//25// http://www.apache.org/licenses/LICENSE-2.026//27// Unless required by applicable law or agreed to in writing, software28// distributed under the License is distributed on an "AS IS" BASIS,29// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.30// See the License for the specific language governing permissions and31// limitations under the License.3233use super::*;34use crate as collator_selection;35use frame_support::{36 ord_parameter_types, parameter_types,37 traits::{FindAuthor, GenesisBuild, ValidatorRegistration},38 PalletId,39};40use frame_system as system;41use frame_system::EnsureSignedBy;42use sp_core::H256;43use sp_runtime::{44 testing::{Header, UintAuthorityId},45 traits::{BlakeTwo256, IdentityLookup, OpaqueKeys},46 Perbill, RuntimeAppPublic,47};4849type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;50type Block = frame_system::mocking::MockBlock<Test>;5152// Configure a mock runtime to test the pallet.53frame_support::construct_runtime!(54 pub enum Test where55 Block = Block,56 NodeBlock = Block,57 UncheckedExtrinsic = UncheckedExtrinsic,58 {59 System: frame_system::{Pallet, Call, Config, Storage, Event<T>},60 Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent},61 Session: pallet_session::{Pallet, Call, Storage, Event, Config<T>},62 Aura: pallet_aura::{Pallet, Storage, Config<T>},63 Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},64 CollatorSelection: collator_selection::{Pallet, Call, Storage, Event<T>},65 Authorship: pallet_authorship::{Pallet, Call, Storage, Inherent},66 Configuration: pallet_configuration::{Pallet, Call, Storage, Event<T>},67 }68);6970parameter_types! {71 pub const BlockHashCount: u64 = 250;72 pub const SS58Prefix: u8 = 42;73}7475impl system::Config for Test {76 type BaseCallFilter = frame_support::traits::Everything;77 type BlockWeights = ();78 type BlockLength = ();79 type DbWeight = ();80 type RuntimeOrigin = RuntimeOrigin;81 type RuntimeCall = RuntimeCall;82 type Index = u64;83 type BlockNumber = u64;84 type Hash = H256;85 type Hashing = BlakeTwo256;86 type AccountId = u64;87 type Lookup = IdentityLookup<Self::AccountId>;88 type Header = Header;89 type RuntimeEvent = RuntimeEvent;90 type BlockHashCount = BlockHashCount;91 type Version = ();92 type PalletInfo = PalletInfo;93 type AccountData = pallet_balances::AccountData<u64>;94 type OnNewAccount = ();95 type OnKilledAccount = ();96 type SystemWeightInfo = ();97 type SS58Prefix = SS58Prefix;98 type OnSetCode = ();99 type MaxConsumers = frame_support::traits::ConstU32<16>;100}101102parameter_types! {103 pub const ExistentialDeposit: u64 = 5;104 pub const MaxReserves: u32 = 50;105}106107impl pallet_balances::Config for Test {108 type Balance = u64;109 type RuntimeEvent = RuntimeEvent;110 type DustRemoval = ();111 type ExistentialDeposit = ExistentialDeposit;112 type AccountStore = System;113 type WeightInfo = ();114 type MaxLocks = ();115 type MaxReserves = MaxReserves;116 type ReserveIdentifier = [u8; 8];117}118119pub struct Author4;120impl FindAuthor<u64> for Author4 {121 fn find_author<'a, I>(_digests: I) -> Option<u64>122 where123 I: 'a + IntoIterator<Item = (frame_support::ConsensusEngineId, &'a [u8])>,124 {125 Some(4)126 }127}128129impl pallet_authorship::Config for Test {130 type FindAuthor = Author4;131 type UncleGenerations = ();132 type FilterUncle = ();133 type EventHandler = CollatorSelection;134}135136parameter_types! {137 pub const MinimumPeriod: u64 = 1;138}139140impl pallet_timestamp::Config for Test {141 type Moment = u64;142 type OnTimestampSet = Aura;143 type MinimumPeriod = MinimumPeriod;144 type WeightInfo = ();145}146147impl pallet_aura::Config for Test {148 type AuthorityId = sp_consensus_aura::sr25519::AuthorityId;149 type MaxAuthorities = MaxAuthorities;150 type DisabledValidators = ();151}152153sp_runtime::impl_opaque_keys! {154 pub struct MockSessionKeys {155 // a key for aura authoring156 pub aura: UintAuthorityId,157 }158}159160impl From<UintAuthorityId> for MockSessionKeys {161 fn from(aura: sp_runtime::testing::UintAuthorityId) -> Self {162 Self { aura }163 }164}165166parameter_types! {167 pub static SessionHandlerCollators: Vec<u64> = Vec::new();168 pub static SessionChangeBlock: u64 = 0;169}170171pub struct TestSessionHandler;172impl pallet_session::SessionHandler<u64> for TestSessionHandler {173 const KEY_TYPE_IDS: &'static [sp_runtime::KeyTypeId] = &[UintAuthorityId::ID];174 fn on_genesis_session<Ks: OpaqueKeys>(keys: &[(u64, Ks)]) {175 SessionHandlerCollators::set(keys.into_iter().map(|(a, _)| *a).collect::<Vec<_>>())176 }177 fn on_new_session<Ks: OpaqueKeys>(_: bool, keys: &[(u64, Ks)], _: &[(u64, Ks)]) {178 SessionChangeBlock::set(System::block_number());179 dbg!(keys.len());180 SessionHandlerCollators::set(keys.into_iter().map(|(a, _)| *a).collect::<Vec<_>>())181 }182 fn on_before_session_ending() {}183 fn on_disabled(_: u32) {}184}185186parameter_types! {187 pub const Offset: u64 = 0;188 pub const Period: u64 = 10;189}190191impl pallet_session::Config for Test {192 type RuntimeEvent = RuntimeEvent;193 type ValidatorId = <Self as frame_system::Config>::AccountId;194 // we don't have stash and controller, thus we don't need the convert as well.195 type ValidatorIdOf = IdentityCollator;196 type ShouldEndSession = pallet_session::PeriodicSessions<Period, Offset>;197 type NextSessionRotation = pallet_session::PeriodicSessions<Period, Offset>;198 type SessionManager = CollatorSelection;199 type SessionHandler = TestSessionHandler;200 type Keys = MockSessionKeys;201 type WeightInfo = ();202}203204parameter_types! {205 pub const MaxCollators: u32 = 5;206 pub const LicenseBond: u64 = 10;207 pub const KickThreshold: u64 = 10;208 // the following values do not matter and are meaningless, etc.209 pub const DefaultWeightToFeeCoefficient: u64 = 100_000;210 pub const DefaultMinGasPrice: u64 = 100_000;211 pub const MaxXcmAllowedLocations: u32 = 16;212 pub AppPromotionDailyRate: Perbill = Perbill::from_rational(5u32, 10_000);213 pub const DayRelayBlocks: u32 = 1;214}215216impl pallet_configuration::Config for Test {217 type RuntimeEvent = RuntimeEvent;218 type Currency = Balances;219 type DefaultCollatorSelectionMaxCollators = MaxCollators;220 type DefaultCollatorSelectionKickThreshold = KickThreshold;221 type DefaultCollatorSelectionLicenseBond = LicenseBond;222 // the following we don't care about223 type DefaultWeightToFeeCoefficient = DefaultWeightToFeeCoefficient;224 type DefaultMinGasPrice = DefaultMinGasPrice;225 type MaxXcmAllowedLocations = MaxXcmAllowedLocations;226 type AppPromotionDailyRate = AppPromotionDailyRate;227 type DayRelayBlocks = DayRelayBlocks;228}229230ord_parameter_types! {231 pub const RootAccount: u64 = 777;232}233234parameter_types! {235 pub const PotId: PalletId = PalletId(*b"PotStake");236 pub const MaxAuthorities: u32 = 100_000;237 pub const SlashRatio: Perbill = Perbill::one();238}239240pub struct IsRegistered;241impl ValidatorRegistration<u64> for IsRegistered {242 fn is_registered(id: &u64) -> bool {243 if *id == 7u64 {244 false245 } else {246 true247 }248 }249}250251impl Config for Test {252 type RuntimeEvent = RuntimeEvent;253 type UpdateOrigin = EnsureSignedBy<RootAccount, u64>;254 type PotId = PotId;255 type MaxCollators = MaxCollators;256 type SlashRatio = SlashRatio;257 type TreasuryAccountId = ();258 type ValidatorId = <Self as frame_system::Config>::AccountId;259 type ValidatorIdOf = IdentityCollator;260 type ValidatorRegistration = IsRegistered;261 type WeightInfo = ();262}263264pub fn new_test_ext() -> sp_io::TestExternalities {265 sp_tracing::try_init_simple();266 let mut t = frame_system::GenesisConfig::default()267 .build_storage::<Test>()268 .unwrap();269 let invulnerables = vec![1, 2];270271 let balances = vec![(1, 100), (2, 100), (3, 100), (4, 100), (5, 100)];272 let keys = balances273 .iter()274 .map(|&(i, _)| {275 (276 i,277 i,278 MockSessionKeys {279 aura: UintAuthorityId(i),280 },281 )282 })283 .collect::<Vec<_>>();284 let collator_selection = collator_selection::GenesisConfig::<Test> { invulnerables };285 let session = pallet_session::GenesisConfig::<Test> { keys };286 pallet_balances::GenesisConfig::<Test> { balances }287 .assimilate_storage(&mut t)288 .unwrap();289 // collator selection must be initialized before session.290 collator_selection.assimilate_storage(&mut t).unwrap();291 session.assimilate_storage(&mut t).unwrap();292293 t.into()294}295296pub fn initialize_to_block(n: u64) {297 for i in System::block_number() + 1..=n {298 System::set_block_number(i);299 <AllPalletsWithSystem as frame_support::traits::OnInitialize<u64>>::on_initialize(i);300 }301}1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617// Original license:18// Copyright (C) 2021 Parity Technologies (UK) Ltd.19// SPDX-License-Identifier: Apache-2.02021// Licensed under the Apache License, Version 2.0 (the "License");22// you may not use this file except in compliance with the License.23// You may obtain a copy of the License at24//25// http://www.apache.org/licenses/LICENSE-2.026//27// Unless required by applicable law or agreed to in writing, software28// distributed under the License is distributed on an "AS IS" BASIS,29// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.30// See the License for the specific language governing permissions and31// limitations under the License.3233use super::*;34use crate as collator_selection;35use frame_support::{36 ord_parameter_types, parameter_types,37 traits::{FindAuthor, GenesisBuild, ValidatorRegistration},38 PalletId,39};40use frame_system as system;41use frame_system::EnsureSignedBy;42use sp_core::H256;43use sp_runtime::{44 testing::{Header, UintAuthorityId},45 traits::{BlakeTwo256, IdentityLookup, OpaqueKeys},46 Perbill, RuntimeAppPublic,47};4849type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;50type Block = frame_system::mocking::MockBlock<Test>;5152// Configure a mock runtime to test the pallet.53frame_support::construct_runtime!(54 pub enum Test where55 Block = Block,56 NodeBlock = Block,57 UncheckedExtrinsic = UncheckedExtrinsic,58 {59 System: frame_system::{Pallet, Call, Config, Storage, Event<T>},60 Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent},61 Session: pallet_session::{Pallet, Call, Storage, Event, Config<T>},62 Aura: pallet_aura::{Pallet, Storage, Config<T>},63 Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},64 CollatorSelection: collator_selection::{Pallet, Call, Storage, Event<T>},65 Authorship: pallet_authorship::{Pallet, Call, Storage, Inherent},66 Configuration: pallet_configuration::{Pallet, Call, Storage, Event<T>},67 }68);6970parameter_types! {71 pub const BlockHashCount: u64 = 250;72 pub const SS58Prefix: u8 = 42;73}7475impl system::Config for Test {76 type BaseCallFilter = frame_support::traits::Everything;77 type BlockWeights = ();78 type BlockLength = ();79 type DbWeight = ();80 type RuntimeOrigin = RuntimeOrigin;81 type RuntimeCall = RuntimeCall;82 type Index = u64;83 type BlockNumber = u64;84 type Hash = H256;85 type Hashing = BlakeTwo256;86 type AccountId = u64;87 type Lookup = IdentityLookup<Self::AccountId>;88 type Header = Header;89 type RuntimeEvent = RuntimeEvent;90 type BlockHashCount = BlockHashCount;91 type Version = ();92 type PalletInfo = PalletInfo;93 type AccountData = pallet_balances::AccountData<u64>;94 type OnNewAccount = ();95 type OnKilledAccount = ();96 type SystemWeightInfo = ();97 type SS58Prefix = SS58Prefix;98 type OnSetCode = ();99 type MaxConsumers = frame_support::traits::ConstU32<16>;100}101102parameter_types! {103 pub const ExistentialDeposit: u64 = 5;104 pub const MaxReserves: u32 = 50;105}106107impl pallet_balances::Config for Test {108 type Balance = u64;109 type RuntimeEvent = RuntimeEvent;110 type DustRemoval = ();111 type ExistentialDeposit = ExistentialDeposit;112 type AccountStore = System;113 type WeightInfo = ();114 type MaxLocks = ();115 type MaxReserves = MaxReserves;116 type ReserveIdentifier = [u8; 8];117}118119pub struct Author4;120impl FindAuthor<u64> for Author4 {121 fn find_author<'a, I>(_digests: I) -> Option<u64>122 where123 I: 'a + IntoIterator<Item = (frame_support::ConsensusEngineId, &'a [u8])>,124 {125 Some(4)126 }127}128129impl pallet_authorship::Config for Test {130 type FindAuthor = Author4;131 type UncleGenerations = ();132 type FilterUncle = ();133 type EventHandler = CollatorSelection;134}135136parameter_types! {137 pub const MinimumPeriod: u64 = 1;138}139140impl pallet_timestamp::Config for Test {141 type Moment = u64;142 type OnTimestampSet = Aura;143 type MinimumPeriod = MinimumPeriod;144 type WeightInfo = ();145}146147impl pallet_aura::Config for Test {148 type AuthorityId = sp_consensus_aura::sr25519::AuthorityId;149 type MaxAuthorities = MaxAuthorities;150 type DisabledValidators = ();151}152153sp_runtime::impl_opaque_keys! {154 pub struct MockSessionKeys {155 // a key for aura authoring156 pub aura: UintAuthorityId,157 }158}159160impl From<UintAuthorityId> for MockSessionKeys {161 fn from(aura: sp_runtime::testing::UintAuthorityId) -> Self {162 Self { aura }163 }164}165166parameter_types! {167 pub static SessionHandlerCollators: Vec<u64> = Vec::new();168 pub static SessionChangeBlock: u64 = 0;169}170171pub struct TestSessionHandler;172impl pallet_session::SessionHandler<u64> for TestSessionHandler {173 const KEY_TYPE_IDS: &'static [sp_runtime::KeyTypeId] = &[UintAuthorityId::ID];174 fn on_genesis_session<Ks: OpaqueKeys>(keys: &[(u64, Ks)]) {175 SessionHandlerCollators::set(keys.into_iter().map(|(a, _)| *a).collect::<Vec<_>>())176 }177 fn on_new_session<Ks: OpaqueKeys>(_: bool, keys: &[(u64, Ks)], _: &[(u64, Ks)]) {178 SessionChangeBlock::set(System::block_number());179 dbg!(keys.len());180 SessionHandlerCollators::set(keys.into_iter().map(|(a, _)| *a).collect::<Vec<_>>())181 }182 fn on_before_session_ending() {}183 fn on_disabled(_: u32) {}184}185186parameter_types! {187 pub const Offset: u64 = 0;188 pub const Period: u64 = 10;189}190191impl pallet_session::Config for Test {192 type RuntimeEvent = RuntimeEvent;193 type ValidatorId = <Self as frame_system::Config>::AccountId;194 // we don't have stash and controller, thus we don't need the convert as well.195 type ValidatorIdOf = IdentityCollator;196 type ShouldEndSession = pallet_session::PeriodicSessions<Period, Offset>;197 type NextSessionRotation = pallet_session::PeriodicSessions<Period, Offset>;198 type SessionManager = CollatorSelection;199 type SessionHandler = TestSessionHandler;200 type Keys = MockSessionKeys;201 type WeightInfo = ();202}203204parameter_types! {205 pub const MaxCollators: u32 = 5;206 pub const LicenseBond: u64 = 10;207 pub const KickThreshold: u64 = 10;208 // the following values do not matter and are meaningless, etc.209 pub const DefaultWeightToFeeCoefficient: u64 = 100_000;210 pub const DefaultMinGasPrice: u64 = 100_000;211 pub const MaxXcmAllowedLocations: u32 = 16;212 pub AppPromotionDailyRate: Perbill = Perbill::from_rational(5u32, 10_000);213 pub const DayRelayBlocks: u32 = 1;214}215216impl pallet_configuration::Config for Test {217 type RuntimeEvent = RuntimeEvent;218 type Currency = Balances;219 type DefaultCollatorSelectionMaxCollators = MaxCollators;220 type DefaultCollatorSelectionKickThreshold = KickThreshold;221 type DefaultCollatorSelectionLicenseBond = LicenseBond;222 // the following we don't care about223 type DefaultWeightToFeeCoefficient = DefaultWeightToFeeCoefficient;224 type DefaultMinGasPrice = DefaultMinGasPrice;225 type MaxXcmAllowedLocations = MaxXcmAllowedLocations;226 type AppPromotionDailyRate = AppPromotionDailyRate;227 type DayRelayBlocks = DayRelayBlocks;228 type WeightInfo = ();229}230231ord_parameter_types! {232 pub const RootAccount: u64 = 777;233}234235parameter_types! {236 pub const PotId: PalletId = PalletId(*b"PotStake");237 pub const MaxAuthorities: u32 = 100_000;238 pub const SlashRatio: Perbill = Perbill::one();239}240241pub struct IsRegistered;242impl ValidatorRegistration<u64> for IsRegistered {243 fn is_registered(id: &u64) -> bool {244 if *id == 7u64 {245 false246 } else {247 true248 }249 }250}251252impl Config for Test {253 type RuntimeEvent = RuntimeEvent;254 type UpdateOrigin = EnsureSignedBy<RootAccount, u64>;255 type PotId = PotId;256 type MaxCollators = MaxCollators;257 type SlashRatio = SlashRatio;258 type TreasuryAccountId = ();259 type ValidatorId = <Self as frame_system::Config>::AccountId;260 type ValidatorIdOf = IdentityCollator;261 type ValidatorRegistration = IsRegistered;262 type WeightInfo = ();263}264265pub fn new_test_ext() -> sp_io::TestExternalities {266 sp_tracing::try_init_simple();267 let mut t = frame_system::GenesisConfig::default()268 .build_storage::<Test>()269 .unwrap();270 let invulnerables = vec![1, 2];271272 let balances = vec![(1, 100), (2, 100), (3, 100), (4, 100), (5, 100)];273 let keys = balances274 .iter()275 .map(|&(i, _)| {276 (277 i,278 i,279 MockSessionKeys {280 aura: UintAuthorityId(i),281 },282 )283 })284 .collect::<Vec<_>>();285 let collator_selection = collator_selection::GenesisConfig::<Test> { invulnerables };286 let session = pallet_session::GenesisConfig::<Test> { keys };287 pallet_balances::GenesisConfig::<Test> { balances }288 .assimilate_storage(&mut t)289 .unwrap();290 // collator selection must be initialized before session.291 collator_selection.assimilate_storage(&mut t).unwrap();292 session.assimilate_storage(&mut t).unwrap();293294 t.into()295}296297pub fn initialize_to_block(n: u64) {298 for i in System::block_number() + 1..=n {299 System::set_block_number(i);300 <AllPalletsWithSystem as frame_support::traits::OnInitialize<u64>>::on_initialize(i);301 }302}pallets/configuration/Cargo.tomldiffbeforeafterboth--- a/pallets/configuration/Cargo.toml
+++ b/pallets/configuration/Cargo.toml
@@ -12,6 +12,7 @@
] }
frame-support = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" }
frame-system = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" }
+frame-benchmarking = { default-features = false, optional = true, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" }
sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" }
sp-std = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" }
sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" }
@@ -22,10 +23,12 @@
[features]
default = ["std"]
+runtime-benchmarks = ["frame-benchmarking"]
std = [
"parity-scale-codec/std",
"frame-support/std",
"frame-system/std",
+ "frame-benchmarking/std",
"sp-runtime/std",
"sp-std/std",
"sp-core/std",
pallets/configuration/src/benchmarking.rsdiffbeforeafterboth--- /dev/null
+++ b/pallets/configuration/src/benchmarking.rs
@@ -0,0 +1,100 @@
+// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
+// This file is part of Unique Network.
+
+// Unique Network 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.
+
+// Unique Network 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 Unique Network. If not, see <http://www.gnu.org/licenses/>.
+
+//! Benchmarking setup for pallet-configuration
+
+use super::*;
+use frame_benchmarking::benchmarks;
+use frame_system::{EventRecord, RawOrigin};
+use frame_support::{assert_ok, BoundedVec, traits::Currency};
+use xcm::v1::MultiLocation;
+
+fn assert_last_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {
+ let events = frame_system::Pallet::<T>::events();
+ let system_event: <T as frame_system::Config>::RuntimeEvent = generic_event.into();
+ // compare to the last event record
+ let EventRecord { event, .. } = &events[events.len() - 1];
+ assert_eq!(event, &system_event);
+}
+
+benchmarks! {
+ where_clause { where T: Config }
+
+ set_weight_to_fee_coefficient_override {
+ let coeff: u64 = 999;
+ }: {
+ assert_ok!(
+ <Pallet<T>>::set_weight_to_fee_coefficient_override(RawOrigin::Root.into(), Some(coeff))
+ );
+ }
+
+ set_min_gas_price_override {
+ let coeff: u64 = 999;
+ }: {
+ assert_ok!(
+ <Pallet<T>>::set_min_gas_price_override(RawOrigin::Root.into(), Some(coeff))
+ );
+ }
+
+ set_xcm_allowed_locations {
+ let locations: BoundedVec<MultiLocation, T::MaxXcmAllowedLocations> = Default::default();
+ }: {
+ assert_ok!(
+ <Pallet<T>>::set_xcm_allowed_locations(RawOrigin::Root.into(), Some(locations))
+ );
+ }
+
+ set_app_promotion_configuration_override {
+ let configuration: AppPromotionConfiguration<T::BlockNumber> = Default::default();
+ }: {
+ assert_ok!(
+ <Pallet<T>>::set_app_promotion_configuration_override(RawOrigin::Root.into(), configuration)
+ );
+ }
+
+ set_collator_selection_desired_collators {
+ let max: u32 = 999;
+ }: {
+ assert_ok!(
+ <Pallet<T>>::set_collator_selection_desired_collators(RawOrigin::Root.into(), Some(max.clone()))
+ );
+ }
+ verify {
+ assert_last_event::<T>(Event::NewDesiredCollators{desired_collators: Some(max)}.into());
+ }
+
+ set_collator_selection_license_bond {
+ let bond_cost: Option<BalanceOf<T>> = Some(T::Currency::minimum_balance() * 10u32.into());
+ }: {
+ assert_ok!(
+ <Pallet<T>>::set_collator_selection_license_bond(RawOrigin::Root.into(), bond_cost.clone())
+ );
+ }
+ verify {
+ assert_last_event::<T>(Event::NewCollatorLicenseBond{bond_cost}.into());
+ }
+
+ set_collator_selection_kick_threshold {
+ let threshold: Option<T::BlockNumber> = Some(900u32.into());
+ }: {
+ assert_ok!(
+ <Pallet<T>>::set_collator_selection_kick_threshold(RawOrigin::Root.into(), threshold.clone())
+ );
+ }
+ verify {
+ assert_last_event::<T>(Event::NewCollatorKickThreshold{length_in_blocks: threshold}.into());
+ }
+}
pallets/configuration/src/lib.rsdiffbeforeafterboth--- a/pallets/configuration/src/lib.rs
+++ b/pallets/configuration/src/lib.rs
@@ -34,6 +34,10 @@
pub use pallet::*;
use sp_core::U256;
+#[cfg(feature = "runtime-benchmarks")]
+mod benchmarking;
+pub mod weights;
+
#[pallet]
mod pallet {
use super::*;
@@ -45,6 +49,7 @@
use frame_system::{pallet_prelude::OriginFor, ensure_root, Config as SystemConfig};
use xcm::v1::MultiLocation;
+ pub use crate::weights::WeightInfo;
pub type BalanceOf<T> =
<<T as Config>::Currency as Currency<<T as SystemConfig>::AccountId>>::Balance;
@@ -74,6 +79,9 @@
type DefaultCollatorSelectionLicenseBond: Get<BalanceOf<Self>>;
#[pallet::constant]
type DefaultCollatorSelectionKickThreshold: Get<Self::BlockNumber>;
+
+ /// The weight information of this pallet.
+ type WeightInfo: WeightInfo;
}
#[pallet::event]
@@ -140,7 +148,7 @@
#[pallet::call]
impl<T: Config> Pallet<T> {
#[pallet::call_index(0)]
- #[pallet::weight(T::DbWeight::get().writes(1))]
+ #[pallet::weight(T::WeightInfo::set_weight_to_fee_coefficient_override())]
pub fn set_weight_to_fee_coefficient_override(
origin: OriginFor<T>,
coeff: Option<u64>,
@@ -155,7 +163,7 @@
}
#[pallet::call_index(1)]
- #[pallet::weight(T::DbWeight::get().writes(1))]
+ #[pallet::weight(T::WeightInfo::set_min_gas_price_override())]
pub fn set_min_gas_price_override(
origin: OriginFor<T>,
coeff: Option<u64>,
@@ -170,7 +178,7 @@
}
#[pallet::call_index(2)]
- #[pallet::weight(T::DbWeight::get().writes(1))]
+ #[pallet::weight(T::WeightInfo::set_xcm_allowed_locations())]
pub fn set_xcm_allowed_locations(
origin: OriginFor<T>,
locations: Option<BoundedVec<MultiLocation, T::MaxXcmAllowedLocations>>,
@@ -181,7 +189,7 @@
}
#[pallet::call_index(3)]
- #[pallet::weight(T::DbWeight::get().writes(1))]
+ #[pallet::weight(T::WeightInfo::set_app_promotion_configuration_override())]
pub fn set_app_promotion_configuration_override(
origin: OriginFor<T>,
mut configuration: AppPromotionConfiguration<T::BlockNumber>,
@@ -202,7 +210,7 @@
}
#[pallet::call_index(4)]
- #[pallet::weight(T::DbWeight::get().writes(1))]
+ #[pallet::weight(T::WeightInfo::set_collator_selection_desired_collators())]
pub fn set_collator_selection_desired_collators(
origin: OriginFor<T>,
max: Option<u32>,
@@ -224,7 +232,7 @@
}
#[pallet::call_index(5)]
- #[pallet::weight(T::DbWeight::get().writes(1))]
+ #[pallet::weight(T::WeightInfo::set_collator_selection_license_bond())]
pub fn set_collator_selection_license_bond(
origin: OriginFor<T>,
amount: Option<BalanceOf<T>>,
@@ -240,7 +248,7 @@
}
#[pallet::call_index(6)]
- #[pallet::weight(T::DbWeight::get().writes(1))]
+ #[pallet::weight(T::WeightInfo::set_collator_selection_kick_threshold())]
pub fn set_collator_selection_kick_threshold(
origin: OriginFor<T>,
threshold: Option<T::BlockNumber>,
pallets/configuration/src/weights.rsdiffbeforeafterboth--- /dev/null
+++ b/pallets/configuration/src/weights.rs
@@ -0,0 +1,123 @@
+// Template adopted from https://github.com/paritytech/substrate/blob/master/.maintain/frame-weight-template.hbs
+
+//! Autogenerated weights for pallet_configuration
+//!
+//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
+//! DATE: 2022-12-28, STEPS: `50`, REPEAT: 80, LOW RANGE: `[]`, HIGH RANGE: `[]`
+//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024
+
+// Executed Command:
+// target/release/unique-collator
+// benchmark
+// pallet
+// --pallet
+// pallet-configuration
+// --wasm-execution
+// compiled
+// --extrinsic
+// *
+// --template
+// .maintain/frame-weight-template.hbs
+// --steps=50
+// --repeat=80
+// --heap-pages=4096
+// --output=./pallets/configuration/src/weights.rs
+
+#![cfg_attr(rustfmt, rustfmt_skip)]
+#![allow(unused_parens)]
+#![allow(unused_imports)]
+#![allow(missing_docs)]
+#![allow(clippy::unnecessary_cast)]
+
+use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
+use sp_std::marker::PhantomData;
+
+/// Weight functions needed for pallet_configuration.
+pub trait WeightInfo {
+ fn set_weight_to_fee_coefficient_override() -> Weight;
+ fn set_min_gas_price_override() -> Weight;
+ fn set_xcm_allowed_locations() -> Weight;
+ fn set_app_promotion_configuration_override() -> Weight;
+ fn set_collator_selection_desired_collators() -> Weight;
+ fn set_collator_selection_license_bond() -> Weight;
+ fn set_collator_selection_kick_threshold() -> Weight;
+}
+
+/// Weights for pallet_configuration using the Substrate node and recommended hardware.
+pub struct SubstrateWeight<T>(PhantomData<T>);
+impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
+ // Storage: Configuration WeightToFeeCoefficientOverride (r:0 w:1)
+ fn set_weight_to_fee_coefficient_override() -> Weight {
+ Weight::from_ref_time(5_691_000 as u64)
+ .saturating_add(T::DbWeight::get().writes(1 as u64))
+ }
+ // Storage: Configuration MinGasPriceOverride (r:0 w:1)
+ fn set_min_gas_price_override() -> Weight {
+ Weight::from_ref_time(5_521_000 as u64)
+ .saturating_add(T::DbWeight::get().writes(1 as u64))
+ }
+ // Storage: Configuration XcmAllowedLocationsOverride (r:0 w:1)
+ fn set_xcm_allowed_locations() -> Weight {
+ Weight::from_ref_time(6_091_000 as u64)
+ .saturating_add(T::DbWeight::get().writes(1 as u64))
+ }
+ // Storage: Configuration AppPromomotionConfigurationOverride (r:0 w:1)
+ fn set_app_promotion_configuration_override() -> Weight {
+ Weight::from_ref_time(6_241_000 as u64)
+ .saturating_add(T::DbWeight::get().writes(1 as u64))
+ }
+ // Storage: Configuration CollatorSelectionDesiredCollatorsOverride (r:0 w:1)
+ fn set_collator_selection_desired_collators() -> Weight {
+ Weight::from_ref_time(25_298_000 as u64)
+ .saturating_add(T::DbWeight::get().writes(1 as u64))
+ }
+ // Storage: Configuration CollatorSelectionLicenseBondOverride (r:0 w:1)
+ fn set_collator_selection_license_bond() -> Weight {
+ Weight::from_ref_time(18_675_000 as u64)
+ .saturating_add(T::DbWeight::get().writes(1 as u64))
+ }
+ // Storage: Configuration CollatorSelectionKickThresholdOverride (r:0 w:1)
+ fn set_collator_selection_kick_threshold() -> Weight {
+ Weight::from_ref_time(18_044_000 as u64)
+ .saturating_add(T::DbWeight::get().writes(1 as u64))
+ }
+}
+
+// For backwards compatibility and tests
+impl WeightInfo for () {
+ // Storage: Configuration WeightToFeeCoefficientOverride (r:0 w:1)
+ fn set_weight_to_fee_coefficient_override() -> Weight {
+ Weight::from_ref_time(5_691_000 as u64)
+ .saturating_add(RocksDbWeight::get().writes(1 as u64))
+ }
+ // Storage: Configuration MinGasPriceOverride (r:0 w:1)
+ fn set_min_gas_price_override() -> Weight {
+ Weight::from_ref_time(5_521_000 as u64)
+ .saturating_add(RocksDbWeight::get().writes(1 as u64))
+ }
+ // Storage: Configuration XcmAllowedLocationsOverride (r:0 w:1)
+ fn set_xcm_allowed_locations() -> Weight {
+ Weight::from_ref_time(6_091_000 as u64)
+ .saturating_add(RocksDbWeight::get().writes(1 as u64))
+ }
+ // Storage: Configuration AppPromomotionConfigurationOverride (r:0 w:1)
+ fn set_app_promotion_configuration_override() -> Weight {
+ Weight::from_ref_time(6_241_000 as u64)
+ .saturating_add(RocksDbWeight::get().writes(1 as u64))
+ }
+ // Storage: Configuration CollatorSelectionDesiredCollatorsOverride (r:0 w:1)
+ fn set_collator_selection_desired_collators() -> Weight {
+ Weight::from_ref_time(25_298_000 as u64)
+ .saturating_add(RocksDbWeight::get().writes(1 as u64))
+ }
+ // Storage: Configuration CollatorSelectionLicenseBondOverride (r:0 w:1)
+ fn set_collator_selection_license_bond() -> Weight {
+ Weight::from_ref_time(18_675_000 as u64)
+ .saturating_add(RocksDbWeight::get().writes(1 as u64))
+ }
+ // Storage: Configuration CollatorSelectionKickThresholdOverride (r:0 w:1)
+ fn set_collator_selection_kick_threshold() -> Weight {
+ Weight::from_ref_time(18_044_000 as u64)
+ .saturating_add(RocksDbWeight::get().writes(1 as u64))
+ }
+}
runtime/common/config/pallets/mod.rsdiffbeforeafterboth--- a/runtime/common/config/pallets/mod.rs
+++ b/runtime/common/config/pallets/mod.rs
@@ -121,6 +121,7 @@
type MaxXcmAllowedLocations = ConstU32<16>;
type AppPromotionDailyRate = AppPromotionDailyRate;
type DayRelayBlocks = DayRelayBlocks;
+ type WeightInfo = pallet_configuration::weights::SubstrateWeight<Self>;
}
impl pallet_maintenance::Config for Runtime {
runtime/common/construct_runtime/mod.rsdiffbeforeafterboth--- a/runtime/common/construct_runtime/mod.rs
+++ b/runtime/common/construct_runtime/mod.rs
@@ -32,17 +32,17 @@
ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Config, Storage, Inherent, Event<T>, ValidateUnsigned} = 20,
ParachainInfo: parachain_info::{Pallet, Storage, Config} = 21,
- Aura: pallet_aura::{Pallet, Config<T>} = 22,
- AuraExt: cumulus_pallet_aura_ext::{Pallet, Config} = 23,
+ #[runtimes(opal)]
+ Authorship: pallet_authorship::{Pallet, Call, Storage} = 22,
#[runtimes(opal)]
- Authorship: pallet_authorship::{Pallet, Call, Storage} = 24,
+ CollatorSelection: pallet_collator_selection::{Pallet, Call, Storage, Event<T>, Config<T>} = 23,
#[runtimes(opal)]
- CollatorSelection: pallet_collator_selection::{Pallet, Call, Storage, Event<T>, Config<T>} = 25,
+ Session: pallet_session::{Pallet, Call, Storage, Event, Config<T>} = 24,
- #[runtimes(opal)]
- Session: pallet_session::{Pallet, Call, Storage, Event, Config<T>} = 26,
+ Aura: pallet_aura::{Pallet, Config<T>} = 25,
+ AuraExt: cumulus_pallet_aura_ext::{Pallet, Config} = 26,
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 30,
RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Storage} = 31,
runtime/common/runtime_apis.rsdiffbeforeafterboth--- a/runtime/common/runtime_apis.rs
+++ b/runtime/common/runtime_apis.rs
@@ -686,6 +686,7 @@
list_benchmark!(list, extra, pallet_unique, Unique);
list_benchmark!(list, extra, pallet_structure, Structure);
list_benchmark!(list, extra, pallet_inflation, Inflation);
+ list_benchmark!(list, extra, pallet_configuration, Configuration);
#[cfg(feature = "app-promotion")]
list_benchmark!(list, extra, pallet_app_promotion, AppPromotion);
@@ -755,6 +756,7 @@
add_benchmark!(params, batches, pallet_unique, Unique);
add_benchmark!(params, batches, pallet_structure, Structure);
add_benchmark!(params, batches, pallet_inflation, Inflation);
+ add_benchmark!(params, batches, pallet_configuration, Configuration);
#[cfg(feature = "app-promotion")]
add_benchmark!(params, batches, pallet_app_promotion, AppPromotion);
runtime/opal/Cargo.tomldiffbeforeafterboth--- a/runtime/opal/Cargo.toml
+++ b/runtime/opal/Cargo.toml
@@ -28,6 +28,7 @@
'pallet-evm-coder-substrate/runtime-benchmarks',
'pallet-balances/runtime-benchmarks',
'pallet-timestamp/runtime-benchmarks',
+ 'pallet-configuration/runtime-benchmarks',
'pallet-common/runtime-benchmarks',
'pallet-structure/runtime-benchmarks',
'pallet-fungible/runtime-benchmarks',
runtime/quartz/Cargo.tomldiffbeforeafterboth--- a/runtime/quartz/Cargo.toml
+++ b/runtime/quartz/Cargo.toml
@@ -28,6 +28,7 @@
'pallet-evm-coder-substrate/runtime-benchmarks',
'pallet-balances/runtime-benchmarks',
'pallet-timestamp/runtime-benchmarks',
+ 'pallet-configuration/runtime-benchmarks',
'pallet-common/runtime-benchmarks',
'pallet-structure/runtime-benchmarks',
'pallet-fungible/runtime-benchmarks',
runtime/unique/Cargo.tomldiffbeforeafterboth--- a/runtime/unique/Cargo.toml
+++ b/runtime/unique/Cargo.toml
@@ -28,6 +28,7 @@
'pallet-evm-coder-substrate/runtime-benchmarks',
'pallet-balances/runtime-benchmarks',
'pallet-timestamp/runtime-benchmarks',
+ 'pallet-configuration/runtime-benchmarks',
'pallet-common/runtime-benchmarks',
'pallet-structure/runtime-benchmarks',
'pallet-fungible/runtime-benchmarks',