git.delta.rocks / unique-network / refs/commits / 313a9f3da734

difftreelog

feat(collator-selection) licenses + onboarding

Fahrrader2022-12-22parent: #218082e.patch.diff
in: master

8 files changed

modifiednode/cli/src/chain_spec.rsdiffbeforeafterboth
--- a/node/cli/src/chain_spec.rs
+++ b/node/cli/src/chain_spec.rs
@@ -24,7 +24,7 @@
 use serde_json::map::Map;
 
 use up_common::types::opaque::*;
-use up_common::constants::{GENESIS_CANDIDACY_BOND, SESSION_LENGTH};
+use up_common::constants::{GENESIS_LICENSE_BOND, SESSION_LENGTH};
 
 #[cfg(feature = "unique-runtime")]
 pub use unique_runtime as default_runtime;
@@ -196,7 +196,7 @@
 					.cloned()
 					.map(|(acc, _)| acc)
 					.collect(),
-				candidacy_bond: GENESIS_CANDIDACY_BOND,
+				license_bond: GENESIS_LICENSE_BOND,
 				kick_threshold: SESSION_LENGTH,
 				..Default::default()
 			},
modifiedpallets/collator-selection/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/collator-selection/src/benchmarking.rs
+++ b/pallets/collator-selection/src/benchmarking.rs
@@ -116,12 +116,12 @@
 		.map(|c| account("candidate", c, SEED))
 		.collect::<Vec<_>>();
 	assert!(
-		<CandidacyBond<T>>::get() > 0u32.into(),
+		<LicenseBond<T>>::get() > 0u32.into(),
 		"Bond cannot be zero!"
 	);
 
 	for who in candidates {
-		T::Currency::make_free_balance_be(&who, <CandidacyBond<T>>::get() * 2u32.into());
+		T::Currency::make_free_balance_be(&who, <LicenseBond<T>>::get() * 2u32.into());
 		<CollatorSelection<T>>::register_as_candidate(RawOrigin::Signed(who).into()).unwrap();
 	}
 }
@@ -154,16 +154,16 @@
 		assert_last_event::<T>(Event::NewDesiredCandidates{desired_candidates: max}.into());
 	}
 
