parachain_template_runtime/configs/
mod.rs1mod xcm_config;
27
28use polkadot_sdk::{staging_parachain_info as parachain_info, staging_xcm as xcm, *};
29#[cfg(not(feature = "runtime-benchmarks"))]
30use polkadot_sdk::{staging_xcm_builder as xcm_builder, staging_xcm_executor as xcm_executor};
31
32use cumulus_pallet_parachain_system::RelayNumberMonotonicallyIncreases;
34use cumulus_primitives_core::{AggregateMessageOrigin, ParaId};
35use frame_support::{
36 derive_impl,
37 dispatch::DispatchClass,
38 parameter_types,
39 traits::{
40 ConstBool, ConstU32, ConstU64, ConstU8, EitherOfDiverse, TransformOrigin, VariantCountOf,
41 },
42 weights::{ConstantMultiplier, Weight},
43 PalletId,
44};
45use frame_system::{
46 limits::{BlockLength, BlockWeights},
47 EnsureRoot,
48};
49use pallet_xcm::{EnsureXcm, IsVoiceOfBody};
50use parachains_common::message_queue::{NarrowOriginToSibling, ParaIdToSibling};
51use polkadot_runtime_common::{
52 xcm_sender::NoPriceForMessageDelivery, BlockHashCount, SlowAdjustingFeeUpdate,
53};
54use sp_consensus_aura::sr25519::AuthorityId as AuraId;
55use sp_runtime::Perbill;
56use sp_version::RuntimeVersion;
57use xcm::latest::prelude::BodyId;
58
59use super::{
61 weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight},
62 AccountId, Aura, Balance, Balances, Block, BlockNumber, CollatorSelection, ConsensusHook, Hash,
63 MessageQueue, Nonce, PalletInfo, ParachainSystem, Runtime, RuntimeCall, RuntimeEvent,
64 RuntimeFreezeReason, RuntimeHoldReason, RuntimeOrigin, RuntimeTask, Session, SessionKeys,
65 System, WeightToFee, XcmpQueue, AVERAGE_ON_INITIALIZE_RATIO, EXISTENTIAL_DEPOSIT, HOURS,
66 MAXIMUM_BLOCK_WEIGHT, MICRO_UNIT, NORMAL_DISPATCH_RATIO, SLOT_DURATION, VERSION,
67};
68use xcm_config::{RelayLocation, XcmOriginToTransactDispatchOrigin};
69
70parameter_types! {
71 pub const Version: RuntimeVersion = VERSION;
72
73 pub RuntimeBlockLength: BlockLength =
78 BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);
79 pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()
80 .base_block(BlockExecutionWeight::get())
81 .for_class(DispatchClass::all(), |weights| {
82 weights.base_extrinsic = ExtrinsicBaseWeight::get();
83 })
84 .for_class(DispatchClass::Normal, |weights| {
85 weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);
86 })
87 .for_class(DispatchClass::Operational, |weights| {
88 weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);
89 weights.reserved = Some(
92 MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT
93 );
94 })
95 .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)
96 .build_or_panic();
97 pub const SS58Prefix: u16 = 42;
98}
99
100#[allow(unused_parens)]
104type SingleBlockMigrations = ();
105
106#[derive_impl(frame_system::config_preludes::ParaChainDefaultConfig)]
110impl frame_system::Config for Runtime {
111 type AccountId = AccountId;
113 type Nonce = Nonce;
115 type Hash = Hash;
117 type Block = Block;
119 type BlockHashCount = BlockHashCount;
121 type Version = Version;
123 type AccountData = pallet_balances::AccountData<Balance>;
125 type DbWeight = RocksDbWeight;
127 type BlockWeights = RuntimeBlockWeights;
129 type BlockLength = RuntimeBlockLength;
131 type SS58Prefix = SS58Prefix;
133 type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;
135 type MaxConsumers = frame_support::traits::ConstU32<16>;
136 type SingleBlockMigrations = SingleBlockMigrations;
137}
138
139impl cumulus_pallet_weight_reclaim::Config for Runtime {
141 type WeightInfo = ();
142}
143
144impl pallet_timestamp::Config for Runtime {
145 type Moment = u64;
147 type OnTimestampSet = Aura;
148 type MinimumPeriod = ConstU64<0>;
149 type WeightInfo = ();
150}
151
152impl pallet_authorship::Config for Runtime {
153 type FindAuthor = pallet_session::FindAccountFromAuthorIndex<Self, Aura>;
154 type EventHandler = (CollatorSelection,);
155}
156
157parameter_types! {
158 pub const ExistentialDeposit: Balance = EXISTENTIAL_DEPOSIT;
159}
160
161impl pallet_balances::Config for Runtime {
162 type MaxLocks = ConstU32<50>;
163 type Balance = Balance;
165 type RuntimeEvent = RuntimeEvent;
167 type DustRemoval = ();
168 type ExistentialDeposit = ExistentialDeposit;
169 type AccountStore = System;
170 type WeightInfo = pallet_balances::weights::SubstrateWeight<Runtime>;
171 type MaxReserves = ConstU32<50>;
172 type ReserveIdentifier = [u8; 8];
173 type RuntimeHoldReason = RuntimeHoldReason;
174 type RuntimeFreezeReason = RuntimeFreezeReason;
175 type FreezeIdentifier = RuntimeFreezeReason;
176 type MaxFreezes = VariantCountOf<RuntimeFreezeReason>;
177 type DoneSlashHandler = ();
178}
179
180parameter_types! {
181 pub const TransactionByteFee: Balance = 10 * MICRO_UNIT;
183}
184
185impl pallet_transaction_payment::Config for Runtime {
186 type RuntimeEvent = RuntimeEvent;
187 type OnChargeTransaction = pallet_transaction_payment::FungibleAdapter<Balances, ()>;
188 type WeightToFee = WeightToFee;
189 type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;
190 type FeeMultiplierUpdate = SlowAdjustingFeeUpdate<Self>;
191 type OperationalFeeMultiplier = ConstU8<5>;
192 type WeightInfo = ();
193}
194
195impl pallet_sudo::Config for Runtime {
196 type RuntimeEvent = RuntimeEvent;
197 type RuntimeCall = RuntimeCall;
198 type WeightInfo = ();
199}
200
201parameter_types! {
202 pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(4);
203 pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(4);
204 pub const RelayOrigin: AggregateMessageOrigin = AggregateMessageOrigin::Parent;
205}
206
207impl cumulus_pallet_parachain_system::Config for Runtime {
208 type WeightInfo = ();
209 type RuntimeEvent = RuntimeEvent;
210 type OnSystemEvent = ();
211 type SelfParaId = parachain_info::Pallet<Runtime>;
212 type OutboundXcmpMessageSource = XcmpQueue;
213 type DmpQueue = frame_support::traits::EnqueueWithOrigin<MessageQueue, RelayOrigin>;
214 type ReservedDmpWeight = ReservedDmpWeight;
215 type XcmpMessageHandler = XcmpQueue;
216 type ReservedXcmpWeight = ReservedXcmpWeight;
217 type CheckAssociatedRelayNumber = RelayNumberMonotonicallyIncreases;
218 type ConsensusHook = ConsensusHook;
219 type RelayParentOffset = ConstU32<0>;
220}
221
222impl parachain_info::Config for Runtime {}
223
224parameter_types! {
225 pub MessageQueueServiceWeight: Weight = Perbill::from_percent(35) * RuntimeBlockWeights::get().max_block;
226}
227
228impl pallet_message_queue::Config for Runtime {
229 type RuntimeEvent = RuntimeEvent;
230 type WeightInfo = ();
231 #[cfg(feature = "runtime-benchmarks")]
232 type MessageProcessor = pallet_message_queue::mock_helpers::NoopMessageProcessor<
233 cumulus_primitives_core::AggregateMessageOrigin,
234 >;
235 #[cfg(not(feature = "runtime-benchmarks"))]
236 type MessageProcessor = xcm_builder::ProcessXcmMessage<
237 AggregateMessageOrigin,
238 xcm_executor::XcmExecutor<xcm_config::XcmConfig>,
239 RuntimeCall,
240 >;
241 type Size = u32;
242 type QueueChangeHandler = NarrowOriginToSibling<XcmpQueue>;
244 type QueuePausedQuery = NarrowOriginToSibling<XcmpQueue>;
245 type HeapSize = sp_core::ConstU32<{ 103 * 1024 }>;
246 type MaxStale = sp_core::ConstU32<8>;
247 type ServiceWeight = MessageQueueServiceWeight;
248 type IdleMaxServiceWeight = ();
249}
250
251impl cumulus_pallet_aura_ext::Config for Runtime {}
252
253impl cumulus_pallet_xcmp_queue::Config for Runtime {
254 type RuntimeEvent = RuntimeEvent;
255 type ChannelInfo = ParachainSystem;
256 type VersionWrapper = ();
257 type XcmpQueue = TransformOrigin<MessageQueue, AggregateMessageOrigin, ParaId, ParaIdToSibling>;
259 type MaxInboundSuspended = sp_core::ConstU32<1_000>;
260 type MaxActiveOutboundChannels = ConstU32<128>;
261 type MaxPageSize = ConstU32<{ 1 << 16 }>;
262 type ControllerOrigin = EnsureRoot<AccountId>;
263 type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;
264 type WeightInfo = ();
265 type PriceForSiblingDelivery = NoPriceForMessageDelivery<ParaId>;
266}
267
268parameter_types! {
269 pub const Period: u32 = 6 * HOURS;
270 pub const Offset: u32 = 0;
271}
272
273impl pallet_session::Config for Runtime {
274 type RuntimeEvent = RuntimeEvent;
275 type ValidatorId = <Self as frame_system::Config>::AccountId;
276 type ValidatorIdOf = pallet_collator_selection::IdentityCollator;
278 type ShouldEndSession = pallet_session::PeriodicSessions<Period, Offset>;
279 type NextSessionRotation = pallet_session::PeriodicSessions<Period, Offset>;
280 type SessionManager = CollatorSelection;
281 type SessionHandler = <SessionKeys as sp_runtime::traits::OpaqueKeys>::KeyTypeIdProviders;
283 type Keys = SessionKeys;
284 type DisablingStrategy = ();
285 type WeightInfo = ();
286 type Currency = Balances;
287 type KeyDeposit = ();
288}
289
290#[docify::export(aura_config)]
291impl pallet_aura::Config for Runtime {
292 type AuthorityId = AuraId;
293 type DisabledValidators = ();
294 type MaxAuthorities = ConstU32<100_000>;
295 type AllowMultipleBlocksPerSlot = ConstBool<true>;
296 type SlotDuration = ConstU64<SLOT_DURATION>;
297}
298
299parameter_types! {
300 pub const PotId: PalletId = PalletId(*b"PotStake");
301 pub const SessionLength: BlockNumber = 6 * HOURS;
302 pub const StakingAdminBodyId: BodyId = BodyId::Defense;
304}
305
306pub type CollatorSelectionUpdateOrigin = EitherOfDiverse<
308 EnsureRoot<AccountId>,
309 EnsureXcm<IsVoiceOfBody<RelayLocation, StakingAdminBodyId>>,
310>;
311
312impl pallet_collator_selection::Config for Runtime {
313 type RuntimeEvent = RuntimeEvent;
314 type Currency = Balances;
315 type UpdateOrigin = CollatorSelectionUpdateOrigin;
316 type PotId = PotId;
317 type MaxCandidates = ConstU32<100>;
318 type MinEligibleCollators = ConstU32<4>;
319 type MaxInvulnerables = ConstU32<20>;
320 type KickThreshold = Period;
322 type ValidatorId = <Self as frame_system::Config>::AccountId;
323 type ValidatorIdOf = pallet_collator_selection::IdentityCollator;
324 type ValidatorRegistration = Session;
325 type WeightInfo = ();
326}
327
328impl pallet_parachain_template::Config for Runtime {
330 type RuntimeEvent = RuntimeEvent;
331 type WeightInfo = pallet_parachain_template::weights::SubstrateWeight<Runtime>;
332}