git.delta.rocks / unique-network / refs/commits / 8f7419bc1620

difftreelog

source

runtime/common/config/pallets/collator_selection.rs3.0 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, BlockNumber, Runtime, RuntimeEvent, Balances, Aura, Session, SessionKeys,21	CollatorSelection,22};23use up_common::constants::*;2425parameter_types! {26	pub const SessionPeriod: BlockNumber = HOURS;27	pub const SessionOffset: BlockNumber = 0;28}2930impl pallet_session::Config for Runtime {31	type RuntimeEvent = RuntimeEvent;32	type ValidatorId = <Self as frame_system::Config>::AccountId;33	// we don't have stash and controller, thus we don't need the convert as well.34	type ValidatorIdOf = pallet_collator_selection::IdentityCollator;35	type ShouldEndSession = pallet_session::PeriodicSessions<SessionPeriod, SessionOffset>;36	type NextSessionRotation = pallet_session::PeriodicSessions<SessionPeriod, SessionOffset>;37	type SessionManager = CollatorSelection;38	// Essentially just Aura, but lets be pedantic.39	type SessionHandler = <SessionKeys as sp_runtime::traits::OpaqueKeys>::KeyTypeIdProviders;40	type Keys = SessionKeys;41	type WeightInfo = pallet_session::weights::SubstrateWeight<Self>; // ();42}4344parameter_types! {45	pub const UncleGenerations: u32 = 0;46}4748impl pallet_authorship::Config for Runtime {49	type FindAuthor = pallet_session::FindAccountFromAuthorIndex<Self, Aura>;50	type UncleGenerations = UncleGenerations;51	type FilterUncle = ();52	type EventHandler = CollatorSelection;53}5455parameter_types! {56	pub const PotId: PalletId = PalletId(*b"PotStake");57	pub const MaxCandidates: u32 = 1000;58	pub const MinCandidates: u32 = 5;59	pub const MaxInvulnerables: u32 = 100;60}6162impl pallet_collator_selection::Config for Runtime {63	type RuntimeEvent = RuntimeEvent;64	type Currency = Balances;65	// We allow root only to execute privileged collator selection operations.66	type UpdateOrigin = EnsureRoot<AccountId>;67	type PotId = PotId;68	type MaxCandidates = MaxCandidates;69	type MinCandidates = MinCandidates;70	type MaxInvulnerables = MaxInvulnerables;71	// todo:collator kick threshold should be in storage and configured only by root -- or rather UpdateOrigin72	// Should be a multiple of session or things will get inconsistent.73	type KickThreshold = SessionPeriod;74	type ValidatorId = <Self as frame_system::Config>::AccountId;75	type ValidatorIdOf = pallet_collator_selection::IdentityCollator;76	type ValidatorRegistration = Session;77	type WeightInfo = ();78}