git.delta.rocks / unique-network / refs/commits / e48f2d1c76b5

difftreelog

fixup(imports): post-rebase

Yaroslav Bolyukin2023-10-02parent: #2eca527.patch.diff
in: master

14 files changed

modifiedCargo.tomldiffbeforeafterboth
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -26,8 +26,8 @@
 opt-level = 3
 
 [profile.integration-tests]
+debug-assertions = true
 inherits = "release"
-debug-assertions = true
 
 [workspace.dependencies]
 # Unique
modifiednode/cli/src/command.rsdiffbeforeafterboth
--- a/node/cli/src/command.rs
+++ b/node/cli/src/command.rs
@@ -32,20 +32,15 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-use std::time::Duration;
-
-use codec::Encode;
-use cumulus_client_cli::generate_genesis_block;
 use cumulus_primitives_core::ParaId;
-use log::{debug, info};
+use log::info;
 use sc_cli::{
 	ChainSpec, CliConfiguration, DefaultConfigurationValues, ImportParams, KeystoreParams,
-	NetworkParams, Result, RuntimeVersion, SharedParams, SubstrateCli,
+	NetworkParams, Result, SharedParams, SubstrateCli,
 };
 use sc_service::config::{BasePath, PrometheusConfig};
-use sp_core::hexdisplay::HexDisplay;
-use sp_runtime::traits::{AccountIdConversion, Block as BlockT};
-use up_common::types::opaque::{Block, RuntimeId};
+use sp_runtime::traits::AccountIdConversion;
+use up_common::types::opaque::RuntimeId;
 
 #[cfg(feature = "runtime-benchmarks")]
 use crate::chain_spec::default_runtime;
