git.delta.rocks / unique-network / refs/commits / 540966542a36

difftreelog

feat(configuration) benchmarks

Fahrrader2022-12-28parent: #63282b0.patch.diff
in: master

15 files changed

modifiedCargo.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",
modifiedMakefilediffbeforeafterboth
--- 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
modifiedpallets/collator-selection/src/benchmarking.rsdiffbeforeafterboth
before · pallets/collator-selection/src/benchmarking.rs
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.3233//! Benchmarking setup for pallet-collator-selection3435use super::*;3637#[allow(unused)]38use crate::Pallet as CollatorSelection;39use frame_benchmarking::{account, benchmarks, impl_benchmark_test_suite, whitelisted_caller};40use frame_support::{41	assert_ok,42	codec::Decode,43	traits::{Currency, EnsureOrigin, Get},44};45use frame_system::{EventRecord, RawOrigin};46use pallet_authorship::EventHandler;47use pallet_session::{self as session, SessionManager};48use pallet_configuration::{49	self as configuration, BalanceOf,50	CollatorSelectionDesiredCollatorsOverride as DesiredCollators,51	CollatorSelectionLicenseBondOverride as LicenseBond,52};53use sp_std::prelude::*;5455/*pub type BalanceOf<T> =56<<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance;*/5758const SEED: u32 = 0;5960// TODO: remove if this is given in substrate commit.61macro_rules! whitelist {62	($acc:ident) => {63		frame_benchmarking::benchmarking::add_to_whitelist(64			frame_system::Account::<T>::hashed_key_for(&$acc).into(),65		);66	};67}6869fn assert_last_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {70	let events = frame_system::Pallet::<T>::events();71	let system_event: <T as frame_system::Config>::RuntimeEvent = generic_event.into();72	// compare to the last event record73	let EventRecord { event, .. } = &events[events.len() - 1];74	assert_eq!(event, &system_event);75}7677fn create_funded_user<T: Config>(78	string: &'static str,79	n: u32,80	balance_factor: u32,81) -> T::AccountId {82	let user = account(string, n, SEED);83	let balance = T::Currency::minimum_balance() * balance_factor.into();84	let _ = T::Currency::make_free_balance_be(&user, balance);85	user86}8788fn keys<T: Config + session::Config>(c: u32) -> <T as session::Config>::Keys {89	use rand::{RngCore, SeedableRng};9091	let keys = {92		let mut keys = [0u8; 128];9394		if c > 0 {95			let mut rng = rand::rngs::StdRng::seed_from_u64(c as u64);96			rng.fill_bytes(&mut keys);97		}9899		keys100	};101102	Decode::decode(&mut &keys[..]).unwrap()103}104105fn validator<T: Config + session::Config>(c: u32) -> (T::AccountId, <T as session::Config>::Keys) {106	(create_funded_user::<T>("candidate", c, 1000), keys::<T>(c))107}108109fn register_validators<T: Config + session::Config>(count: u32) -> Vec<T::AccountId> {110	let validators = (0..count).map(|c| validator::<T>(c)).collect::<Vec<_>>();111112	for (who, keys) in validators.clone() {113		<session::Pallet<T>>::set_keys(RawOrigin::Signed(who).into(), keys, Vec::new()).unwrap();114	}115116	validators.into_iter().map(|(who, _)| who).collect()117}118119fn register_candidates<T: Config + configuration::Config>(count: u32) {120	let candidates = (0..count)121		.map(|c| account("candidate", c, SEED))122		.collect::<Vec<_>>();123	assert!(124		<LicenseBond<T>>::get() > 0u32.into(),125		"Bond cannot be zero!"126	);127128	for who in candidates {129		T::Currency::make_free_balance_be(&who, <LicenseBond<T>>::get() * 2u32.into());130		<CollatorSelection<T>>::get_license(RawOrigin::Signed(who.clone()).into()).unwrap();131		<CollatorSelection<T>>::onboard(RawOrigin::Signed(who).into()).unwrap();132	}133}134135benchmarks! {136	where_clause { where T: pallet_authorship::Config + session::Config + configuration::Config }137138	add_invulnerable {139		let b in 1 .. T::MaxCollators::get();140		let new_invulnerable = register_validators::<T>(b)[0].clone();141		let origin = T::UpdateOrigin::successful_origin();142	}: {143		assert_ok!(144			<CollatorSelection<T>>::add_invulnerable(origin, new_invulnerable.clone())145		);146	}147	verify {148		assert_last_event::<T>(Event::InvulnerableAdded{invulnerable: new_invulnerable}.into());149	}150151	remove_invulnerable {152		let b in 1 .. T::MaxCollators::get();153		let new_invulnerable = register_validators::<T>(b)[0].clone();154		let origin = T::UpdateOrigin::successful_origin();155		assert_ok!(156			<CollatorSelection<T>>::add_invulnerable(origin.clone(), new_invulnerable.clone())157		);158	}: {159		assert_ok!(160			<CollatorSelection<T>>::remove_invulnerable(origin, new_invulnerable.clone())161		);162	}163	verify {164		assert_last_event::<T>(Event::InvulnerableRemoved{invulnerable: new_invulnerable}.into());165	}166167	/*set_desired_collators {168		let max: u32 = 999;169		let origin = T::UpdateOrigin::successful_origin();170	}: {171		assert_ok!(172			<CollatorSelection<T>>::set_desired_collators(origin, max.clone())173		);174	}175	verify {176		assert_last_event::<T>(Event::NewDesiredCollators{desired_collators: max}.into());177	}178179	set_license_bond {180		let bond_amount: BalanceOf<T> = T::Currency::minimum_balance() * 10u32.into();181		let origin = T::UpdateOrigin::successful_origin();182	}: {183		assert_ok!(184			<CollatorSelection<T>>::set_license_bond(origin, bond_amount.clone())185		);186	}187	verify {188		assert_last_event::<T>(Event::NewLicenseBond{bond_amount}.into());189	}*/190191	get_license {192		let c in 1 .. T::MaxCollators::get();193194		<LicenseBond<T>>::put(T::Currency::minimum_balance());195		<DesiredCollators<T>>::put(c + 1);196197		register_validators::<T>(c);198		register_candidates::<T>(c);199200		let caller: T::AccountId = whitelisted_caller();201		let bond: BalanceOf<T> = T::Currency::minimum_balance() * 2u32.into();202		T::Currency::make_free_balance_be(&caller, bond.clone());203204		<session::Pallet<T>>::set_keys(205			RawOrigin::Signed(caller.clone()).into(),206			keys::<T>(c + 1),207			Vec::new()208		).unwrap();209210	}: _(RawOrigin::Signed(caller.clone()))211	verify {212		assert_last_event::<T>(Event::LicenseObtained{account_id: caller, deposit: bond / 2u32.into()}.into());213	}214215	// worst case is when we have all the max-candidate slots filled except one, and we fill that216	// one.217	onboard {218		let c in 1 .. T::MaxCollators::get();219220		<LicenseBond<T>>::put(T::Currency::minimum_balance());221		<DesiredCollators<T>>::put(c + 1);222223		register_validators::<T>(c);224		register_candidates::<T>(c);225226		let caller: T::AccountId = whitelisted_caller();227		let bond: BalanceOf<T> = T::Currency::minimum_balance() * 2u32.into();228		T::Currency::make_free_balance_be(&caller, bond.clone());229230		let origin = RawOrigin::Signed(caller.clone());231232		<session::Pallet<T>>::set_keys(233			origin.clone().into(),234			keys::<T>(c + 1),235			Vec::new()236		).unwrap();237238		assert_ok!(239			<CollatorSelection<T>>::get_license(origin.clone().into())240		);241	}: _(origin)242	verify {243		assert_last_event::<T>(Event::CandidateAdded{account_id: caller}.into());244	}245246	// worst case is the last candidate leaving.247	offboard {248		let c in 1 .. T::MaxCollators::get();249		<LicenseBond<T>>::put(T::Currency::minimum_balance());250		<DesiredCollators<T>>::put(c);251252		register_validators::<T>(c);253		register_candidates::<T>(c);254255		let leaving = <Candidates<T>>::get().last().unwrap().clone();256		whitelist!(leaving);257	}: _(RawOrigin::Signed(leaving.clone()))258	verify {259		assert_last_event::<T>(Event::CandidateRemoved{account_id: leaving}.into());260	}261262	// worst case is the last candidate leaving.263	release_license {264		let c in 1 .. T::MaxCollators::get();265		let bond = T::Currency::minimum_balance();266		<LicenseBond<T>>::put(bond);267		<DesiredCollators<T>>::put(c);268269		register_validators::<T>(c);270		register_candidates::<T>(c);271272		let leaving = <Candidates<T>>::get().last().unwrap().clone();273		whitelist!(leaving);274	}: _(RawOrigin::Signed(leaving.clone()))275	verify {276		assert_last_event::<T>(Event::LicenseReleased{account_id: leaving, deposit_returned: bond}.into());277	}278279	// worst case is the last candidate leaving.280	force_release_license {281		let c in 1 .. T::MaxCollators::get();282		let bond = T::Currency::minimum_balance();283		<LicenseBond<T>>::put(bond);284		<DesiredCollators<T>>::put(c);285286		register_validators::<T>(c);287		register_candidates::<T>(c);288289		let leaving = <Candidates<T>>::get().last().unwrap().clone();290		whitelist!(leaving);291		let origin = T::UpdateOrigin::successful_origin();292	}: {293		assert_ok!(294			<CollatorSelection<T>>::force_release_license(origin, leaving.clone())295		);296	}297	verify {298		assert_last_event::<T>(Event::LicenseReleased{account_id: leaving, deposit_returned: bond}.into());299	}300301	// worst case is paying a non-existing candidate account.302	note_author {303		<LicenseBond<T>>::put(T::Currency::minimum_balance());304		T::Currency::make_free_balance_be(305			&<CollatorSelection<T>>::account_id(),306			T::Currency::minimum_balance() * 4u32.into(),307		);308		let author = account("author", 0, SEED);309		let new_block: T::BlockNumber = 10u32.into();310311		frame_system::Pallet::<T>::set_block_number(new_block);312		assert!(T::Currency::free_balance(&author) == 0u32.into());313	}: {314		<CollatorSelection<T> as EventHandler<_, _>>::note_author(author.clone())315	} verify {316		assert!(T::Currency::free_balance(&author) > 0u32.into());317		assert_eq!(frame_system::Pallet::<T>::block_number(), new_block);318	}319320	// worst case for new session.321	new_session {322		let r in 1 .. T::MaxCollators::get();323		let c in 1 .. T::MaxCollators::get();324325		<LicenseBond<T>>::put(T::Currency::minimum_balance());326		<DesiredCollators<T>>::put(c);327		frame_system::Pallet::<T>::set_block_number(0u32.into());328329		register_validators::<T>(c);330		register_candidates::<T>(c);331332		let new_block: T::BlockNumber = 1800u32.into();333		let zero_block: T::BlockNumber = 0u32.into();334		let candidates = <Candidates<T>>::get();335336		let non_removals = c.saturating_sub(r);337338		for i in 0..c {339			<LastAuthoredBlock<T>>::insert(candidates[i as usize].clone(), zero_block);340		}341342		if non_removals > 0 {343			for i in 0..non_removals {344				<LastAuthoredBlock<T>>::insert(candidates[i as usize].clone(), new_block);345			}346		} else {347			for i in 0..c {348				<LastAuthoredBlock<T>>::insert(candidates[i as usize].clone(), new_block);349			}350		}351352		let pre_length = <Candidates<T>>::get().len();353354		frame_system::Pallet::<T>::set_block_number(new_block);355356		assert!(<Candidates<T>>::get().len() == c as usize);357	}: {358		<CollatorSelection<T> as SessionManager<_>>::new_session(0)359	} verify {360		if c > r {361			assert!(<Candidates<T>>::get().len() < pre_length);362		} else {363			assert!(<Candidates<T>>::get().len() == pre_length);364		}365	}366}367368impl_benchmark_test_suite!(369	CollatorSelection,370	crate::mock::new_test_ext(),371	crate::mock::Test,372);
modifiedpallets/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)
modifiedpallets/collator-selection/src/mock.rsdiffbeforeafterboth
--- a/pallets/collator-selection/src/mock.rs
+++ b/pallets/collator-selection/src/mock.rs
@@ -225,6 +225,7 @@
 	type MaxXcmAllowedLocations = MaxXcmAllowedLocations;
 	type AppPromotionDailyRate = AppPromotionDailyRate;
 	type DayRelayBlocks = DayRelayBlocks;
+	type WeightInfo = ();
 }
 
 ord_parameter_types! {
modifiedpallets/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",
addedpallets/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());
+	}
+}
modifiedpallets/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>,
addedpallets/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))
+	}
+}
modifiedruntime/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 {
modifiedruntime/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,
modifiedruntime/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);
modifiedruntime/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',
modifiedruntime/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',
modifiedruntime/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',