git.delta.rocks / unique-network / refs/commits / 3ce5f80a2a4f

difftreelog

refactor(collator-selection) rename revoke to release + update tx + cargo fmt

Fahrrader2022-12-27parent: #8de2dcb.patch.diff
in: master

13 files changed

modifiedpallets/collator-selection/src/lib.rsdiffbeforeafterboth
--- a/pallets/collator-selection/src/lib.rs
+++ b/pallets/collator-selection/src/lib.rs
@@ -217,7 +217,7 @@
 			let bounded_invulnerables =
 				BoundedVec::<_, T::MaxCollators>::try_from(self.invulnerables.clone())
 					.expect("genesis invulnerables are more than T::MaxCollators");
-			
+
 			<Invulnerables<T>>::put(bounded_invulnerables);
 		}
 	}
@@ -284,6 +284,7 @@
 	#[pallet::call]
 	impl<T: Config> Pallet<T> {
 		/// Add a collator to the list of invulnerable (fixed) collators.
+		#[pallet::call_index(0)]
 		#[pallet::weight(T::WeightInfo::set_invulnerables(1u32))] // todo:collator weight
 		pub fn add_invulnerable(
 			origin: OriginFor<T>,
@@ -313,6 +314,7 @@
 		}
 
 		/// Remove a collator from the list of invulnerable (fixed) collators.
+		#[pallet::call_index(1)]
 		#[pallet::weight(T::WeightInfo::set_invulnerables(1))] // todo:collator weight
 		pub fn remove_invulnerable(
 			origin: OriginFor<T>,
@@ -341,6 +343,7 @@
 		/// (a) already have registered session keys and (b) be able to reserve the `LicenseBond`.
 		///
 		/// This call is not available to `Invulnerable` collators.
+		#[pallet::call_index(2)]
 		#[pallet::weight(T::WeightInfo::register_as_candidate(T::MaxCollators::get()))] // todo:collator weight
 		pub fn get_license(origin: OriginFor<T>) -> DispatchResultWithPostInfo {
 			// register_as_candidate
@@ -373,6 +376,7 @@
 		/// The account must already hold a license, and cannot offboard immediately during a session.
 		///
 		/// This call is not available to `Invulnerable` collators.
+		#[pallet::call_index(3)]
 		#[pallet::weight(T::WeightInfo::register_as_candidate(T::MaxCollators::get()))] // todo:collator weight
 		pub fn onboard(origin: OriginFor<T>) -> DispatchResultWithPostInfo {
 			// register_as_candidate
@@ -418,6 +422,7 @@
 
 		/// 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::leave_intent(T::MaxCollators::get()))] // todo:collator weight
 		pub fn offboard(origin: OriginFor<T>) -> DispatchResultWithPostInfo {
 			// leave_intent
@@ -430,6 +435,7 @@
 		/// 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::leave_intent(T::MaxCollators::get()))] // todo:collator weight
 		pub fn release_license(origin: OriginFor<T>) -> DispatchResultWithPostInfo {
 			// leave_intent
@@ -445,8 +451,9 @@
 		/// The `LicenseBond` will be unreserved and returned immediately.
 		///
 		/// This call is, of course, not applicable to `Invulnerable` collators.
+		#[pallet::call_index(6)]
 		#[pallet::weight(T::WeightInfo::leave_intent(T::MaxCollators::get()))] // todo:collator weight
-		pub fn force_revoke_license(
+		pub fn force_release_license(
 			origin: OriginFor<T>,
 			who: T::AccountId,
 		) -> DispatchResultWithPostInfo {
modifiedpallets/collator-selection/src/mock.rsdiffbeforeafterboth
--- a/pallets/collator-selection/src/mock.rs
+++ b/pallets/collator-selection/src/mock.rs
@@ -281,9 +281,7 @@
 			)
 		})
 		.collect::<Vec<_>>();
-	let collator_selection = collator_selection::GenesisConfig::<Test> {
-		invulnerables,
-	};
+	let collator_selection = collator_selection::GenesisConfig::<Test> { invulnerables };
 	let session = pallet_session::GenesisConfig::<Test> { keys };
 	pallet_balances::GenesisConfig::<Test> { balances }
 		.assimilate_storage(&mut t)
modifiedpallets/collator-selection/src/tests.rsdiffbeforeafterboth
--- a/pallets/collator-selection/src/tests.rs
+++ b/pallets/collator-selection/src/tests.rs
@@ -380,7 +380,7 @@
 }
 
 #[test]
-fn force_revoke_license() {
+fn force_release_license() {
 	new_test_ext().execute_with(|| {
 		// obtain a license to collate and reserve the bond.
 		assert_ok!(CollatorSelection::get_license(RuntimeOrigin::signed(3)));
@@ -388,12 +388,12 @@
 
 		// cannot execute the operation as non-root
 		assert_noop!(
-			CollatorSelection::force_revoke_license(RuntimeOrigin::signed(3), 3),
+			CollatorSelection::force_release_license(RuntimeOrigin::signed(3), 3),
 			BadOrigin
 		);
 
 		// release the license and get the bond back.
-		assert_ok!(CollatorSelection::force_revoke_license(
+		assert_ok!(CollatorSelection::force_release_license(
 			RuntimeOrigin::signed(RootAccount::get()),
 			3
 		));
@@ -404,7 +404,7 @@
 		assert_eq!(Balances::free_balance(3), 90);
 
 		// can release license even if onboarded.
-		assert_ok!(CollatorSelection::force_revoke_license(
+		assert_ok!(CollatorSelection::force_release_license(
 			RuntimeOrigin::signed(RootAccount::get()),
 			3
 		));
@@ -532,9 +532,7 @@
 		.unwrap();
 	let invulnerables = vec![1, 1];
 
-	let collator_selection = collator_selection::GenesisConfig::<Test> {
-		invulnerables,
-	};
+	let collator_selection = collator_selection::GenesisConfig::<Test> { invulnerables };
 	// collator selection must be initialized before session.
 	collator_selection.assimilate_storage(&mut t).unwrap();
 }
modifiedpallets/configuration/src/lib.rsdiffbeforeafterboth
--- a/pallets/configuration/src/lib.rs
+++ b/pallets/configuration/src/lib.rs
@@ -201,6 +201,7 @@
 			Ok(())
 		}
 
+		#[pallet::call_index(4)]
 		#[pallet::weight(T::DbWeight::get().writes(1))]
 		pub fn set_collator_selection_desired_collators(
 			origin: OriginFor<T>,
@@ -216,10 +217,13 @@
 			} else {
 				<CollatorSelectionDesiredCollatorsOverride<T>>::kill();
 			}
-			Self::deposit_event(Event::NewDesiredCollators { desired_collators: max });
+			Self::deposit_event(Event::NewDesiredCollators {
+				desired_collators: max,
+			});
 			Ok(())
 		}
 
+		#[pallet::call_index(5)]
 		#[pallet::weight(T::DbWeight::get().writes(1))]
 		pub fn set_collator_selection_license_bond(
 			origin: OriginFor<T>,
@@ -235,6 +239,7 @@
 			Ok(())
 		}
 
+		#[pallet::call_index(6)]
 		#[pallet::weight(T::DbWeight::get().writes(1))]
 		pub fn set_collator_selection_kick_threshold(
 			origin: OriginFor<T>,
@@ -246,7 +251,9 @@
 			} else {
 				<CollatorSelectionKickThresholdOverride<T>>::kill();
 			}
-			Self::deposit_event(Event::NewCollatorKickThreshold { length_in_blocks: threshold });
+			Self::deposit_event(Event::NewCollatorKickThreshold {
+				length_in_blocks: threshold,
+			});
 			Ok(())
 		}
 	}
modifiedruntime/common/data_management.rsdiffbeforeafterboth
--- a/runtime/common/data_management.rs
+++ b/runtime/common/data_management.rs
@@ -58,10 +58,10 @@
 		_info: &DispatchInfoOf<Self::Call>,
 		_len: usize,
 	) -> TransactionValidity {
-        match call {
-            #[cfg(feature = "collator-selection")]
-            RuntimeCall::Identity(_) => Err(TransactionValidityError::Invalid(InvalidTransaction::Call)),
-            _ => Ok(ValidTransaction::default()),
-        }
+		match call {
+			#[cfg(feature = "collator-selection")]
+			RuntimeCall::Identity(_) => Err(TransactionValidityError::Invalid(InvalidTransaction::Call)),
+			_ => Ok(ValidTransaction::default()),
+		}
 	}
 }
modifiedruntime/common/mod.rsdiffbeforeafterboth
before · runtime/common/mod.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/>.1617pub mod config;18pub mod construct_runtime;19pub mod dispatch;20pub mod ethereum;21pub mod instance;22pub mod maintenance;23pub mod data_management;24pub mod runtime_apis;25pub mod xcm;2627#[cfg(feature = "scheduler")]28pub mod scheduler;2930pub mod sponsoring;31pub mod weights;3233#[cfg(test)]34pub mod tests;3536use sp_core::H160;37use frame_support::{38	traits::{Currency, OnUnbalanced, Imbalance},39	weights::Weight,40};41use sp_runtime::{42	generic,43	traits::{BlakeTwo256, BlockNumberProvider},44	impl_opaque_keys,45};46use sp_std::vec::Vec;4748#[cfg(feature = "std")]49use sp_version::NativeVersion;5051use crate::{52	Runtime, RuntimeCall, Balances, Treasury, Aura, Signature, AllPalletsWithSystem,53	InherentDataExt,54};55use up_common::types::{AccountId, BlockNumber};5657#[macro_export]58macro_rules! unsupported {59	() => {60		pallet_common::unsupported!($crate::Runtime)61	};62}6364/// The address format for describing accounts.65pub type Address = sp_runtime::MultiAddress<AccountId, ()>;66/// Block header type as expected by this runtime.67pub type Header = generic::Header<BlockNumber, BlakeTwo256>;68/// Block type as expected by this runtime.69pub type Block = generic::Block<Header, UncheckedExtrinsic>;70/// A Block signed with a Justification71pub type SignedBlock = generic::SignedBlock<Block>;72/// BlockId type as expected by this runtime.73pub type BlockId = generic::BlockId<Block>;7475impl_opaque_keys! {76	pub struct SessionKeys {77		pub aura: Aura,78	}79}8081/// The version information used to identify this runtime when compiled natively.82#[cfg(feature = "std")]83pub fn native_version() -> NativeVersion {84	NativeVersion {85		runtime_version: crate::VERSION,86		can_author_with: Default::default(),87	}88}8990pub type ChargeTransactionPayment = pallet_charge_transaction::ChargeTransactionPayment<Runtime>;9192pub type SignedExtra = (93	frame_system::CheckSpecVersion<Runtime>,94	frame_system::CheckTxVersion<Runtime>,95	frame_system::CheckGenesis<Runtime>,96	frame_system::CheckEra<Runtime>,97	frame_system::CheckNonce<Runtime>,98	frame_system::CheckWeight<Runtime>,99	maintenance::CheckMaintenance,100	data_management::FilterIdentity,101	ChargeTransactionPayment,102	//pallet_contract_helpers::ContractHelpersExtension<Runtime>,103	pallet_ethereum::FakeTransactionFinalizer<Runtime>,104);105106/// Unchecked extrinsic type as expected by this runtime.107pub type UncheckedExtrinsic =108	fp_self_contained::UncheckedExtrinsic<Address, RuntimeCall, Signature, SignedExtra>;109110/// Extrinsic type that has already been checked.111pub type CheckedExtrinsic =112	fp_self_contained::CheckedExtrinsic<AccountId, RuntimeCall, SignedExtra, H160>;113114/// Executive: handles dispatch to the various modules.115pub type Executive = frame_executive::Executive<116	Runtime,117	Block,118	frame_system::ChainContext<Runtime>,119	Runtime,120	AllPalletsWithSystem,121	AuraToCollatorSelection,122>;123124type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;125126pub struct DealWithFees;127impl OnUnbalanced<NegativeImbalance> for DealWithFees {128	fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance>) {129		if let Some(fees) = fees_then_tips.next() {130			// for fees, 100% to treasury131			let mut split = fees.ration(100, 0);132			if let Some(tips) = fees_then_tips.next() {133				// for tips, if any, 100% to treasury134				tips.ration_merge_into(100, 0, &mut split);135			}136			Treasury::on_unbalanced(split.0);137			// Author::on_unbalanced(split.1);138		}139	}140}141142pub struct RelayChainBlockNumberProvider<T>(sp_std::marker::PhantomData<T>);143144impl<T: cumulus_pallet_parachain_system::Config> BlockNumberProvider145	for RelayChainBlockNumberProvider<T>146{147	type BlockNumber = BlockNumber;148149	fn current_block_number() -> Self::BlockNumber {150		cumulus_pallet_parachain_system::Pallet::<T>::validation_data()151			.map(|d| d.relay_parent_number)152			.unwrap_or_default()153	}154	#[cfg(feature = "runtime-benchmarks")]155	fn set_block_number(block: Self::BlockNumber) {156		cumulus_pallet_parachain_system::RelaychainBlockNumberProvider::<T>::set_block_number(block)157	}158}159160pub(crate) struct CheckInherents;161162impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {163	fn check_inherents(164		block: &Block,165		relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof,166	) -> sp_inherents::CheckInherentsResult {167		let relay_chain_slot = relay_state_proof168			.read_slot()169			.expect("Could not read the relay chain slot from the proof");170171		let inherent_data =172			cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration(173				relay_chain_slot,174				sp_std::time::Duration::from_secs(6),175			)176			.create_inherent_data()177			.expect("Could not create the timestamp inherent data");178179		inherent_data.check_extrinsics(block)180	}181}182183#[derive(codec::Encode, codec::Decode)]184pub enum XCMPMessage<XAccountId, XBalance> {185	/// Transfer tokens to the given account from the Parachain account.186	TransferToken(XAccountId, XBalance),187}188189pub struct AuraToCollatorSelection;190impl frame_support::traits::OnRuntimeUpgrade for AuraToCollatorSelection {191	fn on_runtime_upgrade() -> Weight {192		#[cfg(feature = "collator-selection")]193		{194			use frame_support::{BoundedVec, storage::migration};195			use sp_runtime::{traits::OpaqueKeys, RuntimeAppPublic};196			use pallet_session::SessionManager;197			use crate::config::pallets::MaxCollators;198199			let mut weight = <Runtime as frame_system::Config>::DbWeight::get().reads(1);200201			let version = migration::get_storage_value::<()>(202				b"AuraToCollatorSelection",203				b"StorageVersion",204				&[],205			);206207			let should_upgrade = match version {208				None => true,209				Some(_) => false,210			};211212			if should_upgrade {213				log::info!(214					target: "runtime::aura_to_collator_selection",215					"Running migration of Aura authorities to Collator Selection invulnerables"216				);217218				let invulnerables = pallet_aura::Pallet::<Runtime>::authorities()219					.iter()220					.cloned()221					.filter_map(|authority_id| {222						weight.saturating_accrue(<Runtime as frame_system::Config>::DbWeight::get().reads_writes(1, 1));223						let vec = authority_id.clone().to_raw_vec();224						let slice = vec.as_slice();225						let array: Option<[u8; 32]> = match slice.try_into() {226							Ok(a) => Some(a),227							Err(_) => {228								log::error!("Failed to convert an Aura authority to a Collator Selection invulnerable: {:?}", authority_id);229								None230							},231						};232						array.map(|a| (AccountId::from(a), authority_id))233					})234					.collect::<Vec<_>>();235236				let bounded_invulnerables = BoundedVec::<_, MaxCollators>::try_from(237					invulnerables238						.iter()239						.cloned()240						.map(|(acc, _)| acc)241						.collect::<Vec<_>>(),242				)243				.expect("Existing collators/invulnerables are more than MaxCollators");244245				<pallet_collator_selection::Invulnerables<Runtime>>::put(bounded_invulnerables);246247				let keys = invulnerables248					.into_iter()249					.map(|(acc, aura)| {250						(251							acc.clone(),                        // account id252							acc,                                // validator id253							SessionKeys { aura: aura.clone() }, // session keys254						)255					})256					.collect::<Vec<_>>();257258				for (account, val, keys) in keys.iter().cloned() {259					for id in <Runtime as pallet_session::Config>::Keys::key_ids() {260						<pallet_session::KeyOwner<Runtime>>::insert((*id, keys.get_raw(*id)), &val)261					}262					<pallet_session::NextKeys<Runtime>>::insert(&val, &keys);263					// todo exercise caution, the following is taken from genesis264					if frame_system::Pallet::<Runtime>::inc_consumers_without_limit(&account)265						.is_err()266					{267						log::warn!(268							"We have entered an error with incrementing consumers without limit during the migration"269						);270						// This will leak a provider reference, however it only happens once (at271						// genesis) so it's really not a big deal and we assume that the user wants to272						// do this since it's the only way a non-endowed account can contain a session273						// key.274						frame_system::Pallet::<Runtime>::inc_providers(&account);275					}276				}277278				let initial_validators_0 =279					<Runtime as pallet_session::Config>::SessionManager::new_session(0)280						.unwrap_or_else(|| {281							frame_support::print(282								"No initial validator provided by `SessionManager`, use \283							session config keys to generate initial validator set.",284							);285							keys.iter().map(|x| x.1.clone()).collect()286						});287				/*assert!(288					!initial_validators_0.is_empty(),289					"Empty validator set for session 0 in (pseudo) genesis block!"290				);*/291292				let initial_validators_1 =293					<Runtime as pallet_session::Config>::SessionManager::new_session(1)294						.unwrap_or_else(|| initial_validators_0.clone());295				/*assert!(296					!initial_validators_1.is_empty(),297					"Empty validator set for session 1 in (pseudo) genesis block!"298				);*/299300				let queued_keys: Vec<_> = initial_validators_1301					.iter()302					.cloned()303					.map(|v| {304						(305							v.clone(),306							<pallet_session::NextKeys<Runtime>>::get(&v)307								.expect("Validator in session 1 missing keys!"),308						)309					})310					.collect();311312				// Tell everyone about the genesis session keys -- Aura must've already initialized it313				//<Runtime as pallet_session::Config>::SessionHandler::on_genesis_session::<<Runtime as pallet_session::Config>::Keys>(&queued_keys);314315				<pallet_session::Validators<Runtime>>::put(initial_validators_0);316				<pallet_session::QueuedKeys<Runtime>>::put(queued_keys);317318				<Runtime as pallet_session::Config>::SessionManager::start_session(0);319320				log::info!(321					target: "runtime::aura_to_collator_selection",322					"Migration of Aura authorities to Collator Selection invulnerables is complete."323				);324325				migration::put_storage_value::<()>(326					b"AuraToCollatorSelection",327					b"StorageVersion",328					&[],329					(),330				);331332				weight += <Runtime as frame_system::Config>::DbWeight::get().writes(1)333			} else {334				log::info!(335					target: "runtime::aura_to_collator_selection",336					"The storage migration has already been flagged as complete. No migration needs to be done.",337				);338			}339340			weight341		}342343		#[cfg(not(feature = "collator-selection"))]344		{345			Weight::zero()346		}347	}348}
after · runtime/common/mod.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/>.1617pub mod config;18pub mod construct_runtime;19pub mod data_management;20pub mod dispatch;21pub mod ethereum;22pub mod instance;23pub mod maintenance;24pub mod runtime_apis;25pub mod xcm;2627#[cfg(feature = "scheduler")]28pub mod scheduler;2930pub mod sponsoring;31pub mod weights;3233#[cfg(test)]34pub mod tests;3536use sp_core::H160;37use frame_support::{38	traits::{Currency, OnUnbalanced, Imbalance},39	weights::Weight,40};41use sp_runtime::{42	generic,43	traits::{BlakeTwo256, BlockNumberProvider},44	impl_opaque_keys,45};46use sp_std::vec::Vec;4748#[cfg(feature = "std")]49use sp_version::NativeVersion;5051use crate::{52	Runtime, RuntimeCall, Balances, Treasury, Aura, Signature, AllPalletsWithSystem,53	InherentDataExt,54};55use up_common::types::{AccountId, BlockNumber};5657#[macro_export]58macro_rules! unsupported {59	() => {60		pallet_common::unsupported!($crate::Runtime)61	};62}6364/// The address format for describing accounts.65pub type Address = sp_runtime::MultiAddress<AccountId, ()>;66/// Block header type as expected by this runtime.67pub type Header = generic::Header<BlockNumber, BlakeTwo256>;68/// Block type as expected by this runtime.69pub type Block = generic::Block<Header, UncheckedExtrinsic>;70/// A Block signed with a Justification71pub type SignedBlock = generic::SignedBlock<Block>;72/// BlockId type as expected by this runtime.73pub type BlockId = generic::BlockId<Block>;7475impl_opaque_keys! {76	pub struct SessionKeys {77		pub aura: Aura,78	}79}8081/// The version information used to identify this runtime when compiled natively.82#[cfg(feature = "std")]83pub fn native_version() -> NativeVersion {84	NativeVersion {85		runtime_version: crate::VERSION,86		can_author_with: Default::default(),87	}88}8990pub type ChargeTransactionPayment = pallet_charge_transaction::ChargeTransactionPayment<Runtime>;9192pub type SignedExtra = (93	frame_system::CheckSpecVersion<Runtime>,94	frame_system::CheckTxVersion<Runtime>,95	frame_system::CheckGenesis<Runtime>,96	frame_system::CheckEra<Runtime>,97	frame_system::CheckNonce<Runtime>,98	frame_system::CheckWeight<Runtime>,99	maintenance::CheckMaintenance,100	data_management::FilterIdentity,101	ChargeTransactionPayment,102	//pallet_contract_helpers::ContractHelpersExtension<Runtime>,103	pallet_ethereum::FakeTransactionFinalizer<Runtime>,104);105106/// Unchecked extrinsic type as expected by this runtime.107pub type UncheckedExtrinsic =108	fp_self_contained::UncheckedExtrinsic<Address, RuntimeCall, Signature, SignedExtra>;109110/// Extrinsic type that has already been checked.111pub type CheckedExtrinsic =112	fp_self_contained::CheckedExtrinsic<AccountId, RuntimeCall, SignedExtra, H160>;113114/// Executive: handles dispatch to the various modules.115pub type Executive = frame_executive::Executive<116	Runtime,117	Block,118	frame_system::ChainContext<Runtime>,119	Runtime,120	AllPalletsWithSystem,121	AuraToCollatorSelection,122>;123124type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;125126pub struct DealWithFees;127impl OnUnbalanced<NegativeImbalance> for DealWithFees {128	fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance>) {129		if let Some(fees) = fees_then_tips.next() {130			// for fees, 100% to treasury131			let mut split = fees.ration(100, 0);132			if let Some(tips) = fees_then_tips.next() {133				// for tips, if any, 100% to treasury134				tips.ration_merge_into(100, 0, &mut split);135			}136			Treasury::on_unbalanced(split.0);137			// Author::on_unbalanced(split.1);138		}139	}140}141142pub struct RelayChainBlockNumberProvider<T>(sp_std::marker::PhantomData<T>);143144impl<T: cumulus_pallet_parachain_system::Config> BlockNumberProvider145	for RelayChainBlockNumberProvider<T>146{147	type BlockNumber = BlockNumber;148149	fn current_block_number() -> Self::BlockNumber {150		cumulus_pallet_parachain_system::Pallet::<T>::validation_data()151			.map(|d| d.relay_parent_number)152			.unwrap_or_default()153	}154	#[cfg(feature = "runtime-benchmarks")]155	fn set_block_number(block: Self::BlockNumber) {156		cumulus_pallet_parachain_system::RelaychainBlockNumberProvider::<T>::set_block_number(block)157	}158}159160pub(crate) struct CheckInherents;161162impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {163	fn check_inherents(164		block: &Block,165		relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof,166	) -> sp_inherents::CheckInherentsResult {167		let relay_chain_slot = relay_state_proof168			.read_slot()169			.expect("Could not read the relay chain slot from the proof");170171		let inherent_data =172			cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration(173				relay_chain_slot,174				sp_std::time::Duration::from_secs(6),175			)176			.create_inherent_data()177			.expect("Could not create the timestamp inherent data");178179		inherent_data.check_extrinsics(block)180	}181}182183#[derive(codec::Encode, codec::Decode)]184pub enum XCMPMessage<XAccountId, XBalance> {185	/// Transfer tokens to the given account from the Parachain account.186	TransferToken(XAccountId, XBalance),187}188189pub struct AuraToCollatorSelection;190impl frame_support::traits::OnRuntimeUpgrade for AuraToCollatorSelection {191	fn on_runtime_upgrade() -> Weight {192		#[cfg(feature = "collator-selection")]193		{194			use frame_support::{BoundedVec, storage::migration};195			use sp_runtime::{traits::OpaqueKeys, RuntimeAppPublic};196			use pallet_session::SessionManager;197			use crate::config::pallets::MaxCollators;198199			let mut weight = <Runtime as frame_system::Config>::DbWeight::get().reads(1);200201			let version = migration::get_storage_value::<()>(202				b"AuraToCollatorSelection",203				b"StorageVersion",204				&[],205			);206207			let should_upgrade = match version {208				None => true,209				Some(_) => false,210			};211212			if should_upgrade {213				log::info!(214					target: "runtime::aura_to_collator_selection",215					"Running migration of Aura authorities to Collator Selection invulnerables"216				);217218				let invulnerables = pallet_aura::Pallet::<Runtime>::authorities()219					.iter()220					.cloned()221					.filter_map(|authority_id| {222						weight.saturating_accrue(<Runtime as frame_system::Config>::DbWeight::get().reads_writes(1, 1));223						let vec = authority_id.clone().to_raw_vec();224						let slice = vec.as_slice();225						let array: Option<[u8; 32]> = match slice.try_into() {226							Ok(a) => Some(a),227							Err(_) => {228								log::error!("Failed to convert an Aura authority to a Collator Selection invulnerable: {:?}", authority_id);229								None230							},231						};232						array.map(|a| (AccountId::from(a), authority_id))233					})234					.collect::<Vec<_>>();235236				let bounded_invulnerables = BoundedVec::<_, MaxCollators>::try_from(237					invulnerables238						.iter()239						.cloned()240						.map(|(acc, _)| acc)241						.collect::<Vec<_>>(),242				)243				.expect("Existing collators/invulnerables are more than MaxCollators");244245				<pallet_collator_selection::Invulnerables<Runtime>>::put(bounded_invulnerables);246247				let keys = invulnerables248					.into_iter()249					.map(|(acc, aura)| {250						(251							acc.clone(),                        // account id252							acc,                                // validator id253							SessionKeys { aura: aura.clone() }, // session keys254						)255					})256					.collect::<Vec<_>>();257258				for (account, val, keys) in keys.iter().cloned() {259					for id in <Runtime as pallet_session::Config>::Keys::key_ids() {260						<pallet_session::KeyOwner<Runtime>>::insert((*id, keys.get_raw(*id)), &val)261					}262					<pallet_session::NextKeys<Runtime>>::insert(&val, &keys);263					// todo exercise caution, the following is taken from genesis264					if frame_system::Pallet::<Runtime>::inc_consumers_without_limit(&account)265						.is_err()266					{267						log::warn!(268							"We have entered an error with incrementing consumers without limit during the migration"269						);270						// This will leak a provider reference, however it only happens once (at271						// genesis) so it's really not a big deal and we assume that the user wants to272						// do this since it's the only way a non-endowed account can contain a session273						// key.274						frame_system::Pallet::<Runtime>::inc_providers(&account);275					}276				}277278				let initial_validators_0 =279					<Runtime as pallet_session::Config>::SessionManager::new_session(0)280						.unwrap_or_else(|| {281							frame_support::print(282								"No initial validator provided by `SessionManager`, use \283							session config keys to generate initial validator set.",284							);285							keys.iter().map(|x| x.1.clone()).collect()286						});287				/*assert!(288					!initial_validators_0.is_empty(),289					"Empty validator set for session 0 in (pseudo) genesis block!"290				);*/291292				let initial_validators_1 =293					<Runtime as pallet_session::Config>::SessionManager::new_session(1)294						.unwrap_or_else(|| initial_validators_0.clone());295				/*assert!(296					!initial_validators_1.is_empty(),297					"Empty validator set for session 1 in (pseudo) genesis block!"298				);*/299300				let queued_keys: Vec<_> = initial_validators_1301					.iter()302					.cloned()303					.map(|v| {304						(305							v.clone(),306							<pallet_session::NextKeys<Runtime>>::get(&v)307								.expect("Validator in session 1 missing keys!"),308						)309					})310					.collect();311312				// Tell everyone about the genesis session keys -- Aura must've already initialized it313				//<Runtime as pallet_session::Config>::SessionHandler::on_genesis_session::<<Runtime as pallet_session::Config>::Keys>(&queued_keys);314315				<pallet_session::Validators<Runtime>>::put(initial_validators_0);316				<pallet_session::QueuedKeys<Runtime>>::put(queued_keys);317318				<Runtime as pallet_session::Config>::SessionManager::start_session(0);319320				log::info!(321					target: "runtime::aura_to_collator_selection",322					"Migration of Aura authorities to Collator Selection invulnerables is complete."323				);324325				migration::put_storage_value::<()>(326					b"AuraToCollatorSelection",327					b"StorageVersion",328					&[],329					(),330				);331332				weight += <Runtime as frame_system::Config>::DbWeight::get().writes(1)333			} else {334				log::info!(335					target: "runtime::aura_to_collator_selection",336					"The storage migration has already been flagged as complete. No migration needs to be done.",337				);338			}339340			weight341		}342343		#[cfg(not(feature = "collator-selection"))]344		{345			Weight::zero()346		}347	}348}
modifiedruntime/common/tests/mod.rsdiffbeforeafterboth
--- a/runtime/common/tests/mod.rs
+++ b/runtime/common/tests/mod.rs
@@ -63,9 +63,7 @@
 		.collect::<Vec<_>>();
 
 	let cfg = GenesisConfig {
-		collator_selection: CollatorSelectionConfig {
-			invulnerables,
-		},
+		collator_selection: CollatorSelectionConfig { invulnerables },
 		session: SessionConfig { keys },
 		parachain_info: ParachainInfoConfig {
 			parachain_id: para_id.into(),
modifiedtests/src/collatorSelection.seqtest.tsdiffbeforeafterboth
--- a/tests/src/collatorSelection.seqtest.ts
+++ b/tests/src/collatorSelection.seqtest.ts
@@ -209,7 +209,7 @@
         expect(await helper.collatorSelection.hasLicense(account.address)).to.be.equal(licenseBond);
 
         // force-releasing a license un-reserves the license bond cost as well
-        await helper.getSudo().collatorSelection.forceRevokeLicense(superuser, account.address);
+        await helper.getSudo().collatorSelection.forceReleaseLicense(superuser, account.address);
         expect(await helper.collatorSelection.hasLicense(account.address)).to.be.equal(previousBalance.reserved);
 
         const balance = await helper.balance.getSubstrateFull(account.address);
@@ -243,7 +243,7 @@
       itSub('Cannot force revoke a license as non-sudo', async ({helper}) => {
         const account = crowd.pop()!;
         await helper.collatorSelection.obtainLicense(account);
-        await expect(helper.collatorSelection.forceRevokeLicense(superuser, account.address))
+        await expect(helper.collatorSelection.forceReleaseLicense(superuser, account.address))
           .to.be.rejectedWith(/BadOrigin/);
       });
     });
@@ -459,7 +459,7 @@
       const candidates = await helper.collatorSelection.getCandidates();
       let nonce = await helper.chain.getNonce(superuser.address);
       await Promise.all(candidates.map(candidate =>
-        helper.getSudo().executeExtrinsic(superuser, 'api.tx.collatorSelection.forceRevokeLicense', [candidate], true, {nonce: nonce++})));
+        helper.getSudo().executeExtrinsic(superuser, 'api.tx.collatorSelection.forceReleaseLicense', [candidate], true, {nonce: nonce++})));
     });
   });
 });