modifiednode/cli/src/service.rsdiffbeforeafterboth
--- a/node/cli/src/service.rs
+++ b/node/cli/src/service.rs
@@ -824,8 +824,8 @@
 {
 	use fc_consensus::FrontierBlockImport;
 	use sc_consensus_manual_seal::{
-		run_manual_seal, run_delayed_finalize, EngineCommand, ManualSealParams,
-		DelayedFinalizeParams,
+		run_delayed_finalize, run_manual_seal, DelayedFinalizeParams, EngineCommand,
+		ManualSealParams,
 	};
 
 	let sc_service::PartialComponents {
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 frame_benchmarking::{account, benchmarks, impl_benchmark_test_suite, whitelisted_caller};36use frame_support::{37	assert_ok,38	parity_scale_codec::Decode,39	traits::{40		fungible::{Inspect, Mutate},41		EnsureOrigin, Get,42	},43};44use frame_system::{EventRecord, RawOrigin};45use pallet_authorship::EventHandler;46use pallet_session::{self as session, SessionManager};47use sp_std::prelude::*;4849use super::*;50#[allow(unused)]51use crate::{BalanceOf, Pallet as CollatorSelection};5253const SEED: u32 = 0;5455// TODO: remove if this is given in substrate commit.56macro_rules! whitelist {57	($acc:ident) => {58		frame_benchmarking::benchmarking::add_to_whitelist(59			frame_system::Account::<T>::hashed_key_for(&$acc).into(),60		);61	};62}6364fn assert_last_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {65	let events = frame_system::Pallet::<T>::events();66	let system_event: <T as frame_system::Config>::RuntimeEvent = generic_event.into();67	// compare to the last event record68	let EventRecord { event, .. } = &events[events.len() - 1];69	assert_eq!(event, &system_event);70}7172fn create_funded_user<T: Config>(73	string: &'static str,74	n: u32,75	balance_factor: u32,76) -> T::AccountId {77	let user = account(string, n, SEED);78	let balance = balance_unit::<T>() * balance_factor.into();79	let _ = T::Currency::set_balance(&user, balance);80	user81}8283fn keys<T: Config + session::Config>(c: u32) -> <T as session::Config>::Keys {84	use rand::{RngCore, SeedableRng};8586	let keys = {87		let mut keys = [0u8; 128];8889		if c > 0 {90			let mut rng = rand::rngs::StdRng::seed_from_u64(c as u64);91			rng.fill_bytes(&mut keys);92		}9394		keys95	};9697	Decode::decode(&mut &keys[..]).unwrap()98}99100fn validator<T: Config + session::Config>(c: u32) -> (T::AccountId, <T as session::Config>::Keys) {101	(create_funded_user::<T>("candidate", c, 1000), keys::<T>(c))102}103104fn register_validators<T: Config + session::Config>(count: u32) -> Vec<T::AccountId> {105	let validators = (0..count).map(|c| validator::<T>(c)).collect::<Vec<_>>();106107	for (who, keys) in validators.clone() {108		<session::Pallet<T>>::set_keys(RawOrigin::Signed(who).into(), keys, Vec::new()).unwrap();109	}110111	validators.into_iter().map(|(who, _)| who).collect()112}113114fn register_invulnerables<T: Config>(count: u32) {115	let candidates = (0..count)116		.map(|c| account("candidate", c, SEED))117		.collect::<Vec<_>>();118119	for who in candidates {120		<CollatorSelection<T>>::add_invulnerable(121			T::UpdateOrigin::try_successful_origin().unwrap(),122			who,123		)124		.unwrap();125	}126}127128fn register_candidates<T: Config>(count: u32) {129	let candidates = (0..count)130		.map(|c| account("candidate", c, SEED))131		.collect::<Vec<_>>();132	assert!(T::LicenseBond::get() > 0u32.into(), "Bond cannot be zero!");133134	for who in candidates {135		T::Currency::set_balance(&who, T::LicenseBond::get() * 2u32.into());136		<CollatorSelection<T>>::get_license(RawOrigin::Signed(who.clone()).into()).unwrap();137		<CollatorSelection<T>>::onboard(RawOrigin::Signed(who).into()).unwrap();138	}139}140141fn get_licenses<T: Config>(count: u32) {142	let candidates = (0..count)143		.map(|c| account("candidate", c, SEED))144		.collect::<Vec<_>>();145	assert!(T::LicenseBond::get() > 0u32.into(), "Bond cannot be zero!");146147	for who in candidates {148		T::Currency::set_balance(&who, T::LicenseBond::get() * 2u32.into());149		<CollatorSelection<T>>::get_license(RawOrigin::Signed(who.clone()).into()).unwrap();150	}151}152153/// `Currency::minimum_balance` was used originally, but in unique-chain, we have154/// zero existential deposit, thus triggering zero bond assertion.155fn balance_unit<T: Config>() -> BalanceOf<T> {156	T::LicenseBond::get()157}158159/// Our benchmarking environment already has invulnerables registered.160const INITIAL_INVULNERABLES: u32 = 2;161162benchmarks! {163	where_clause { where164		T: Config + pallet_authorship::Config + session::Config165	}166167	// todo:collator this and all the following do not work for some reason, going all the way up to 10 in length168	// Both invulnerables and candidates count together against MaxCollators.169	// Maybe try putting it in braces? 1 .. (T::MaxCollators::get() - 2)170	add_invulnerable {171		let b in 1 .. T::MaxCollators::get() - INITIAL_INVULNERABLES - 1;172		register_validators::<T>(b);173		register_invulnerables::<T>(b);174175		// log::info!("{} {}", <Invulnerables<T>>::get().len(), b);176177		let new_invulnerable: T::AccountId = whitelisted_caller();178		let bond: BalanceOf<T> = balance_unit::<T>() * 2u32.into();179		<T as Config>::Currency::set_balance(&new_invulnerable, bond);180181		<session::Pallet<T>>::set_keys(182			RawOrigin::Signed(new_invulnerable.clone()).into(),183			keys::<T>(b + 1),184			Vec::new()185		).unwrap();186187		let root_origin = T::UpdateOrigin::try_successful_origin().unwrap();188	}: {189		assert_ok!(190			<CollatorSelection<T>>::add_invulnerable(root_origin, new_invulnerable.clone())191		);192	}193	verify {194		assert_last_event::<T>(Event::InvulnerableAdded{invulnerable: new_invulnerable}.into());195	}196197	remove_invulnerable {198		let b in 1 .. T::MaxCollators::get() - INITIAL_INVULNERABLES - 1;199		register_validators::<T>(b);200		register_invulnerables::<T>(b);201202		let root_origin = T::UpdateOrigin::try_successful_origin().unwrap();203		let leaving = <Invulnerables<T>>::get().last().unwrap().clone();204		whitelist!(leaving);205	}: {206		assert_ok!(207			<CollatorSelection<T>>::remove_invulnerable(root_origin, leaving.clone())208		);209	}210	verify {211		assert_last_event::<T>(Event::InvulnerableRemoved{invulnerable: leaving}.into());212	}213214	get_license {215		let c in 1 .. T::MaxCollators::get() - 1;216217		register_validators::<T>(c);218		get_licenses::<T>(c);219220		let caller: T::AccountId = whitelisted_caller();221		let bond: BalanceOf<T> = balance_unit::<T>() * 2u32.into();222		T::Currency::set_balance(&caller, bond);223224		<session::Pallet<T>>::set_keys(225			RawOrigin::Signed(caller.clone()).into(),226			keys::<T>(c + 1),227			Vec::new()228		).unwrap();229230	}: _(RawOrigin::Signed(caller.clone()))231	verify {232		assert_last_event::<T>(Event::LicenseObtained{account_id: caller, deposit: bond / 2u32.into()}.into());233	}234235	// worst case is when we have all the max-candidate slots filled except one, and we fill that236	// one.237	onboard {238		let c in 1 .. T::MaxCollators::get() - INITIAL_INVULNERABLES - 1;239240		register_validators::<T>(c);241		register_candidates::<T>(c);242243		let caller: T::AccountId = whitelisted_caller();244		let bond: BalanceOf<T> = balance_unit::<T>() * 2u32.into();245		T::Currency::set_balance(&caller, bond);246247		let origin = RawOrigin::Signed(caller.clone());248249		<session::Pallet<T>>::set_keys(250			origin.clone().into(),251			keys::<T>(c + 1),252			Vec::new()253		).unwrap();254255		assert_ok!(256			<CollatorSelection<T>>::get_license(origin.clone().into())257		);258	}: _(origin)259	verify {260		assert_last_event::<T>(Event::CandidateAdded{account_id: caller}.into());261	}262263	// worst case is the last candidate leaving.264	offboard {265		let c in 1 .. T::MaxCollators::get() - INITIAL_INVULNERABLES;266267		register_validators::<T>(c);268		register_candidates::<T>(c);269270		let leaving = <Candidates<T>>::get().last().unwrap().clone();271		whitelist!(leaving);272	}: _(RawOrigin::Signed(leaving.clone()))273	verify {274		assert_last_event::<T>(Event::CandidateRemoved{account_id: leaving}.into());275	}276277	// worst case is the last candidate leaving.278	release_license {279		let c in 1 .. T::MaxCollators::get() - INITIAL_INVULNERABLES;280		let bond = balance_unit::<T>();281282		register_validators::<T>(c);283		register_candidates::<T>(c);284285		let leaving = <Candidates<T>>::get().last().unwrap().clone();286		whitelist!(leaving);287	}: _(RawOrigin::Signed(leaving.clone()))288	verify {289		assert_last_event::<T>(Event::LicenseReleased{account_id: leaving, deposit_returned: bond}.into());290	}291292	// worst case is the last candidate leaving.293	force_release_license {294		let c in 1 .. T::MaxCollators::get() - INITIAL_INVULNERABLES;295		let bond = balance_unit::<T>();296297		register_validators::<T>(c);298		register_candidates::<T>(c);299300		let leaving = <Candidates<T>>::get().last().unwrap().clone();301		whitelist!(leaving);302		let origin = T::UpdateOrigin::try_successful_origin().unwrap();303	}: {304		assert_ok!(305			<CollatorSelection<T>>::force_release_license(origin, leaving.clone())306		);307	}308	verify {309		assert_last_event::<T>(Event::LicenseReleased{account_id: leaving, deposit_returned: bond}.into());310	}311312	// worst case is paying a non-existing candidate account.313	note_author {314		T::Currency::set_balance(315			&<CollatorSelection<T>>::account_id(),316			balance_unit::<T>() * 4u32.into(),317		);318		let author = account("author", 0, SEED);319		let new_block: BlockNumberFor<T>= 10u32.into();320321		frame_system::Pallet::<T>::set_block_number(new_block);322		assert!(T::Currency::balance(&author) == 0u32.into());323	}: {324		<CollatorSelection<T> as EventHandler<_, _>>::note_author(author.clone())325	} verify {326		assert!(T::Currency::balance(&author) > 0u32.into());327		assert_eq!(frame_system::Pallet::<T>::block_number(), new_block);328	}329330	// worst case for new session.331	new_session {332		let r in 1 .. T::MaxCollators::get() - INITIAL_INVULNERABLES;333		let c in 1 .. T::MaxCollators::get() - INITIAL_INVULNERABLES;334335		frame_system::Pallet::<T>::set_block_number(0u32.into());336337		register_validators::<T>(c);338		register_candidates::<T>(c);339340		let new_block: BlockNumberFor<T>= 1800u32.into();341		let zero_block: T::BlockNumber = 0u32.into();342		let candidates = <Candidates<T>>::get();343344		let non_removals = c.saturating_sub(r);345346		for i in 0..c {347			<LastAuthoredBlock<T>>::insert(candidates[i as usize].clone(), zero_block);348		}349350		if non_removals > 0 {351			for i in 0..non_removals {352				<LastAuthoredBlock<T>>::insert(candidates[i as usize].clone(), new_block);353			}354		} else {355			for i in 0..c {356				<LastAuthoredBlock<T>>::insert(candidates[i as usize].clone(), new_block);357			}358		}359360		let pre_length = <Candidates<T>>::get().len();361362		frame_system::Pallet::<T>::set_block_number(new_block);363364		assert!(<Candidates<T>>::get().len() == c as usize);365	}: {366		<CollatorSelection<T> as SessionManager<_>>::new_session(0)367	} verify {368		if c > r {369			assert!(<Candidates<T>>::get().len() < pre_length);370		} else {371			assert!(<Candidates<T>>::get().len() == pre_length);372		}373	}374}375376impl_benchmark_test_suite!(377	CollatorSelection,378	crate::mock::new_test_ext(),379	crate::mock::Test,380);
after · 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 frame_benchmarking::{account, benchmarks, impl_benchmark_test_suite, whitelisted_caller};36use frame_support::{37	assert_ok,38	traits::{39		fungible::{Inspect, Mutate},40		EnsureOrigin, Get,41	},42};43use frame_system::{pallet_prelude::*, EventRecord, RawOrigin};44use pallet_authorship::EventHandler;45use pallet_session::{self as session, SessionManager};46use parity_scale_codec::Decode;47use sp_std::prelude::*;4849use super::*;50#[allow(unused)]51use crate::{BalanceOf, Pallet as CollatorSelection};5253const SEED: u32 = 0;5455// TODO: remove if this is given in substrate commit.56macro_rules! whitelist {57	($acc:ident) => {58		frame_benchmarking::benchmarking::add_to_whitelist(59			frame_system::Account::<T>::hashed_key_for(&$acc).into(),60		);61	};62}6364fn assert_last_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {65	let events = frame_system::Pallet::<T>::events();66	let system_event: <T as frame_system::Config>::RuntimeEvent = generic_event.into();67	// compare to the last event record68	let EventRecord { event, .. } = &events[events.len() - 1];69	assert_eq!(event, &system_event);70}7172fn create_funded_user<T: Config>(73	string: &'static str,74	n: u32,75	balance_factor: u32,76) -> T::AccountId {77	let user = account(string, n, SEED);78	let balance = balance_unit::<T>() * balance_factor.into();79	let _ = T::Currency::set_balance(&user, balance);80	user81}8283fn keys<T: Config + session::Config>(c: u32) -> <T as session::Config>::Keys {84	use rand::{RngCore, SeedableRng};8586	let keys = {87		let mut keys = [0u8; 128];8889		if c > 0 {90			let mut rng = rand::rngs::StdRng::seed_from_u64(c as u64);91			rng.fill_bytes(&mut keys);92		}9394		keys95	};9697	Decode::decode(&mut &keys[..]).unwrap()98}99100fn validator<T: Config + session::Config>(c: u32) -> (T::AccountId, <T as session::Config>::Keys) {101	(create_funded_user::<T>("candidate", c, 1000), keys::<T>(c))102}103104fn register_validators<T: Config + session::Config>(count: u32) -> Vec<T::AccountId> {105	let validators = (0..count).map(|c| validator::<T>(c)).collect::<Vec<_>>();106107	for (who, keys) in validators.clone() {108		<session::Pallet<T>>::set_keys(RawOrigin::Signed(who).into(), keys, Vec::new()).unwrap();109	}110111	validators.into_iter().map(|(who, _)| who).collect()112}113114fn register_invulnerables<T: Config>(count: u32) {115	let candidates = (0..count)116		.map(|c| account("candidate", c, SEED))117		.collect::<Vec<_>>();118119	for who in candidates {120		<CollatorSelection<T>>::add_invulnerable(121			T::UpdateOrigin::try_successful_origin().unwrap(),122			who,123		)124		.unwrap();125	}126}127128fn register_candidates<T: Config>(count: u32) {129	let candidates = (0..count)130		.map(|c| account("candidate", c, SEED))131		.collect::<Vec<_>>();132	assert!(T::LicenseBond::get() > 0u32.into(), "Bond cannot be zero!");133134	for who in candidates {135		T::Currency::set_balance(&who, T::LicenseBond::get() * 2u32.into());136		<CollatorSelection<T>>::get_license(RawOrigin::Signed(who.clone()).into()).unwrap();137		<CollatorSelection<T>>::onboard(RawOrigin::Signed(who).into()).unwrap();138	}139}140141fn get_licenses<T: Config>(count: u32) {142	let candidates = (0..count)143		.map(|c| account("candidate", c, SEED))144		.collect::<Vec<_>>();145	assert!(T::LicenseBond::get() > 0u32.into(), "Bond cannot be zero!");146147	for who in candidates {148		T::Currency::set_balance(&who, T::LicenseBond::get() * 2u32.into());149		<CollatorSelection<T>>::get_license(RawOrigin::Signed(who.clone()).into()).unwrap();150	}151}152153/// `Currency::minimum_balance` was used originally, but in unique-chain, we have154/// zero existential deposit, thus triggering zero bond assertion.155fn balance_unit<T: Config>() -> BalanceOf<T> {156	T::LicenseBond::get()157}158159/// Our benchmarking environment already has invulnerables registered.160const INITIAL_INVULNERABLES: u32 = 2;161162benchmarks! {163	where_clause { where164		T: Config + pallet_authorship::Config + session::Config165	}166167	// todo:collator this and all the following do not work for some reason, going all the way up to 10 in length168	// Both invulnerables and candidates count together against MaxCollators.169	// Maybe try putting it in braces? 1 .. (T::MaxCollators::get() - 2)170	add_invulnerable {171		let b in 1 .. T::MaxCollators::get() - INITIAL_INVULNERABLES - 1;172		register_validators::<T>(b);173		register_invulnerables::<T>(b);174175		// log::info!("{} {}", <Invulnerables<T>>::get().len(), b);176177		let new_invulnerable: T::AccountId = whitelisted_caller();178		let bond: BalanceOf<T> = balance_unit::<T>() * 2u32.into();179		<T as Config>::Currency::set_balance(&new_invulnerable, bond);180181		<session::Pallet<T>>::set_keys(182			RawOrigin::Signed(new_invulnerable.clone()).into(),183			keys::<T>(b + 1),184			Vec::new()185		).unwrap();186187		let root_origin = T::UpdateOrigin::try_successful_origin().unwrap();188	}: {189		assert_ok!(190			<CollatorSelection<T>>::add_invulnerable(root_origin, new_invulnerable.clone())191		);192	}193	verify {194		assert_last_event::<T>(Event::InvulnerableAdded{invulnerable: new_invulnerable}.into());195	}196197	remove_invulnerable {198		let b in 1 .. T::MaxCollators::get() - INITIAL_INVULNERABLES - 1;199		register_validators::<T>(b);200		register_invulnerables::<T>(b);201202		let root_origin = T::UpdateOrigin::try_successful_origin().unwrap();203		let leaving = <Invulnerables<T>>::get().last().unwrap().clone();204		whitelist!(leaving);205	}: {206		assert_ok!(207			<CollatorSelection<T>>::remove_invulnerable(root_origin, leaving.clone())208		);209	}210	verify {211		assert_last_event::<T>(Event::InvulnerableRemoved{invulnerable: leaving}.into());212	}213214	get_license {215		let c in 1 .. T::MaxCollators::get() - 1;216217		register_validators::<T>(c);218		get_licenses::<T>(c);219220		let caller: T::AccountId = whitelisted_caller();221		let bond: BalanceOf<T> = balance_unit::<T>() * 2u32.into();222		T::Currency::set_balance(&caller, bond);223224		<session::Pallet<T>>::set_keys(225			RawOrigin::Signed(caller.clone()).into(),226			keys::<T>(c + 1),227			Vec::new()228		).unwrap();229230	}: _(RawOrigin::Signed(caller.clone()))231	verify {232		assert_last_event::<T>(Event::LicenseObtained{account_id: caller, deposit: bond / 2u32.into()}.into());233	}234235	// worst case is when we have all the max-candidate slots filled except one, and we fill that236	// one.237	onboard {238		let c in 1 .. T::MaxCollators::get() - INITIAL_INVULNERABLES - 1;239240		register_validators::<T>(c);241		register_candidates::<T>(c);242243		let caller: T::AccountId = whitelisted_caller();244		let bond: BalanceOf<T> = balance_unit::<T>() * 2u32.into();245		T::Currency::set_balance(&caller, bond);246247		let origin = RawOrigin::Signed(caller.clone());248249		<session::Pallet<T>>::set_keys(250			origin.clone().into(),251			keys::<T>(c + 1),252			Vec::new()253		).unwrap();254255		assert_ok!(256			<CollatorSelection<T>>::get_license(origin.clone().into())257		);258	}: _(origin)259	verify {260		assert_last_event::<T>(Event::CandidateAdded{account_id: caller}.into());261	}262263	// worst case is the last candidate leaving.264	offboard {265		let c in 1 .. T::MaxCollators::get() - INITIAL_INVULNERABLES;266267		register_validators::<T>(c);268		register_candidates::<T>(c);269270		let leaving = <Candidates<T>>::get().last().unwrap().clone();271		whitelist!(leaving);272	}: _(RawOrigin::Signed(leaving.clone()))273	verify {274		assert_last_event::<T>(Event::CandidateRemoved{account_id: leaving}.into());275	}276277	// worst case is the last candidate leaving.278	release_license {279		let c in 1 .. T::MaxCollators::get() - INITIAL_INVULNERABLES;280		let bond = balance_unit::<T>();281282		register_validators::<T>(c);283		register_candidates::<T>(c);284285		let leaving = <Candidates<T>>::get().last().unwrap().clone();286		whitelist!(leaving);287	}: _(RawOrigin::Signed(leaving.clone()))288	verify {289		assert_last_event::<T>(Event::LicenseReleased{account_id: leaving, deposit_returned: bond}.into());290	}291292	// worst case is the last candidate leaving.293	force_release_license {294		let c in 1 .. T::MaxCollators::get() - INITIAL_INVULNERABLES;295		let bond = balance_unit::<T>();296297		register_validators::<T>(c);298		register_candidates::<T>(c);299300		let leaving = <Candidates<T>>::get().last().unwrap().clone();301		whitelist!(leaving);302		let origin = T::UpdateOrigin::try_successful_origin().unwrap();303	}: {304		assert_ok!(305			<CollatorSelection<T>>::force_release_license(origin, leaving.clone())306		);307	}308	verify {309		assert_last_event::<T>(Event::LicenseReleased{account_id: leaving, deposit_returned: bond}.into());310	}311312	// worst case is paying a non-existing candidate account.313	note_author {314		T::Currency::set_balance(315			&<CollatorSelection<T>>::account_id(),316			balance_unit::<T>() * 4u32.into(),317		);318		let author = account("author", 0, SEED);319		let new_block: BlockNumberFor<T>= 10u32.into();320321		frame_system::Pallet::<T>::set_block_number(new_block);322		assert!(T::Currency::balance(&author) == 0u32.into());323	}: {324		<CollatorSelection<T> as EventHandler<_, _>>::note_author(author.clone())325	} verify {326		assert!(T::Currency::balance(&author) > 0u32.into());327		assert_eq!(frame_system::Pallet::<T>::block_number(), new_block);328	}329330	// worst case for new session.331	new_session {332		let r in 1 .. T::MaxCollators::get() - INITIAL_INVULNERABLES;333		let c in 1 .. T::MaxCollators::get() - INITIAL_INVULNERABLES;334335		frame_system::Pallet::<T>::set_block_number(0u32.into());336337		register_validators::<T>(c);338		register_candidates::<T>(c);339340		let new_block: BlockNumberFor<T>= 1800u32.into();341		let zero_block: BlockNumberFor<T> = 0u32.into();342		let candidates = <Candidates<T>>::get();343344		let non_removals = c.saturating_sub(r);345346		for i in 0..c {347			<LastAuthoredBlock<T>>::insert(candidates[i as usize].clone(), zero_block);348		}349350		if non_removals > 0 {351			for i in 0..non_removals {352				<LastAuthoredBlock<T>>::insert(candidates[i as usize].clone(), new_block);353			}354		} else {355			for i in 0..c {356				<LastAuthoredBlock<T>>::insert(candidates[i as usize].clone(), new_block);357			}358		}359360		let pre_length = <Candidates<T>>::get().len();361362		frame_system::Pallet::<T>::set_block_number(new_block);363364		assert!(<Candidates<T>>::get().len() == c as usize);365	}: {366		<CollatorSelection<T> as SessionManager<_>>::new_session(0)367	} verify {368		if c > r {369			assert!(<Candidates<T>>::get().len() < pre_length);370		} else {371			assert!(<Candidates<T>>::get().len() == pre_length);372		}373	}374}375376impl_benchmark_test_suite!(377	CollatorSelection,378	crate::mock::new_test_ext(),379	crate::mock::Test,380);
modifiedpallets/common/src/lib.rsdiffbeforeafterboth
--- a/pallets/common/src/lib.rs
+++ b/pallets/common/src/lib.rs
@@ -54,9 +54,9 @@
 extern crate alloc;
 
 use core::{
+	marker::PhantomData,
 	ops::{Deref, DerefMut},
 	slice::from_ref,
-	marker::PhantomData,
 };
 
 use evm_coder::ToLog;
modifiedpallets/configuration/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/configuration/src/benchmarking.rs
+++ b/pallets/configuration/src/benchmarking.rs
@@ -18,7 +18,7 @@
 
 use frame_benchmarking::benchmarks;
 use frame_support::assert_ok;
-use frame_system::{EventRecord, RawOrigin};
+use frame_system::{pallet_prelude::*, EventRecord, RawOrigin};
 
 use super::*;
 
modifiedpallets/inflation/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/inflation/src/benchmarking.rs
+++ b/pallets/inflation/src/benchmarking.rs
@@ -17,7 +17,7 @@
 #![cfg(feature = "runtime-benchmarks")]
 
 use frame_benchmarking::benchmarks;
-use frame_support::traits::OnInitialize;
+use frame_support::{pallet_prelude::*, traits::Hooks};
 
 use super::*;
 use crate::Pallet as Inflation;
@@ -25,9 +25,9 @@
 benchmarks! {
 
 	on_initialize {
-		let block1: T::BlockNumber = T::BlockNumber::from(1u32);
-		let block2: T::BlockNumber = T::BlockNumber::from(2u32);
-		Inflation::<T>::on_initialize(block1); // Create Treasury account
-	}: { Inflation::<T>::on_initialize(block2); } // Benchmark deposit_into_existing path
+		let block1: BlockNumberFor<T> = 1u32.into();
+		let block2: BlockNumberFor<T> = 2u32.into();
+		<Inflation<T> as Hooks>::on_initialize(block1); // Create Treasury account
+	}: { <Inflation<T> as Hooks>::on_initialize(block2); } // Benchmark deposit_into_existing path
 
 }
modifiedpallets/nonfungible/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/benchmarking.rs
+++ b/pallets/nonfungible/src/benchmarking.rs
@@ -18,7 +18,7 @@
 use pallet_common::{
 	bench_init,
 	benchmarking::{
-		create_collection_raw, property_key, property_value, load_is_admin_and_property_permissions,
+		create_collection_raw, load_is_admin_and_property_permissions, property_key, property_value,
 	},
 	CommonCollectionOperations,
 };
modifiedpallets/nonfungible/src/lib.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/lib.rs
+++ b/pallets/nonfungible/src/lib.rs
@@ -103,9 +103,9 @@
 };
 pub use pallet::*;
 use pallet_common::{
-	Error as CommonError, Pallet as PalletCommon, Event as CommonEvent, CollectionHandle,
-	eth::collection_id_to_address, SelfWeightOf as PalletCommonWeightOf,
-	weights::WeightInfo as CommonWeightInfo, helpers::add_weight_to_post_info,
+	eth::collection_id_to_address, helpers::add_weight_to_post_info,
+	weights::WeightInfo as CommonWeightInfo, CollectionHandle, Error as CommonError,
+	Event as CommonEvent, Pallet as PalletCommon, SelfWeightOf as PalletCommonWeightOf,
 };
 use pallet_evm::{account::CrossAccountId, Pallet as PalletEvm};
 use pallet_evm_coder_substrate::{SubstrateRecorder, WithRecorder};
