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

difftreelog

source

runtime/common/config/pallets/collator_selection.rs4.4 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};26use pallet_configuration::{27	CollatorSelectionKickThresholdOverride, CollatorSelectionLicenseBondOverride,28	CollatorSelectionDesiredCollatorsOverride,29};30parameter_types! {31	pub const SessionOffset: BlockNumber = 0;32}3334impl pallet_session::Config for Runtime {35	type RuntimeEvent = RuntimeEvent;36	type ValidatorId = <Self as frame_system::Config>::AccountId;37	// we don't have stash and controller, thus we don't need the convert as well.38	type ValidatorIdOf = pallet_collator_selection::IdentityCollator;39	type ShouldEndSession = pallet_session::PeriodicSessions<SessionPeriod, SessionOffset>;40	type NextSessionRotation = pallet_session::PeriodicSessions<SessionPeriod, SessionOffset>;41	type SessionManager = CollatorSelection;42	// Essentially just Aura, but lets be pedantic.43	type SessionHandler = <SessionKeys as sp_runtime::traits::OpaqueKeys>::KeyTypeIdProviders;44	type Keys = SessionKeys;45	type WeightInfo = pallet_session::weights::SubstrateWeight<Self>; // ();46}4748parameter_types! {49	pub const UncleGenerations: u32 = 0;50}5152impl pallet_authorship::Config for Runtime {53	type FindAuthor = pallet_session::FindAccountFromAuthorIndex<Self, Aura>;54	type EventHandler = CollatorSelection;55}5657parameter_types! {58	// These do not matter as we forbid non-sudo operations with the identity pallet59	pub const BasicDeposit: Balance = 10 * UNIQUE;60	pub const FieldDeposit: Balance = 25 * MILLIUNIQUE;61	pub const SubAccountDeposit: Balance = 2 * UNIQUE;62	pub const MaxSubAccounts: u32 = 100;63	pub const MaxAdditionalFields: u32 = 100;64	pub const MaxRegistrars: u32 = 20;65	pub const LicenceBondIdentifier: [u8; 16] = *b"licenceidentifie";66	pub LicenseBond: Balance =  CollatorSelectionLicenseBondOverride::<Runtime>::get();67	pub DesiredCollators: u32 = CollatorSelectionDesiredCollatorsOverride::<Runtime>::get();68	pub KickThreshold: BlockNumber = CollatorSelectionKickThresholdOverride::<Runtime>::get();69}7071impl pallet_identity::Config for Runtime {72	type RuntimeEvent = RuntimeEvent;73	type Currency = Balances;74	type BasicDeposit = BasicDeposit;75	type FieldDeposit = FieldDeposit;76	type MaxAdditionalFields = MaxAdditionalFields;77	type MaxRegistrars = MaxRegistrars;78	type MaxSubAccounts = MaxSubAccounts;79	type SubAccountDeposit = SubAccountDeposit;80	type RegistrarOrigin = EnsureRoot<<Self as frame_system::Config>::AccountId>;81	type ForceOrigin = EnsureRoot<<Self as frame_system::Config>::AccountId>;82	type Slashed = Treasury;83	type WeightInfo = pallet_identity::weights::SubstrateWeight<Runtime>;84}8586parameter_types! {87	pub const PotId: PalletId = PalletId(*b"PotStake");88	pub const SlashRatio: Perbill = Perbill::from_percent(100);89}9091impl pallet_collator_selection::Config for Runtime {92	type RuntimeEvent = RuntimeEvent;93	type Currency = Balances;94	// We allow root only to execute privileged collator selection operations.95	type UpdateOrigin = EnsureRoot<AccountId>;96	type TreasuryAccountId = TreasuryAccountId;97	type PotId = PotId;98	type MaxCollators = MaxCollators;99	type SlashRatio = SlashRatio;100	type ValidatorId = <Self as frame_system::Config>::AccountId;101	type ValidatorIdOf = pallet_collator_selection::IdentityCollator;102	type ValidatorRegistration = Session;103	type WeightInfo = pallet_collator_selection::weights::SubstrateWeight<Runtime>;104	type LicenceBondIdentifier = LicenceBondIdentifier;105	type DesiredCollators = DesiredCollators;106	type LicenseBond = LicenseBond;107	type KickThreshold = KickThreshold;108}