Skip to main content

coretime_westend_runtime/
lib.rs

1// Copyright (C) Parity Technologies (UK) Ltd.
2// SPDX-License-Identifier: Apache-2.0
3
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// 	http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15
16#![cfg_attr(not(feature = "std"), no_std)]
17// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256.
18#![recursion_limit = "256"]
19
20// Make the WASM binary available.
21#[cfg(feature = "std")]
22include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
23
24/// Provides the `WASM_BINARY` build with `fast-runtime` feature enabled.
25///
26/// This is for example useful for local test chains.
27#[cfg(feature = "std")]
28pub mod fast_runtime_binary {
29	include!(concat!(env!("OUT_DIR"), "/fast_runtime_binary.rs"));
30}
31
32mod coretime;
33mod genesis_config_presets;
34mod weights;
35pub mod xcm_config;
36
37extern crate alloc;
38
39use alloc::{vec, vec::Vec};
40use codec::{Decode, DecodeWithMemTracking, Encode, MaxEncodedLen};
41use cumulus_pallet_parachain_system::RelayNumberMonotonicallyIncreases;
42use cumulus_primitives_core::{AggregateMessageOrigin, ClaimQueueOffset, CoreSelector, ParaId};
43use frame_support::{
44	construct_runtime, derive_impl,
45	dispatch::DispatchClass,
46	genesis_builder_helper::{build_state, get_preset},
47	parameter_types,
48	traits::{
49		ConstBool, ConstU32, ConstU64, ConstU8, EitherOfDiverse, InstanceFilter, TransformOrigin,
50	},
51	weights::{ConstantMultiplier, Weight},
52	PalletId,
53};
54use frame_system::{
55	limits::{BlockLength, BlockWeights},
56	EnsureRoot,
57};
58use pallet_xcm::{EnsureXcm, IsVoiceOfBody};
59use parachains_common::{
60	impls::DealWithFees,
61	message_queue::{NarrowOriginToSibling, ParaIdToSibling},
62	AccountId, AuraId, Balance, BlockNumber, Hash, Header, Nonce, Signature,
63	AVERAGE_ON_INITIALIZE_RATIO, NORMAL_DISPATCH_RATIO,
64};
65use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate};
66use sp_api::impl_runtime_apis;
67use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
68#[cfg(any(feature = "std", test))]
69pub use sp_runtime::BuildStorage;
70use sp_runtime::{
71	generic, impl_opaque_keys,
72	traits::{BlakeTwo256, Block as BlockT, BlockNumberProvider},
73	transaction_validity::{TransactionSource, TransactionValidity},
74	ApplyExtrinsicResult, DispatchError, MultiAddress, Perbill, RuntimeDebug,
75};
76#[cfg(feature = "std")]
77use sp_version::NativeVersion;
78use sp_version::RuntimeVersion;
79use testnet_parachains_constants::westend::{consensus::*, currency::*, fee::WeightToFee, time::*};
80use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight};
81use xcm::{prelude::*, Version as XcmVersion};
82use xcm_config::{
83	FellowshipLocation, GovernanceLocation, TokenRelayLocation, XcmOriginToTransactDispatchOrigin,
84};
85use xcm_runtime_apis::{
86	dry_run::{CallDryRunEffects, Error as XcmDryRunApiError, XcmDryRunEffects},
87	fees::Error as XcmPaymentApiError,
88};
89
90/// The address format for describing accounts.
91pub type Address = MultiAddress<AccountId, ()>;
92
93/// Block type as expected by this runtime.
94pub type Block = generic::Block<Header, UncheckedExtrinsic>;
95
96/// A Block signed with a Justification
97pub type SignedBlock = generic::SignedBlock<Block>;
98
99/// BlockId type as expected by this runtime.
100pub type BlockId = generic::BlockId<Block>;
101
102/// The TransactionExtension to the basic transaction logic.
103pub type TxExtension = cumulus_pallet_weight_reclaim::StorageWeightReclaim<
104	Runtime,
105	(
106		frame_system::AuthorizeCall<Runtime>,
107		frame_system::CheckNonZeroSender<Runtime>,
108		frame_system::CheckSpecVersion<Runtime>,
109		frame_system::CheckTxVersion<Runtime>,
110		frame_system::CheckGenesis<Runtime>,
111		frame_system::CheckEra<Runtime>,
112		frame_system::CheckNonce<Runtime>,
113		frame_system::CheckWeight<Runtime>,
114		pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
115		frame_metadata_hash_extension::CheckMetadataHash<Runtime>,
116	),
117>;
118
119/// Unchecked extrinsic type as expected by this runtime.
120pub type UncheckedExtrinsic =
121	generic::UncheckedExtrinsic<Address, RuntimeCall, Signature, TxExtension>;
122
123/// Migrations to apply on runtime upgrade.
124pub type Migrations = (
125	pallet_collator_selection::migration::v2::MigrationToV2<Runtime>,
126	cumulus_pallet_xcmp_queue::migration::v4::MigrationToV4<Runtime>,
127	cumulus_pallet_xcmp_queue::migration::v5::MigrateV4ToV5<Runtime>,
128	pallet_broker::migration::MigrateV0ToV1<Runtime>,
129	pallet_broker::migration::MigrateV1ToV2<Runtime>,
130	pallet_broker::migration::MigrateV2ToV3<Runtime>,
131	pallet_broker::migration::MigrateV3ToV4<Runtime, BrokerMigrationV4BlockConversion>,
132	pallet_session::migrations::v1::MigrateV0ToV1<
133		Runtime,
134		pallet_session::migrations::v1::InitOffenceSeverity<Runtime>,
135	>,
136	// permanent
137	pallet_xcm::migration::MigrateToLatestXcmVersion<Runtime>,
138	cumulus_pallet_aura_ext::migration::MigrateV0ToV1<Runtime>,
139);
140
141/// Executive: handles dispatch to the various modules.
142pub type Executive = frame_executive::Executive<
143	Runtime,
144	Block,
145	frame_system::ChainContext<Runtime>,
146	Runtime,
147	AllPalletsWithSystem,
148	Migrations,
149>;
150
151impl_opaque_keys! {
152	pub struct SessionKeys {
153		pub aura: Aura,
154	}
155}
156
157#[sp_version::runtime_version]
158pub const VERSION: RuntimeVersion = RuntimeVersion {
159	spec_name: alloc::borrow::Cow::Borrowed("coretime-westend"),
160	impl_name: alloc::borrow::Cow::Borrowed("coretime-westend"),
161	authoring_version: 1,
162	spec_version: 1_018_001,
163	impl_version: 0,
164	apis: RUNTIME_API_VERSIONS,
165	transaction_version: 2,
166	system_version: 1,
167};
168
169/// The version information used to identify this runtime when compiled natively.
170#[cfg(feature = "std")]
171pub fn native_version() -> NativeVersion {
172	NativeVersion { runtime_version: VERSION, can_author_with: Default::default() }
173}
174
175parameter_types! {
176	pub const Version: RuntimeVersion = VERSION;
177	pub RuntimeBlockLength: BlockLength =
178		BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);
179	pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()
180		.base_block(BlockExecutionWeight::get())
181		.for_class(DispatchClass::all(), |weights| {
182			weights.base_extrinsic = ExtrinsicBaseWeight::get();
183		})
184		.for_class(DispatchClass::Normal, |weights| {
185			weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);
186		})
187		.for_class(DispatchClass::Operational, |weights| {
188			weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);
189			// Operational transactions have some extra reserved space, so that they
190			// are included even if block reached `MAXIMUM_BLOCK_WEIGHT`.
191			weights.reserved = Some(
192				MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT
193			);
194		})
195		.avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)
196		.build_or_panic();
197	pub const SS58Prefix: u8 = 42;
198}
199
200// Configure FRAME pallets to include in runtime.
201#[derive_impl(frame_system::config_preludes::ParaChainDefaultConfig)]
202impl frame_system::Config for Runtime {
203	/// The identifier used to distinguish between accounts.
204	type AccountId = AccountId;
205	/// The nonce type for storing how many extrinsics an account has signed.
206	type Nonce = Nonce;
207	/// The type for hashing blocks and tries.
208	type Hash = Hash;
209	/// The block type.
210	type Block = Block;
211	/// Maximum number of block number to block hash mappings to keep (oldest pruned first).
212	type BlockHashCount = BlockHashCount;
213	/// Runtime version.
214	type Version = Version;
215	/// The data to be stored in an account.
216	type AccountData = pallet_balances::AccountData<Balance>;
217	/// The weight of database operations that the runtime can invoke.
218	type DbWeight = RocksDbWeight;
219	/// Weight information for the extrinsics of this pallet.
220	type SystemWeightInfo = weights::frame_system::WeightInfo<Runtime>;
221	/// Weight information for the extensions of this pallet.
222	type ExtensionsWeightInfo = weights::frame_system_extensions::WeightInfo<Runtime>;
223	/// Block & extrinsics weights: base values and limits.
224	type BlockWeights = RuntimeBlockWeights;
225	/// The maximum length of a block (in bytes).
226	type BlockLength = RuntimeBlockLength;
227	type SS58Prefix = SS58Prefix;
228	/// The action to take on a Runtime Upgrade
229	type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;
230	type MaxConsumers = ConstU32<16>;
231}
232
233impl cumulus_pallet_weight_reclaim::Config for Runtime {
234	type WeightInfo = weights::cumulus_pallet_weight_reclaim::WeightInfo<Runtime>;
235}
236
237impl pallet_timestamp::Config for Runtime {
238	/// A timestamp: milliseconds since the unix epoch.
239	type Moment = u64;
240	type OnTimestampSet = Aura;
241	type MinimumPeriod = ConstU64<0>;
242	type WeightInfo = weights::pallet_timestamp::WeightInfo<Runtime>;
243}
244
245impl pallet_authorship::Config for Runtime {
246	type FindAuthor = pallet_session::FindAccountFromAuthorIndex<Self, Aura>;
247	type EventHandler = (CollatorSelection,);
248}
249
250parameter_types! {
251	pub const ExistentialDeposit: Balance = EXISTENTIAL_DEPOSIT;
252	pub const RandomParaId: ParaId = ParaId::new(43211234);
253}
254
255impl pallet_balances::Config for Runtime {
256	type Balance = Balance;
257	type DustRemoval = ();
258	type RuntimeEvent = RuntimeEvent;
259	type ExistentialDeposit = ExistentialDeposit;
260	type AccountStore = System;
261	type WeightInfo = weights::pallet_balances::WeightInfo<Runtime>;
262	type MaxLocks = ConstU32<50>;
263	type MaxReserves = ConstU32<50>;
264	type ReserveIdentifier = [u8; 8];
265	type RuntimeHoldReason = RuntimeHoldReason;
266	type RuntimeFreezeReason = RuntimeFreezeReason;
267	type FreezeIdentifier = ();
268	type MaxFreezes = ConstU32<0>;
269	type DoneSlashHandler = ();
270}
271
272parameter_types! {
273	/// Relay Chain `TransactionByteFee` / 10
274	pub const TransactionByteFee: Balance = MILLICENTS;
275}
276
277impl pallet_transaction_payment::Config for Runtime {
278	type RuntimeEvent = RuntimeEvent;
279	type OnChargeTransaction =
280		pallet_transaction_payment::FungibleAdapter<Balances, DealWithFees<Runtime>>;
281	type OperationalFeeMultiplier = ConstU8<5>;
282	type WeightToFee = WeightToFee;
283	type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;
284	type FeeMultiplierUpdate = SlowAdjustingFeeUpdate<Self>;
285	type WeightInfo = weights::pallet_transaction_payment::WeightInfo<Runtime>;
286}
287
288parameter_types! {
289	pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(4);
290	pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(4);
291	pub const RelayOrigin: AggregateMessageOrigin = AggregateMessageOrigin::Parent;
292}
293
294impl cumulus_pallet_parachain_system::Config for Runtime {
295	type WeightInfo = weights::cumulus_pallet_parachain_system::WeightInfo<Runtime>;
296	type RuntimeEvent = RuntimeEvent;
297	type OnSystemEvent = ();
298	type SelfParaId = parachain_info::Pallet<Runtime>;
299	type DmpQueue = frame_support::traits::EnqueueWithOrigin<MessageQueue, RelayOrigin>;
300	type OutboundXcmpMessageSource = XcmpQueue;
301	type ReservedDmpWeight = ReservedDmpWeight;
302	type XcmpMessageHandler = XcmpQueue;
303	type ReservedXcmpWeight = ReservedXcmpWeight;
304	type CheckAssociatedRelayNumber = RelayNumberMonotonicallyIncreases;
305	type ConsensusHook = ConsensusHook;
306	type SelectCore = cumulus_pallet_parachain_system::DefaultCoreSelector<Runtime>;
307	type RelayParentOffset = ConstU32<0>;
308}
309
310type ConsensusHook = cumulus_pallet_aura_ext::FixedVelocityConsensusHook<
311	Runtime,
312	RELAY_CHAIN_SLOT_DURATION_MILLIS,
313	BLOCK_PROCESSING_VELOCITY,
314	UNINCLUDED_SEGMENT_CAPACITY,
315>;
316
317parameter_types! {
318	pub MessageQueueServiceWeight: Weight = Perbill::from_percent(35) * RuntimeBlockWeights::get().max_block;
319}
320
321impl pallet_message_queue::Config for Runtime {
322	type RuntimeEvent = RuntimeEvent;
323	type WeightInfo = weights::pallet_message_queue::WeightInfo<Runtime>;
324	#[cfg(feature = "runtime-benchmarks")]
325	type MessageProcessor = pallet_message_queue::mock_helpers::NoopMessageProcessor<
326		cumulus_primitives_core::AggregateMessageOrigin,
327	>;
328	#[cfg(not(feature = "runtime-benchmarks"))]
329	type MessageProcessor = xcm_builder::ProcessXcmMessage<
330		AggregateMessageOrigin,
331		xcm_executor::XcmExecutor<xcm_config::XcmConfig>,
332		RuntimeCall,
333	>;
334	type Size = u32;
335	// The XCMP queue pallet is only ever able to handle the `Sibling(ParaId)` origin:
336	type QueueChangeHandler = NarrowOriginToSibling<XcmpQueue>;
337	type QueuePausedQuery = NarrowOriginToSibling<XcmpQueue>;
338	type HeapSize = sp_core::ConstU32<{ 103 * 1024 }>;
339	type MaxStale = sp_core::ConstU32<8>;
340	type ServiceWeight = MessageQueueServiceWeight;
341	type IdleMaxServiceWeight = MessageQueueServiceWeight;
342}
343
344impl parachain_info::Config for Runtime {}
345
346impl cumulus_pallet_aura_ext::Config for Runtime {}
347
348parameter_types! {
349	/// Fellows pluralistic body.
350	pub const FellowsBodyId: BodyId = BodyId::Technical;
351}
352
353/// Privileged origin that represents Root or Fellows pluralistic body.
354pub type RootOrFellows = EitherOfDiverse<
355	EnsureRoot<AccountId>,
356	EnsureXcm<IsVoiceOfBody<FellowshipLocation, FellowsBodyId>>,
357>;
358
359parameter_types! {
360	/// The asset ID for the asset that we use to pay for message delivery fees.
361	pub FeeAssetId: AssetId = AssetId(TokenRelayLocation::get());
362	/// The base fee for the message delivery fees.
363	pub const BaseDeliveryFee: u128 = CENTS.saturating_mul(3);
364}
365
366pub type PriceForSiblingParachainDelivery = polkadot_runtime_common::xcm_sender::ExponentialPrice<
367	FeeAssetId,
368	BaseDeliveryFee,
369	TransactionByteFee,
370	XcmpQueue,
371>;
372
373impl cumulus_pallet_xcmp_queue::Config for Runtime {
374	type RuntimeEvent = RuntimeEvent;
375	type ChannelInfo = ParachainSystem;
376	type VersionWrapper = PolkadotXcm;
377	type XcmpQueue = TransformOrigin<MessageQueue, AggregateMessageOrigin, ParaId, ParaIdToSibling>;
378	type MaxInboundSuspended = ConstU32<1_000>;
379	type MaxActiveOutboundChannels = ConstU32<128>;
380	// Most on-chain HRMP channels are configured to use 102400 bytes of max message size, so we
381	// need to set the page size larger than that until we reduce the channel size on-chain.
382	type MaxPageSize = ConstU32<{ 103 * 1024 }>;
383	type ControllerOrigin = RootOrFellows;
384	type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;
385	type WeightInfo = weights::cumulus_pallet_xcmp_queue::WeightInfo<Runtime>;
386	type PriceForSiblingDelivery = PriceForSiblingParachainDelivery;
387}
388
389impl cumulus_pallet_xcmp_queue::migration::v5::V5Config for Runtime {
390	// This must be the same as the `ChannelInfo` from the `Config`:
391	type ChannelList = ParachainSystem;
392}
393
394pub const PERIOD: u32 = 6 * HOURS;
395pub const OFFSET: u32 = 0;
396
397impl pallet_session::Config for Runtime {
398	type RuntimeEvent = RuntimeEvent;
399	type ValidatorId = <Self as frame_system::Config>::AccountId;
400	// we don't have stash and controller, thus we don't need the convert as well.
401	type ValidatorIdOf = pallet_collator_selection::IdentityCollator;
402	type ShouldEndSession = pallet_session::PeriodicSessions<ConstU32<PERIOD>, ConstU32<OFFSET>>;
403	type NextSessionRotation = pallet_session::PeriodicSessions<ConstU32<PERIOD>, ConstU32<OFFSET>>;
404	type SessionManager = CollatorSelection;
405	// Essentially just Aura, but let's be pedantic.
406	type SessionHandler = <SessionKeys as sp_runtime::traits::OpaqueKeys>::KeyTypeIdProviders;
407	type Keys = SessionKeys;
408	type DisablingStrategy = ();
409	type WeightInfo = weights::pallet_session::WeightInfo<Runtime>;
410	type Currency = Balances;
411	type KeyDeposit = ();
412}
413
414impl pallet_aura::Config for Runtime {
415	type AuthorityId = AuraId;
416	type DisabledValidators = ();
417	type MaxAuthorities = ConstU32<100_000>;
418	type AllowMultipleBlocksPerSlot = ConstBool<true>;
419	type SlotDuration = ConstU64<SLOT_DURATION>;
420}
421
422parameter_types! {
423	pub const PotId: PalletId = PalletId(*b"PotStake");
424	pub const SessionLength: BlockNumber = 6 * HOURS;
425	/// StakingAdmin pluralistic body.
426	pub const StakingAdminBodyId: BodyId = BodyId::Defense;
427}
428
429/// We allow Root and the `StakingAdmin` to execute privileged collator selection operations.
430pub type CollatorSelectionUpdateOrigin = EitherOfDiverse<
431	EnsureRoot<AccountId>,
432	EnsureXcm<IsVoiceOfBody<GovernanceLocation, StakingAdminBodyId>>,
433>;
434
435impl pallet_collator_selection::Config for Runtime {
436	type RuntimeEvent = RuntimeEvent;
437	type Currency = Balances;
438	type UpdateOrigin = CollatorSelectionUpdateOrigin;
439	type PotId = PotId;
440	type MaxCandidates = ConstU32<100>;
441	type MinEligibleCollators = ConstU32<4>;
442	type MaxInvulnerables = ConstU32<20>;
443	// should be a multiple of session or things will get inconsistent
444	type KickThreshold = ConstU32<PERIOD>;
445	type ValidatorId = <Self as frame_system::Config>::AccountId;
446	type ValidatorIdOf = pallet_collator_selection::IdentityCollator;
447	type ValidatorRegistration = Session;
448	type WeightInfo = weights::pallet_collator_selection::WeightInfo<Runtime>;
449}
450
451parameter_types! {
452	/// One storage item; key size is 32; value is size 4+4+16+32 bytes = 56 bytes.
453	pub const DepositBase: Balance = deposit(1, 88);
454	/// Additional storage item size of 32 bytes.
455	pub const DepositFactor: Balance = deposit(0, 32);
456}
457
458impl pallet_multisig::Config for Runtime {
459	type RuntimeEvent = RuntimeEvent;
460	type RuntimeCall = RuntimeCall;
461	type Currency = Balances;
462	type DepositBase = DepositBase;
463	type DepositFactor = DepositFactor;
464	type MaxSignatories = ConstU32<100>;
465	type WeightInfo = weights::pallet_multisig::WeightInfo<Runtime>;
466	type BlockNumberProvider = frame_system::Pallet<Runtime>;
467}
468
469/// The type used to represent the kinds of proxying allowed.
470#[derive(
471	Copy,
472	Clone,
473	Eq,
474	PartialEq,
475	Ord,
476	PartialOrd,
477	Encode,
478	Decode,
479	DecodeWithMemTracking,
480	RuntimeDebug,
481	MaxEncodedLen,
482	scale_info::TypeInfo,
483)]
484pub enum ProxyType {
485	/// Fully permissioned proxy. Can execute any call on behalf of _proxied_.
486	Any,
487	/// Can execute any call that does not transfer funds or assets.
488	NonTransfer,
489	/// Proxy with the ability to reject time-delay proxy announcements.
490	CancelProxy,
491	/// Proxy for all Broker pallet calls.
492	Broker,
493	/// Proxy for renewing coretime.
494	CoretimeRenewer,
495	/// Proxy able to purchase on-demand coretime credits.
496	OnDemandPurchaser,
497	/// Collator selection proxy. Can execute calls related to collator selection mechanism.
498	Collator,
499}
500impl Default for ProxyType {
501	fn default() -> Self {
502		Self::Any
503	}
504}
505
506impl InstanceFilter<RuntimeCall> for ProxyType {
507	fn filter(&self, c: &RuntimeCall) -> bool {
508		match self {
509			ProxyType::Any => true,
510			ProxyType::NonTransfer => !matches!(
511				c,
512				RuntimeCall::Balances { .. } |
513				// `purchase`, `renew`, `transfer` and `purchase_credit` are pretty self explanatory.
514				RuntimeCall::Broker(pallet_broker::Call::purchase { .. }) |
515				RuntimeCall::Broker(pallet_broker::Call::renew { .. }) |
516				RuntimeCall::Broker(pallet_broker::Call::transfer { .. }) |
517				RuntimeCall::Broker(pallet_broker::Call::purchase_credit { .. }) |
518				// `pool` doesn't transfer, but it defines the account to be paid for contributions
519				RuntimeCall::Broker(pallet_broker::Call::pool { .. }) |
520				// `assign` is essentially a transfer of a region NFT
521				RuntimeCall::Broker(pallet_broker::Call::assign { .. })
522			),
523			ProxyType::CancelProxy => matches!(
524				c,
525				RuntimeCall::Proxy(pallet_proxy::Call::reject_announcement { .. }) |
526					RuntimeCall::Utility { .. } |
527					RuntimeCall::Multisig { .. }
528			),
529			ProxyType::Broker => {
530				matches!(
531					c,
532					RuntimeCall::Broker { .. } |
533						RuntimeCall::Utility { .. } |
534						RuntimeCall::Multisig { .. }
535				)
536			},
537			ProxyType::CoretimeRenewer => {
538				matches!(
539					c,
540					RuntimeCall::Broker(pallet_broker::Call::renew { .. }) |
541						RuntimeCall::Utility { .. } |
542						RuntimeCall::Multisig { .. }
543				)
544			},
545			ProxyType::OnDemandPurchaser => {
546				matches!(
547					c,
548					RuntimeCall::Broker(pallet_broker::Call::purchase_credit { .. }) |
549						RuntimeCall::Utility { .. } |
550						RuntimeCall::Multisig { .. }
551				)
552			},
553			ProxyType::Collator => matches!(
554				c,
555				RuntimeCall::CollatorSelection { .. } |
556					RuntimeCall::Utility { .. } |
557					RuntimeCall::Multisig { .. }
558			),
559		}
560	}
561
562	fn is_superset(&self, o: &Self) -> bool {
563		match (self, o) {
564			(x, y) if x == y => true,
565			(ProxyType::Any, _) => true,
566			(_, ProxyType::Any) => false,
567			(ProxyType::Broker, ProxyType::CoretimeRenewer) => true,
568			(ProxyType::Broker, ProxyType::OnDemandPurchaser) => true,
569			(ProxyType::NonTransfer, ProxyType::Collator) => true,
570			_ => false,
571		}
572	}
573}
574
575parameter_types! {
576	// One storage item; key size 32, value size 8; .
577	pub const ProxyDepositBase: Balance = deposit(1, 40);
578	// Additional storage item size of 33 bytes.
579	pub const ProxyDepositFactor: Balance = deposit(0, 33);
580	pub const MaxProxies: u16 = 32;
581	// One storage item; key size 32, value size 16
582	pub const AnnouncementDepositBase: Balance = deposit(1, 48);
583	pub const AnnouncementDepositFactor: Balance = deposit(0, 66);
584	pub const MaxPending: u16 = 32;
585}
586
587impl pallet_proxy::Config for Runtime {
588	type RuntimeEvent = RuntimeEvent;
589	type RuntimeCall = RuntimeCall;
590	type Currency = Balances;
591	type ProxyType = ProxyType;
592	type ProxyDepositBase = ProxyDepositBase;
593	type ProxyDepositFactor = ProxyDepositFactor;
594	type MaxProxies = MaxProxies;
595	type WeightInfo = weights::pallet_proxy::WeightInfo<Runtime>;
596	type MaxPending = MaxPending;
597	type CallHasher = BlakeTwo256;
598	type AnnouncementDepositBase = AnnouncementDepositBase;
599	type AnnouncementDepositFactor = AnnouncementDepositFactor;
600	type BlockNumberProvider = frame_system::Pallet<Runtime>;
601}
602
603impl pallet_utility::Config for Runtime {
604	type RuntimeEvent = RuntimeEvent;
605	type RuntimeCall = RuntimeCall;
606	type PalletsOrigin = OriginCaller;
607	type WeightInfo = weights::pallet_utility::WeightInfo<Runtime>;
608}
609
610impl pallet_sudo::Config for Runtime {
611	type RuntimeCall = RuntimeCall;
612	type RuntimeEvent = RuntimeEvent;
613	type WeightInfo = pallet_sudo::weights::SubstrateWeight<Runtime>;
614}
615
616pub struct BrokerMigrationV4BlockConversion;
617
618impl pallet_broker::migration::v4::BlockToRelayHeightConversion<Runtime>
619	for BrokerMigrationV4BlockConversion
620{
621	fn convert_block_number_to_relay_height(input_block_number: u32) -> u32 {
622		let relay_height = pallet_broker::RCBlockNumberProviderOf::<
623			<Runtime as pallet_broker::Config>::Coretime,
624		>::current_block_number();
625		let parachain_block_number = frame_system::Pallet::<Runtime>::block_number();
626		let offset = relay_height - parachain_block_number * 2;
627		offset + input_block_number * 2
628	}
629
630	fn convert_block_length_to_relay_length(input_block_length: u32) -> u32 {
631		input_block_length * 2
632	}
633}
634
635// Create the runtime by composing the FRAME pallets that were previously configured.
636construct_runtime!(
637	pub enum Runtime
638	{
639		// System support stuff.
640		System: frame_system = 0,
641		ParachainSystem: cumulus_pallet_parachain_system = 1,
642		Timestamp: pallet_timestamp = 3,
643		ParachainInfo: parachain_info = 4,
644		WeightReclaim: cumulus_pallet_weight_reclaim = 5,
645
646		// Monetary stuff.
647		Balances: pallet_balances = 10,
648		TransactionPayment: pallet_transaction_payment = 11,
649
650		// Collator support. The order of these 5 are important and shall not change.
651		Authorship: pallet_authorship = 20,
652		CollatorSelection: pallet_collator_selection = 21,
653		Session: pallet_session = 22,
654		Aura: pallet_aura = 23,
655		AuraExt: cumulus_pallet_aura_ext = 24,
656
657		// XCM & related
658		XcmpQueue: cumulus_pallet_xcmp_queue = 30,
659		PolkadotXcm: pallet_xcm = 31,
660		CumulusXcm: cumulus_pallet_xcm = 32,
661		MessageQueue: pallet_message_queue = 34,
662
663		// Handy utilities.
664		Utility: pallet_utility = 40,
665		Multisig: pallet_multisig = 41,
666		Proxy: pallet_proxy = 42,
667
668		// The main stage.
669		Broker: pallet_broker = 50,
670
671		// Sudo
672		Sudo: pallet_sudo = 100,
673	}
674);
675
676#[cfg(feature = "runtime-benchmarks")]
677mod benches {
678	frame_benchmarking::define_benchmarks!(
679		[frame_system, SystemBench::<Runtime>]
680		[cumulus_pallet_parachain_system, ParachainSystem]
681		[pallet_timestamp, Timestamp]
682		[pallet_balances, Balances]
683		[pallet_broker, Broker]
684		[pallet_collator_selection, CollatorSelection]
685		[pallet_session, SessionBench::<Runtime>]
686		[cumulus_pallet_xcmp_queue, XcmpQueue]
687		[pallet_xcm, PalletXcmExtrinsicsBenchmark::<Runtime>]
688		[pallet_message_queue, MessageQueue]
689		[pallet_multisig, Multisig]
690		[pallet_proxy, Proxy]
691		[pallet_utility, Utility]
692		// NOTE: Make sure you point to the individual modules below.
693		[pallet_xcm_benchmarks::fungible, XcmBalances]
694		[pallet_xcm_benchmarks::generic, XcmGeneric]
695		[cumulus_pallet_weight_reclaim, WeightReclaim]
696	);
697}
698
699impl_runtime_apis! {
700	impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {
701		fn slot_duration() -> sp_consensus_aura::SlotDuration {
702			sp_consensus_aura::SlotDuration::from_millis(SLOT_DURATION)
703		}
704
705		fn authorities() -> Vec<AuraId> {
706			pallet_aura::Authorities::<Runtime>::get().into_inner()
707		}
708	}
709
710	impl cumulus_primitives_core::RelayParentOffsetApi<Block> for Runtime {
711		fn relay_parent_offset() -> u32 {
712			0
713		}
714	}
715
716	impl cumulus_primitives_aura::AuraUnincludedSegmentApi<Block> for Runtime {
717		fn can_build_upon(
718			included_hash: <Block as BlockT>::Hash,
719			slot: cumulus_primitives_aura::Slot,
720		) -> bool {
721			ConsensusHook::can_build_upon(included_hash, slot)
722		}
723	}
724
725	impl sp_api::Core<Block> for Runtime {
726		fn version() -> RuntimeVersion {
727			VERSION
728		}
729
730		fn execute_block(block: Block) {
731			Executive::execute_block(block)
732		}
733
734		fn initialize_block(header: &<Block as BlockT>::Header) -> sp_runtime::ExtrinsicInclusionMode {
735			Executive::initialize_block(header)
736		}
737	}
738
739	impl sp_api::Metadata<Block> for Runtime {
740		fn metadata() -> OpaqueMetadata {
741			OpaqueMetadata::new(Runtime::metadata().into())
742		}
743
744		fn metadata_at_version(version: u32) -> Option<OpaqueMetadata> {
745			Runtime::metadata_at_version(version)
746		}
747
748		fn metadata_versions() -> alloc::vec::Vec<u32> {
749			Runtime::metadata_versions()
750		}
751	}
752
753	impl sp_block_builder::BlockBuilder<Block> for Runtime {
754		fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {
755			Executive::apply_extrinsic(extrinsic)
756		}
757
758		fn finalize_block() -> <Block as BlockT>::Header {
759			Executive::finalize_block()
760		}
761
762		fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {
763			data.create_extrinsics()
764		}
765
766		fn check_inherents(
767			block: Block,
768			data: sp_inherents::InherentData,
769		) -> sp_inherents::CheckInherentsResult {
770			data.check_extrinsics(&block)
771		}
772	}
773
774	impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {
775		fn validate_transaction(
776			source: TransactionSource,
777			tx: <Block as BlockT>::Extrinsic,
778			block_hash: <Block as BlockT>::Hash,
779		) -> TransactionValidity {
780			Executive::validate_transaction(source, tx, block_hash)
781		}
782	}
783
784	impl sp_offchain::OffchainWorkerApi<Block> for Runtime {
785		fn offchain_worker(header: &<Block as BlockT>::Header) {
786			Executive::offchain_worker(header)
787		}
788	}
789
790	impl sp_session::SessionKeys<Block> for Runtime {
791		fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {
792			SessionKeys::generate(seed)
793		}
794
795		fn decode_session_keys(
796			encoded: Vec<u8>,
797		) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {
798			SessionKeys::decode_into_raw_public_keys(&encoded)
799		}
800	}
801
802	impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce> for Runtime {
803		fn account_nonce(account: AccountId) -> Nonce {
804			System::account_nonce(account)
805		}
806	}
807
808	impl pallet_broker::runtime_api::BrokerApi<Block, Balance> for Runtime {
809		fn sale_price() -> Result<Balance, DispatchError> {
810			Broker::current_price()
811		}
812	}
813
814	impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {
815		fn query_info(
816			uxt: <Block as BlockT>::Extrinsic,
817			len: u32,
818		) -> pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo<Balance> {
819			TransactionPayment::query_info(uxt, len)
820		}
821		fn query_fee_details(
822			uxt: <Block as BlockT>::Extrinsic,
823			len: u32,
824		) -> pallet_transaction_payment::FeeDetails<Balance> {
825			TransactionPayment::query_fee_details(uxt, len)
826		}
827		fn query_weight_to_fee(weight: Weight) -> Balance {
828			TransactionPayment::weight_to_fee(weight)
829		}
830		fn query_length_to_fee(length: u32) -> Balance {
831			TransactionPayment::length_to_fee(length)
832		}
833	}
834
835	impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentCallApi<Block, Balance, RuntimeCall>
836		for Runtime
837	{
838		fn query_call_info(
839			call: RuntimeCall,
840			len: u32,
841		) -> pallet_transaction_payment::RuntimeDispatchInfo<Balance> {
842			TransactionPayment::query_call_info(call, len)
843		}
844		fn query_call_fee_details(
845			call: RuntimeCall,
846			len: u32,
847		) -> pallet_transaction_payment::FeeDetails<Balance> {
848			TransactionPayment::query_call_fee_details(call, len)
849		}
850		fn query_weight_to_fee(weight: Weight) -> Balance {
851			TransactionPayment::weight_to_fee(weight)
852		}
853		fn query_length_to_fee(length: u32) -> Balance {
854			TransactionPayment::length_to_fee(length)
855		}
856	}
857
858	impl xcm_runtime_apis::fees::XcmPaymentApi<Block> for Runtime {
859		fn query_acceptable_payment_assets(xcm_version: xcm::Version) -> Result<Vec<VersionedAssetId>, XcmPaymentApiError> {
860			let acceptable_assets = vec![AssetId(xcm_config::TokenRelayLocation::get())];
861			PolkadotXcm::query_acceptable_payment_assets(xcm_version, acceptable_assets)
862		}
863
864		fn query_weight_to_asset_fee(weight: Weight, asset: VersionedAssetId) -> Result<u128, XcmPaymentApiError> {
865			use crate::xcm_config::XcmConfig;
866
867			type Trader = <XcmConfig as xcm_executor::Config>::Trader;
868
869			PolkadotXcm::query_weight_to_asset_fee::<Trader>(weight, asset)
870		}
871
872		fn query_xcm_weight(message: VersionedXcm<()>) -> Result<Weight, XcmPaymentApiError> {
873			PolkadotXcm::query_xcm_weight(message)
874		}
875
876		fn query_delivery_fees(destination: VersionedLocation, message: VersionedXcm<()>) -> Result<VersionedAssets, XcmPaymentApiError> {
877			PolkadotXcm::query_delivery_fees(destination, message)
878		}
879	}
880
881	impl xcm_runtime_apis::dry_run::DryRunApi<Block, RuntimeCall, RuntimeEvent, OriginCaller> for Runtime {
882		fn dry_run_call(origin: OriginCaller, call: RuntimeCall, result_xcms_version: XcmVersion) -> Result<CallDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
883			PolkadotXcm::dry_run_call::<Runtime, xcm_config::XcmRouter, OriginCaller, RuntimeCall>(origin, call, result_xcms_version)
884		}
885
886		fn dry_run_xcm(origin_location: VersionedLocation, xcm: VersionedXcm<RuntimeCall>) -> Result<XcmDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
887			PolkadotXcm::dry_run_xcm::<Runtime, xcm_config::XcmRouter, RuntimeCall, xcm_config::XcmConfig>(origin_location, xcm)
888		}
889	}
890
891	impl xcm_runtime_apis::conversions::LocationToAccountApi<Block, AccountId> for Runtime {
892		fn convert_location(location: VersionedLocation) -> Result<
893			AccountId,
894			xcm_runtime_apis::conversions::Error
895		> {
896			xcm_runtime_apis::conversions::LocationToAccountHelper::<
897				AccountId,
898				xcm_config::LocationToAccountId,
899			>::convert_location(location)
900		}
901	}
902
903	impl xcm_runtime_apis::trusted_query::TrustedQueryApi<Block> for Runtime {
904		fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult {
905			PolkadotXcm::is_trusted_reserve(asset, location)
906		}
907		fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult {
908			PolkadotXcm::is_trusted_teleporter(asset, location)
909		}
910	}
911
912	impl xcm_runtime_apis::authorized_aliases::AuthorizedAliasersApi<Block> for Runtime {
913		fn authorized_aliasers(target: VersionedLocation) -> Result<
914			Vec<xcm_runtime_apis::authorized_aliases::OriginAliaser>,
915			xcm_runtime_apis::authorized_aliases::Error
916		> {
917			PolkadotXcm::authorized_aliasers(target)
918		}
919		fn is_authorized_alias(origin: VersionedLocation, target: VersionedLocation) -> Result<
920			bool,
921			xcm_runtime_apis::authorized_aliases::Error
922		> {
923			PolkadotXcm::is_authorized_alias(origin, target)
924		}
925	}
926
927	impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {
928		fn collect_collation_info(header: &<Block as BlockT>::Header) -> cumulus_primitives_core::CollationInfo {
929			ParachainSystem::collect_collation_info(header)
930		}
931	}
932
933	impl cumulus_primitives_core::GetCoreSelectorApi<Block> for Runtime {
934		fn core_selector() -> (CoreSelector, ClaimQueueOffset) {
935			ParachainSystem::core_selector()
936		}
937	}
938
939	#[cfg(feature = "try-runtime")]
940	impl frame_try_runtime::TryRuntime<Block> for Runtime {
941		fn on_runtime_upgrade(checks: frame_try_runtime::UpgradeCheckSelect) -> (Weight, Weight) {
942			let weight = Executive::try_runtime_upgrade(checks).unwrap();
943			(weight, RuntimeBlockWeights::get().max_block)
944		}
945
946		fn execute_block(
947			block: Block,
948			state_root_check: bool,
949			signature_check: bool,
950			select: frame_try_runtime::TryStateSelect,
951		) -> Weight {
952			// NOTE: intentional unwrap: we don't want to propagate the error backwards, and want to
953			// have a backtrace here.
954			Executive::try_execute_block(block, state_root_check, signature_check, select).unwrap()
955		}
956	}
957
958	#[cfg(feature = "runtime-benchmarks")]
959	impl frame_benchmarking::Benchmark<Block> for Runtime {
960		fn benchmark_metadata(extra: bool) -> (
961			Vec<frame_benchmarking::BenchmarkList>,
962			Vec<frame_support::traits::StorageInfo>,
963		) {
964			use frame_benchmarking::BenchmarkList;
965			use frame_support::traits::StorageInfoTrait;
966			use frame_system_benchmarking::Pallet as SystemBench;
967			use cumulus_pallet_session_benchmarking::Pallet as SessionBench;
968			use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsicsBenchmark;
969
970			// This is defined once again in dispatch_benchmark, because list_benchmarks!
971			// and add_benchmarks! are macros exported by define_benchmarks! macros and those types
972			// are referenced in that call.
973			type XcmBalances = pallet_xcm_benchmarks::fungible::Pallet::<Runtime>;
974			type XcmGeneric = pallet_xcm_benchmarks::generic::Pallet::<Runtime>;
975
976			let mut list = Vec::<BenchmarkList>::new();
977			list_benchmarks!(list, extra);
978
979			let storage_info = AllPalletsWithSystem::storage_info();
980			(list, storage_info)
981		}
982
983		#[allow(non_local_definitions)]
984		fn dispatch_benchmark(
985			config: frame_benchmarking::BenchmarkConfig
986		) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, alloc::string::String> {
987			use frame_benchmarking::{BenchmarkBatch, BenchmarkError};
988			use sp_storage::TrackedStorageKey;
989
990			use frame_system_benchmarking::Pallet as SystemBench;
991			impl frame_system_benchmarking::Config for Runtime {
992				fn setup_set_code_requirements(code: &alloc::vec::Vec<u8>) -> Result<(), BenchmarkError> {
993					ParachainSystem::initialize_for_set_code_benchmark(code.len() as u32);
994					Ok(())
995				}
996
997				fn verify_set_code() {
998					System::assert_last_event(cumulus_pallet_parachain_system::Event::<Runtime>::ValidationFunctionStored.into());
999				}
1000			}
1001
1002			use cumulus_pallet_session_benchmarking::Pallet as SessionBench;
1003			impl cumulus_pallet_session_benchmarking::Config for Runtime {}
1004
1005			use xcm::latest::prelude::*;
1006			use xcm_config::TokenRelayLocation;
1007
1008			use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsicsBenchmark;
1009			impl pallet_xcm::benchmarking::Config for Runtime {
1010				type DeliveryHelper = (
1011					cumulus_primitives_utility::ToParentDeliveryHelper<
1012						xcm_config::XcmConfig,
1013						ExistentialDepositAsset,
1014						xcm_config::PriceForParentDelivery,
1015					>,
1016					polkadot_runtime_common::xcm_sender::ToParachainDeliveryHelper<
1017						xcm_config::XcmConfig,
1018						ExistentialDepositAsset,
1019						PriceForSiblingParachainDelivery,
1020						RandomParaId,
1021						ParachainSystem,
1022					>
1023				);
1024
1025				fn reachable_dest() -> Option<Location> {
1026					Some(Parent.into())
1027				}
1028
1029				fn teleportable_asset_and_dest() -> Option<(Asset, Location)> {
1030					// Relay/native token can be teleported between AH and Relay.
1031					Some((
1032						Asset {
1033							fun: Fungible(ExistentialDeposit::get()),
1034							id: AssetId(Parent.into())
1035						},
1036						Parent.into(),
1037					))
1038				}
1039
1040				fn reserve_transferable_asset_and_dest() -> Option<(Asset, Location)> {
1041					// Coretime chain can reserve transfer regions to some random parachain.
1042
1043					// Properties of a mock region:
1044					let core = 0;
1045					let begin = 0;
1046					let end = 42;
1047
1048					let region_id = pallet_broker::Pallet::<Runtime>::issue(core, begin, pallet_broker::CoreMask::complete(), end, None, None);
1049					Some((
1050						Asset {
1051							fun: NonFungible(Index(region_id.into())),
1052							id: AssetId(xcm_config::BrokerPalletLocation::get())
1053						},
1054						ParentThen(Parachain(RandomParaId::get().into()).into()).into(),
1055					))
1056				}
1057
1058				fn set_up_complex_asset_transfer() -> Option<(Assets, u32, Location, alloc::boxed::Box<dyn FnOnce()>)> {
1059					let native_location = Parent.into();
1060					let dest = Parent.into();
1061
1062					pallet_xcm::benchmarking::helpers::native_teleport_as_asset_transfer::<Runtime>(
1063						native_location,
1064						dest,
1065					)
1066				}
1067
1068				fn get_asset() -> Asset {
1069					Asset {
1070						id: AssetId(Location::parent()),
1071						fun: Fungible(ExistentialDeposit::get()),
1072					}
1073				}
1074			}
1075
1076			parameter_types! {
1077				pub ExistentialDepositAsset: Option<Asset> = Some((
1078					TokenRelayLocation::get(),
1079					ExistentialDeposit::get()
1080				).into());
1081			}
1082
1083			impl pallet_xcm_benchmarks::Config for Runtime {
1084				type XcmConfig = xcm_config::XcmConfig;
1085
1086				type DeliveryHelper = (
1087					cumulus_primitives_utility::ToParentDeliveryHelper<
1088						xcm_config::XcmConfig,
1089						ExistentialDepositAsset,
1090						xcm_config::PriceForParentDelivery,
1091					>,
1092					polkadot_runtime_common::xcm_sender::ToParachainDeliveryHelper<
1093						xcm_config::XcmConfig,
1094						ExistentialDepositAsset,
1095						PriceForSiblingParachainDelivery,
1096						RandomParaId,
1097						ParachainSystem,
1098					>
1099				);
1100
1101				type AccountIdConverter = xcm_config::LocationToAccountId;
1102				fn valid_destination() -> Result<Location, BenchmarkError> {
1103					Ok(TokenRelayLocation::get())
1104				}
1105				fn worst_case_holding(_depositable_count: u32) -> Assets {
1106					// just concrete assets according to relay chain.
1107					let assets: Vec<Asset> = vec![
1108						Asset {
1109							id: AssetId(TokenRelayLocation::get()),
1110							fun: Fungible(1_000_000 * UNITS),
1111						}
1112					];
1113					assets.into()
1114				}
1115			}
1116
1117			parameter_types! {
1118				pub const TrustedTeleporter: Option<(Location, Asset)> = Some((
1119					TokenRelayLocation::get(),
1120					Asset { fun: Fungible(UNITS), id: AssetId(TokenRelayLocation::get()) },
1121				));
1122				pub const CheckedAccount: Option<(AccountId, xcm_builder::MintLocation)> = None;
1123				pub const TrustedReserve: Option<(Location, Asset)> = None;
1124			}
1125
1126			impl pallet_xcm_benchmarks::fungible::Config for Runtime {
1127				type TransactAsset = Balances;
1128
1129				type CheckedAccount = CheckedAccount;
1130				type TrustedTeleporter = TrustedTeleporter;
1131				type TrustedReserve = TrustedReserve;
1132
1133				fn get_asset() -> Asset {
1134					Asset {
1135						id: AssetId(TokenRelayLocation::get()),
1136						fun: Fungible(UNITS),
1137					}
1138				}
1139			}
1140
1141			impl pallet_xcm_benchmarks::generic::Config for Runtime {
1142				type RuntimeCall = RuntimeCall;
1143				type TransactAsset = Balances;
1144
1145				fn worst_case_response() -> (u64, Response) {
1146					(0u64, Response::Version(Default::default()))
1147				}
1148
1149				fn worst_case_asset_exchange() -> Result<(Assets, Assets), BenchmarkError> {
1150					Err(BenchmarkError::Skip)
1151				}
1152
1153				fn universal_alias() -> Result<(Location, Junction), BenchmarkError> {
1154					Err(BenchmarkError::Skip)
1155				}
1156
1157				fn transact_origin_and_runtime_call() -> Result<(Location, RuntimeCall), BenchmarkError> {
1158					Ok((TokenRelayLocation::get(), frame_system::Call::remark_with_event { remark: vec![] }.into()))
1159				}
1160
1161				fn subscribe_origin() -> Result<Location, BenchmarkError> {
1162					Ok(TokenRelayLocation::get())
1163				}
1164
1165				fn claimable_asset() -> Result<(Location, Location, Assets), BenchmarkError> {
1166					let origin = TokenRelayLocation::get();
1167					let assets: Assets = (AssetId(TokenRelayLocation::get()), 1_000 * UNITS).into();
1168					let ticket = Location { parents: 0, interior: Here };
1169					Ok((origin, ticket, assets))
1170				}
1171
1172				fn worst_case_for_trader() -> Result<(Asset, WeightLimit), BenchmarkError> {
1173					Ok((Asset {
1174						id: AssetId(TokenRelayLocation::get()),
1175						fun: Fungible(1_000_000 * UNITS),
1176					}, WeightLimit::Limited(Weight::from_parts(5000, 5000))))
1177				}
1178
1179				fn unlockable_asset() -> Result<(Location, Location, Asset), BenchmarkError> {
1180					Err(BenchmarkError::Skip)
1181				}
1182
1183				fn export_message_origin_and_destination(
1184				) -> Result<(Location, NetworkId, InteriorLocation), BenchmarkError> {
1185					Err(BenchmarkError::Skip)
1186				}
1187
1188				fn alias_origin() -> Result<(Location, Location), BenchmarkError> {
1189					let origin = Location::new(1, [Parachain(1000)]);
1190					let target = Location::new(1, [Parachain(1000), AccountId32 { id: [128u8; 32], network: None }]);
1191					Ok((origin, target))
1192				}
1193			}
1194
1195			type XcmBalances = pallet_xcm_benchmarks::fungible::Pallet::<Runtime>;
1196			type XcmGeneric = pallet_xcm_benchmarks::generic::Pallet::<Runtime>;
1197
1198			use frame_support::traits::WhitelistedStorageKeys;
1199			let whitelist: Vec<TrackedStorageKey> = AllPalletsWithSystem::whitelisted_storage_keys();
1200
1201			let mut batches = Vec::<BenchmarkBatch>::new();
1202			let params = (&config, &whitelist);
1203			add_benchmarks!(params, batches);
1204
1205			Ok(batches)
1206		}
1207	}
1208
1209	impl sp_genesis_builder::GenesisBuilder<Block> for Runtime {
1210		fn build_state(config: Vec<u8>) -> sp_genesis_builder::Result {
1211			build_state::<RuntimeGenesisConfig>(config)
1212		}
1213
1214		fn get_preset(id: &Option<sp_genesis_builder::PresetId>) -> Option<Vec<u8>> {
1215			get_preset::<RuntimeGenesisConfig>(id, &genesis_config_presets::get_preset)
1216		}
1217
1218		fn preset_names() -> Vec<sp_genesis_builder::PresetId> {
1219			genesis_config_presets::preset_names()
1220		}
1221	}
1222
1223	impl cumulus_primitives_core::GetParachainInfo<Block> for Runtime {
1224		fn parachain_id() -> ParaId {
1225			ParachainInfo::parachain_id()
1226		}
1227	}
1228}
1229
1230cumulus_pallet_parachain_system::register_validate_block! {
1231	Runtime = Runtime,
1232	BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,
1233}