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};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 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 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 59 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 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}