\ No newline at end of file
modifiedtests/src/interfaces/augment-api-tx.tsdiffbeforeafterboth
--- a/tests/src/interfaces/augment-api-tx.ts
+++ b/tests/src/interfaces/augment-api-tx.ts
@@ -237,7 +237,7 @@
        * 
        * This call is, of course, not applicable to `Invulnerable` collators.
        **/
-      forceRevokeLicense: AugmentedSubmittable<(who: AccountId32 | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [AccountId32]>;
+      forceReleaseLicense: AugmentedSubmittable<(who: AccountId32 | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [AccountId32]>;
       /**
        * Purchase a license on block collation for this account.
        * It does not make it a collator candidate, use `onboard` afterward. The account must
modifiedtests/src/interfaces/default/types.tsdiffbeforeafterboth
--- a/tests/src/interfaces/default/types.ts
+++ b/tests/src/interfaces/default/types.ts
@@ -1243,11 +1243,11 @@
   readonly isOnboard: boolean;
   readonly isOffboard: boolean;
   readonly isReleaseLicense: boolean;
-  readonly isForceRevokeLicense: boolean;
-  readonly asForceRevokeLicense: {
+  readonly isForceReleaseLicense: boolean;
+  readonly asForceReleaseLicense: {
     readonly who: AccountId32;
   } & Struct;
-  readonly type: 'AddInvulnerable' | 'RemoveInvulnerable' | 'GetLicense' | 'Onboard' | 'Offboard' | 'ReleaseLicense' | 'ForceRevokeLicense';
+  readonly type: 'AddInvulnerable' | 'RemoveInvulnerable' | 'GetLicense' | 'Onboard' | 'Offboard' | 'ReleaseLicense' | 'ForceReleaseLicense';
 }
 
 /** @name PalletCollatorSelectionError */
modifiedtests/src/interfaces/lookup.tsdiffbeforeafterboth
--- a/tests/src/interfaces/lookup.ts
+++ b/tests/src/interfaces/lookup.ts
@@ -1692,7 +1692,7 @@
       onboard: 'Null',
       offboard: 'Null',
       release_license: 'Null',
-      force_revoke_license: {
+      force_release_license: {
         who: 'AccountId32'
       }
     }
modifiedtests/src/interfaces/types-lookup.tsdiffbeforeafterboth
--- a/tests/src/interfaces/types-lookup.ts
+++ b/tests/src/interfaces/types-lookup.ts
@@ -1867,11 +1867,11 @@
     readonly isOnboard: boolean;
     readonly isOffboard: boolean;
     readonly isReleaseLicense: boolean;
-    readonly isForceRevokeLicense: boolean;
-    readonly asForceRevokeLicense: {
+    readonly isForceReleaseLicense: boolean;
+    readonly asForceReleaseLicense: {
       readonly who: AccountId32;
     } & Struct;
-    readonly type: 'AddInvulnerable' | 'RemoveInvulnerable' | 'GetLicense' | 'Onboard' | 'Offboard' | 'ReleaseLicense' | 'ForceRevokeLicense';
+    readonly type: 'AddInvulnerable' | 'RemoveInvulnerable' | 'GetLicense' | 'Onboard' | 'Offboard' | 'ReleaseLicense' | 'ForceReleaseLicense';
   }
 
   /** @name PalletCollatorSelectionError (185) */
modifiedtests/src/util/playgrounds/unique.tsdiffbeforeafterboth
--- a/tests/src/util/playgrounds/unique.ts
+++ b/tests/src/util/playgrounds/unique.ts
@@ -2772,8 +2772,8 @@
     return this.helper.executeExtrinsic(signer, 'api.tx.collatorSelection.releaseLicense', []);
   }
 
-  forceRevokeLicense(signer: TSigner, released: string) {
-    return this.helper.executeExtrinsic(signer, 'api.tx.collatorSelection.forceRevokeLicense', [released]);
+  forceReleaseLicense(signer: TSigner, released: string) {
+    return this.helper.executeExtrinsic(signer, 'api.tx.collatorSelection.forceReleaseLicense', [released]);
   }
 
   async hasLicense(address: string): Promise<bigint> {