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

difftreelog

source

runtime/common/config/pallets/collator_selection.rs5.2 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};18use crate::{19	Balance, Balances, BlockNumber, Runtime, RuntimeEvent, Aura, Session, SessionKeys,20	CollatorSelection, Treasury,21	config::pallets::{MaxCollators, SessionPeriod, TreasuryAccountId},22};2324#[cfg(feature = "governance")]25use crate::config::governance;2627#[cfg(not(feature = "governance"))]28use frame_system::EnsureRoot;2930use sp_runtime::Perbill;31use up_common::constants::{UNIQUE, MILLIUNIQUE};32use pallet_configuration::{33	CollatorSelectionKickThresholdOverride, CollatorSelectionLicenseBondOverride,34	CollatorSelectionDesiredCollatorsOverride,35};36parameter_types! {37	pub const SessionOffset: BlockNumber = 0;38}3940impl pallet_session::Config for Runtime {41	type RuntimeEvent = RuntimeEvent;42	type ValidatorId = <Self as frame_system::Config>::AccountId;43	// we don't have stash and controller, thus we don't need the convert as well.44	type ValidatorIdOf = pallet_collator_selection::IdentityCollator;45	type ShouldEndSession = pallet_session::PeriodicSessions<SessionPeriod, SessionOffset>;46	type NextSessionRotation = pallet_session::PeriodicSessions<SessionPeriod, SessionOffset>;47	type SessionManager = CollatorSelection;48	// Essentially just Aura, but lets be pedantic.49	type SessionHandler = <SessionKeys as sp_runtime::traits::OpaqueKeys>::KeyTypeIdProviders;50	type Keys = SessionKeys;51	type WeightInfo = pallet_session::weights::SubstrateWeight<Self>; // ();52}5354parameter_types! {55	pub const UncleGenerations: u32 = 0;56}5758impl pallet_authorship::Config for Runtime {59	type FindAuthor = pallet_session::FindAccountFromAuthorIndex<Self, Aura>;60	type EventHandler = CollatorSelection;61}6263parameter_types! {64	// These do not matter as we forbid non-sudo operations with the identity pallet65	pub const BasicDeposit: Balance = 10 * UNIQUE;66	pub const FieldDeposit: Balance = 25 * MILLIUNIQUE;67	pub const SubAccountDeposit: Balance = 2 * UNIQUE;68	pub const MaxSubAccounts: u32 = 100;69	pub const MaxAdditionalFields: u32 = 100;70	pub const MaxRegistrars: u32 = 20;71	pub const LicenceBondIdentifier: [u8; 16] = *b"licenceidentifie";72	pub LicenseBond: Balance =  CollatorSelectionLicenseBondOverride::<Runtime>::get();73	pub DesiredCollators: u32 = CollatorSelectionDesiredCollatorsOverride::<Runtime>::get();74	pub KickThreshold: BlockNumber = CollatorSelectionKickThresholdOverride::<Runtime>::get();75}7677impl pallet_identity::Config for Runtime {78	type RuntimeEvent = RuntimeEvent;79	type Currency = Balances;80	type BasicDeposit = BasicDeposit;81	type FieldDeposit = FieldDeposit;82	type MaxAdditionalFields = MaxAdditionalFields;83	type MaxRegistrars = MaxRegistrars;84	type MaxSubAccounts = MaxSubAccounts;85	type SubAccountDeposit = SubAccountDeposit;8687	#[cfg(feature = "governance")]88	type RegistrarOrigin = governance::RootOrTechnicalCommitteeMember;8990	#[cfg(feature = "governance")]91	type ForceOrigin = governance::RootOrTechnicalCommitteeMember;9293	#[cfg(not(feature = "governance"))]94	type RegistrarOrigin = EnsureRoot<<Self as frame_system::Config>::AccountId>;9596	#[cfg(not(feature = "governance"))]97	type ForceOrigin = EnsureRoot<<Self as frame_system::Config>::AccountId>;9899	type Slashed = Treasury;100	type WeightInfo = pallet_identity::weights::SubstrateWeight<Runtime>;101}102103parameter_types! {104	pub const PotId: PalletId = PalletId(*b"PotStake");105	pub const SlashRatio: Perbill = Perbill::from_percent(100);106}107108impl pallet_collator_selection::Config for Runtime {109	type RuntimeEvent = RuntimeEvent;110	type Currency = Balances;111	// We allow root only to execute privileged collator selection operations.112113	// We allow root or the unanimous technical committee114	// to execute privileged collator selection operations.115	#[cfg(feature = "governance")]116	type UpdateOrigin = governance::RootOrAllTechnicalCommittee;117118	// If there is no governance,119	// we allow root only to execute privileged collator selection operations.120	#[cfg(not(feature = "governance"))]121	type UpdateOrigin = EnsureRoot<<Self as frame_system::Config>::AccountId>;122123	type TreasuryAccountId = TreasuryAccountId;124	type PotId = PotId;125	type MaxCollators = MaxCollators;126	type SlashRatio = SlashRatio;127	type ValidatorId = <Self as frame_system::Config>::AccountId;128	type ValidatorIdOf = pallet_collator_selection::IdentityCollator;129	type ValidatorRegistration = Session;130	type WeightInfo = pallet_collator_selection::weights::SubstrateWeight<Runtime>;131	type LicenceBondIdentifier = LicenceBondIdentifier;132	type DesiredCollators = DesiredCollators;133	type LicenseBond = LicenseBond;134	type KickThreshold = KickThreshold;135}