git.delta.rocks / unique-network / refs/commits / 647ca2aac4ad

difftreelog

source

runtime/common/config/pallets/collator_selection.rs3.8 KiBsourcehistory
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/>.1617use frame_support::{parameter_types, PalletId};18#[cfg(not(feature = "governance"))]19use frame_system::EnsureRoot;20use pallet_configuration::{21	CollatorSelectionDesiredCollatorsOverride, CollatorSelectionKickThresholdOverride,22	CollatorSelectionLicenseBondOverride,23};24use sp_runtime::Perbill;2526#[cfg(feature = "governance")]27use crate::config::governance;28use crate::{29	config::pallets::{MaxCollators, SessionPeriod, TreasuryAccountId},30	Aura, Balance, Balances, BlockNumber, CollatorSelection, Runtime, RuntimeEvent,31	RuntimeHoldReason, Session, SessionKeys,32};33parameter_types! {34	pub const SessionOffset: BlockNumber = 0;35}3637impl pallet_session::Config for Runtime {38	type RuntimeEvent = RuntimeEvent;39	type ValidatorId = <Self as frame_system::Config>::AccountId;40	// we don't have stash and controller, thus we don't need the convert as well.41	type ValidatorIdOf = pallet_collator_selection::IdentityCollator;42	type ShouldEndSession = pallet_session::PeriodicSessions<SessionPeriod, SessionOffset>;43	type NextSessionRotation = pallet_session::PeriodicSessions<SessionPeriod, SessionOffset>;44	type SessionManager = CollatorSelection;45	// Essentially just Aura, but lets be pedantic.46	type SessionHandler = <SessionKeys as sp_runtime::traits::OpaqueKeys>::KeyTypeIdProviders;47	type Keys = SessionKeys;48	type WeightInfo = pallet_session::weights::SubstrateWeight<Self>; // ();49}5051parameter_types! {52	pub const UncleGenerations: u32 = 0;53}5455impl pallet_authorship::Config for Runtime {56	type FindAuthor = pallet_session::FindAccountFromAuthorIndex<Self, Aura>;57	type EventHandler = CollatorSelection;58}5960parameter_types! {61	pub LicenseBond: Balance =  CollatorSelectionLicenseBondOverride::<Runtime>::get();62	pub DesiredCollators: u32 = CollatorSelectionDesiredCollatorsOverride::<Runtime>::get();63	pub KickThreshold: BlockNumber = CollatorSelectionKickThresholdOverride::<Runtime>::get();64}6566parameter_types! {67	pub const PotId: PalletId = PalletId(*b"PotStake");68	pub const SlashRatio: Perbill = Perbill::from_percent(100);69}7071impl pallet_collator_selection::Config for Runtime {72	type RuntimeEvent = RuntimeEvent;73	type RuntimeHoldReason = RuntimeHoldReason;74	type Currency = Balances;75	// We allow root only to execute privileged collator selection operations.7677	// We allow root or the unanimous technical committee78	// to execute privileged collator selection operations.79	#[cfg(feature = "governance")]80	type UpdateOrigin = governance::RootOrAllTechnicalCommittee;8182	// If there is no governance,83	// we allow root only to execute privileged collator selection operations.84	#[cfg(not(feature = "governance"))]85	type UpdateOrigin = EnsureRoot<<Self as frame_system::Config>::AccountId>;8687	type TreasuryAccountId = TreasuryAccountId;88	type PotId = PotId;89	type MaxCollators = MaxCollators;90	type SlashRatio = SlashRatio;91	type ValidatorId = <Self as frame_system::Config>::AccountId;92	type ValidatorIdOf = pallet_collator_selection::IdentityCollator;93	type ValidatorRegistration = Session;94	type WeightInfo = pallet_collator_selection::weights::SubstrateWeight<Runtime>;95	type DesiredCollators = DesiredCollators;96	type LicenseBond = LicenseBond;97	type KickThreshold = KickThreshold;98}