difftreelog
fix(collator-selection) proper weights
in: master
1 file changed
runtime/common/config/pallets/collator_selection.rsdiffbeforeafterboth1// 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 UncleGenerations = UncleGenerations;52 type FilterUncle = ();53 type EventHandler = CollatorSelection;54}5556parameter_types! {57 // These do not matter as we forbid non-sudo operations with the identity pallet58 pub const BasicDeposit: Balance = 10 * UNIQUE;59 pub const FieldDeposit: Balance = 25 * MILLIUNIQUE;60 pub const SubAccountDeposit: Balance = 2 * UNIQUE;61 pub const MaxSubAccounts: u32 = 100;62 pub const MaxAdditionalFields: u32 = 100;63 pub const MaxRegistrars: u32 = 20;64}6566impl pallet_identity::Config for Runtime {67 type RuntimeEvent = RuntimeEvent;68 type Currency = Balances;69 type BasicDeposit = BasicDeposit;70 type FieldDeposit = FieldDeposit;71 type MaxAdditionalFields = MaxAdditionalFields;72 type MaxRegistrars = MaxRegistrars;73 type MaxSubAccounts = MaxSubAccounts;74 type SubAccountDeposit = SubAccountDeposit;75 type RegistrarOrigin = EnsureRoot<<Self as frame_system::Config>::AccountId>;76 type ForceOrigin = EnsureRoot<<Self as frame_system::Config>::AccountId>;77 type Slashed = Treasury;78 type WeightInfo = pallet_identity::weights::SubstrateWeight<Runtime>;79}8081parameter_types! {82 pub const PotId: PalletId = PalletId(*b"PotStake");83 pub const SlashRatio: Perbill = Perbill::from_percent(100);84}8586impl pallet_collator_selection::Config for Runtime {87 type RuntimeEvent = RuntimeEvent;88 // We allow root only to execute privileged collator selection operations.89 type UpdateOrigin = EnsureRoot<AccountId>;90 type TreasuryAccountId = TreasuryAccountId;91 type PotId = PotId;92 type MaxCollators = MaxCollators;93 type SlashRatio = SlashRatio;94 type ValidatorId = <Self as frame_system::Config>::AccountId;95 type ValidatorIdOf = pallet_collator_selection::IdentityCollator;96 type ValidatorRegistration = Session;97 type WeightInfo = pallet_collator_selection::weights::SubstrateWeight<Runtime>;98}