@@ -116,9 +116,9 @@
 use sp_runtime::{ArithmeticError, DispatchError, DispatchResult, TransactionOutcome};
 use sp_std::{collections::btree_map::BTreeMap, vec, vec::Vec};
 use up_data_structs::{
-	AccessMode, CollectionId, CustomDataLimit, TokenId, CreateCollectionData, CreateNftExData,
-	mapping::TokenAddressMapping, budget::Budget, Property, PropertyKey, PropertyValue,
-	PropertyKeyPermission, PropertyScope, TokenChild, AuxPropertyValue, PropertiesPermissionMap,
+	budget::Budget, mapping::TokenAddressMapping, AccessMode, AuxPropertyValue, CollectionId,
+	CreateCollectionData, CreateNftExData, CustomDataLimit, PropertiesPermissionMap, Property,
+	PropertyKey, PropertyKeyPermission, PropertyScope, PropertyValue, TokenChild, TokenId,
 	TokenProperties as TokenPropertiesT,
 };
 use weights::WeightInfo;
modifiedpallets/refungible/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/refungible/src/benchmarking.rs
+++ b/pallets/refungible/src/benchmarking.rs
@@ -20,7 +20,7 @@
 use pallet_common::{
 	bench_init,
 	benchmarking::{
-		create_collection_raw, property_key, property_value, load_is_admin_and_property_permissions,
+		create_collection_raw, load_is_admin_and_property_permissions, property_key, property_value,
 	},
 };
 use sp_std::prelude::*;
