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

difftreelog

source

runtime/common/config/pallets/collator_selection.rs3.9 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 frame_system::EnsureRoot;19use crate::{20	AccountId, Balance, Balances, BlockNumber, Runtime, RuntimeEvent, Aura, Session, SessionKeys,21	CollatorSelection, Treasury,22	config::pallets::{MaxCollators, SessionPeriod, TreasuryAccountId},23};24use sp_runtime::Perbill;25use up_common::constants::{UNIQUE, MILLIUNIQUE};2627parameter_types! {28	pub const SessionOffset: BlockNumber = 0;29}3031impl pallet_session::Config for Runtime {32	type RuntimeEvent = RuntimeEvent;33	type ValidatorId = <Self as frame_system::Config>::AccountId;34	// we don't have stash and controller, thus we don't need the convert as well.35	type ValidatorIdOf = pallet_collator_selection::IdentityCollator;36	type ShouldEndSession = pallet_session::PeriodicSessions<SessionPeriod, SessionOffset>;37	type NextSessionRotation = pallet_session::PeriodicSessions<SessionPeriod, SessionOffset>;38	type SessionManager = CollatorSelection;39	// Essentially just Aura, but lets be pedantic.40	type SessionHandler = <SessionKeys as sp_runtime::traits::OpaqueKeys>::KeyTypeIdProviders;41	type Keys = SessionKeys;42	type WeightInfo = pallet_session::weights::SubstrateWeight<Self>; // ();43}4445parameter_types! {46	pub const UncleGenerations: u32 = 0;47}4849impl pallet_authorship::Config for Runtime {50	type FindAuthor = pallet_session::FindAccountFromAuthorIndex<Self, Aura>;51	type EventHandler = CollatorSelection;52}5354parameter_types! {55	// These do not matter as we forbid non-sudo operations with the identity pallet56	pub const BasicDeposit: Balance = 10 * UNIQUE;57	pub const FieldDeposit: Balance = 25 * MILLIUNIQUE;58	pub const SubAccountDeposit: Balance = 2 * UNIQUE;59	pub const MaxSubAccounts: u32 = 100;60	pub const MaxAdditionalFields: u32 = 100;61	pub const MaxRegistrars: u32 = 20;62	pub const LicenceBondIdentifier: [u8; 16] = *b"licenceidentifie";63}6465impl pallet_identity::Config for Runtime {66	type RuntimeEvent = RuntimeEvent;67	type Currency = Balances;68	type BasicDeposit = BasicDeposit;69	type FieldDeposit = FieldDeposit;70	type MaxAdditionalFields = MaxAdditionalFields;71	type MaxRegistrars = MaxRegistrars;72	type MaxSubAccounts = MaxSubAccounts;73	type SubAccountDeposit = SubAccountDeposit;74	type RegistrarOrigin = EnsureRoot<<Self as frame_system::Config>::AccountId>;75	type ForceOrigin = EnsureRoot<<Self as frame_system::Config>::AccountId>;76	type Slashed = Treasury;77	type WeightInfo = pallet_identity::weights::SubstrateWeight<Runtime>;78}7980parameter_types! {81	pub const PotId: PalletId = PalletId(*b"PotStake");82	pub const SlashRatio: Perbill = Perbill::from_percent(100);83}8485impl pallet_collator_selection::Config for Runtime {86	type RuntimeEvent = RuntimeEvent;87	// We allow root only to execute privileged collator selection operations.88	type UpdateOrigin = EnsureRoot<AccountId>;89	type TreasuryAccountId = TreasuryAccountId;90	type PotId = PotId;91	type MaxCollators = MaxCollators;92	type SlashRatio = SlashRatio;93	type ValidatorId = <Self as frame_system::Config>::AccountId;94	type ValidatorIdOf = pallet_collator_selection::IdentityCollator;95	type ValidatorRegistration = Session;96	type WeightInfo = pallet_collator_selection::weights::SubstrateWeight<Runtime>;97	type LicenceBondIdentifier = LicenceBondIdentifier;98}