-	set_candidacy_bond {
+	set_license_bond {
 		let bond_amount: BalanceOf<T> = T::Currency::minimum_balance() * 10u32.into();
 		let origin = T::UpdateOrigin::successful_origin();
 	}: {
 		assert_ok!(
-			<CollatorSelection<T>>::set_candidacy_bond(origin, bond_amount.clone())
+			<CollatorSelection<T>>::set_license_bond(origin, bond_amount.clone())
 		);
 	}
 	verify {
-		assert_last_event::<T>(Event::NewCandidacyBond{bond_amount}.into());
+		assert_last_event::<T>(Event::NewLicenseBond{bond_amount}.into());
 	}
 
 	// worse case is when we have all the max-candidate slots filled except one, and we fill that
@@ -171,7 +171,7 @@
 	register_as_candidate {
 		let c in 1 .. T::MaxCandidates::get();
 
-		<CandidacyBond<T>>::put(T::Currency::minimum_balance());
+		<LicenseBond<T>>::put(T::Currency::minimum_balance());
 		<DesiredCandidates<T>>::put(c + 1);
 
 		register_validators::<T>(c);
@@ -195,7 +195,7 @@
 	// worse case is the last candidate leaving.
 	leave_intent {
 		let c in (T::MinCandidates::get() + 1) .. T::MaxCandidates::get();
-		<CandidacyBond<T>>::put(T::Currency::minimum_balance());
+		<LicenseBond<T>>::put(T::Currency::minimum_balance());
 		<DesiredCandidates<T>>::put(c);
 
 		register_validators::<T>(c);
@@ -211,7 +211,7 @@
 
 	// worse case is paying a non-existing candidate account.
 	note_author {
-		<CandidacyBond<T>>::put(T::Currency::minimum_balance());
+		<LicenseBond<T>>::put(T::Currency::minimum_balance());
 		T::Currency::make_free_balance_be(
 			&<CollatorSelection<T>>::account_id(),
 			T::Currency::minimum_balance() * 4u32.into(),
@@ -233,7 +233,7 @@
 		let r in 1 .. T::MaxCandidates::get();
 		let c in 1 .. T::MaxCandidates::get();
 
-		<CandidacyBond<T>>::put(T::Currency::minimum_balance());
+		<LicenseBond<T>>::put(T::Currency::minimum_balance());
 		<DesiredCandidates<T>>::put(c);
 		frame_system::Pallet::<T>::set_block_number(0u32.into());
 
modifiedpallets/collator-selection/src/lib.rsdiffbeforeafterboth
--- a/pallets/collator-selection/src/lib.rs
+++ b/pallets/collator-selection/src/lib.rs
@@ -181,7 +181,7 @@
 	#[derive(
 		PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug, scale_info::TypeInfo, MaxEncodedLen,
 	)]
-	pub struct CandidateInfo<AccountId, Balance> {
+	pub struct LicenseInfo<AccountId, Balance> {
 		/// Account identifier.
 		pub who: AccountId,
 		/// Reserved deposit.
@@ -198,12 +198,18 @@
 	pub type Invulnerables<T: Config> =
 		StorageValue<_, BoundedVec<T::AccountId, T::MaxInvulnerables>, ValueQuery>;
 
+	/// The (community) collation license holders.
+	#[pallet::storage]
+	#[pallet::getter(fn licenses)]
+	pub type Licenses<T: Config> =
+		StorageMap<_, Blake2_128Concat, T::AccountId, BalanceOf<T>, ValueQuery>;
+
 	/// The (community, limited) collation candidates.
 	#[pallet::storage]
 	#[pallet::getter(fn candidates)]
 	pub type Candidates<T: Config> = StorageValue<
 		_,
-		BoundedVec<CandidateInfo<T::AccountId, BalanceOf<T>>, T::MaxCandidates>,
+		BoundedVec<T::AccountId, T::MaxCandidates>, //LicenseInfo<T::AccountId, BalanceOf<T>>, T::MaxCandidates>, // license ID?
 		ValueQuery,
 	>;
 
@@ -231,13 +237,13 @@
 	///
 	/// When a collator calls `leave_intent` they immediately receive the deposit back.
 	#[pallet::storage]
-	#[pallet::getter(fn candidacy_bond)]
-	pub type CandidacyBond<T> = StorageValue<_, BalanceOf<T>, ValueQuery>;
+	#[pallet::getter(fn license_bond)]
+	pub type LicenseBond<T> = StorageValue<_, BalanceOf<T>, ValueQuery>;
 
 	#[pallet::genesis_config]
 	pub struct GenesisConfig<T: Config> {
 		pub invulnerables: Vec<T::AccountId>,
-		pub candidacy_bond: BalanceOf<T>,
+		pub license_bond: BalanceOf<T>,
 		pub kick_threshold: T::BlockNumber,
 		pub desired_candidates: u32,
 	}
@@ -247,7 +253,7 @@
 		fn default() -> Self {
 			Self {
 				invulnerables: Default::default(),
-				candidacy_bond: Default::default(),
+				license_bond: Default::default(),
 				kick_threshold: T::BlockNumber::one(),
 				desired_candidates: Default::default(),
 			}
@@ -275,7 +281,7 @@
 			);
 
 			<DesiredCandidates<T>>::put(&self.desired_candidates);
-			<CandidacyBond<T>>::put(&self.candidacy_bond);
+			<LicenseBond<T>>::put(&self.license_bond);
 			<KickThreshold<T>>::put(&self.kick_threshold);
 			<Invulnerables<T>>::put(bounded_invulnerables);
 		}
@@ -287,7 +293,7 @@
 		NewDesiredCandidates {
 			desired_candidates: u32,
 		},
-		NewCandidacyBond {
+		NewLicenseBond {
 			bond_amount: BalanceOf<T>,
 		},
 		NewKickThreshold {
@@ -299,13 +305,19 @@
 		InvulnerableRemoved {
 			invulnerable: T::AccountId,
 		},
-		CandidateAdded {
+		LicenseObtained {
 			account_id: T::AccountId,
 			deposit: BalanceOf<T>,
 		},
+		LicenseForfeited {
+			account_id: T::AccountId,
+			deposit_returned: BalanceOf<T>,
+		},
+		CandidateAdded {
+			account_id: T::AccountId,
+		},
 		CandidateRemoved {
 			account_id: T::AccountId,
-			deposit_returned: BalanceOf<T>,
 		},
 	}
 
@@ -320,6 +332,10 @@
 		Unknown,
 		/// Permission issue
 		Permission,
+		/// User already holds license to collate
+		AlreadyLicenseHolder,
+		/// User does not hold a license to collate
+		NoLicense,
 		/// User is already a candidate
 		AlreadyCandidate,
 		/// User is not a candidate
@@ -363,6 +379,9 @@
 				return Ok(().into());
 			}
 
+			// todo:collator check license holders, release moneys, promotion!
+			// force_release_license? Error::<T>::lreadyLicenseHolder?
+
 			<Invulnerables<T>>::try_append(new.clone())
 				.map_err(|_| Error::<T>::TooManyInvulnerables)?;
 			Self::deposit_event(Event::InvulnerableAdded { invulnerable: new });
@@ -419,20 +438,20 @@
 		}
 
 		/// Set the candidacy bond amount.
-		#[pallet::weight(T::WeightInfo::set_candidacy_bond())]
-		pub fn set_candidacy_bond(
+		#[pallet::weight(T::WeightInfo::set_license_bond())]
+		pub fn set_license_bond(
 			origin: OriginFor<T>,
 			bond: BalanceOf<T>,
 		) -> DispatchResultWithPostInfo {
 			T::UpdateOrigin::ensure_origin(origin)?;
-			<CandidacyBond<T>>::put(&bond);
-			Self::deposit_event(Event::NewCandidacyBond { bond_amount: bond });
+			<LicenseBond<T>>::put(&bond);
+			Self::deposit_event(Event::NewLicenseBond { bond_amount: bond });
 			Ok(().into())
 		}
 
 		/// Set the length of the kick threshold.
 		/// Note that if the length is not a multiple of the session period, it might get inconsistent.
-		#[pallet::weight(T::WeightInfo::set_candidacy_bond())] // todo:collator weight
+		#[pallet::weight(T::WeightInfo::set_license_bond())] // todo:collator weight
 		pub fn set_kick_threshold(
 			origin: OriginFor<T>,
 			kick_threshold: T::BlockNumber,
@@ -446,21 +465,20 @@
 			Ok(().into())
 		}
 
-		/// Register this account as a collator candidate. The account must (a) already have
-		/// registered session keys and (b) be able to reserve the `CandidacyBond`.
+		/// Purchase a license on block collation for this account.
+		/// It does not make it a collator candidate, use `onboard` afterward. The account must
+		/// (a) already have registered session keys and (b) be able to reserve the `LicenseBond`.
 		///
 		/// This call is not available to `Invulnerable` collators.
-		#[pallet::weight(T::WeightInfo::register_as_candidate(T::MaxCandidates::get()))]
-		pub fn register_as_candidate(origin: OriginFor<T>) -> DispatchResultWithPostInfo {
+		#[pallet::weight(T::WeightInfo::register_as_candidate(T::MaxCandidates::get()))] // todo:collator weight
+		pub fn get_license(origin: OriginFor<T>) -> DispatchResultWithPostInfo {
+			// register_as_candidate
 			let who = ensure_signed(origin)?;
 
-			// ensure we are below limit.
-			let length = <Candidates<T>>::decode_len().unwrap_or_default();
-			ensure!(
-				(length as u32) < Self::desired_candidates(),
-				Error::<T>::TooManyCandidates
-			);
-			// todo:collator really need it?
+			if Licenses::<T>::contains_key(&who) {
+				return Ok(().into());
+			}
+
 			ensure!(
 				!Self::invulnerables().contains(&who),
 				Error::<T>::AlreadyInvulnerable
@@ -473,21 +491,81 @@
 				Error::<T>::ValidatorNotRegistered
 			);
 
-			let deposit = Self::candidacy_bond();
+			let deposit = Self::license_bond();
 			// First authored block is current block plus kick threshold to handle session delay
-			let incoming = CandidateInfo {
+			/*let incoming = LicenseInfo {
 				who: who.clone(),
 				deposit,
-			};
+			};*/
 
+			T::Currency::reserve(&who, deposit)?;
+			Licenses::<T>::insert(who.clone(), deposit);
+
+			/*let current_count =
+			<Licenses<T>>::try_mutate(|licenses| -> Result<usize, DispatchError> {
+				if T::OriginPrivilegeCmp::cmp_privilege(&origin, &scheduled.origin) {
+					return Err(BadOrigin.into());
+				}
+				if candidates.iter().any(|candidate| *candidate == who) {
+					Err(Error::<T>::AlreadyLicenseHolder)?
+				} else {
+					T::Currency::reserve(&who, deposit)?;
+					candidates
+						.try_push(incoming)
+						.map_err(|_| Error::<T>::TooManyCandidates)?;
+					<LastAuthoredBlock<T>>::insert(
+						who.clone(),
+						frame_system::Pallet::<T>::block_number() + Self::kick_threshold(),
+					);
+					Ok(candidates.len())
+				}
+			})?;*/
+
+			Self::deposit_event(Event::LicenseObtained {
+				account_id: who,
+				deposit,
+			});
+			Ok(().into()) // Some(T::WeightInfo::register_as_candidate(current_count as u32)).into())
+		}
+
+		/// Register this account as a candidate for collators for next sessions.
+		/// The account must already hold a license, and cannot offboard immediately during a session.
+		///
+		/// This call is not available to `Invulnerable` collators.
+		#[pallet::weight(T::WeightInfo::register_as_candidate(T::MaxCandidates::get()))] // todo:collator weight
+		pub fn onboard(origin: OriginFor<T>) -> DispatchResultWithPostInfo {
+			// register_as_candidate
+			let who = ensure_signed(origin)?;
+
+			// ensure the user obtained the license.
+			ensure!(Licenses::<T>::contains_key(&who), Error::<T>::NoLicense);
+			// ensure we are below limit.
+			let length = <Candidates<T>>::decode_len().unwrap_or_default();
+			ensure!(
+				(length as u32) < Self::desired_candidates(),
+				Error::<T>::TooManyCandidates
+			);
+			// todo:collator really need it?
+			ensure!(
+				!Self::invulnerables().contains(&who),
+				Error::<T>::AlreadyInvulnerable
+			);
+
+			let deposit = Self::license_bond();
+			// First authored block is current block plus kick threshold to handle session delay
+			/*let incoming = LicenseInfo {
+				who: who.clone(),
+				deposit,
+			};*/
+
 			let current_count =
 				<Candidates<T>>::try_mutate(|candidates| -> Result<usize, DispatchError> {
-					if candidates.iter().any(|candidate| candidate.who == who) {
+					if candidates.iter().any(|candidate| *candidate == who) {
 						Err(Error::<T>::AlreadyCandidate)?
 					} else {
 						T::Currency::reserve(&who, deposit)?;
 						candidates
-							.try_push(incoming)
+							.try_push(who.clone())
 							.map_err(|_| Error::<T>::TooManyCandidates)?;
 						<LastAuthoredBlock<T>>::insert(
 							who.clone(),
@@ -497,31 +575,59 @@
 					}
 				})?;
 
-			Self::deposit_event(Event::CandidateAdded {
-				account_id: who,
-				deposit,
-			});
+			Self::deposit_event(Event::CandidateAdded { account_id: who });
 			Ok(Some(T::WeightInfo::register_as_candidate(current_count as u32)).into())
 		}
 
 		/// Deregister `origin` as a collator candidate. Note that the collator can only leave on
-		/// session change. The `CandidacyBond` will be unreserved immediately.
-		///
-		/// This call will fail if the total number of candidates would drop below `MinCandidates`.
+		/// session change. The license to `onboard` later at any other time will remain.
 		///
-		/// This call is not available to `Invulnerable` collators.
-		#[pallet::weight(T::WeightInfo::leave_intent(T::MaxCandidates::get()))]
-		pub fn leave_intent(origin: OriginFor<T>) -> DispatchResultWithPostInfo {
+		/// This call will fail if the total number of candidates would drop below `MinCandidates`. todo:collator maybe not
+		#[pallet::weight(T::WeightInfo::leave_intent(T::MaxCandidates::get()))] // todo:collator weight
+		pub fn offboard(origin: OriginFor<T>) -> DispatchResultWithPostInfo {
+			// leave_intent
 			let who = ensure_signed(origin)?;
 			// todo:collator invulnerables and candidates should count against min candidates together
 			ensure!(
 				Self::candidates().len() as u32 > T::MinCandidates::get(),
 				Error::<T>::TooFewCandidates
 			);
-			let current_count = Self::try_remove_candidate(&who, false)?;
+			let current_count = Self::try_remove_candidate(&who)?;
 
 			Ok(Some(T::WeightInfo::leave_intent(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::weight(T::WeightInfo::leave_intent(T::MaxCandidates::get()))] // todo:collator weight
+		pub fn release_license(origin: OriginFor<T>) -> DispatchResultWithPostInfo {
+			// leave_intent
+			let who = ensure_signed(origin)?;
+			// let current_count = Self::try_remove_candidate(&who, false)?;
+			Self::try_release_license(&who, false)?;
+
+			Ok(().into())
+		}
+
+		/// Force deregister `origin` as a collator candidate as a governing authority, and revoke its license.
+		/// Note that the collator can only leave on session change.
+		/// The `LicenseBond` will be unreserved and returned immediately.
+		///
+		/// This call is not available to `Invulnerable` collators.
+		#[pallet::weight(T::WeightInfo::leave_intent(T::MaxCandidates::get()))] // todo:collator weight
+		pub fn force_release_license(
+			origin: OriginFor<T>,
+			who: T::AccountId,
+		) -> DispatchResultWithPostInfo {
+			// leave_intent
+			T::UpdateOrigin::ensure_origin(origin)?;
+
+			let current_count = Self::try_remove_candidate(&who)?;
+			Self::try_release_license(&who, false)?;
+
+			Ok(Some(T::WeightInfo::leave_intent(current_count as u32)).into()) // todo:collator weight
+		}
 	}
 
 	impl<T: Config> Pallet<T> {
@@ -530,21 +636,29 @@
 			T::PotId::get().into_account_truncating()
 		}
 
-		/// Removes a candidate if they exist and sends them back their deposit, optionally slashed.
-		fn try_remove_candidate(
-			who: &T::AccountId,
-			should_slash: bool,
-		) -> Result<usize, DispatchError> {
-			let mut deposit_returned = BalanceOf::<T>::default();
+		/// Removes a candidate from the collator pool for the next session if they exist.
+		fn try_remove_candidate(who: &T::AccountId) -> Result<usize, DispatchError> {
 			let current_count =
 				<Candidates<T>>::try_mutate(|candidates| -> Result<usize, DispatchError> {
 					let index = candidates
 						.iter()
-						.position(|candidate| candidate.who == *who)
+						.position(|candidate| *candidate == *who)
 						.ok_or(Error::<T>::NotCandidate)?;
-					let candidate = candidates.remove(index);
-					let deposit = candidate.deposit;
+					candidates.remove(index);
+					<LastAuthoredBlock<T>>::remove(who.clone());
+					Ok(candidates.len())
+				})?;
+			Self::deposit_event(Event::CandidateRemoved {
+				account_id: who.clone(),
+			});
+			Ok(current_count)
+		}
 
+		/// Removes a candidate if they exist and sends them back their deposit, optionally slashed.
+		fn try_release_license(who: &T::AccountId, should_slash: bool) -> DispatchResult {
+			let mut deposit_returned = BalanceOf::<T>::default();
+			Licenses::<T>::try_mutate_exists(&who, |deposit| -> DispatchResult {
+				if let Some(deposit) = deposit.take() {
 					if should_slash {
 						let slashed = T::SlashRatio::get() * deposit;
 						let remaining = deposit - slashed;
@@ -554,23 +668,22 @@
 						deposit_returned = remaining;
 
 						T::Currency::resolve_creating(&T::TreasuryAccountId::get(), imbalance);
-
-					// Self::deposit_event(Event::CandidateSlashed(who.clone()));
 					} else {
 						//T::Currency::unreserve(who, deposit);
 						deposit_returned = deposit;
 					}
 
 					T::Currency::unreserve(who, deposit_returned);
-					// candidates.remove(index);
-					<LastAuthoredBlock<T>>::remove(who.clone());
-					Ok(candidates.len())
-				})?;
-			Self::deposit_event(Event::CandidateRemoved {
+					Ok(())
+				} else {
+					Err(Error::<T>::NoLicense.into())
+				}
+			})?;
+			Self::deposit_event(Event::LicenseForfeited {
 				account_id: who.clone(),
 				deposit_returned,
 			});
-			Ok(current_count)
+			Ok(())
 		}
 
 		/// Assemble the current set of candidates and invulnerables into the next collator set.
@@ -587,24 +700,30 @@
 		/// Kicks out candidates that did not produce a block in the kick threshold
 		/// and **confiscates** their deposits to the treasury.
 		pub fn kick_stale_candidates(
-			candidates: BoundedVec<CandidateInfo<T::AccountId, BalanceOf<T>>, T::MaxCandidates>,
+			candidates: BoundedVec<T::AccountId, T::MaxCandidates>, //LicenseInfo<T::AccountId, BalanceOf<T>>
 		) -> BoundedVec<T::AccountId, T::MaxCandidates> {
 			let now = frame_system::Pallet::<T>::block_number();
 			let kick_threshold = Self::kick_threshold();
 			candidates
 				.into_iter()
 				.filter_map(|c| {
-					let last_block = <LastAuthoredBlock<T>>::get(c.who.clone());
+					let last_block = <LastAuthoredBlock<T>>::get(c.clone());
 					let since_last = now.saturating_sub(last_block);
 					if since_last < kick_threshold ||
 						Self::candidates().len() as u32 <= T::MinCandidates::get()
 					{
-						Some(c.who)
+						Some(c)
 					} else {
-						let outcome = Self::try_remove_candidate(&c.who, true);
+						let outcome = Self::try_remove_candidate(&c);
 						if let Err(why) = outcome {
 							log::warn!("Failed to remove candidate {:?}", why);
 							debug_assert!(false, "failed to remove candidate {:?}", why);
+							return None;
+						}
+						let outcome = Self::try_release_license(&c, true);
+						if let Err(why) = outcome {
+							log::warn!("Failed to release license {:?}", why);
+							debug_assert!(false, "failed to release license {:?}", why);
 						}
 						None
 					}
modifiedpallets/collator-selection/src/mock.rsdiffbeforeafterboth
before · pallets/collator-selection/src/mock.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.3233use super::*;34use crate as collator_selection;35use frame_support::{36	ord_parameter_types, parameter_types,37	traits::{FindAuthor, GenesisBuild, ValidatorRegistration},38	PalletId,39};40use frame_system as system;41use frame_system::EnsureSignedBy;42use sp_core::H256;43use sp_runtime::{44	testing::{Header, UintAuthorityId},45	traits::{BlakeTwo256, IdentityLookup, OpaqueKeys},46	Perbill, RuntimeAppPublic,47};4849type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;50type Block = frame_system::mocking::MockBlock<Test>;5152// Configure a mock runtime to test the pallet.53frame_support::construct_runtime!(54	pub enum Test where55		Block = Block,56		NodeBlock = Block,57		UncheckedExtrinsic = UncheckedExtrinsic,58	{59		System: frame_system::{Pallet, Call, Config, Storage, Event<T>},60		Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent},61		Session: pallet_session::{Pallet, Call, Storage, Event, Config<T>},62		Aura: pallet_aura::{Pallet, Storage, Config<T>},63		Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},64		CollatorSelection: collator_selection::{Pallet, Call, Storage, Event<T>},65		Authorship: pallet_authorship::{Pallet, Call, Storage, Inherent},66	}67);6869parameter_types! {70	pub const BlockHashCount: u64 = 250;71	pub const SS58Prefix: u8 = 42;72}7374impl system::Config for Test {75	type BaseCallFilter = frame_support::traits::Everything;76	type BlockWeights = ();77	type BlockLength = ();78	type DbWeight = ();79	type RuntimeOrigin = RuntimeOrigin;80	type RuntimeCall = RuntimeCall;81	type Index = u64;82	type BlockNumber = u64;83	type Hash = H256;84	type Hashing = BlakeTwo256;85	type AccountId = u64;86	type Lookup = IdentityLookup<Self::AccountId>;87	type Header = Header;88	type RuntimeEvent = RuntimeEvent;89	type BlockHashCount = BlockHashCount;90	type Version = ();91	type PalletInfo = PalletInfo;92	type AccountData = pallet_balances::AccountData<u64>;93	type OnNewAccount = ();94	type OnKilledAccount = ();95	type SystemWeightInfo = ();96	type SS58Prefix = SS58Prefix;97	type OnSetCode = ();98	type MaxConsumers = frame_support::traits::ConstU32<16>;99}100101parameter_types! {102	pub const ExistentialDeposit: u64 = 5;103	pub const MaxReserves: u32 = 50;104}105106impl pallet_balances::Config for Test {107	type Balance = u64;108	type RuntimeEvent = RuntimeEvent;109	type DustRemoval = ();110	type ExistentialDeposit = ExistentialDeposit;111	type AccountStore = System;112	type WeightInfo = ();113	type MaxLocks = ();114	type MaxReserves = MaxReserves;115	type ReserveIdentifier = [u8; 8];116}117118pub struct Author4;119impl FindAuthor<u64> for Author4 {120	fn find_author<'a, I>(_digests: I) -> Option<u64>121	where122		I: 'a + IntoIterator<Item = (frame_support::ConsensusEngineId, &'a [u8])>,123	{124		Some(4)125	}126}127128impl pallet_authorship::Config for Test {129	type FindAuthor = Author4;130	type UncleGenerations = ();131	type FilterUncle = ();132	type EventHandler = CollatorSelection;133}134135parameter_types! {136	pub const MinimumPeriod: u64 = 1;137}138139impl pallet_timestamp::Config for Test {140	type Moment = u64;141	type OnTimestampSet = Aura;142	type MinimumPeriod = MinimumPeriod;143	type WeightInfo = ();144}145146impl pallet_aura::Config for Test {147	type AuthorityId = sp_consensus_aura::sr25519::AuthorityId;148	type MaxAuthorities = MaxAuthorities;149	type DisabledValidators = ();150}151152sp_runtime::impl_opaque_keys! {153	pub struct MockSessionKeys {154		// a key for aura authoring155		pub aura: UintAuthorityId,156	}157}158159impl From<UintAuthorityId> for MockSessionKeys {160	fn from(aura: sp_runtime::testing::UintAuthorityId) -> Self {161		Self { aura }162	}163}164165parameter_types! {166	pub static SessionHandlerCollators: Vec<u64> = Vec::new();167	pub static SessionChangeBlock: u64 = 0;168}169170pub struct TestSessionHandler;171impl pallet_session::SessionHandler<u64> for TestSessionHandler {172	const KEY_TYPE_IDS: &'static [sp_runtime::KeyTypeId] = &[UintAuthorityId::ID];173	fn on_genesis_session<Ks: OpaqueKeys>(keys: &[(u64, Ks)]) {174		SessionHandlerCollators::set(keys.into_iter().map(|(a, _)| *a).collect::<Vec<_>>())175	}176	fn on_new_session<Ks: OpaqueKeys>(_: bool, keys: &[(u64, Ks)], _: &[(u64, Ks)]) {177		SessionChangeBlock::set(System::block_number());178		dbg!(keys.len());179		SessionHandlerCollators::set(keys.into_iter().map(|(a, _)| *a).collect::<Vec<_>>())180	}181	fn on_before_session_ending() {}182	fn on_disabled(_: u32) {}183}184185parameter_types! {186	pub const Offset: u64 = 0;187	pub const Period: u64 = 10;188}189190impl pallet_session::Config for Test {191	type RuntimeEvent = RuntimeEvent;192	type ValidatorId = <Self as frame_system::Config>::AccountId;193	// we don't have stash and controller, thus we don't need the convert as well.194	type ValidatorIdOf = IdentityCollator;195	type ShouldEndSession = pallet_session::PeriodicSessions<Period, Offset>;196	type NextSessionRotation = pallet_session::PeriodicSessions<Period, Offset>;197	type SessionManager = CollatorSelection;198	type SessionHandler = TestSessionHandler;199	type Keys = MockSessionKeys;200	type WeightInfo = ();201}202203ord_parameter_types! {204	pub const RootAccount: u64 = 777;205}206207parameter_types! {208	pub const PotId: PalletId = PalletId(*b"PotStake");209	pub const MaxCandidates: u32 = 20;210	pub const MaxInvulnerables: u32 = 20;211	pub const MinCandidates: u32 = 1;212	pub const MaxAuthorities: u32 = 100_000;213	pub const SlashRatio: Perbill = Perbill::one();214}215216pub struct IsRegistered;217impl ValidatorRegistration<u64> for IsRegistered {218	fn is_registered(id: &u64) -> bool {219		if *id == 7u64 {220			false221		} else {222			true223		}224	}225}226227impl Config for Test {228	// todo:collator mocks and stocks229	type RuntimeEvent = RuntimeEvent;230	type Currency = Balances;231	type UpdateOrigin = EnsureSignedBy<RootAccount, u64>;232	type PotId = PotId;233	type MaxCandidates = MaxCandidates;234	type MinCandidates = MinCandidates;235	type MaxInvulnerables = MaxInvulnerables;236	// type KickThreshold = Period;237	type SlashRatio = SlashRatio;238	type TreasuryAccountId = ();239	type ValidatorId = <Self as frame_system::Config>::AccountId;240	type ValidatorIdOf = IdentityCollator;241	type ValidatorRegistration = IsRegistered;242	type WeightInfo = ();243}244245pub fn new_test_ext() -> sp_io::TestExternalities {246	sp_tracing::try_init_simple();247	let mut t = frame_system::GenesisConfig::default()248		.build_storage::<Test>()249		.unwrap();250	let invulnerables = vec![1, 2];251252	let balances = vec![(1, 100), (2, 100), (3, 100), (4, 100), (5, 100)];253	let keys = balances254		.iter()255		.map(|&(i, _)| {256			(257				i,258				i,259				MockSessionKeys {260					aura: UintAuthorityId(i),261				},262			)263		})264		.collect::<Vec<_>>();265	let collator_selection = collator_selection::GenesisConfig::<Test> {266		desired_candidates: 2,267		candidacy_bond: 10,268		kick_threshold: 1,269		invulnerables,270	};271	let session = pallet_session::GenesisConfig::<Test> { keys };272	pallet_balances::GenesisConfig::<Test> { balances }273		.assimilate_storage(&mut t)274		.unwrap();275	// collator selection must be initialized before session.276	collator_selection.assimilate_storage(&mut t).unwrap();277	session.assimilate_storage(&mut t).unwrap();278279	t.into()280}281282pub fn initialize_to_block(n: u64) {283	for i in System::block_number() + 1..=n {284		System::set_block_number(i);285		<AllPalletsWithSystem as frame_support::traits::OnInitialize<u64>>::on_initialize(i);286	}287}
after · pallets/collator-selection/src/mock.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.3233use super::*;34use crate as collator_selection;35use frame_support::{36	ord_parameter_types, parameter_types,37	traits::{FindAuthor, GenesisBuild, ValidatorRegistration},38	PalletId,39};40use frame_system as system;41use frame_system::EnsureSignedBy;42use sp_core::H256;43use sp_runtime::{44	testing::{Header, UintAuthorityId},45	traits::{BlakeTwo256, IdentityLookup, OpaqueKeys},46	Perbill, RuntimeAppPublic,47};4849type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;50type Block = frame_system::mocking::MockBlock<Test>;5152// Configure a mock runtime to test the pallet.53frame_support::construct_runtime!(54	pub enum Test where55		Block = Block,56		NodeBlock = Block,57		UncheckedExtrinsic = UncheckedExtrinsic,58	{59		System: frame_system::{Pallet, Call, Config, Storage, Event<T>},60		Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent},61		Session: pallet_session::{Pallet, Call, Storage, Event, Config<T>},62		Aura: pallet_aura::{Pallet, Storage, Config<T>},63		Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},64		CollatorSelection: collator_selection::{Pallet, Call, Storage, Event<T>},65		Authorship: pallet_authorship::{Pallet, Call, Storage, Inherent},66	}67);6869parameter_types! {70	pub const BlockHashCount: u64 = 250;71	pub const SS58Prefix: u8 = 42;72}7374impl system::Config for Test {75	type BaseCallFilter = frame_support::traits::Everything;76	type BlockWeights = ();77	type BlockLength = ();78	type DbWeight = ();79	type RuntimeOrigin = RuntimeOrigin;80	type RuntimeCall = RuntimeCall;81	type Index = u64;82	type BlockNumber = u64;83	type Hash = H256;84	type Hashing = BlakeTwo256;85	type AccountId = u64;86	type Lookup = IdentityLookup<Self::AccountId>;87	type Header = Header;88	type RuntimeEvent = RuntimeEvent;89	type BlockHashCount = BlockHashCount;90	type Version = ();91	type PalletInfo = PalletInfo;92	type AccountData = pallet_balances::AccountData<u64>;93	type OnNewAccount = ();94	type OnKilledAccount = ();95	type SystemWeightInfo = ();96	type SS58Prefix = SS58Prefix;97	type OnSetCode = ();98	type MaxConsumers = frame_support::traits::ConstU32<16>;99}100101parameter_types! {102	pub const ExistentialDeposit: u64 = 5;103	pub const MaxReserves: u32 = 50;104}105106impl pallet_balances::Config for Test {107	type Balance = u64;108	type RuntimeEvent = RuntimeEvent;109	type DustRemoval = ();110	type ExistentialDeposit = ExistentialDeposit;111	type AccountStore = System;112	type WeightInfo = ();113	type MaxLocks = ();114	type MaxReserves = MaxReserves;115	type ReserveIdentifier = [u8; 8];116}117118pub struct Author4;119impl FindAuthor<u64> for Author4 {120	fn find_author<'a, I>(_digests: I) -> Option<u64>121	where122		I: 'a + IntoIterator<Item = (frame_support::ConsensusEngineId, &'a [u8])>,123	{124		Some(4)125	}126}127128impl pallet_authorship::Config for Test {129	type FindAuthor = Author4;130	type UncleGenerations = ();131	type FilterUncle = ();132	type EventHandler = CollatorSelection;133}134135parameter_types! {136	pub const MinimumPeriod: u64 = 1;137}138139impl pallet_timestamp::Config for Test {140	type Moment = u64;141	type OnTimestampSet = Aura;142	type MinimumPeriod = MinimumPeriod;143	type WeightInfo = ();144}145146impl pallet_aura::Config for Test {147	type AuthorityId = sp_consensus_aura::sr25519::AuthorityId;148	type MaxAuthorities = MaxAuthorities;149	type DisabledValidators = ();150}151152sp_runtime::impl_opaque_keys! {153	pub struct MockSessionKeys {154		// a key for aura authoring155		pub aura: UintAuthorityId,156	}157}158159impl From<UintAuthorityId> for MockSessionKeys {160	fn from(aura: sp_runtime::testing::UintAuthorityId) -> Self {161		Self { aura }162	}163}164165parameter_types! {166	pub static SessionHandlerCollators: Vec<u64> = Vec::new();167	pub static SessionChangeBlock: u64 = 0;168}169170pub struct TestSessionHandler;171impl pallet_session::SessionHandler<u64> for TestSessionHandler {172	const KEY_TYPE_IDS: &'static [sp_runtime::KeyTypeId] = &[UintAuthorityId::ID];173	fn on_genesis_session<Ks: OpaqueKeys>(keys: &[(u64, Ks)]) {174		SessionHandlerCollators::set(keys.into_iter().map(|(a, _)| *a).collect::<Vec<_>>())175	}176	fn on_new_session<Ks: OpaqueKeys>(_: bool, keys: &[(u64, Ks)], _: &[(u64, Ks)]) {177		SessionChangeBlock::set(System::block_number());178		dbg!(keys.len());179		SessionHandlerCollators::set(keys.into_iter().map(|(a, _)| *a).collect::<Vec<_>>())180	}181	fn on_before_session_ending() {}182	fn on_disabled(_: u32) {}183}184185parameter_types! {186	pub const Offset: u64 = 0;187	pub const Period: u64 = 10;188}189190impl pallet_session::Config for Test {191	type RuntimeEvent = RuntimeEvent;192	type ValidatorId = <Self as frame_system::Config>::AccountId;193	// we don't have stash and controller, thus we don't need the convert as well.194	type ValidatorIdOf = IdentityCollator;195	type ShouldEndSession = pallet_session::PeriodicSessions<Period, Offset>;196	type NextSessionRotation = pallet_session::PeriodicSessions<Period, Offset>;197	type SessionManager = CollatorSelection;198	type SessionHandler = TestSessionHandler;199	type Keys = MockSessionKeys;200	type WeightInfo = ();201}202203ord_parameter_types! {204	pub const RootAccount: u64 = 777;205}206207parameter_types! {208	pub const PotId: PalletId = PalletId(*b"PotStake");209	pub const MaxCandidates: u32 = 20;210	pub const MaxInvulnerables: u32 = 20;211	pub const MinCandidates: u32 = 1;212	pub const MaxAuthorities: u32 = 100_000;213	pub const SlashRatio: Perbill = Perbill::one();214}215216pub struct IsRegistered;217impl ValidatorRegistration<u64> for IsRegistered {218	fn is_registered(id: &u64) -> bool {219		if *id == 7u64 {220			false221		} else {222			true223		}224	}225}226227impl Config for Test {228	// todo:collator mocks and stocks229	type RuntimeEvent = RuntimeEvent;230	type Currency = Balances;231	type UpdateOrigin = EnsureSignedBy<RootAccount, u64>;232	type PotId = PotId;233	type MaxCandidates = MaxCandidates;234	type MinCandidates = MinCandidates;235	type MaxInvulnerables = MaxInvulnerables;236	// type KickThreshold = Period;237	type SlashRatio = SlashRatio;238	type TreasuryAccountId = ();239	type ValidatorId = <Self as frame_system::Config>::AccountId;240	type ValidatorIdOf = IdentityCollator;241	type ValidatorRegistration = IsRegistered;242	type WeightInfo = ();243}244245pub fn new_test_ext() -> sp_io::TestExternalities {246	sp_tracing::try_init_simple();247	let mut t = frame_system::GenesisConfig::default()248		.build_storage::<Test>()249		.unwrap();250	let invulnerables = vec![1, 2];251252	let balances = vec![(1, 100), (2, 100), (3, 100), (4, 100), (5, 100)];253	let keys = balances254		.iter()255		.map(|&(i, _)| {256			(257				i,258				i,259				MockSessionKeys {260					aura: UintAuthorityId(i),261				},262			)263		})264		.collect::<Vec<_>>();265	let collator_selection = collator_selection::GenesisConfig::<Test> {266		desired_candidates: 2,267		license_bond: 10,268		kick_threshold: 1,269		invulnerables,270	};271	let session = pallet_session::GenesisConfig::<Test> { keys };272	pallet_balances::GenesisConfig::<Test> { balances }273		.assimilate_storage(&mut t)274		.unwrap();275	// collator selection must be initialized before session.276	collator_selection.assimilate_storage(&mut t).unwrap();277	session.assimilate_storage(&mut t).unwrap();278279	t.into()280}281282pub fn initialize_to_block(n: u64) {283	for i in System::block_number() + 1..=n {284		System::set_block_number(i);285		<AllPalletsWithSystem as frame_support::traits::OnInitialize<u64>>::on_initialize(i);286	}287}
modifiedpallets/collator-selection/src/tests.rsdiffbeforeafterboth
--- a/pallets/collator-selection/src/tests.rs
+++ b/pallets/collator-selection/src/tests.rs
@@ -31,7 +31,7 @@
 // limitations under the License.
 
 use crate as collator_selection;
-use crate::{mock::*, CandidateInfo, Error};
+use crate::{mock::*, LicenseInfo, Error};
 use frame_support::{
 	assert_noop, assert_ok,
 	traits::{Currency, GenesisBuild, OnInitialize},
@@ -43,7 +43,7 @@
 fn basic_setup_works() {
 	new_test_ext().execute_with(|| {
 		assert_eq!(CollatorSelection::desired_candidates(), 2);
-		assert_eq!(CollatorSelection::candidacy_bond(), 10);
+		assert_eq!(CollatorSelection::license_bond(), 10);
 
 		assert!(CollatorSelection::candidates().is_empty());
 		assert_eq!(CollatorSelection::invulnerables(), vec![1, 2]);
@@ -133,21 +133,21 @@
 }
 
 #[test]
-fn set_candidacy_bond() {
+fn set_license_bond() {
 	new_test_ext().execute_with(|| {
 		// given
-		assert_eq!(CollatorSelection::candidacy_bond(), 10);
+		assert_eq!(CollatorSelection::license_bond(), 10);
 
 		// can set
-		assert_ok!(CollatorSelection::set_candidacy_bond(
+		assert_ok!(CollatorSelection::set_license_bond(
 			RuntimeOrigin::signed(RootAccount::get()),
 			7
 		));
-		assert_eq!(CollatorSelection::candidacy_bond(), 7);
+		assert_eq!(CollatorSelection::license_bond(), 7);
 
 		// rejects bad origin.
 		assert_noop!(
-			CollatorSelection::set_candidacy_bond(RuntimeOrigin::signed(1), 8),
+			CollatorSelection::set_license_bond(RuntimeOrigin::signed(1), 8),
 			BadOrigin
 		);
 	});
@@ -227,7 +227,7 @@
 		assert_ok!(CollatorSelection::register_as_candidate(
 			RuntimeOrigin::signed(3)
 		));
-		let addition = CandidateInfo {
+		let addition = LicenseInfo {
 			who: 3,
 			deposit: 10,
 		};
@@ -267,7 +267,7 @@
 	new_test_ext().execute_with(|| {
 		// given
 		assert_eq!(CollatorSelection::desired_candidates(), 2);
-		assert_eq!(CollatorSelection::candidacy_bond(), 10);
+		assert_eq!(CollatorSelection::license_bond(), 10);
 		assert_eq!(CollatorSelection::candidates(), Vec::new());
 		assert_eq!(CollatorSelection::invulnerables(), vec![1, 2]);
 
@@ -331,7 +331,7 @@
 		// triggers `note_author`
 		Authorship::on_initialize(1);
 
-		let collator = CandidateInfo {
+		let collator = LicenseInfo {
 			who: 4,
 			deposit: 10,
 		};
@@ -361,7 +361,7 @@
 		// triggers `note_author`
 		Authorship::on_initialize(1);
 
-		let collator = CandidateInfo {
+		let collator = LicenseInfo {
 			who: 4,
 			deposit: 10,
 		};
@@ -432,7 +432,7 @@
 		assert_eq!(CollatorSelection::candidates().len(), 1);
 		// 3 will be kicked after 1 session delay
 		assert_eq!(SessionHandlerCollators::get(), vec![1, 2, 3, 4]);
-		let collator = CandidateInfo {
+		let collator = LicenseInfo {
 			who: 4,
 			deposit: 10,
 		};
@@ -465,7 +465,7 @@
 		assert_eq!(CollatorSelection::candidates().len(), 1);
 		// 3 will be kicked after 1 session delay
 		assert_eq!(SessionHandlerCollators::get(), vec![1, 2, 3, 5]);
-		let collator = CandidateInfo {
+		let collator = LicenseInfo {
 			who: 5,
 			deposit: 10,
 		};
@@ -490,7 +490,7 @@
 
 	let collator_selection = collator_selection::GenesisConfig::<Test> {
 		desired_candidates: 2,
-		candidacy_bond: 10,
+		license_bond: 10,
 		kick_threshold: 1,
 		invulnerables,
 	};
modifiedpallets/collator-selection/src/weights.rsdiffbeforeafterboth
--- a/pallets/collator-selection/src/weights.rs
+++ b/pallets/collator-selection/src/weights.rs
@@ -46,7 +46,7 @@
 pub trait WeightInfo {
 	fn set_invulnerables(_b: u32) -> Weight;
 	fn set_desired_candidates() -> Weight;
-	fn set_candidacy_bond() -> Weight;
+	fn set_license_bond() -> Weight;
 	fn register_as_candidate(_c: u32) -> Weight;
 	fn leave_intent(_c: u32) -> Weight;
 	fn note_author() -> Weight;
@@ -65,7 +65,7 @@
 	fn set_desired_candidates() -> Weight {
 		Weight::from_ref_time(16_363_000 as u64).saturating_add(T::DbWeight::get().writes(1 as u64))
 	}
-	fn set_candidacy_bond() -> Weight {
+	fn set_license_bond() -> Weight {
 		Weight::from_ref_time(16_840_000 as u64).saturating_add(T::DbWeight::get().writes(1 as u64))
 	}
 	fn register_as_candidate(c: u32) -> Weight {
@@ -112,7 +112,7 @@
 		Weight::from_ref_time(16_363_000 as u64)
 			.saturating_add(RocksDbWeight::get().writes(1 as u64))
 	}
-	fn set_candidacy_bond() -> Weight {
+	fn set_license_bond() -> Weight {
 		Weight::from_ref_time(16_840_000 as u64)
 			.saturating_add(RocksDbWeight::get().writes(1 as u64))
 	}
modifiedprimitives/common/src/constants.rsdiffbeforeafterboth
--- a/primitives/common/src/constants.rs
+++ b/primitives/common/src/constants.rs
@@ -45,9 +45,9 @@
 /// Minimum balance required to create or keep an account open.
 pub const EXISTENTIAL_DEPOSIT: u128 = 0;
 /// Amount of Balance reserved for candidate registration.
-pub const GENESIS_CANDIDACY_BOND: u128 = EXISTENTIAL_DEPOSIT;
+pub const GENESIS_LICENSE_BOND: u128 = EXISTENTIAL_DEPOSIT;
 /// How long a periodic session lasts in blocks.
-pub const SESSION_LENGTH: BlockNumber = HOURS;
+pub const SESSION_LENGTH: BlockNumber = MINUTES;
 
 // Targeting 0.1 UNQ per transfer
 pub const WEIGHT_TO_FEE_COEFF: u32 = /*<weight2fee>*/175_199_920/*</weight2fee>*/;
modifiedruntime/common/mod.rsdiffbeforeafterboth
--- a/runtime/common/mod.rs
+++ b/runtime/common/mod.rs
@@ -191,7 +191,7 @@
 				RuntimeAppPublic,
 			};
 			use pallet_session::SessionManager;
-			use up_common::constants::GENESIS_CANDIDACY_BOND;
+			use up_common::constants::GENESIS_LICENSE_BOND;
 			use crate::config::pallets::collator_selection::MaxInvulnerables;
 
 			let mut weight = <Runtime as frame_system::Config>::DbWeight::get().reads(1);
@@ -242,7 +242,7 @@
 
 				<pallet_collator_selection::Invulnerables<Runtime>>::put(bounded_invulnerables);
 				<pallet_collator_selection::DesiredCandidates<Runtime>>::put(0);
-				<pallet_collator_selection::CandidacyBond<Runtime>>::put(GENESIS_CANDIDACY_BOND);
+				<pallet_collator_selection::LicenseBond<Runtime>>::put(GENESIS_LICENSE_BOND);
 
 				let keys = invulnerables
 					.into_iter()