modifiedpallets/refungible/src/lib.rsdiffbeforeafterboth
--- a/pallets/refungible/src/lib.rs
+++ b/pallets/refungible/src/lib.rs
@@ -106,7 +106,7 @@
 	budget::Budget, mapping::TokenAddressMapping, AccessMode, CollectionId, CreateCollectionData,
 	CreateRefungibleExMultipleOwners, PropertiesPermissionMap, Property, PropertyKey,
 	PropertyKeyPermission, PropertyScope, PropertyValue, TokenId, TokenOwnerError,
-	TokenProperties as TokenPropertiesT, TrySetProperty, MAX_REFUNGIBLE_PIECES,
+	TokenProperties as TokenPropertiesT, MAX_REFUNGIBLE_PIECES,
 };
 
 use crate::{erc::ERC721Events, erc_token::ERC20Events};
modifiedruntime/opal/src/xcm_barrier.rsdiffbeforeafterboth
--- a/runtime/opal/src/xcm_barrier.rs
+++ b/runtime/opal/src/xcm_barrier.rs
@@ -15,8 +15,10 @@
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
 use frame_support::{match_types, traits::Everything};
-use xcm::latest::{Junctions::*, MultiLocation};
-use staging_xcm_builder::{AllowTopLevelPaidExecutionFrom, TakeWeightCredit, AllowExplicitUnpaidExecutionFrom};
+use staging_xcm::latest::{Junctions::*, MultiLocation};
+use staging_xcm_builder::{
+	AllowExplicitUnpaidExecutionFrom, AllowTopLevelPaidExecutionFrom, TakeWeightCredit,
+};
 
 match_types! {
 	pub type ParentOnly: impl Contains<MultiLocation> = {
modifiedruntime/quartz/src/xcm_barrier.rsdiffbeforeafterboth
--- a/runtime/quartz/src/xcm_barrier.rs
+++ b/runtime/quartz/src/xcm_barrier.rs
@@ -17,8 +17,8 @@
 use frame_support::{match_types, traits::Everything};
 use staging_xcm::latest::{Junctions::*, MultiLocation};
 use staging_xcm_builder::{
-	AllowKnownQueryResponses, AllowSubscriptionsFrom, TakeWeightCredit,
-	AllowTopLevelPaidExecutionFrom, AllowExplicitUnpaidExecutionFrom,
+	AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, AllowSubscriptionsFrom,
+	AllowTopLevelPaidExecutionFrom, TakeWeightCredit,
 };
 
 use crate::PolkadotXcm;
modifiedruntime/unique/src/xcm_barrier.rsdiffbeforeafterboth
--- a/runtime/unique/src/xcm_barrier.rs
+++ b/runtime/unique/src/xcm_barrier.rs
@@ -17,8 +17,8 @@
 use frame_support::{match_types, traits::Everything};
 use staging_xcm::latest::{Junctions::*, MultiLocation};
 use staging_xcm_builder::{
-	AllowKnownQueryResponses, AllowSubscriptionsFrom, TakeWeightCredit,
-	AllowTopLevelPaidExecutionFrom, AllowExplicitUnpaidExecutionFrom,
+	AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, AllowSubscriptionsFrom,
+	AllowTopLevelPaidExecutionFrom, TakeWeightCredit,
 };
 
 use crate::PolkadotXcm;