1234567891011121314151617use 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 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 EventHandler = CollatorSelection;52}5354parameter_types! {55 56 pub const BasicDeposit: Balance = 10 * UNIQUE;57 pub const FieldDeposit: Balance = 25 * MILLIUNIQUE;58 pub const SubAccountDeposit: Balance = 2 * UNIQUE;59 pub const MaxSubAccounts: u32 = 100;60 pub const MaxAdditionalFields: u32 = 100;61 pub const MaxRegistrars: u32 = 20;62}6364impl pallet_identity::Config for Runtime {65 type RuntimeEvent = RuntimeEvent;66 type Currency = Balances;67 type BasicDeposit = BasicDeposit;68 type FieldDeposit = FieldDeposit;69 type MaxAdditionalFields = MaxAdditionalFields;70 type MaxRegistrars = MaxRegistrars;71 type MaxSubAccounts = MaxSubAccounts;72 type SubAccountDeposit = SubAccountDeposit;73 type RegistrarOrigin = EnsureRoot<<Self as frame_system::Config>::AccountId>;74 type ForceOrigin = EnsureRoot<<Self as frame_system::Config>::AccountId>;75 type Slashed = Treasury;76 type WeightInfo = pallet_identity::weights::SubstrateWeight<Runtime>;77}7879parameter_types! {80 pub const PotId: PalletId = PalletId(*b"PotStake");81 pub const SlashRatio: Perbill = Perbill::from_percent(100);82}8384impl pallet_collator_selection::Config for Runtime {85 type RuntimeEvent = RuntimeEvent;86 87 type UpdateOrigin = EnsureRoot<AccountId>;88 type TreasuryAccountId = TreasuryAccountId;89 type PotId = PotId;90 type MaxCollators = MaxCollators;91 type SlashRatio = SlashRatio;92 type ValidatorId = <Self as frame_system::Config>::AccountId;93 type ValidatorIdOf = pallet_collator_selection::IdentityCollator;94 type ValidatorRegistration = Session;95 type WeightInfo = pallet_collator_selection::weights::SubstrateWeight<Runtime>;96}