1#![cfg_attr(not(feature = "std"), no_std)]
18#![recursion_limit = "256"]
20
21#[cfg(feature = "std")]
23include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
24
25mod genesis_config_presets;
26
27extern crate alloc;
28
29use alloc::vec::Vec;
30use cumulus_pallet_parachain_system::RelayNumberMonotonicallyIncreases;
31use polkadot_runtime_common::xcm_sender::NoPriceForMessageDelivery;
32use sp_api::impl_runtime_apis;
33use sp_core::OpaqueMetadata;
34use sp_runtime::{
35 generic, impl_opaque_keys,
36 traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, Hash as HashT},
37 transaction_validity::{TransactionSource, TransactionValidity},
38 ApplyExtrinsicResult,
39};
40#[cfg(feature = "std")]
41use sp_version::NativeVersion;
42use sp_version::RuntimeVersion;
43
44pub use frame_support::{
46 construct_runtime, derive_impl,
47 dispatch::DispatchClass,
48 genesis_builder_helper::{build_state, get_preset},
49 parameter_types,
50 traits::{
51 AsEnsureOriginWithArg, ConstBool, ConstU32, ConstU64, ConstU8, Contains, EitherOfDiverse,
52 Everything, IsInVec, Nothing, Randomness,
53 },
54 weights::{
55 constants::{
56 BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_REF_TIME_PER_SECOND,
57 },
58 ConstantMultiplier, IdentityFee, Weight,
59 },
60 StorageValue,
61};
62use frame_system::{
63 limits::{BlockLength, BlockWeights},
64 EnsureRoot, EnsureSigned,
65};
66pub use pallet_balances::Call as BalancesCall;
67pub use pallet_timestamp::Call as TimestampCall;
68pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;
69#[cfg(any(feature = "std", test))]
70pub use sp_runtime::BuildStorage;
71pub use sp_runtime::{Perbill, Permill};
72
73use cumulus_primitives_core::{AggregateMessageOrigin, ParaId};
74use frame_support::traits::{Disabled, TransformOrigin};
75use parachains_common::{
76 impls::{AssetsFrom, NonZeroIssuance},
77 message_queue::{NarrowOriginToSibling, ParaIdToSibling},
78 AccountId, AssetIdForTrustBackedAssets, Signature,
79};
80use xcm_builder::{
81 AllowHrmpNotificationsFromRelayChain, AllowKnownQueryResponses, AllowSubscriptionsFrom,
82 AsPrefixedGeneralIndex, ConvertedConcreteId, FrameTransactionalProcessor, FungiblesAdapter,
83 LocalMint, TrailingSetTopicAsId, WithUniqueTopic,
84};
85use xcm_executor::traits::JustTry;
86
87use pallet_xcm::{EnsureXcm, IsMajorityOfBody, XcmPassthrough};
89use polkadot_parachain_primitives::primitives::Sibling;
90use xcm::latest::{prelude::*, ROCOCO_GENESIS_HASH};
91use xcm_builder::{
92 AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowTopLevelPaidExecutionFrom,
93 EnsureXcmOrigin, FixedWeightBounds, FungibleAdapter, IsConcrete, NativeAsset,
94 ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative,
95 SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,
96 SovereignSignedViaLocation, TakeWeightCredit, UsingComponents,
97};
98use xcm_executor::XcmExecutor;
99
100pub type SessionHandlers = ();
101
102impl_opaque_keys! {
103 pub struct SessionKeys {
104 pub aura: Aura,
105 }
106}
107
108#[sp_version::runtime_version]
110pub const VERSION: RuntimeVersion = RuntimeVersion {
111 spec_name: alloc::borrow::Cow::Borrowed("test-parachain"),
112 impl_name: alloc::borrow::Cow::Borrowed("test-parachain"),
113 authoring_version: 1,
114 spec_version: 1_014_000,
115 impl_version: 0,
116 apis: RUNTIME_API_VERSIONS,
117 transaction_version: 6,
118 system_version: 0,
119};
120
121pub const MILLISECS_PER_BLOCK: u64 = 6000;
122
123pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;
124
125pub const EPOCH_DURATION_IN_BLOCKS: u32 = 10 * MINUTES;
126
127pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);
129pub const HOURS: BlockNumber = MINUTES * 60;
130pub const DAYS: BlockNumber = HOURS * 24;
131
132pub const ROC: Balance = 1_000_000_000_000;
133pub const MILLIROC: Balance = 1_000_000_000;
134pub const MICROROC: Balance = 1_000_000;
135
136pub const PRIMARY_PROBABILITY: (u64, u64) = (1, 4);
138
139#[cfg(feature = "std")]
141pub fn native_version() -> NativeVersion {
142 NativeVersion { runtime_version: VERSION, can_author_with: Default::default() }
143}
144
145const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(10);
148const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);
151const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_parts(
153 WEIGHT_REF_TIME_PER_SECOND.saturating_mul(2),
154 cumulus_primitives_core::relay_chain::MAX_POV_SIZE as u64,
155);
156
157const UNINCLUDED_SEGMENT_CAPACITY: u32 = 3;
160const BLOCK_PROCESSING_VELOCITY: u32 = 2;
163const RELAY_CHAIN_SLOT_DURATION_MILLIS: u32 = 6000;
165
166parameter_types! {
167 pub const BlockHashCount: BlockNumber = 250;
168 pub const Version: RuntimeVersion = VERSION;
169 pub RuntimeBlockLength: BlockLength =
170 BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);
171 pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()
172 .base_block(BlockExecutionWeight::get())
173 .for_class(DispatchClass::all(), |weights| {
174 weights.base_extrinsic = ExtrinsicBaseWeight::get();
175 })
176 .for_class(DispatchClass::Normal, |weights| {
177 weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);
178 })
179 .for_class(DispatchClass::Operational, |weights| {
180 weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);
181 weights.reserved = Some(
184 MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT
185 );
186 })
187 .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)
188 .build_or_panic();
189 pub const SS58Prefix: u8 = 42;
190}
191
192#[derive_impl(frame_system::config_preludes::TestDefaultConfig)]
193impl frame_system::Config for Runtime {
194 type AccountId = AccountId;
196 type RuntimeCall = RuntimeCall;
198 type Lookup = AccountIdLookup<AccountId, ()>;
200 type Nonce = Nonce;
202 type Hash = Hash;
204 type Hashing = BlakeTwo256;
206 type Block = Block;
208 type RuntimeEvent = RuntimeEvent;
210 type RuntimeOrigin = RuntimeOrigin;
212 type BlockHashCount = BlockHashCount;
214 type Version = Version;
216 type PalletInfo = PalletInfo;
218 type AccountData = pallet_balances::AccountData<Balance>;
219 type OnNewAccount = ();
220 type OnKilledAccount = ();
221 type DbWeight = RocksDbWeight;
222 type BaseCallFilter = frame_support::traits::Everything;
223 type SystemWeightInfo = ();
224 type BlockWeights = RuntimeBlockWeights;
225 type BlockLength = RuntimeBlockLength;
226 type SS58Prefix = SS58Prefix;
227 type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;
228 type MaxConsumers = frame_support::traits::ConstU32<16>;
229}
230
231impl cumulus_pallet_weight_reclaim::Config for Runtime {
232 type WeightInfo = ();
233}
234
235impl pallet_timestamp::Config for Runtime {
236 type Moment = u64;
238 type OnTimestampSet = Aura;
239 type MinimumPeriod = ConstU64<0>;
240 type WeightInfo = ();
241}
242
243parameter_types! {
244 pub const ExistentialDeposit: u128 = MILLIROC;
245 pub const TransferFee: u128 = MILLIROC;
246 pub const CreationFee: u128 = MILLIROC;
247 pub const TransactionByteFee: u128 = MICROROC;
248}
249
250impl pallet_balances::Config for Runtime {
251 type Balance = Balance;
253 type DustRemoval = ();
254 type RuntimeEvent = RuntimeEvent;
256 type ExistentialDeposit = ExistentialDeposit;
257 type AccountStore = System;
258 type WeightInfo = ();
259 type MaxLocks = ConstU32<50>;
260 type MaxReserves = ConstU32<50>;
261 type ReserveIdentifier = [u8; 8];
262 type RuntimeHoldReason = RuntimeHoldReason;
263 type RuntimeFreezeReason = RuntimeFreezeReason;
264 type FreezeIdentifier = ();
265 type MaxFreezes = ConstU32<0>;
266 type DoneSlashHandler = ();
267}
268
269impl pallet_transaction_payment::Config for Runtime {
270 type RuntimeEvent = RuntimeEvent;
271 type OnChargeTransaction = pallet_transaction_payment::FungibleAdapter<Balances, ()>;
272 type WeightToFee = IdentityFee<Balance>;
273 type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;
274 type FeeMultiplierUpdate = ();
275 type OperationalFeeMultiplier = ConstU8<5>;
276 type WeightInfo = ();
277}
278
279impl pallet_sudo::Config for Runtime {
280 type RuntimeCall = RuntimeCall;
281 type RuntimeEvent = RuntimeEvent;
282 type WeightInfo = pallet_sudo::weights::SubstrateWeight<Runtime>;
283}
284
285parameter_types! {
286 pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(4);
287 pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(4);
288 pub const RelayOrigin: AggregateMessageOrigin = AggregateMessageOrigin::Parent;
289}
290
291type ConsensusHook = cumulus_pallet_aura_ext::FixedVelocityConsensusHook<
292 Runtime,
293 RELAY_CHAIN_SLOT_DURATION_MILLIS,
294 BLOCK_PROCESSING_VELOCITY,
295 UNINCLUDED_SEGMENT_CAPACITY,
296>;
297
298impl cumulus_pallet_parachain_system::Config for Runtime {
299 type WeightInfo = ();
300 type RuntimeEvent = RuntimeEvent;
301 type OnSystemEvent = ();
302 type SelfParaId = parachain_info::Pallet<Runtime>;
303 type OutboundXcmpMessageSource = XcmpQueue;
304 type DmpQueue = frame_support::traits::EnqueueWithOrigin<MessageQueue, RelayOrigin>;
305 type ReservedDmpWeight = ReservedDmpWeight;
306 type XcmpMessageHandler = XcmpQueue;
307 type ReservedXcmpWeight = ReservedXcmpWeight;
308 type CheckAssociatedRelayNumber = RelayNumberMonotonicallyIncreases;
309 type ConsensusHook = ConsensusHook;
310 type RelayParentOffset = ConstU32<0>;
311}
312
313impl parachain_info::Config for Runtime {}
314
315parameter_types! {
316 pub MessageQueueServiceWeight: Weight = Perbill::from_percent(35) * RuntimeBlockWeights::get().max_block;
317}
318
319impl pallet_message_queue::Config for Runtime {
320 type RuntimeEvent = RuntimeEvent;
321 type WeightInfo = ();
322 type MessageProcessor = xcm_builder::ProcessXcmMessage<
323 AggregateMessageOrigin,
324 xcm_executor::XcmExecutor<XcmConfig>,
325 RuntimeCall,
326 >;
327 type Size = u32;
328 type QueueChangeHandler = NarrowOriginToSibling<XcmpQueue>;
330 type QueuePausedQuery = NarrowOriginToSibling<XcmpQueue>;
331 type HeapSize = sp_core::ConstU32<{ 103 * 1024 }>;
332 type MaxStale = sp_core::ConstU32<8>;
333 type ServiceWeight = MessageQueueServiceWeight;
334 type IdleMaxServiceWeight = ();
335}
336
337impl cumulus_pallet_aura_ext::Config for Runtime {}
338
339parameter_types! {
340 pub const RocLocation: Location = Location::parent();
341 pub const RococoNetwork: NetworkId = NetworkId::ByGenesis(ROCOCO_GENESIS_HASH);
342 pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into();
343 pub UniversalLocation: InteriorLocation = [GlobalConsensus(RococoNetwork::get()), Parachain(ParachainInfo::parachain_id().into())].into();
344 pub CheckingAccount: AccountId = PolkadotXcm::check_account();
345}
346
347pub type LocationToAccountId = (
351 ParentIsPreset<AccountId>,
353 SiblingParachainConvertsVia<Sibling, AccountId>,
355 AccountId32Aliases<RococoNetwork, AccountId>,
357);
358
359pub type FungibleTransactor = FungibleAdapter<
361 Balances,
363 IsConcrete<RocLocation>,
365 LocationToAccountId,
367 AccountId,
369 (),
371>;
372
373pub type FungiblesTransactor = FungiblesAdapter<
375 Assets,
377 ConvertedConcreteId<
379 AssetIdForTrustBackedAssets,
380 u64,
381 AsPrefixedGeneralIndex<
382 SystemAssetHubAssetsPalletLocation,
383 AssetIdForTrustBackedAssets,
384 JustTry,
385 >,
386 JustTry,
387 >,
388 LocationToAccountId,
390 AccountId,
392 LocalMint<NonZeroIssuance<AccountId, Assets>>,
395 CheckingAccount,
397>;
398pub type AssetTransactors = (FungibleTransactor, FungiblesTransactor);
400
401pub type XcmOriginToTransactDispatchOrigin = (
405 SovereignSignedViaLocation<LocationToAccountId, RuntimeOrigin>,
409 RelayChainAsNative<RelayChainOrigin, RuntimeOrigin>,
412 SiblingParachainAsNative<cumulus_pallet_xcm::Origin, RuntimeOrigin>,
415 ParentAsSuperuser<RuntimeOrigin>,
418 SignedAccountId32AsNative<RococoNetwork, RuntimeOrigin>,
421 XcmPassthrough<RuntimeOrigin>,
423);
424
425parameter_types! {
426 pub UnitWeightCost: Weight = Weight::from_parts(1_000_000_000, 64 * 1024);
428 pub const WeightPrice: (Location, u128) = (Location::parent(), ROC);
430 pub const MaxInstructions: u32 = 100;
431}
432
433pub struct ParentOrParentsUnitPlurality;
434impl Contains<Location> for ParentOrParentsUnitPlurality {
435 fn contains(location: &Location) -> bool {
436 matches!(location.unpack(), (1, []) | (1, [Plurality { id: BodyId::Unit, .. }]))
437 }
438}
439
440pub struct AssetHub;
441impl Contains<Location> for AssetHub {
442 fn contains(location: &Location) -> bool {
443 matches!(location.unpack(), (1, [Parachain(1000)]))
444 }
445}
446
447pub type Barrier = TrailingSetTopicAsId<(
448 TakeWeightCredit,
449 AllowTopLevelPaidExecutionFrom<Everything>,
450 AllowExplicitUnpaidExecutionFrom<ParentOrParentsUnitPlurality>,
452 AllowExplicitUnpaidExecutionFrom<AssetHub>,
454 AllowKnownQueryResponses<PolkadotXcm>,
456 AllowSubscriptionsFrom<Everything>,
458 AllowHrmpNotificationsFromRelayChain,
460)>;
461
462parameter_types! {
463 pub MaxAssetsIntoHolding: u32 = 64;
464 pub SystemAssetHubLocation: Location = Location::new(1, [Parachain(1000)]);
465 pub SystemAssetHubAssetsPalletLocation: Location =
468 Location::new(1, [Parachain(1000), PalletInstance(50)]);
469}
470
471pub type Reserves = (NativeAsset, AssetsFrom<SystemAssetHubLocation>);
472
473pub struct XcmConfig;
474impl xcm_executor::Config for XcmConfig {
475 type RuntimeCall = RuntimeCall;
476 type XcmSender = XcmRouter;
477 type XcmEventEmitter = PolkadotXcm;
478 type AssetTransactor = AssetTransactors;
480 type OriginConverter = XcmOriginToTransactDispatchOrigin;
481 type IsReserve = Reserves;
482 type IsTeleporter = NativeAsset; type UniversalLocation = UniversalLocation;
484 type Barrier = Barrier;
485 type Weigher = FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>;
486 type Trader = UsingComponents<IdentityFee<Balance>, RocLocation, AccountId, Balances, ()>;
487 type ResponseHandler = PolkadotXcm;
488 type AssetTrap = PolkadotXcm;
489 type AssetClaims = PolkadotXcm;
490 type SubscriptionService = PolkadotXcm;
491 type PalletInstancesInfo = AllPalletsWithSystem;
492 type MaxAssetsIntoHolding = MaxAssetsIntoHolding;
493 type AssetLocker = ();
494 type AssetExchanger = ();
495 type FeeManager = ();
496 type MessageExporter = ();
497 type UniversalAliases = Nothing;
498 type CallDispatcher = RuntimeCall;
499 type SafeCallFilter = Everything;
500 type Aliasers = Nothing;
501 type TransactionalProcessor = FrameTransactionalProcessor;
502 type HrmpNewChannelOpenRequestHandler = ();
503 type HrmpChannelAcceptedHandler = ();
504 type HrmpChannelClosingHandler = ();
505 type XcmRecorder = PolkadotXcm;
506}
507
508pub type LocalOriginToLocation = SignedToAccountId32<RuntimeOrigin, AccountId, RococoNetwork>;
511
512pub type XcmRouter = WithUniqueTopic<(
515 cumulus_primitives_utility::ParentAsUmp<ParachainSystem, (), ()>,
517 XcmpQueue,
519)>;
520
521impl pallet_xcm::Config for Runtime {
522 type RuntimeEvent = RuntimeEvent;
523 type SendXcmOrigin = EnsureXcmOrigin<RuntimeOrigin, LocalOriginToLocation>;
524 type XcmRouter = XcmRouter;
525 type ExecuteXcmOrigin = EnsureXcmOrigin<RuntimeOrigin, LocalOriginToLocation>;
526 type XcmExecuteFilter = Everything;
527 type XcmExecutor = XcmExecutor<XcmConfig>;
528 type XcmTeleportFilter = Everything;
529 type XcmReserveTransferFilter = Nothing;
530 type Weigher = FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>;
531 type UniversalLocation = UniversalLocation;
532 type RuntimeOrigin = RuntimeOrigin;
533 type RuntimeCall = RuntimeCall;
534 const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
535 type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
536 type Currency = Balances;
537 type CurrencyMatcher = ();
538 type TrustedLockers = ();
539 type SovereignAccountOf = LocationToAccountId;
540 type MaxLockers = ConstU32<8>;
541 type WeightInfo = pallet_xcm::TestWeightInfo;
542 type AdminOrigin = EnsureRoot<AccountId>;
543 type MaxRemoteLockConsumers = ConstU32<0>;
544 type RemoteLockConsumerIdentifier = ();
545 type AuthorizedAliasConsideration = Disabled;
547}
548
549impl cumulus_pallet_xcm::Config for Runtime {
550 type RuntimeEvent = RuntimeEvent;
551 type XcmExecutor = XcmExecutor<XcmConfig>;
552}
553
554impl cumulus_pallet_xcmp_queue::Config for Runtime {
555 type RuntimeEvent = RuntimeEvent;
556 type ChannelInfo = ParachainSystem;
557 type VersionWrapper = ();
558 type XcmpQueue = TransformOrigin<MessageQueue, AggregateMessageOrigin, ParaId, ParaIdToSibling>;
560 type MaxInboundSuspended = ConstU32<1_000>;
561 type MaxActiveOutboundChannels = ConstU32<128>;
562 type MaxPageSize = ConstU32<{ 103 * 1024 }>;
565 type ControllerOrigin = EnsureRoot<AccountId>;
566 type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;
567 type WeightInfo = cumulus_pallet_xcmp_queue::weights::SubstrateWeight<Runtime>;
568 type PriceForSiblingDelivery = NoPriceForMessageDelivery<ParaId>;
569}
570
571impl cumulus_ping::Config for Runtime {
572 type RuntimeEvent = RuntimeEvent;
573 type RuntimeOrigin = RuntimeOrigin;
574 type RuntimeCall = RuntimeCall;
575 type XcmSender = XcmRouter;
576}
577
578parameter_types! {
579 pub const AssetDeposit: Balance = ROC;
580 pub const AssetAccountDeposit: Balance = ROC;
581 pub const ApprovalDeposit: Balance = 100 * MILLIROC;
582 pub const AssetsStringLimit: u32 = 50;
583 pub const MetadataDepositBase: Balance = ROC;
584 pub const MetadataDepositPerByte: Balance = 10 * MILLIROC;
585 pub const UnitBody: BodyId = BodyId::Unit;
586}
587
588pub type AdminOrigin =
590 EitherOfDiverse<EnsureRoot<AccountId>, EnsureXcm<IsMajorityOfBody<RocLocation, UnitBody>>>;
591
592impl pallet_assets::Config for Runtime {
593 type RuntimeEvent = RuntimeEvent;
594 type Balance = u64;
595 type AssetId = AssetIdForTrustBackedAssets;
596 type AssetIdParameter = codec::Compact<AssetIdForTrustBackedAssets>;
597 type Currency = Balances;
598 type CreateOrigin = AsEnsureOriginWithArg<EnsureSigned<AccountId>>;
599 type ForceOrigin = AdminOrigin;
600 type AssetDeposit = AssetDeposit;
601 type MetadataDepositBase = MetadataDepositBase;
602 type MetadataDepositPerByte = MetadataDepositPerByte;
603 type ApprovalDeposit = ApprovalDeposit;
604 type StringLimit = AssetsStringLimit;
605 type Holder = ();
606 type Freezer = ();
607 type Extra = ();
608 type WeightInfo = pallet_assets::weights::SubstrateWeight<Runtime>;
609 type CallbackHandle = ();
610 type AssetAccountDeposit = AssetAccountDeposit;
611 type RemoveItemsLimit = frame_support::traits::ConstU32<1000>;
612 #[cfg(feature = "runtime-benchmarks")]
613 type BenchmarkHelper = ();
614}
615
616impl pallet_aura::Config for Runtime {
617 type AuthorityId = AuraId;
618 type DisabledValidators = ();
619 type MaxAuthorities = ConstU32<100_000>;
620 type AllowMultipleBlocksPerSlot = ConstBool<true>;
621 type SlotDuration = ConstU64<SLOT_DURATION>;
622}
623
624construct_runtime! {
625 pub enum Runtime
626 {
627 System: frame_system,
628 Timestamp: pallet_timestamp,
629 Sudo: pallet_sudo,
630 TransactionPayment: pallet_transaction_payment,
631 WeightReclaim: cumulus_pallet_weight_reclaim,
632
633 ParachainSystem: cumulus_pallet_parachain_system = 20,
634 ParachainInfo: parachain_info = 21,
635
636 Balances: pallet_balances = 30,
637 Assets: pallet_assets = 31,
638
639 Aura: pallet_aura,
640 AuraExt: cumulus_pallet_aura_ext,
641
642 XcmpQueue: cumulus_pallet_xcmp_queue = 50,
644 PolkadotXcm: pallet_xcm = 51,
645 CumulusXcm: cumulus_pallet_xcm = 52,
646 MessageQueue: pallet_message_queue = 54,
648
649 Spambot: cumulus_ping = 99,
650 }
651}
652
653pub type Balance = u128;
655pub type Nonce = u32;
657pub type Hash = <BlakeTwo256 as HashT>::Output;
659pub type BlockNumber = u32;
661pub type Address = sp_runtime::MultiAddress<AccountId, ()>;
663pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
665pub type Block = generic::Block<Header, UncheckedExtrinsic>;
667pub type SignedBlock = generic::SignedBlock<Block>;
669pub type BlockId = generic::BlockId<Block>;
671pub type TxExtension = cumulus_pallet_weight_reclaim::StorageWeightReclaim<
673 Runtime,
674 (
675 frame_system::AuthorizeCall<Runtime>,
676 frame_system::CheckNonZeroSender<Runtime>,
677 frame_system::CheckSpecVersion<Runtime>,
678 frame_system::CheckTxVersion<Runtime>,
679 frame_system::CheckGenesis<Runtime>,
680 frame_system::CheckEra<Runtime>,
681 frame_system::CheckNonce<Runtime>,
682 frame_system::CheckWeight<Runtime>,
683 pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
684 ),
685>;
686
687pub type UncheckedExtrinsic =
689 generic::UncheckedExtrinsic<Address, RuntimeCall, Signature, TxExtension>;
690pub type Executive = frame_executive::Executive<
692 Runtime,
693 Block,
694 frame_system::ChainContext<Runtime>,
695 Runtime,
696 AllPalletsWithSystem,
697 RemoveCollectiveFlip,
698>;
699
700pub struct RemoveCollectiveFlip;
701impl frame_support::traits::OnRuntimeUpgrade for RemoveCollectiveFlip {
702 fn on_runtime_upgrade() -> Weight {
703 use frame_support::storage::migration;
704 #[allow(deprecated)]
706 migration::remove_storage_prefix(b"RandomnessCollectiveFlip", b"RandomMaterial", b"");
707 <Runtime as frame_system::Config>::DbWeight::get().writes(1)
708 }
709}
710
711impl_runtime_apis! {
712 impl sp_api::Core<Block> for Runtime {
713 fn version() -> RuntimeVersion {
714 VERSION
715 }
716
717 fn execute_block(block: Block) {
718 Executive::execute_block(block);
719 }
720
721 fn initialize_block(header: &<Block as BlockT>::Header) -> sp_runtime::ExtrinsicInclusionMode {
722 Executive::initialize_block(header)
723 }
724 }
725
726 impl sp_api::Metadata<Block> for Runtime {
727 fn metadata() -> OpaqueMetadata {
728 OpaqueMetadata::new(Runtime::metadata().into())
729 }
730
731 fn metadata_at_version(version: u32) -> Option<OpaqueMetadata> {
732 Runtime::metadata_at_version(version)
733 }
734
735 fn metadata_versions() -> alloc::vec::Vec<u32> {
736 Runtime::metadata_versions()
737 }
738 }
739
740 impl sp_block_builder::BlockBuilder<Block> for Runtime {
741 fn apply_extrinsic(
742 extrinsic: <Block as BlockT>::Extrinsic,
743 ) -> ApplyExtrinsicResult {
744 Executive::apply_extrinsic(extrinsic)
745 }
746
747 fn finalize_block() -> <Block as BlockT>::Header {
748 Executive::finalize_block()
749 }
750
751 fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {
752 data.create_extrinsics()
753 }
754
755 fn check_inherents(block: Block, data: sp_inherents::InherentData) -> sp_inherents::CheckInherentsResult {
756 data.check_extrinsics(&block)
757 }
758 }
759
760 impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {
761 fn validate_transaction(
762 source: TransactionSource,
763 tx: <Block as BlockT>::Extrinsic,
764 block_hash: <Block as BlockT>::Hash,
765 ) -> TransactionValidity {
766 Executive::validate_transaction(source, tx, block_hash)
767 }
768 }
769
770 impl sp_offchain::OffchainWorkerApi<Block> for Runtime {
771 fn offchain_worker(header: &<Block as BlockT>::Header) {
772 Executive::offchain_worker(header)
773 }
774 }
775
776 impl sp_session::SessionKeys<Block> for Runtime {
777 fn decode_session_keys(
778 encoded: Vec<u8>,
779 ) -> Option<Vec<(Vec<u8>, sp_core::crypto::KeyTypeId)>> {
780 SessionKeys::decode_into_raw_public_keys(&encoded)
781 }
782
783 fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {
784 SessionKeys::generate(seed)
785 }
786 }
787
788 impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {
789 fn slot_duration() -> sp_consensus_aura::SlotDuration {
790 sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())
791 }
792
793 fn authorities() -> Vec<AuraId> {
794 pallet_aura::Authorities::<Runtime>::get().into_inner()
795 }
796 }
797
798 impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce> for Runtime {
799 fn account_nonce(account: AccountId) -> Nonce {
800 System::account_nonce(account)
801 }
802 }
803
804 impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {
805 fn query_info(
806 uxt: <Block as BlockT>::Extrinsic,
807 len: u32,
808 ) -> pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo<Balance> {
809 TransactionPayment::query_info(uxt, len)
810 }
811 fn query_fee_details(
812 uxt: <Block as BlockT>::Extrinsic,
813 len: u32,
814 ) -> pallet_transaction_payment::FeeDetails<Balance> {
815 TransactionPayment::query_fee_details(uxt, len)
816 }
817 fn query_weight_to_fee(weight: Weight) -> Balance {
818 TransactionPayment::weight_to_fee(weight)
819 }
820 fn query_length_to_fee(length: u32) -> Balance {
821 TransactionPayment::length_to_fee(length)
822 }
823 }
824
825 impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentCallApi<Block, Balance, RuntimeCall>
826 for Runtime
827 {
828 fn query_call_info(
829 call: RuntimeCall,
830 len: u32,
831 ) -> pallet_transaction_payment::RuntimeDispatchInfo<Balance> {
832 TransactionPayment::query_call_info(call, len)
833 }
834 fn query_call_fee_details(
835 call: RuntimeCall,
836 len: u32,
837 ) -> pallet_transaction_payment::FeeDetails<Balance> {
838 TransactionPayment::query_call_fee_details(call, len)
839 }
840 fn query_weight_to_fee(weight: Weight) -> Balance {
841 TransactionPayment::weight_to_fee(weight)
842 }
843 fn query_length_to_fee(length: u32) -> Balance {
844 TransactionPayment::length_to_fee(length)
845 }
846 }
847
848 impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {
849 fn collect_collation_info(header: &<Block as BlockT>::Header) -> cumulus_primitives_core::CollationInfo {
850 ParachainSystem::collect_collation_info(header)
851 }
852 }
853
854 impl sp_genesis_builder::GenesisBuilder<Block> for Runtime {
855 fn build_state(config: Vec<u8>) -> sp_genesis_builder::Result {
856 build_state::<RuntimeGenesisConfig>(config)
857 }
858
859 fn get_preset(id: &Option<sp_genesis_builder::PresetId>) -> Option<Vec<u8>> {
860 get_preset::<RuntimeGenesisConfig>(id, &genesis_config_presets::get_preset)
861 }
862
863 fn preset_names() -> Vec<sp_genesis_builder::PresetId> {
864 genesis_config_presets::preset_names()
865 }
866 }
867
868 impl cumulus_primitives_core::RelayParentOffsetApi<Block> for Runtime {
869 fn relay_parent_offset() -> u32 {
870 0
871 }
872 }
873
874 impl cumulus_primitives_aura::AuraUnincludedSegmentApi<Block> for Runtime {
875 fn can_build_upon(
876 included_hash: <Block as BlockT>::Hash,
877 slot: cumulus_primitives_aura::Slot,
878 ) -> bool {
879 ConsensusHook::can_build_upon(included_hash, slot)
880 }
881 }
882
883 impl cumulus_primitives_core::GetParachainInfo<Block> for Runtime {
884 fn parachain_id() -> ParaId {
885 ParachainInfo::parachain_id()
886 }
887 }
888}
889
890cumulus_pallet_parachain_system::register_validate_block! {
891 Runtime = Runtime,
892 BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,
893}