1234567891011121314151617use 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 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 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; 59 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 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 75 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}