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_020_001,
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 type SingleBlockMigrations = RemoveCollectiveFlip;
230}
231
232impl cumulus_pallet_weight_reclaim::Config for Runtime {
233 type WeightInfo = ();
234}
235
236impl pallet_timestamp::Config for Runtime {
237 type Moment = u64;
239 type OnTimestampSet = Aura;
240 type MinimumPeriod = ConstU64<0>;
241 type WeightInfo = ();
242}
243
244parameter_types! {
245 pub const ExistentialDeposit: u128 = MILLIROC;
246 pub const TransferFee: u128 = MILLIROC;
247 pub const CreationFee: u128 = MILLIROC;
248 pub const TransactionByteFee: u128 = MICROROC;
249}
250
251impl pallet_balances::Config for Runtime {
252 type Balance = Balance;
254 type DustRemoval = ();
255 type RuntimeEvent = RuntimeEvent;
257 type ExistentialDeposit = ExistentialDeposit;
258 type AccountStore = System;
259 type WeightInfo = ();
260 type MaxLocks = ConstU32<50>;
261 type MaxReserves = ConstU32<50>;
262 type ReserveIdentifier = [u8; 8];
263 type RuntimeHoldReason = RuntimeHoldReason;
264 type RuntimeFreezeReason = RuntimeFreezeReason;
265 type FreezeIdentifier = ();
266 type MaxFreezes = ConstU32<0>;
267 type DoneSlashHandler = ();
268}
269
270impl pallet_transaction_payment::Config for Runtime {
271 type RuntimeEvent = RuntimeEvent;
272 type OnChargeTransaction = pallet_transaction_payment::FungibleAdapter<Balances, ()>;
273 type WeightToFee = IdentityFee<Balance>;
274 type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;
275 type FeeMultiplierUpdate = ();
276 type OperationalFeeMultiplier = ConstU8<5>;
277 type WeightInfo = ();
278}
279
280impl pallet_sudo::Config for Runtime {
281 type RuntimeCall = RuntimeCall;
282 type RuntimeEvent = RuntimeEvent;
283 type WeightInfo = pallet_sudo::weights::SubstrateWeight<Runtime>;
284}
285
286parameter_types! {
287 pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(4);
288 pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(4);
289 pub const RelayOrigin: AggregateMessageOrigin = AggregateMessageOrigin::Parent;
290}
291
292type ConsensusHook = cumulus_pallet_aura_ext::FixedVelocityConsensusHook<
293 Runtime,
294 RELAY_CHAIN_SLOT_DURATION_MILLIS,
295 BLOCK_PROCESSING_VELOCITY,
296 UNINCLUDED_SEGMENT_CAPACITY,
297>;
298
299impl cumulus_pallet_parachain_system::Config for Runtime {
300 type WeightInfo = ();
301 type RuntimeEvent = RuntimeEvent;
302 type OnSystemEvent = ();
303 type SelfParaId = parachain_info::Pallet<Runtime>;
304 type OutboundXcmpMessageSource = XcmpQueue;
305 type DmpQueue = frame_support::traits::EnqueueWithOrigin<MessageQueue, RelayOrigin>;
306 type ReservedDmpWeight = ReservedDmpWeight;
307 type XcmpMessageHandler = XcmpQueue;
308 type ReservedXcmpWeight = ReservedXcmpWeight;
309 type CheckAssociatedRelayNumber = RelayNumberMonotonicallyIncreases;
310 type ConsensusHook = ConsensusHook;
311 type RelayParentOffset = ConstU32<0>;
312}
313
314impl parachain_info::Config for Runtime {}
315
316parameter_types! {
317 pub MessageQueueServiceWeight: Weight = Perbill::from_percent(35) * RuntimeBlockWeights::get().max_block;
318}
319
320impl pallet_message_queue::Config for Runtime {
321 type RuntimeEvent = RuntimeEvent;
322 type WeightInfo = ();
323 type MessageProcessor = xcm_builder::ProcessXcmMessage<
324 AggregateMessageOrigin,
325 xcm_executor::XcmExecutor<XcmConfig>,
326 RuntimeCall,
327 >;
328 type Size = u32;
329 type QueueChangeHandler = NarrowOriginToSibling<XcmpQueue>;
331 type QueuePausedQuery = NarrowOriginToSibling<XcmpQueue>;
332 type HeapSize = sp_core::ConstU32<{ 103 * 1024 }>;
333 type MaxStale = sp_core::ConstU32<8>;
334 type ServiceWeight = MessageQueueServiceWeight;
335 type IdleMaxServiceWeight = ();
336}
337
338impl cumulus_pallet_aura_ext::Config for Runtime {}
339
340parameter_types! {
341 pub const RocLocation: Location = Location::parent();
342 pub const RococoNetwork: NetworkId = NetworkId::ByGenesis(ROCOCO_GENESIS_HASH);
343 pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into();
344 pub UniversalLocation: InteriorLocation = [GlobalConsensus(RococoNetwork::get()), Parachain(ParachainInfo::parachain_id().into())].into();
345 pub CheckingAccount: AccountId = PolkadotXcm::check_account();
346}
347
348pub type LocationToAccountId = (
352 ParentIsPreset<AccountId>,
354 SiblingParachainConvertsVia<Sibling, AccountId>,
356 AccountId32Aliases<RococoNetwork, AccountId>,
358);
359
360pub type FungibleTransactor = FungibleAdapter<
362 Balances,
364 IsConcrete<RocLocation>,
366 LocationToAccountId,
368 AccountId,
370 (),
372>;
373
374pub type FungiblesTransactor = FungiblesAdapter<
376 Assets,
378 ConvertedConcreteId<
380 AssetIdForTrustBackedAssets,
381 u64,
382 AsPrefixedGeneralIndex<
383 SystemAssetHubAssetsPalletLocation,
384 AssetIdForTrustBackedAssets,
385 JustTry,
386 >,
387 JustTry,
388 >,
389 LocationToAccountId,
391 AccountId,
393 LocalMint<NonZeroIssuance<AccountId, Assets>>,
396 CheckingAccount,
398>;
399pub type AssetTransactors = (FungibleTransactor, FungiblesTransactor);
401
402pub type XcmOriginToTransactDispatchOrigin = (
406 SovereignSignedViaLocation<LocationToAccountId, RuntimeOrigin>,
410 RelayChainAsNative<RelayChainOrigin, RuntimeOrigin>,
413 SiblingParachainAsNative<cumulus_pallet_xcm::Origin, RuntimeOrigin>,
416 ParentAsSuperuser<RuntimeOrigin>,
419 SignedAccountId32AsNative<RococoNetwork, RuntimeOrigin>,
422 XcmPassthrough<RuntimeOrigin>,
424);
425
426parameter_types! {
427 pub UnitWeightCost: Weight = Weight::from_parts(1_000_000_000, 64 * 1024);
429 pub const WeightPrice: (Location, u128) = (Location::parent(), ROC);
431 pub const MaxInstructions: u32 = 100;
432}
433
434pub struct ParentOrParentsUnitPlurality;
435impl Contains<Location> for ParentOrParentsUnitPlurality {
436 fn contains(location: &Location) -> bool {
437 matches!(location.unpack(), (1, []) | (1, [Plurality { id: BodyId::Unit, .. }]))
438 }
439}
440
441pub struct AssetHub;
442impl Contains<Location> for AssetHub {
443 fn contains(location: &Location) -> bool {
444 matches!(location.unpack(), (1, [Parachain(1000)]))
445 }
446}
447
448pub type Barrier = TrailingSetTopicAsId<(
449 TakeWeightCredit,
450 AllowTopLevelPaidExecutionFrom<Everything>,
451 AllowExplicitUnpaidExecutionFrom<ParentOrParentsUnitPlurality>,
453 AllowExplicitUnpaidExecutionFrom<AssetHub>,
455 AllowKnownQueryResponses<PolkadotXcm>,
457 AllowSubscriptionsFrom<Everything>,
459 AllowHrmpNotificationsFromRelayChain,
461)>;
462
463parameter_types! {
464 pub MaxAssetsIntoHolding: u32 = 64;
465 pub SystemAssetHubLocation: Location = Location::new(1, [Parachain(1000)]);
466 pub SystemAssetHubAssetsPalletLocation: Location =
469 Location::new(1, [Parachain(1000), PalletInstance(50)]);
470}
471
472pub type Reserves = (NativeAsset, AssetsFrom<SystemAssetHubLocation>);
473
474pub struct XcmConfig;
475impl xcm_executor::Config for XcmConfig {
476 type RuntimeCall = RuntimeCall;
477 type XcmSender = XcmRouter;
478 type XcmEventEmitter = PolkadotXcm;
479 type AssetTransactor = AssetTransactors;
481 type OriginConverter = XcmOriginToTransactDispatchOrigin;
482 type IsReserve = Reserves;
483 type IsTeleporter = NativeAsset; type UniversalLocation = UniversalLocation;
485 type Barrier = Barrier;
486 type Weigher = FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>;
487 type Trader = UsingComponents<IdentityFee<Balance>, RocLocation, AccountId, Balances, ()>;
488 type ResponseHandler = PolkadotXcm;
489 type AssetTrap = PolkadotXcm;
490 type AssetClaims = PolkadotXcm;
491 type SubscriptionService = PolkadotXcm;
492 type PalletInstancesInfo = AllPalletsWithSystem;
493 type MaxAssetsIntoHolding = MaxAssetsIntoHolding;
494 type AssetLocker = ();
495 type AssetExchanger = ();
496 type FeeManager = ();
497 type MessageExporter = ();
498 type UniversalAliases = Nothing;
499 type CallDispatcher = RuntimeCall;
500 type SafeCallFilter = Everything;
501 type Aliasers = Nothing;
502 type TransactionalProcessor = FrameTransactionalProcessor;
503 type HrmpNewChannelOpenRequestHandler = ();
504 type HrmpChannelAcceptedHandler = ();
505 type HrmpChannelClosingHandler = ();
506 type XcmRecorder = PolkadotXcm;
507}
508
509pub type LocalOriginToLocation = SignedToAccountId32<RuntimeOrigin, AccountId, RococoNetwork>;
512
513pub type XcmRouter = WithUniqueTopic<(
516 cumulus_primitives_utility::ParentAsUmp<ParachainSystem, (), ()>,
518 XcmpQueue,
520)>;
521
522impl pallet_xcm::Config for Runtime {
523 type RuntimeEvent = RuntimeEvent;
524 type SendXcmOrigin = EnsureXcmOrigin<RuntimeOrigin, LocalOriginToLocation>;
525 type XcmRouter = XcmRouter;
526 type ExecuteXcmOrigin = EnsureXcmOrigin<RuntimeOrigin, LocalOriginToLocation>;
527 type XcmExecuteFilter = Everything;
528 type XcmExecutor = XcmExecutor<XcmConfig>;
529 type XcmTeleportFilter = Everything;
530 type XcmReserveTransferFilter = Nothing;
531 type Weigher = FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>;
532 type UniversalLocation = UniversalLocation;
533 type RuntimeOrigin = RuntimeOrigin;
534 type RuntimeCall = RuntimeCall;
535 const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
536 type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
537 type Currency = Balances;
538 type CurrencyMatcher = ();
539 type TrustedLockers = ();
540 type SovereignAccountOf = LocationToAccountId;
541 type MaxLockers = ConstU32<8>;
542 type WeightInfo = pallet_xcm::TestWeightInfo;
543 type AdminOrigin = EnsureRoot<AccountId>;
544 type MaxRemoteLockConsumers = ConstU32<0>;
545 type RemoteLockConsumerIdentifier = ();
546 type AuthorizedAliasConsideration = Disabled;
548}
549
550impl cumulus_pallet_xcm::Config for Runtime {
551 type RuntimeEvent = RuntimeEvent;
552 type XcmExecutor = XcmExecutor<XcmConfig>;
553}
554
555impl cumulus_pallet_xcmp_queue::Config for Runtime {
556 type RuntimeEvent = RuntimeEvent;
557 type ChannelInfo = ParachainSystem;
558 type VersionWrapper = ();
559 type XcmpQueue = TransformOrigin<MessageQueue, AggregateMessageOrigin, ParaId, ParaIdToSibling>;
561 type MaxInboundSuspended = ConstU32<1_000>;
562 type MaxActiveOutboundChannels = ConstU32<128>;
563 type MaxPageSize = ConstU32<{ 103 * 1024 }>;
566 type ControllerOrigin = EnsureRoot<AccountId>;
567 type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;
568 type WeightInfo = cumulus_pallet_xcmp_queue::weights::SubstrateWeight<Runtime>;
569 type PriceForSiblingDelivery = NoPriceForMessageDelivery<ParaId>;
570}
571
572impl cumulus_ping::Config for Runtime {
573 type RuntimeEvent = RuntimeEvent;
574 type RuntimeOrigin = RuntimeOrigin;
575 type RuntimeCall = RuntimeCall;
576 type XcmSender = XcmRouter;
577}
578
579parameter_types! {
580 pub const AssetDeposit: Balance = ROC;
581 pub const AssetAccountDeposit: Balance = ROC;
582 pub const ApprovalDeposit: Balance = 100 * MILLIROC;
583 pub const AssetsStringLimit: u32 = 50;
584 pub const MetadataDepositBase: Balance = ROC;
585 pub const MetadataDepositPerByte: Balance = 10 * MILLIROC;
586 pub const UnitBody: BodyId = BodyId::Unit;
587}
588
589pub type AdminOrigin =
591 EitherOfDiverse<EnsureRoot<AccountId>, EnsureXcm<IsMajorityOfBody<RocLocation, UnitBody>>>;
592
593impl pallet_assets::Config for Runtime {
594 type RuntimeEvent = RuntimeEvent;
595 type Balance = u64;
596 type AssetId = AssetIdForTrustBackedAssets;
597 type AssetIdParameter = codec::Compact<AssetIdForTrustBackedAssets>;
598 type ReserveData = ();
599 type Currency = Balances;
600 type CreateOrigin = AsEnsureOriginWithArg<EnsureSigned<AccountId>>;
601 type ForceOrigin = AdminOrigin;
602 type AssetDeposit = AssetDeposit;
603 type MetadataDepositBase = MetadataDepositBase;
604 type MetadataDepositPerByte = MetadataDepositPerByte;
605 type ApprovalDeposit = ApprovalDeposit;
606 type StringLimit = AssetsStringLimit;
607 type Holder = ();
608 type Freezer = ();
609 type Extra = ();
610 type WeightInfo = pallet_assets::weights::SubstrateWeight<Runtime>;
611 type CallbackHandle = ();
612 type AssetAccountDeposit = AssetAccountDeposit;
613 type RemoveItemsLimit = frame_support::traits::ConstU32<1000>;
614 #[cfg(feature = "runtime-benchmarks")]
615 type BenchmarkHelper = ();
616}
617
618impl pallet_aura::Config for Runtime {
619 type AuthorityId = AuraId;
620 type DisabledValidators = ();
621 type MaxAuthorities = ConstU32<100_000>;
622 type AllowMultipleBlocksPerSlot = ConstBool<true>;
623 type SlotDuration = ConstU64<SLOT_DURATION>;
624}
625
626construct_runtime! {
627 pub enum Runtime
628 {
629 System: frame_system,
630 Timestamp: pallet_timestamp,
631 Sudo: pallet_sudo,
632 TransactionPayment: pallet_transaction_payment,
633 WeightReclaim: cumulus_pallet_weight_reclaim,
634
635 ParachainSystem: cumulus_pallet_parachain_system = 20,
636 ParachainInfo: parachain_info = 21,
637
638 Balances: pallet_balances = 30,
639 Assets: pallet_assets = 31,
640
641 Aura: pallet_aura,
642 AuraExt: cumulus_pallet_aura_ext,
643
644 XcmpQueue: cumulus_pallet_xcmp_queue = 50,
646 PolkadotXcm: pallet_xcm = 51,
647 CumulusXcm: cumulus_pallet_xcm = 52,
648 MessageQueue: pallet_message_queue = 54,
650
651 Spambot: cumulus_ping = 99,
652 }
653}
654
655pub type Balance = u128;
657pub type Nonce = u32;
659pub type Hash = <BlakeTwo256 as HashT>::Output;
661pub type BlockNumber = u32;
663pub type Address = sp_runtime::MultiAddress<AccountId, ()>;
665pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
667pub type Block = generic::Block<Header, UncheckedExtrinsic>;
669pub type SignedBlock = generic::SignedBlock<Block>;
671pub type BlockId = generic::BlockId<Block>;
673pub type TxExtension = cumulus_pallet_weight_reclaim::StorageWeightReclaim<
675 Runtime,
676 (
677 frame_system::AuthorizeCall<Runtime>,
678 frame_system::CheckNonZeroSender<Runtime>,
679 frame_system::CheckSpecVersion<Runtime>,
680 frame_system::CheckTxVersion<Runtime>,
681 frame_system::CheckGenesis<Runtime>,
682 frame_system::CheckEra<Runtime>,
683 frame_system::CheckNonce<Runtime>,
684 frame_system::CheckWeight<Runtime>,
685 pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
686 ),
687>;
688
689pub type UncheckedExtrinsic =
691 generic::UncheckedExtrinsic<Address, RuntimeCall, Signature, TxExtension>;
692pub type Executive = frame_executive::Executive<
694 Runtime,
695 Block,
696 frame_system::ChainContext<Runtime>,
697 Runtime,
698 AllPalletsWithSystem,
699>;
700
701pub struct RemoveCollectiveFlip;
702impl frame_support::traits::OnRuntimeUpgrade for RemoveCollectiveFlip {
703 fn on_runtime_upgrade() -> Weight {
704 use frame_support::storage::migration;
705 #[allow(deprecated)]
707 migration::remove_storage_prefix(b"RandomnessCollectiveFlip", b"RandomMaterial", b"");
708 <Runtime as frame_system::Config>::DbWeight::get().writes(1)
709 }
710}
711
712impl_runtime_apis! {
713 impl sp_api::Core<Block> for Runtime {
714 fn version() -> RuntimeVersion {
715 VERSION
716 }
717
718 fn execute_block(block: <Block as BlockT>::LazyBlock) {
719 Executive::execute_block(block);
720 }
721
722 fn initialize_block(header: &<Block as BlockT>::Header) -> sp_runtime::ExtrinsicInclusionMode {
723 Executive::initialize_block(header)
724 }
725 }
726
727 impl sp_api::Metadata<Block> for Runtime {
728 fn metadata() -> OpaqueMetadata {
729 OpaqueMetadata::new(Runtime::metadata().into())
730 }
731
732 fn metadata_at_version(version: u32) -> Option<OpaqueMetadata> {
733 Runtime::metadata_at_version(version)
734 }
735
736 fn metadata_versions() -> alloc::vec::Vec<u32> {
737 Runtime::metadata_versions()
738 }
739 }
740
741 impl sp_block_builder::BlockBuilder<Block> for Runtime {
742 fn apply_extrinsic(
743 extrinsic: <Block as BlockT>::Extrinsic,
744 ) -> ApplyExtrinsicResult {
745 Executive::apply_extrinsic(extrinsic)
746 }
747
748 fn finalize_block() -> <Block as BlockT>::Header {
749 Executive::finalize_block()
750 }
751
752 fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {
753 data.create_extrinsics()
754 }
755
756 fn check_inherents(block: <Block as BlockT>::LazyBlock, data: sp_inherents::InherentData) -> sp_inherents::CheckInherentsResult {
757 data.check_extrinsics(&block)
758 }
759 }
760
761 impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {
762 fn validate_transaction(
763 source: TransactionSource,
764 tx: <Block as BlockT>::Extrinsic,
765 block_hash: <Block as BlockT>::Hash,
766 ) -> TransactionValidity {
767 Executive::validate_transaction(source, tx, block_hash)
768 }
769 }
770
771 impl sp_offchain::OffchainWorkerApi<Block> for Runtime {
772 fn offchain_worker(header: &<Block as BlockT>::Header) {
773 Executive::offchain_worker(header)
774 }
775 }
776
777 impl sp_session::SessionKeys<Block> for Runtime {
778 fn decode_session_keys(
779 encoded: Vec<u8>,
780 ) -> Option<Vec<(Vec<u8>, sp_core::crypto::KeyTypeId)>> {
781 SessionKeys::decode_into_raw_public_keys(&encoded)
782 }
783
784 fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {
785 SessionKeys::generate(seed)
786 }
787 }
788
789 impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {
790 fn slot_duration() -> sp_consensus_aura::SlotDuration {
791 sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())
792 }
793
794 fn authorities() -> Vec<AuraId> {
795 pallet_aura::Authorities::<Runtime>::get().into_inner()
796 }
797 }
798
799 impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce> for Runtime {
800 fn account_nonce(account: AccountId) -> Nonce {
801 System::account_nonce(account)
802 }
803 }
804
805 impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {
806 fn query_info(
807 uxt: <Block as BlockT>::Extrinsic,
808 len: u32,
809 ) -> pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo<Balance> {
810 TransactionPayment::query_info(uxt, len)
811 }
812 fn query_fee_details(
813 uxt: <Block as BlockT>::Extrinsic,
814 len: u32,
815 ) -> pallet_transaction_payment::FeeDetails<Balance> {
816 TransactionPayment::query_fee_details(uxt, len)
817 }
818 fn query_weight_to_fee(weight: Weight) -> Balance {
819 TransactionPayment::weight_to_fee(weight)
820 }
821 fn query_length_to_fee(length: u32) -> Balance {
822 TransactionPayment::length_to_fee(length)
823 }
824 }
825
826 impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentCallApi<Block, Balance, RuntimeCall>
827 for Runtime
828 {
829 fn query_call_info(
830 call: RuntimeCall,
831 len: u32,
832 ) -> pallet_transaction_payment::RuntimeDispatchInfo<Balance> {
833 TransactionPayment::query_call_info(call, len)
834 }
835 fn query_call_fee_details(
836 call: RuntimeCall,
837 len: u32,
838 ) -> pallet_transaction_payment::FeeDetails<Balance> {
839 TransactionPayment::query_call_fee_details(call, len)
840 }
841 fn query_weight_to_fee(weight: Weight) -> Balance {
842 TransactionPayment::weight_to_fee(weight)
843 }
844 fn query_length_to_fee(length: u32) -> Balance {
845 TransactionPayment::length_to_fee(length)
846 }
847 }
848
849 impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {
850 fn collect_collation_info(header: &<Block as BlockT>::Header) -> cumulus_primitives_core::CollationInfo {
851 ParachainSystem::collect_collation_info(header)
852 }
853 }
854
855 impl sp_genesis_builder::GenesisBuilder<Block> for Runtime {
856 fn build_state(config: Vec<u8>) -> sp_genesis_builder::Result {
857 build_state::<RuntimeGenesisConfig>(config)
858 }
859
860 fn get_preset(id: &Option<sp_genesis_builder::PresetId>) -> Option<Vec<u8>> {
861 get_preset::<RuntimeGenesisConfig>(id, &genesis_config_presets::get_preset)
862 }
863
864 fn preset_names() -> Vec<sp_genesis_builder::PresetId> {
865 genesis_config_presets::preset_names()
866 }
867 }
868
869 impl cumulus_primitives_core::RelayParentOffsetApi<Block> for Runtime {
870 fn relay_parent_offset() -> u32 {
871 0
872 }
873 }
874
875 impl cumulus_primitives_aura::AuraUnincludedSegmentApi<Block> for Runtime {
876 fn can_build_upon(
877 included_hash: <Block as BlockT>::Hash,
878 slot: cumulus_primitives_aura::Slot,
879 ) -> bool {
880 ConsensusHook::can_build_upon(included_hash, slot)
881 }
882 }
883
884 impl cumulus_primitives_core::GetParachainInfo<Block> for Runtime {
885 fn parachain_id() -> ParaId {
886 ParachainInfo::parachain_id()
887 }
888 }
889}
890
891cumulus_pallet_parachain_system::register_validate_block! {
892 Runtime = Runtime,
893 BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,
894}