1234567891011121314151617use frame_support::{parameter_types, PalletId};18use crate::{19 Balance, Balances, BlockNumber, Runtime, RuntimeEvent, Aura, Session, SessionKeys,20 CollatorSelection, Treasury,21 config::pallets::{MaxCollators, SessionPeriod, TreasuryAccountId},22};2324#[cfg(feature = "governance")]25use crate::config::governance;2627#[cfg(not(feature = "governance"))]28use frame_system::EnsureRoot;2930use sp_runtime::Perbill;31use up_common::constants::{UNIQUE, MILLIUNIQUE};32use pallet_configuration::{33 CollatorSelectionKickThresholdOverride, CollatorSelectionLicenseBondOverride,34 CollatorSelectionDesiredCollatorsOverride,35};36parameter_types! {37 pub const SessionOffset: BlockNumber = 0;38}3940impl pallet_session::Config for Runtime {41 type RuntimeEvent = RuntimeEvent;42 type ValidatorId = <Self as frame_system::Config>::AccountId;43 44 type ValidatorIdOf = pallet_collator_selection::IdentityCollator;45 type ShouldEndSession = pallet_session::PeriodicSessions<SessionPeriod, SessionOffset>;46 type NextSessionRotation = pallet_session::PeriodicSessions<SessionPeriod, SessionOffset>;47 type SessionManager = CollatorSelection;48 49 type SessionHandler = <SessionKeys as sp_runtime::traits::OpaqueKeys>::KeyTypeIdProviders;50 type Keys = SessionKeys;51 type WeightInfo = pallet_session::weights::SubstrateWeight<Self>; 52}5354parameter_types! {55 pub const UncleGenerations: u32 = 0;56}5758impl pallet_authorship::Config for Runtime {59 type FindAuthor = pallet_session::FindAccountFromAuthorIndex<Self, Aura>;60 type EventHandler = CollatorSelection;61}6263parameter_types! {64 65 pub const BasicDeposit: Balance = 10 * UNIQUE;66 pub const FieldDeposit: Balance = 25 * MILLIUNIQUE;67 pub const SubAccountDeposit: Balance = 2 * UNIQUE;68 pub const MaxSubAccounts: u32 = 100;69 pub const MaxAdditionalFields: u32 = 100;70 pub const MaxRegistrars: u32 = 20;71 pub const LicenceBondIdentifier: [u8; 16] = *b"licenceidentifie";72 pub LicenseBond: Balance = CollatorSelectionLicenseBondOverride::<Runtime>::get();73 pub DesiredCollators: u32 = CollatorSelectionDesiredCollatorsOverride::<Runtime>::get();74 pub KickThreshold: BlockNumber = CollatorSelectionKickThresholdOverride::<Runtime>::get();75}7677impl pallet_identity::Config for Runtime {78 type RuntimeEvent = RuntimeEvent;79 type Currency = Balances;80 type BasicDeposit = BasicDeposit;81 type FieldDeposit = FieldDeposit;82 type MaxAdditionalFields = MaxAdditionalFields;83 type MaxRegistrars = MaxRegistrars;84 type MaxSubAccounts = MaxSubAccounts;85 type SubAccountDeposit = SubAccountDeposit;8687 #[cfg(feature = "governance")]88 type RegistrarOrigin = governance::RootOrTechnicalCommitteeMember;8990 #[cfg(feature = "governance")]91 type ForceOrigin = governance::RootOrTechnicalCommitteeMember;9293 #[cfg(not(feature = "governance"))]94 type RegistrarOrigin = EnsureRoot<<Self as frame_system::Config>::AccountId>;9596 #[cfg(not(feature = "governance"))]97 type ForceOrigin = EnsureRoot<<Self as frame_system::Config>::AccountId>;9899 type Slashed = Treasury;100 type WeightInfo = pallet_identity::weights::SubstrateWeight<Runtime>;101}102103parameter_types! {104 pub const PotId: PalletId = PalletId(*b"PotStake");105 pub const SlashRatio: Perbill = Perbill::from_percent(100);106}107108impl pallet_collator_selection::Config for Runtime {109 type RuntimeEvent = RuntimeEvent;110 type Currency = Balances;111 112113 114 115 #[cfg(feature = "governance")]116 type UpdateOrigin = governance::RootOrAllTechnicalCommittee;117118 119 120 #[cfg(not(feature = "governance"))]121 type UpdateOrigin = EnsureRoot<<Self as frame_system::Config>::AccountId>;122123 type TreasuryAccountId = TreasuryAccountId;124 type PotId = PotId;125 type MaxCollators = MaxCollators;126 type SlashRatio = SlashRatio;127 type ValidatorId = <Self as frame_system::Config>::AccountId;128 type ValidatorIdOf = pallet_collator_selection::IdentityCollator;129 type ValidatorRegistration = Session;130 type WeightInfo = pallet_collator_selection::weights::SubstrateWeight<Runtime>;131 type LicenceBondIdentifier = LicenceBondIdentifier;132 type DesiredCollators = DesiredCollators;133 type LicenseBond = LicenseBond;134 type KickThreshold = KickThreshold;135}