git.delta.rocks / unique-network / refs/commits / 33d3cd09a241

difftreelog

source

runtime/common/config/pallets/collator_selection.rs3.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 frame_system::EnsureRoot;19use crate::{20	AccountId, BlockNumber, Runtime, RuntimeEvent, Balances, Aura, Session, SessionKeys,21	CollatorSelection, config::pallets::TreasuryAccountId,22};23use sp_runtime::Perbill;24use up_common::constants::*;2526parameter_types! {27	pub const SessionPeriod: BlockNumber = SESSION_LENGTH;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 UncleGenerations = UncleGenerations;52	type FilterUncle = ();53	type EventHandler = CollatorSelection;54}5556parameter_types! {57	pub const PotId: PalletId = PalletId(*b"PotStake");58	pub const MaxCandidates: u32 = 30; // todo:collator 30 collator slots - 3 planned invulnerables59	pub const MinCandidates: u32 = 1;60	pub const MaxInvulnerables: u32 = 30;61	pub const SlashRatio: Perbill = Perbill::from_percent(100);62}6364impl pallet_collator_selection::Config for Runtime {65	type RuntimeEvent = RuntimeEvent;66	type Currency = Balances;67	// We allow root only to execute privileged collator selection operations.68	type UpdateOrigin = EnsureRoot<AccountId>;69	type TreasuryAccountId = TreasuryAccountId;70	type PotId = PotId;71	type MaxCandidates = MaxCandidates;72	type MinCandidates = MinCandidates;73	type MaxInvulnerables = MaxInvulnerables;74	// todo:collator kick threshold should be in storage and configured only by root -- or rather UpdateOrigin75	type SlashRatio = SlashRatio;76	type ValidatorId = <Self as frame_system::Config>::AccountId;77	type ValidatorIdOf = pallet_collator_selection::IdentityCollator;78	type ValidatorRegistration = Session;79	type WeightInfo = ();80}