1#![cfg_attr(not(feature = "std"), no_std)]
17#![recursion_limit = "256"]
18#[cfg(feature = "std")]
19include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
20
21mod genesis_config_presets;
22pub mod people;
23mod weights;
24pub mod xcm_config;
25
26extern crate alloc;
27
28use alloc::{vec, vec::Vec};
29use codec::{Decode, DecodeWithMemTracking, Encode, MaxEncodedLen};
30use cumulus_pallet_parachain_system::RelayNumberMonotonicallyIncreases;
31use cumulus_primitives_core::{AggregateMessageOrigin, ParaId};
32use frame_support::{
33 construct_runtime, derive_impl,
34 dispatch::DispatchClass,
35 genesis_builder_helper::{build_state, get_preset},
36 parameter_types,
37 traits::{
38 ConstBool, ConstU32, ConstU64, ConstU8, EitherOfDiverse, Everything, InstanceFilter,
39 TransformOrigin,
40 },
41 weights::{ConstantMultiplier, Weight},
42 PalletId,
43};
44use frame_system::{
45 limits::{BlockLength, BlockWeights},
46 EnsureRoot,
47};
48use pallet_xcm::{EnsureXcm, IsVoiceOfBody};
49use parachains_common::{
50 impls::DealWithFees,
51 message_queue::{NarrowOriginToSibling, ParaIdToSibling},
52 AccountId, Balance, BlockNumber, Hash, Header, Nonce, Signature, AVERAGE_ON_INITIALIZE_RATIO,
53 NORMAL_DISPATCH_RATIO,
54};
55use polkadot_runtime_common::{identity_migrator, BlockHashCount, SlowAdjustingFeeUpdate};
56use sp_api::impl_runtime_apis;
57pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;
58use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
59#[cfg(any(feature = "std", test))]
60pub use sp_runtime::BuildStorage;
61use sp_runtime::{
62 generic, impl_opaque_keys,
63 traits::{BlakeTwo256, Block as BlockT},
64 transaction_validity::{TransactionSource, TransactionValidity},
65 ApplyExtrinsicResult,
66};
67pub use sp_runtime::{MultiAddress, Perbill, Permill, RuntimeDebug};
68#[cfg(feature = "std")]
69use sp_version::NativeVersion;
70use sp_version::RuntimeVersion;
71use testnet_parachains_constants::rococo::{consensus::*, currency::*, fee::WeightToFee, time::*};
72use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight};
73use xcm::{prelude::*, Version as XcmVersion};
74use xcm_config::{
75 FellowshipLocation, GovernanceLocation, PriceForSiblingParachainDelivery, XcmConfig,
76 XcmOriginToTransactDispatchOrigin,
77};
78use xcm_runtime_apis::{
79 dry_run::{CallDryRunEffects, Error as XcmDryRunApiError, XcmDryRunEffects},
80 fees::Error as XcmPaymentApiError,
81};
82
83pub type Address = MultiAddress<AccountId, ()>;
85
86pub type Block = generic::Block<Header, UncheckedExtrinsic>;
88
89pub type SignedBlock = generic::SignedBlock<Block>;
91
92pub type BlockId = generic::BlockId<Block>;
94
95pub type TxExtension = cumulus_pallet_weight_reclaim::StorageWeightReclaim<
97 Runtime,
98 (
99 frame_system::AuthorizeCall<Runtime>,
100 frame_system::CheckNonZeroSender<Runtime>,
101 frame_system::CheckSpecVersion<Runtime>,
102 frame_system::CheckTxVersion<Runtime>,
103 frame_system::CheckGenesis<Runtime>,
104 frame_system::CheckEra<Runtime>,
105 frame_system::CheckNonce<Runtime>,
106 frame_system::CheckWeight<Runtime>,
107 pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
108 ),
109>;
110
111pub type UncheckedExtrinsic =
113 generic::UncheckedExtrinsic<Address, RuntimeCall, Signature, TxExtension>;
114
115pub type Migrations = (
117 pallet_collator_selection::migration::v2::MigrationToV2<Runtime>,
118 cumulus_pallet_xcmp_queue::migration::v5::MigrateV4ToV5<Runtime>,
119 pallet_session::migrations::v1::MigrateV0ToV1<
120 Runtime,
121 pallet_session::migrations::v1::InitOffenceSeverity<Runtime>,
122 >,
123 pallet_xcm::migration::MigrateToLatestXcmVersion<Runtime>,
125 cumulus_pallet_aura_ext::migration::MigrateV0ToV1<Runtime>,
126);
127
128pub type Executive = frame_executive::Executive<
130 Runtime,
131 Block,
132 frame_system::ChainContext<Runtime>,
133 Runtime,
134 AllPalletsWithSystem,
135>;
136
137impl_opaque_keys! {
138 pub struct SessionKeys {
139 pub aura: Aura,
140 }
141}
142
143#[sp_version::runtime_version]
144pub const VERSION: RuntimeVersion = RuntimeVersion {
145 spec_name: alloc::borrow::Cow::Borrowed("people-rococo"),
146 impl_name: alloc::borrow::Cow::Borrowed("people-rococo"),
147 authoring_version: 1,
148 spec_version: 1_019_004,
149 impl_version: 0,
150 apis: RUNTIME_API_VERSIONS,
151 transaction_version: 1,
152 system_version: 1,
153};
154
155#[cfg(feature = "std")]
157pub fn native_version() -> NativeVersion {
158 NativeVersion { runtime_version: VERSION, can_author_with: Default::default() }
159}
160
161parameter_types! {
162 pub const Version: RuntimeVersion = VERSION;
163 pub RuntimeBlockLength: BlockLength =
164 BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);
165 pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()
166 .base_block(BlockExecutionWeight::get())
167 .for_class(DispatchClass::all(), |weights| {
168 weights.base_extrinsic = ExtrinsicBaseWeight::get();
169 })
170 .for_class(DispatchClass::Normal, |weights| {
171 weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);
172 })
173 .for_class(DispatchClass::Operational, |weights| {
174 weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);
175 weights.reserved = Some(
178 MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT
179 );
180 })
181 .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)
182 .build_or_panic();
183 pub const SS58Prefix: u8 = 42;
184}
185
186#[derive_impl(frame_system::config_preludes::ParaChainDefaultConfig)]
187impl frame_system::Config for Runtime {
188 type BaseCallFilter = Everything;
189 type BlockWeights = RuntimeBlockWeights;
190 type BlockLength = RuntimeBlockLength;
191 type AccountId = AccountId;
192 type Nonce = Nonce;
193 type Hash = Hash;
194 type Block = Block;
195 type BlockHashCount = BlockHashCount;
196 type DbWeight = RocksDbWeight;
197 type Version = Version;
198 type AccountData = pallet_balances::AccountData<Balance>;
199 type SystemWeightInfo = weights::frame_system::WeightInfo<Runtime>;
200 type ExtensionsWeightInfo = weights::frame_system_extensions::WeightInfo<Runtime>;
201 type SS58Prefix = SS58Prefix;
202 type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;
203 type MaxConsumers = ConstU32<16>;
204 type MultiBlockMigrator = MultiBlockMigrations;
205 type SingleBlockMigrations = Migrations;
206}
207
208impl cumulus_pallet_weight_reclaim::Config for Runtime {
209 type WeightInfo = weights::cumulus_pallet_weight_reclaim::WeightInfo<Runtime>;
210}
211
212impl pallet_timestamp::Config for Runtime {
213 type Moment = u64;
215 type OnTimestampSet = Aura;
216 type MinimumPeriod = ConstU64<0>;
217 type WeightInfo = weights::pallet_timestamp::WeightInfo<Runtime>;
218}
219
220impl pallet_authorship::Config for Runtime {
221 type FindAuthor = pallet_session::FindAccountFromAuthorIndex<Self, Aura>;
222 type EventHandler = (CollatorSelection,);
223}
224
225parameter_types! {
226 pub const ExistentialDeposit: Balance = EXISTENTIAL_DEPOSIT;
227}
228
229impl pallet_balances::Config for Runtime {
230 type Balance = Balance;
231 type DustRemoval = ();
232 type RuntimeEvent = RuntimeEvent;
233 type ExistentialDeposit = ExistentialDeposit;
234 type AccountStore = System;
235 type WeightInfo = weights::pallet_balances::WeightInfo<Runtime>;
236 type MaxLocks = ConstU32<50>;
237 type MaxReserves = ConstU32<50>;
238 type ReserveIdentifier = [u8; 8];
239 type RuntimeFreezeReason = RuntimeFreezeReason;
240 type RuntimeHoldReason = RuntimeHoldReason;
241 type FreezeIdentifier = ();
242 type MaxFreezes = ConstU32<0>;
243 type DoneSlashHandler = ();
244}
245
246parameter_types! {
247 pub const TransactionByteFee: Balance = MILLICENTS;
249}
250
251impl pallet_transaction_payment::Config for Runtime {
252 type RuntimeEvent = RuntimeEvent;
253 type OnChargeTransaction =
254 pallet_transaction_payment::FungibleAdapter<Balances, DealWithFees<Runtime>>;
255 type OperationalFeeMultiplier = ConstU8<5>;
256 type WeightToFee = WeightToFee;
257 type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;
258 type FeeMultiplierUpdate = SlowAdjustingFeeUpdate<Self>;
259 type WeightInfo = weights::pallet_transaction_payment::WeightInfo<Runtime>;
260}
261
262parameter_types! {
263 pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(4);
264 pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(4);
265 pub const RelayOrigin: AggregateMessageOrigin = AggregateMessageOrigin::Parent;
266}
267
268impl cumulus_pallet_parachain_system::Config for Runtime {
269 type RuntimeEvent = RuntimeEvent;
270 type OnSystemEvent = ();
271 type SelfParaId = parachain_info::Pallet<Runtime>;
272 type OutboundXcmpMessageSource = XcmpQueue;
273 type DmpQueue = frame_support::traits::EnqueueWithOrigin<MessageQueue, RelayOrigin>;
274 type ReservedDmpWeight = ReservedDmpWeight;
275 type XcmpMessageHandler = XcmpQueue;
276 type ReservedXcmpWeight = ReservedXcmpWeight;
277 type CheckAssociatedRelayNumber = RelayNumberMonotonicallyIncreases;
278 type ConsensusHook = ConsensusHook;
279 type WeightInfo = weights::cumulus_pallet_parachain_system::WeightInfo<Runtime>;
280 type RelayParentOffset = ConstU32<0>;
281}
282
283type ConsensusHook = cumulus_pallet_aura_ext::FixedVelocityConsensusHook<
284 Runtime,
285 RELAY_CHAIN_SLOT_DURATION_MILLIS,
286 BLOCK_PROCESSING_VELOCITY,
287 UNINCLUDED_SEGMENT_CAPACITY,
288>;
289
290parameter_types! {
291 pub MessageQueueServiceWeight: Weight =
292 Perbill::from_percent(35) * RuntimeBlockWeights::get().max_block;
293}
294
295impl pallet_message_queue::Config for Runtime {
296 type RuntimeEvent = RuntimeEvent;
297 #[cfg(feature = "runtime-benchmarks")]
298 type MessageProcessor = pallet_message_queue::mock_helpers::NoopMessageProcessor<
299 cumulus_primitives_core::AggregateMessageOrigin,
300 >;
301 #[cfg(not(feature = "runtime-benchmarks"))]
302 type MessageProcessor = xcm_builder::ProcessXcmMessage<
303 AggregateMessageOrigin,
304 xcm_executor::XcmExecutor<XcmConfig>,
305 RuntimeCall,
306 >;
307 type Size = u32;
308 type QueueChangeHandler = NarrowOriginToSibling<XcmpQueue>;
310 type QueuePausedQuery = NarrowOriginToSibling<XcmpQueue>;
311 type HeapSize = sp_core::ConstU32<{ 103 * 1024 }>;
312 type MaxStale = sp_core::ConstU32<8>;
313 type ServiceWeight = MessageQueueServiceWeight;
314 type IdleMaxServiceWeight = MessageQueueServiceWeight;
315 type WeightInfo = weights::pallet_message_queue::WeightInfo<Runtime>;
316}
317
318impl parachain_info::Config for Runtime {}
319
320impl cumulus_pallet_aura_ext::Config for Runtime {}
321
322parameter_types! {
323 pub const FellowsBodyId: BodyId = BodyId::Technical;
325}
326
327pub type RootOrFellows = EitherOfDiverse<
329 EnsureRoot<AccountId>,
330 EnsureXcm<IsVoiceOfBody<FellowshipLocation, FellowsBodyId>>,
331>;
332
333impl cumulus_pallet_xcmp_queue::Config for Runtime {
334 type RuntimeEvent = RuntimeEvent;
335 type ChannelInfo = ParachainSystem;
336 type VersionWrapper = PolkadotXcm;
337 type XcmpQueue = TransformOrigin<MessageQueue, AggregateMessageOrigin, ParaId, ParaIdToSibling>;
338 type MaxInboundSuspended = ConstU32<1_000>;
339 type MaxActiveOutboundChannels = ConstU32<128>;
340 type MaxPageSize = ConstU32<{ 103 * 1024 }>;
343 type ControllerOrigin = RootOrFellows;
344 type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;
345 type PriceForSiblingDelivery = PriceForSiblingParachainDelivery;
346 type WeightInfo = weights::cumulus_pallet_xcmp_queue::WeightInfo<Runtime>;
347}
348
349impl cumulus_pallet_xcmp_queue::migration::v5::V5Config for Runtime {
350 type ChannelList = ParachainSystem;
352}
353
354pub const PERIOD: u32 = 6 * HOURS;
355pub const OFFSET: u32 = 0;
356
357impl pallet_session::Config for Runtime {
358 type RuntimeEvent = RuntimeEvent;
359 type ValidatorId = <Self as frame_system::Config>::AccountId;
360 type ValidatorIdOf = pallet_collator_selection::IdentityCollator;
362 type ShouldEndSession = pallet_session::PeriodicSessions<ConstU32<PERIOD>, ConstU32<OFFSET>>;
363 type NextSessionRotation = pallet_session::PeriodicSessions<ConstU32<PERIOD>, ConstU32<OFFSET>>;
364 type SessionManager = CollatorSelection;
365 type SessionHandler = <SessionKeys as sp_runtime::traits::OpaqueKeys>::KeyTypeIdProviders;
367 type Keys = SessionKeys;
368 type DisablingStrategy = ();
369 type WeightInfo = weights::pallet_session::WeightInfo<Runtime>;
370 type Currency = Balances;
371 type KeyDeposit = ();
372}
373
374impl pallet_aura::Config for Runtime {
375 type AuthorityId = AuraId;
376 type DisabledValidators = ();
377 type MaxAuthorities = ConstU32<100_000>;
378 type AllowMultipleBlocksPerSlot = ConstBool<true>;
379 type SlotDuration = ConstU64<SLOT_DURATION>;
380}
381
382parameter_types! {
383 pub const PotId: PalletId = PalletId(*b"PotStake");
384 pub const SessionLength: BlockNumber = 6 * HOURS;
385 pub const StakingAdminBodyId: BodyId = BodyId::Defense;
387}
388
389pub type CollatorSelectionUpdateOrigin = EitherOfDiverse<
391 EnsureRoot<AccountId>,
392 EnsureXcm<IsVoiceOfBody<GovernanceLocation, StakingAdminBodyId>>,
393>;
394
395impl pallet_collator_selection::Config for Runtime {
396 type RuntimeEvent = RuntimeEvent;
397 type Currency = Balances;
398 type UpdateOrigin = CollatorSelectionUpdateOrigin;
399 type PotId = PotId;
400 type MaxCandidates = ConstU32<100>;
401 type MinEligibleCollators = ConstU32<4>;
402 type MaxInvulnerables = ConstU32<20>;
403 type KickThreshold = ConstU32<PERIOD>;
405 type ValidatorId = <Self as frame_system::Config>::AccountId;
406 type ValidatorIdOf = pallet_collator_selection::IdentityCollator;
407 type ValidatorRegistration = Session;
408 type WeightInfo = weights::pallet_collator_selection::WeightInfo<Runtime>;
409}
410
411parameter_types! {
412 pub const DepositBase: Balance = deposit(1, 88);
414 pub const DepositFactor: Balance = deposit(0, 32);
416}
417
418impl pallet_multisig::Config for Runtime {
419 type RuntimeEvent = RuntimeEvent;
420 type RuntimeCall = RuntimeCall;
421 type Currency = Balances;
422 type DepositBase = DepositBase;
423 type DepositFactor = DepositFactor;
424 type MaxSignatories = ConstU32<100>;
425 type WeightInfo = weights::pallet_multisig::WeightInfo<Runtime>;
426 type BlockNumberProvider = frame_system::Pallet<Runtime>;
427}
428
429#[derive(
431 Copy,
432 Clone,
433 Eq,
434 PartialEq,
435 Ord,
436 PartialOrd,
437 Encode,
438 Decode,
439 DecodeWithMemTracking,
440 RuntimeDebug,
441 MaxEncodedLen,
442 scale_info::TypeInfo,
443)]
444pub enum ProxyType {
445 Any,
447 NonTransfer,
449 CancelProxy,
451 Identity,
453 IdentityJudgement,
455 Collator,
457}
458impl Default for ProxyType {
459 fn default() -> Self {
460 Self::Any
461 }
462}
463
464impl InstanceFilter<RuntimeCall> for ProxyType {
465 fn filter(&self, c: &RuntimeCall) -> bool {
466 match self {
467 ProxyType::Any => true,
468 ProxyType::NonTransfer => !matches!(
469 c,
470 RuntimeCall::Balances { .. } |
471 RuntimeCall::Identity(pallet_identity::Call::request_judgement { .. })
473 ),
474 ProxyType::CancelProxy => matches!(
475 c,
476 RuntimeCall::Proxy(pallet_proxy::Call::reject_announcement { .. }) |
477 RuntimeCall::Utility { .. } |
478 RuntimeCall::Multisig { .. }
479 ),
480 ProxyType::Identity => {
481 matches!(
482 c,
483 RuntimeCall::Identity { .. } |
484 RuntimeCall::Utility { .. } |
485 RuntimeCall::Multisig { .. }
486 )
487 },
488 ProxyType::IdentityJudgement => matches!(
489 c,
490 RuntimeCall::Identity(pallet_identity::Call::provide_judgement { .. }) |
491 RuntimeCall::Utility(..) |
492 RuntimeCall::Multisig { .. }
493 ),
494 ProxyType::Collator => matches!(
495 c,
496 RuntimeCall::CollatorSelection { .. } |
497 RuntimeCall::Utility { .. } |
498 RuntimeCall::Multisig { .. }
499 ),
500 }
501 }
502
503 fn is_superset(&self, o: &Self) -> bool {
504 match (self, o) {
505 (x, y) if x == y => true,
506 (ProxyType::Any, _) => true,
507 (_, ProxyType::Any) => false,
508 (ProxyType::Identity, ProxyType::IdentityJudgement) => true,
509 (ProxyType::NonTransfer, ProxyType::IdentityJudgement) => true,
510 (ProxyType::NonTransfer, ProxyType::Collator) => true,
511 _ => false,
512 }
513 }
514}
515
516parameter_types! {
517 pub const ProxyDepositBase: Balance = deposit(1, 40);
519 pub const ProxyDepositFactor: Balance = deposit(0, 33);
521 pub const MaxProxies: u16 = 32;
522 pub const AnnouncementDepositBase: Balance = deposit(1, 48);
524 pub const AnnouncementDepositFactor: Balance = deposit(0, 66);
525 pub const MaxPending: u16 = 32;
526}
527
528impl pallet_proxy::Config for Runtime {
529 type RuntimeEvent = RuntimeEvent;
530 type RuntimeCall = RuntimeCall;
531 type Currency = Balances;
532 type ProxyType = ProxyType;
533 type ProxyDepositBase = ProxyDepositBase;
534 type ProxyDepositFactor = ProxyDepositFactor;
535 type MaxProxies = MaxProxies;
536 type WeightInfo = weights::pallet_proxy::WeightInfo<Runtime>;
537 type MaxPending = MaxPending;
538 type CallHasher = BlakeTwo256;
539 type AnnouncementDepositBase = AnnouncementDepositBase;
540 type AnnouncementDepositFactor = AnnouncementDepositFactor;
541 type BlockNumberProvider = frame_system::Pallet<Runtime>;
542}
543
544impl pallet_utility::Config for Runtime {
545 type RuntimeEvent = RuntimeEvent;
546 type RuntimeCall = RuntimeCall;
547 type PalletsOrigin = OriginCaller;
548 type WeightInfo = weights::pallet_utility::WeightInfo<Runtime>;
549}
550
551impl identity_migrator::Config for Runtime {
553 type RuntimeEvent = RuntimeEvent;
554 type Reaper = EnsureRoot<AccountId>;
555 type ReapIdentityHandler = ();
556 type WeightInfo = weights::polkadot_runtime_common_identity_migrator::WeightInfo<Runtime>;
557}
558
559parameter_types! {
560 pub MbmServiceWeight: Weight = Perbill::from_percent(80) * RuntimeBlockWeights::get().max_block;
561}
562
563impl pallet_migrations::Config for Runtime {
564 type RuntimeEvent = RuntimeEvent;
565 #[cfg(not(feature = "runtime-benchmarks"))]
566 type Migrations = pallet_identity::migration::v2::LazyMigrationV1ToV2<Runtime>;
567 #[cfg(feature = "runtime-benchmarks")]
569 type Migrations = pallet_migrations::mock_helpers::MockedMigrations;
570 type CursorMaxLen = ConstU32<65_536>;
571 type IdentifierMaxLen = ConstU32<256>;
572 type MigrationStatusHandler = ();
573 type FailedMigrationHandler = frame_support::migrations::FreezeChainOnFailedMigration;
574 type MaxServiceWeight = MbmServiceWeight;
575 type WeightInfo = weights::pallet_migrations::WeightInfo<Runtime>;
576}
577
578construct_runtime!(
580 pub enum Runtime
581 {
582 System: frame_system = 0,
584 ParachainSystem: cumulus_pallet_parachain_system = 1,
585 Timestamp: pallet_timestamp = 2,
586 ParachainInfo: parachain_info = 3,
587 WeightReclaim: cumulus_pallet_weight_reclaim = 4,
588
589 Balances: pallet_balances = 10,
591 TransactionPayment: pallet_transaction_payment = 11,
592
593 Authorship: pallet_authorship = 20,
595 CollatorSelection: pallet_collator_selection = 21,
596 Session: pallet_session = 22,
597 Aura: pallet_aura = 23,
598 AuraExt: cumulus_pallet_aura_ext = 24,
599
600 XcmpQueue: cumulus_pallet_xcmp_queue = 30,
602 PolkadotXcm: pallet_xcm = 31,
603 CumulusXcm: cumulus_pallet_xcm = 32,
604 MessageQueue: pallet_message_queue = 34,
605
606 Utility: pallet_utility = 40,
608 Multisig: pallet_multisig = 41,
609 Proxy: pallet_proxy = 42,
610
611 Identity: pallet_identity = 50,
613
614 MultiBlockMigrations: pallet_migrations = 98,
616
617 IdentityMigrator: identity_migrator = 248,
619 }
620);
621
622#[cfg(feature = "runtime-benchmarks")]
623mod benches {
624 frame_benchmarking::define_benchmarks!(
625 [frame_system, SystemBench::<Runtime>]
627 [pallet_balances, Balances]
628 [pallet_identity, Identity]
629 [pallet_message_queue, MessageQueue]
630 [pallet_multisig, Multisig]
631 [pallet_proxy, Proxy]
632 [pallet_session, SessionBench::<Runtime>]
633 [pallet_utility, Utility]
634 [pallet_timestamp, Timestamp]
635 [pallet_migrations, MultiBlockMigrations]
636 [pallet_transaction_payment, TransactionPayment]
637 [polkadot_runtime_common::identity_migrator, IdentityMigrator]
639 [cumulus_pallet_parachain_system, ParachainSystem]
641 [cumulus_pallet_xcmp_queue, XcmpQueue]
642 [pallet_collator_selection, CollatorSelection]
643 [pallet_xcm, PalletXcmExtrinsicsBenchmark::<Runtime>]
645 [pallet_xcm_benchmarks::fungible, XcmBalances]
646 [pallet_xcm_benchmarks::generic, XcmGeneric]
647 [cumulus_pallet_weight_reclaim, WeightReclaim]
648 );
649}
650
651impl_runtime_apis! {
652 impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {
653 fn slot_duration() -> sp_consensus_aura::SlotDuration {
654 sp_consensus_aura::SlotDuration::from_millis(SLOT_DURATION)
655 }
656
657 fn authorities() -> Vec<AuraId> {
658 pallet_aura::Authorities::<Runtime>::get().into_inner()
659 }
660 }
661
662 impl cumulus_primitives_core::RelayParentOffsetApi<Block> for Runtime {
663 fn relay_parent_offset() -> u32 {
664 0
665 }
666 }
667
668 impl cumulus_primitives_aura::AuraUnincludedSegmentApi<Block> for Runtime {
669 fn can_build_upon(
670 included_hash: <Block as BlockT>::Hash,
671 slot: cumulus_primitives_aura::Slot,
672 ) -> bool {
673 ConsensusHook::can_build_upon(included_hash, slot)
674 }
675 }
676
677 impl sp_api::Core<Block> for Runtime {
678 fn version() -> RuntimeVersion {
679 VERSION
680 }
681
682 fn execute_block(block: Block) {
683 Executive::execute_block(block)
684 }
685
686 fn initialize_block(header: &<Block as BlockT>::Header) -> sp_runtime::ExtrinsicInclusionMode {
687 Executive::initialize_block(header)
688 }
689 }
690
691 impl sp_api::Metadata<Block> for Runtime {
692 fn metadata() -> OpaqueMetadata {
693 OpaqueMetadata::new(Runtime::metadata().into())
694 }
695
696 fn metadata_at_version(version: u32) -> Option<OpaqueMetadata> {
697 Runtime::metadata_at_version(version)
698 }
699
700 fn metadata_versions() -> alloc::vec::Vec<u32> {
701 Runtime::metadata_versions()
702 }
703 }
704
705 impl sp_block_builder::BlockBuilder<Block> for Runtime {
706 fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {
707 Executive::apply_extrinsic(extrinsic)
708 }
709
710 fn finalize_block() -> <Block as BlockT>::Header {
711 Executive::finalize_block()
712 }
713
714 fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {
715 data.create_extrinsics()
716 }
717
718 fn check_inherents(
719 block: Block,
720 data: sp_inherents::InherentData,
721 ) -> sp_inherents::CheckInherentsResult {
722 data.check_extrinsics(&block)
723 }
724 }
725
726 impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {
727 fn validate_transaction(
728 source: TransactionSource,
729 tx: <Block as BlockT>::Extrinsic,
730 block_hash: <Block as BlockT>::Hash,
731 ) -> TransactionValidity {
732 Executive::validate_transaction(source, tx, block_hash)
733 }
734 }
735
736 impl sp_offchain::OffchainWorkerApi<Block> for Runtime {
737 fn offchain_worker(header: &<Block as BlockT>::Header) {
738 Executive::offchain_worker(header)
739 }
740 }
741
742 impl sp_session::SessionKeys<Block> for Runtime {
743 fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {
744 SessionKeys::generate(seed)
745 }
746
747 fn decode_session_keys(
748 encoded: Vec<u8>,
749 ) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {
750 SessionKeys::decode_into_raw_public_keys(&encoded)
751 }
752 }
753
754 impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce> for Runtime {
755 fn account_nonce(account: AccountId) -> Nonce {
756 System::account_nonce(account)
757 }
758 }
759
760 impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {
761 fn query_info(
762 uxt: <Block as BlockT>::Extrinsic,
763 len: u32,
764 ) -> pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo<Balance> {
765 TransactionPayment::query_info(uxt, len)
766 }
767 fn query_fee_details(
768 uxt: <Block as BlockT>::Extrinsic,
769 len: u32,
770 ) -> pallet_transaction_payment::FeeDetails<Balance> {
771 TransactionPayment::query_fee_details(uxt, len)
772 }
773 fn query_weight_to_fee(weight: Weight) -> Balance {
774 TransactionPayment::weight_to_fee(weight)
775 }
776 fn query_length_to_fee(length: u32) -> Balance {
777 TransactionPayment::length_to_fee(length)
778 }
779 }
780
781 impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentCallApi<Block, Balance, RuntimeCall>
782 for Runtime
783 {
784 fn query_call_info(
785 call: RuntimeCall,
786 len: u32,
787 ) -> pallet_transaction_payment::RuntimeDispatchInfo<Balance> {
788 TransactionPayment::query_call_info(call, len)
789 }
790 fn query_call_fee_details(
791 call: RuntimeCall,
792 len: u32,
793 ) -> pallet_transaction_payment::FeeDetails<Balance> {
794 TransactionPayment::query_call_fee_details(call, len)
795 }
796 fn query_weight_to_fee(weight: Weight) -> Balance {
797 TransactionPayment::weight_to_fee(weight)
798 }
799 fn query_length_to_fee(length: u32) -> Balance {
800 TransactionPayment::length_to_fee(length)
801 }
802 }
803
804 impl xcm_runtime_apis::fees::XcmPaymentApi<Block> for Runtime {
805 fn query_acceptable_payment_assets(xcm_version: xcm::Version) -> Result<Vec<VersionedAssetId>, XcmPaymentApiError> {
806 let acceptable_assets = vec![AssetId(xcm_config::RelayLocation::get())];
807 PolkadotXcm::query_acceptable_payment_assets(xcm_version, acceptable_assets)
808 }
809
810 fn query_weight_to_asset_fee(weight: Weight, asset: VersionedAssetId) -> Result<u128, XcmPaymentApiError> {
811 use crate::xcm_config::XcmConfig;
812
813 type Trader = <XcmConfig as xcm_executor::Config>::Trader;
814
815 PolkadotXcm::query_weight_to_asset_fee::<Trader>(weight, asset)
816 }
817
818 fn query_xcm_weight(message: VersionedXcm<()>) -> Result<Weight, XcmPaymentApiError> {
819 PolkadotXcm::query_xcm_weight(message)
820 }
821
822 fn query_delivery_fees(destination: VersionedLocation, message: VersionedXcm<()>) -> Result<VersionedAssets, XcmPaymentApiError> {
823 PolkadotXcm::query_delivery_fees(destination, message)
824 }
825 }
826
827 impl xcm_runtime_apis::dry_run::DryRunApi<Block, RuntimeCall, RuntimeEvent, OriginCaller> for Runtime {
828 fn dry_run_call(origin: OriginCaller, call: RuntimeCall, result_xcms_version: XcmVersion) -> Result<CallDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
829 PolkadotXcm::dry_run_call::<Runtime, xcm_config::XcmRouter, OriginCaller, RuntimeCall>(origin, call, result_xcms_version)
830 }
831
832 fn dry_run_xcm(origin_location: VersionedLocation, xcm: VersionedXcm<RuntimeCall>) -> Result<XcmDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
833 PolkadotXcm::dry_run_xcm::<Runtime, xcm_config::XcmRouter, RuntimeCall, xcm_config::XcmConfig>(origin_location, xcm)
834 }
835 }
836
837 impl xcm_runtime_apis::conversions::LocationToAccountApi<Block, AccountId> for Runtime {
838 fn convert_location(location: VersionedLocation) -> Result<
839 AccountId,
840 xcm_runtime_apis::conversions::Error
841 > {
842 xcm_runtime_apis::conversions::LocationToAccountHelper::<
843 AccountId,
844 xcm_config::LocationToAccountId,
845 >::convert_location(location)
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 #[cfg(feature = "try-runtime")]
856 impl frame_try_runtime::TryRuntime<Block> for Runtime {
857 fn on_runtime_upgrade(checks: frame_try_runtime::UpgradeCheckSelect) -> (Weight, Weight) {
858 let weight = Executive::try_runtime_upgrade(checks).unwrap();
859 (weight, RuntimeBlockWeights::get().max_block)
860 }
861
862 fn execute_block(
863 block: Block,
864 state_root_check: bool,
865 signature_check: bool,
866 select: frame_try_runtime::TryStateSelect,
867 ) -> Weight {
868 Executive::try_execute_block(block, state_root_check, signature_check, select).unwrap()
871 }
872 }
873
874 #[cfg(feature = "runtime-benchmarks")]
875 impl frame_benchmarking::Benchmark<Block> for Runtime {
876 fn benchmark_metadata(extra: bool) -> (
877 Vec<frame_benchmarking::BenchmarkList>,
878 Vec<frame_support::traits::StorageInfo>,
879 ) {
880 use frame_benchmarking::BenchmarkList;
881 use frame_support::traits::StorageInfoTrait;
882 use frame_system_benchmarking::Pallet as SystemBench;
883 use cumulus_pallet_session_benchmarking::Pallet as SessionBench;
884 use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsicsBenchmark;
885
886 type XcmBalances = pallet_xcm_benchmarks::fungible::Pallet::<Runtime>;
890 type XcmGeneric = pallet_xcm_benchmarks::generic::Pallet::<Runtime>;
891
892 let mut list = Vec::<BenchmarkList>::new();
893 list_benchmarks!(list, extra);
894
895 let storage_info = AllPalletsWithSystem::storage_info();
896 (list, storage_info)
897 }
898
899 #[allow(non_local_definitions)]
900 fn dispatch_benchmark(
901 config: frame_benchmarking::BenchmarkConfig
902 ) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, alloc::string::String> {
903 use frame_benchmarking::{BenchmarkBatch, BenchmarkError};
904 use sp_storage::TrackedStorageKey;
905
906 use frame_system_benchmarking::Pallet as SystemBench;
907 impl frame_system_benchmarking::Config for Runtime {
908 fn setup_set_code_requirements(code: &alloc::vec::Vec<u8>) -> Result<(), BenchmarkError> {
909 ParachainSystem::initialize_for_set_code_benchmark(code.len() as u32);
910 Ok(())
911 }
912
913 fn verify_set_code() {
914 System::assert_last_event(cumulus_pallet_parachain_system::Event::<Runtime>::ValidationFunctionStored.into());
915 }
916 }
917
918 use cumulus_pallet_session_benchmarking::Pallet as SessionBench;
919 impl cumulus_pallet_session_benchmarking::Config for Runtime {}
920 use testnet_parachains_constants::rococo::locations::{AssetHubParaId, AssetHubLocation};
921
922 use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsicsBenchmark;
923 impl pallet_xcm::benchmarking::Config for Runtime {
924 type DeliveryHelper = polkadot_runtime_common::xcm_sender::ToParachainDeliveryHelper<
925 xcm_config::XcmConfig,
926 ExistentialDepositAsset,
927 PriceForSiblingParachainDelivery,
928 AssetHubParaId,
929 ParachainSystem
930 >;
931
932 fn reachable_dest() -> Option<Location> {
933 Some(AssetHubLocation::get())
934 }
935
936 fn teleportable_asset_and_dest() -> Option<(Asset, Location)> {
937 Some((
939 Asset {
940 fun: Fungible(ExistentialDeposit::get()),
941 id: AssetId(RelayLocation::get())
942 },
943 AssetHubLocation::get(),
944 ))
945 }
946
947 fn reserve_transferable_asset_and_dest() -> Option<(Asset, Location)> {
948 None
949 }
950
951 fn set_up_complex_asset_transfer() -> Option<(Assets, u32, Location, alloc::boxed::Box<dyn FnOnce()>)> {
952 let native_location = Parent.into();
953 let dest = AssetHubLocation::get();
954
955 pallet_xcm::benchmarking::helpers::native_teleport_as_asset_transfer::<Runtime>(
956 native_location,
957 dest,
958 )
959 }
960
961 fn get_asset() -> Asset {
962 Asset {
963 id: AssetId(RelayLocation::get()),
964 fun: Fungible(ExistentialDeposit::get()),
965 }
966 }
967 }
968
969 use xcm::latest::prelude::*;
970 use xcm_config::RelayLocation;
971
972 parameter_types! {
973 pub ExistentialDepositAsset: Option<Asset> = Some((
974 RelayLocation::get(),
975 ExistentialDeposit::get()
976 ).into());
977 }
978
979 impl pallet_xcm_benchmarks::Config for Runtime {
980 type XcmConfig = XcmConfig;
981 type AccountIdConverter = xcm_config::LocationToAccountId;
982 type DeliveryHelper = polkadot_runtime_common::xcm_sender::ToParachainDeliveryHelper<
983 xcm_config::XcmConfig,
984 ExistentialDepositAsset,
985 PriceForSiblingParachainDelivery,
986 AssetHubParaId,
987 ParachainSystem,
988 >;
989 fn valid_destination() -> Result<Location, BenchmarkError> {
990 Ok(AssetHubLocation::get())
991 }
992 fn worst_case_holding(_depositable_count: u32) -> Assets {
993 let assets: Vec<Asset> = vec![
995 Asset {
996 id: AssetId(RelayLocation::get()),
997 fun: Fungible(1_000_000 * UNITS),
998 }
999 ];
1000 assets.into()
1001 }
1002 }
1003
1004 parameter_types! {
1005 pub TrustedTeleporter: Option<(Location, Asset)> = Some((
1006 AssetHubLocation::get(),
1007 Asset { fun: Fungible(UNITS), id: AssetId(RelayLocation::get()) },
1008 ));
1009 pub const CheckedAccount: Option<(AccountId, xcm_builder::MintLocation)> = None;
1010 pub const TrustedReserve: Option<(Location, Asset)> = None;
1011 }
1012
1013 impl pallet_xcm_benchmarks::fungible::Config for Runtime {
1014 type TransactAsset = Balances;
1015
1016 type CheckedAccount = CheckedAccount;
1017 type TrustedTeleporter = TrustedTeleporter;
1018 type TrustedReserve = TrustedReserve;
1019
1020 fn get_asset() -> Asset {
1021 Asset {
1022 id: AssetId(RelayLocation::get()),
1023 fun: Fungible(UNITS),
1024 }
1025 }
1026 }
1027
1028 impl pallet_xcm_benchmarks::generic::Config for Runtime {
1029 type RuntimeCall = RuntimeCall;
1030 type TransactAsset = Balances;
1031
1032 fn worst_case_response() -> (u64, Response) {
1033 (0u64, Response::Version(Default::default()))
1034 }
1035
1036 fn worst_case_asset_exchange() -> Result<(Assets, Assets), BenchmarkError> {
1037 Err(BenchmarkError::Skip)
1038 }
1039
1040 fn universal_alias() -> Result<(Location, Junction), BenchmarkError> {
1041 Err(BenchmarkError::Skip)
1042 }
1043
1044 fn transact_origin_and_runtime_call() -> Result<(Location, RuntimeCall), BenchmarkError> {
1045 Ok((AssetHubLocation::get(), frame_system::Call::remark_with_event { remark: vec![] }.into()))
1046 }
1047
1048 fn subscribe_origin() -> Result<Location, BenchmarkError> {
1049 Ok(AssetHubLocation::get())
1050 }
1051
1052 fn claimable_asset() -> Result<(Location, Location, Assets), BenchmarkError> {
1053 let origin = AssetHubLocation::get();
1054 let assets: Assets = (AssetId(RelayLocation::get()), 1_000 * UNITS).into();
1055 let ticket = Location::new(0, []);
1056 Ok((origin, ticket, assets))
1057 }
1058
1059 fn worst_case_for_trader() -> Result<(Asset, WeightLimit), BenchmarkError> {
1060 Ok((Asset {
1061 id: AssetId(RelayLocation::get()),
1062 fun: Fungible(1_000_000 * UNITS),
1063 }, WeightLimit::Limited(Weight::from_parts(5000, 5000))))
1064 }
1065
1066 fn unlockable_asset() -> Result<(Location, Location, Asset), BenchmarkError> {
1067 Err(BenchmarkError::Skip)
1068 }
1069
1070 fn export_message_origin_and_destination(
1071 ) -> Result<(Location, NetworkId, InteriorLocation), BenchmarkError> {
1072 Err(BenchmarkError::Skip)
1073 }
1074
1075 fn alias_origin() -> Result<(Location, Location), BenchmarkError> {
1076 Err(BenchmarkError::Skip)
1077 }
1078 }
1079
1080 type XcmBalances = pallet_xcm_benchmarks::fungible::Pallet::<Runtime>;
1081 type XcmGeneric = pallet_xcm_benchmarks::generic::Pallet::<Runtime>;
1082
1083 use frame_support::traits::WhitelistedStorageKeys;
1084 let whitelist: Vec<TrackedStorageKey> = AllPalletsWithSystem::whitelisted_storage_keys();
1085
1086 let mut batches = Vec::<BenchmarkBatch>::new();
1087 let params = (&config, &whitelist);
1088 add_benchmarks!(params, batches);
1089
1090 Ok(batches)
1091 }
1092 }
1093
1094 impl sp_genesis_builder::GenesisBuilder<Block> for Runtime {
1095 fn build_state(config: Vec<u8>) -> sp_genesis_builder::Result {
1096 build_state::<RuntimeGenesisConfig>(config)
1097 }
1098
1099 fn get_preset(id: &Option<sp_genesis_builder::PresetId>) -> Option<Vec<u8>> {
1100 get_preset::<RuntimeGenesisConfig>(id, &genesis_config_presets::get_preset)
1101 }
1102
1103 fn preset_names() -> Vec<sp_genesis_builder::PresetId> {
1104 genesis_config_presets::preset_names()
1105 }
1106 }
1107
1108 impl xcm_runtime_apis::trusted_query::TrustedQueryApi<Block> for Runtime {
1109 fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult {
1110 PolkadotXcm::is_trusted_reserve(asset, location)
1111 }
1112 fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult {
1113 PolkadotXcm::is_trusted_teleporter(asset, location)
1114 }
1115 }
1116
1117 impl cumulus_primitives_core::GetParachainInfo<Block> for Runtime {
1118 fn parachain_id() -> ParaId {
1119 ParachainInfo::parachain_id()
1120 }
1121 }
1122}
1123
1124cumulus_pallet_parachain_system::register_validate_block! {
1125 Runtime = Runtime,
1126 BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,
1127}