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	cumulus_pallet_xcmp_queue::migration::v6::MigrateV5ToV6<Runtime>,
129	cumulus_pallet_xcmp_queue::migration::v7::MigrateV6ToV7<Runtime>,
130	pallet_broker::migration::MigrateV0ToV1<Runtime>,
131	pallet_broker::migration::MigrateV1ToV2<Runtime>,
132	pallet_broker::migration::MigrateV2ToV3<Runtime>,
133	pallet_broker::migration::MigrateV3ToV4<Runtime, BrokerMigrationV4BlockConversion>,
134	pallet_session::migrations::v1::MigrateV0ToV1<
135		Runtime,
136		pallet_session::migrations::v1::InitOffenceSeverity<Runtime>,
137	>,
138	// permanent
139	pallet_xcm::migration::MigrateToLatestXcmVersion<Runtime>,
140	cumulus_pallet_aura_ext::migration::MigrateV0ToV1<Runtime>,
141);
142
143/// Executive: handles dispatch to the various modules.
144pub type Executive = frame_executive::Executive<
145	Runtime,
146	Block,
147	frame_system::ChainContext<Runtime>,
148	Runtime,
149	AllPalletsWithSystem,
150	Migrations,
151>;
152
153impl_opaque_keys! {
154	pub struct SessionKeys {
155		pub aura: Aura,
156	}
157}
158
159#[sp_version::runtime_version]
160pub const VERSION: RuntimeVersion = RuntimeVersion {
161	spec_name: alloc::borrow::Cow::Borrowed("coretime-westend"),
162	impl_name: alloc::borrow::Cow::Borrowed("coretime-westend"),
163	authoring_version: 1,
164	spec_version: 1_019_004,
165	impl_version: 0,
166	apis: RUNTIME_API_VERSIONS,
167	transaction_version: 2,
168	system_version: 1,
169};
170
171/// The version information used to identify this runtime when compiled natively.
172#[cfg(feature = "std")]
173pub fn native_version() -> NativeVersion {
174	NativeVersion { runtime_version: VERSION, can_author_with: Default::default() }
175}
176
177parameter_types! {
178	pub const Version: RuntimeVersion = VERSION;
179	pub RuntimeBlockLength: BlockLength =
180		BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);
181	pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()
182		.base_block(BlockExecutionWeight::get())
183		.for_class(DispatchClass::all(), |weights| {
184			weights.base_extrinsic = ExtrinsicBaseWeight::get();
185		})
186		.for_class(DispatchClass::Normal, |weights| {
187			weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);
188		})
189		.for_class(DispatchClass::Operational, |weights| {
190			weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);
191			// Operational transactions have some extra reserved space, so that they
192			// are included even if block reached `MAXIMUM_BLOCK_WEIGHT`.
193			weights.reserved = Some(
194				MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT
195			);
196		})
197		.avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)
198		.build_or_panic();
199	pub const SS58Prefix: u8 = 42;
200}
201
202// Configure FRAME pallets to include in runtime.
203#[derive_impl(frame_system::config_preludes::ParaChainDefaultConfig)]
204impl frame_system::Config for Runtime {
205	/// The identifier used to distinguish between accounts.
206	type AccountId = AccountId;
207	/// The nonce type for storing how many extrinsics an account has signed.
208	type Nonce = Nonce;
209	/// The type for hashing blocks and tries.
210	type Hash = Hash;
211	/// The block type.
212	type Block = Block;
213	/// Maximum number of block number to block hash mappings to keep (oldest pruned first).
214	type BlockHashCount = BlockHashCount;
215	/// Runtime version.
216	type Version = Version;
217	/// The data to be stored in an account.
218	type AccountData = pallet_balances::AccountData<Balance>;
219	/// The weight of database operations that the runtime can invoke.
220	type DbWeight = RocksDbWeight;
221	/// Weight information for the extrinsics of this pallet.
222	type SystemWeightInfo = weights::frame_system::WeightInfo<Runtime>;
223	/// Weight information for the extensions of this pallet.
224	type ExtensionsWeightInfo = weights::frame_system_extensions::WeightInfo<Runtime>;
225	/// Block & extrinsics weights: base values and limits.
226	type BlockWeights = RuntimeBlockWeights;
227	/// The maximum length of a block (in bytes).
228	type BlockLength = RuntimeBlockLength;
229	type SS58Prefix = SS58Prefix;
230	/// The action to take on a Runtime Upgrade
231	type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;
232	type MaxConsumers = ConstU32<16>;
233}
234
235impl cumulus_pallet_weight_reclaim::Config for Runtime {
236	type WeightInfo = weights::cumulus_pallet_weight_reclaim::WeightInfo<Runtime>;
237}
238
239impl pallet_timestamp::Config for Runtime {
240	/// A timestamp: milliseconds since the unix epoch.
241	type Moment = u64;
242	type OnTimestampSet = Aura;
243	type MinimumPeriod = ConstU64<0>;
244	type WeightInfo = weights::pallet_timestamp::WeightInfo<Runtime>;
245}
246
247impl pallet_authorship::Config for Runtime {
248	type FindAuthor = pallet_session::FindAccountFromAuthorIndex<Self, Aura>;
249	type EventHandler = (CollatorSelection,);
250}
251
252parameter_types! {
253	pub const ExistentialDeposit: Balance = EXISTENTIAL_DEPOSIT;
254	pub const RandomParaId: ParaId = ParaId::new(43211234);
255}
256
257impl pallet_balances::Config for Runtime {
258	type Balance = Balance;
259	type DustRemoval = ();
260	type RuntimeEvent = RuntimeEvent;
261	type ExistentialDeposit = ExistentialDeposit;
262	type AccountStore = System;
263	type WeightInfo = weights::pallet_balances::WeightInfo<Runtime>;
264	type MaxLocks = ConstU32<50>;
265	type MaxReserves = ConstU32<50>;
266	type ReserveIdentifier = [u8; 8];
267	type RuntimeHoldReason = RuntimeHoldReason;
268	type RuntimeFreezeReason = RuntimeFreezeReason;
269	type FreezeIdentifier = ();
270	type MaxFreezes = ConstU32<0>;
271	type DoneSlashHandler = ();
272}
273
274parameter_types! {
275	/// Relay Chain `TransactionByteFee` / 10
276	pub const TransactionByteFee: Balance = MILLICENTS;
277}
278
279impl pallet_transaction_payment::Config for Runtime {
280	type RuntimeEvent = RuntimeEvent;
281	type OnChargeTransaction =
282		pallet_transaction_payment::FungibleAdapter<Balances, DealWithFees<Runtime>>;
283	type OperationalFeeMultiplier = ConstU8<5>;
284	type WeightToFee = WeightToFee;
285	type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;
286	type FeeMultiplierUpdate = SlowAdjustingFeeUpdate<Self>;
287	type WeightInfo = weights::pallet_transaction_payment::WeightInfo<Runtime>;
288}
289
290parameter_types! {
291	pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(4);
292	pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(4);
293	pub const RelayOrigin: AggregateMessageOrigin = AggregateMessageOrigin::Parent;
294}
295
296impl cumulus_pallet_parachain_system::Config for Runtime {
297	type WeightInfo = weights::cumulus_pallet_parachain_system::WeightInfo<Runtime>;
298	type RuntimeEvent = RuntimeEvent;
299	type OnSystemEvent = ();
300	type SelfParaId = parachain_info::Pallet<Runtime>;
301	type DmpQueue = frame_support::traits::EnqueueWithOrigin<MessageQueue, RelayOrigin>;
302	type OutboundXcmpMessageSource = XcmpQueue;
303	type ReservedDmpWeight = ReservedDmpWeight;
304	type XcmpMessageHandler = XcmpQueue;
305	type ReservedXcmpWeight = ReservedXcmpWeight;
306	type CheckAssociatedRelayNumber = RelayNumberMonotonicallyIncreases;
307	type ConsensusHook = ConsensusHook;
308	type SelectCore = cumulus_pallet_parachain_system::DefaultCoreSelector<Runtime>;
309	type RelayParentOffset = ConstU32<0>;
310}
311
312type ConsensusHook = cumulus_pallet_aura_ext::FixedVelocityConsensusHook<
313	Runtime,
314	RELAY_CHAIN_SLOT_DURATION_MILLIS,
315	BLOCK_PROCESSING_VELOCITY,
316	UNINCLUDED_SEGMENT_CAPACITY,
317>;
318
319parameter_types! {
320	pub MessageQueueServiceWeight: Weight = Perbill::from_percent(35) * RuntimeBlockWeights::get().max_block;
321}
322
323impl pallet_message_queue::Config for Runtime {
324	type RuntimeEvent = RuntimeEvent;
325	type WeightInfo = weights::pallet_message_queue::WeightInfo<Runtime>;
326	#[cfg(feature = "runtime-benchmarks")]
327	type MessageProcessor = pallet_message_queue::mock_helpers::NoopMessageProcessor<
328		cumulus_primitives_core::AggregateMessageOrigin,
329	>;
330	#[cfg(not(feature = "runtime-benchmarks"))]
331	type MessageProcessor = xcm_builder::ProcessXcmMessage<
332		AggregateMessageOrigin,
333		xcm_executor::XcmExecutor<xcm_config::XcmConfig>,
334		RuntimeCall,
335	>;
336	type Size = u32;
337	// The XCMP queue pallet is only ever able to handle the `Sibling(ParaId)` origin:
338	type QueueChangeHandler = NarrowOriginToSibling<XcmpQueue>;
339	type QueuePausedQuery = NarrowOriginToSibling<XcmpQueue>;
340	type HeapSize = sp_core::ConstU32<{ 103 * 1024 }>;
341	type MaxStale = sp_core::ConstU32<8>;
342	type ServiceWeight = MessageQueueServiceWeight;
343	type IdleMaxServiceWeight = MessageQueueServiceWeight;
344}
345
346impl parachain_info::Config for Runtime {}
347
348impl cumulus_pallet_aura_ext::Config for Runtime {}
349
350parameter_types! {
351	/// Fellows pluralistic body.
352	pub const FellowsBodyId: BodyId = BodyId::Technical;
353}
354
355/// Privileged origin that represents Root or Fellows pluralistic body.
356pub type RootOrFellows = EitherOfDiverse<
357	EnsureRoot<AccountId>,
358	EnsureXcm<IsVoiceOfBody<FellowshipLocation, FellowsBodyId>>,
359>;
360
361parameter_types! {
362	/// The asset ID for the asset that we use to pay for message delivery fees.
363	pub FeeAssetId: AssetId = AssetId(TokenRelayLocation::get());
364	/// The base fee for the message delivery fees.
365	pub const BaseDeliveryFee: u128 = CENTS.saturating_mul(3);
366}
367
368pub type PriceForSiblingParachainDelivery = polkadot_runtime_common::xcm_sender::ExponentialPrice<
369	FeeAssetId,
370	BaseDeliveryFee,
371	TransactionByteFee,
372	XcmpQueue,
373>;
374
375impl cumulus_pallet_xcmp_queue::Config for Runtime {
376	type RuntimeEvent = RuntimeEvent;
377	type ChannelInfo = ParachainSystem;
378	type VersionWrapper = PolkadotXcm;
379	type XcmpQueue = TransformOrigin<MessageQueue, AggregateMessageOrigin, ParaId, ParaIdToSibling>;
380	type MaxInboundSuspended = ConstU32<1_000>;
381	type MaxActiveOutboundChannels = ConstU32<128>;
382	// Most on-chain HRMP channels are configured to use 102400 bytes of max message size, so we
383	// need to set the page size larger than that until we reduce the channel size on-chain.
384	type MaxPageSize = ConstU32<{ 103 * 1024 }>;
385	type ControllerOrigin = RootOrFellows;
386	type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;
387	type WeightInfo = weights::cumulus_pallet_xcmp_queue::WeightInfo<Runtime>;
388	type PriceForSiblingDelivery = PriceForSiblingParachainDelivery;
389}
390
391impl cumulus_pallet_xcmp_queue::migration::v5::V5Config for Runtime {
392	// This must be the same as the `ChannelInfo` from the `Config`:
393	type ChannelList = ParachainSystem;
394}
395
396pub const PERIOD: u32 = 6 * HOURS;
397pub const OFFSET: u32 = 0;
398
399impl pallet_session::Config for Runtime {
400	type RuntimeEvent = RuntimeEvent;
401	type ValidatorId = <Self as frame_system::Config>::AccountId;
402	// we don't have stash and controller, thus we don't need the convert as well.
403	type ValidatorIdOf = pallet_collator_selection::IdentityCollator;
404	type ShouldEndSession = pallet_session::PeriodicSessions<ConstU32<PERIOD>, ConstU32<OFFSET>>;
405	type NextSessionRotation = pallet_session::PeriodicSessions<ConstU32<PERIOD>, ConstU32<OFFSET>>;
406	type SessionManager = CollatorSelection;
407	// Essentially just Aura, but let's be pedantic.
408	type SessionHandler = <SessionKeys as sp_runtime::traits::OpaqueKeys>::KeyTypeIdProviders;
409	type Keys = SessionKeys;
410	type DisablingStrategy = ();
411	type WeightInfo = weights::pallet_session::WeightInfo<Runtime>;
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 get_asset() -> Asset {
1059					Asset {
1060						id: AssetId(Location::parent()),
1061						fun: Fungible(ExistentialDeposit::get()),
1062					}
1063				}
1064			}
1065
1066			parameter_types! {
1067				pub ExistentialDepositAsset: Option<Asset> = Some((
1068					TokenRelayLocation::get(),
1069					ExistentialDeposit::get()
1070				).into());
1071			}
1072
1073			impl pallet_xcm_benchmarks::Config for Runtime {
1074				type XcmConfig = xcm_config::XcmConfig;
1075
1076				type DeliveryHelper = (
1077					cumulus_primitives_utility::ToParentDeliveryHelper<
1078						xcm_config::XcmConfig,
1079						ExistentialDepositAsset,
1080						xcm_config::PriceForParentDelivery,
1081					>,
1082					polkadot_runtime_common::xcm_sender::ToParachainDeliveryHelper<
1083						xcm_config::XcmConfig,
1084						ExistentialDepositAsset,
1085						PriceForSiblingParachainDelivery,
1086						RandomParaId,
1087						ParachainSystem,
1088					>
1089				);
1090
1091				type AccountIdConverter = xcm_config::LocationToAccountId;
1092				fn valid_destination() -> Result<Location, BenchmarkError> {
1093					Ok(TokenRelayLocation::get())
1094				}
1095				fn worst_case_holding(_depositable_count: u32) -> Assets {
1096					// just concrete assets according to relay chain.
1097					let assets: Vec<Asset> = vec![
1098						Asset {
1099							id: AssetId(TokenRelayLocation::get()),
1100							fun: Fungible(1_000_000 * UNITS),
1101						}
1102					];
1103					assets.into()
1104				}
1105			}
1106
1107			parameter_types! {
1108				pub const TrustedTeleporter: Option<(Location, Asset)> = Some((
1109					TokenRelayLocation::get(),
1110					Asset { fun: Fungible(UNITS), id: AssetId(TokenRelayLocation::get()) },
1111				));
1112				pub const CheckedAccount: Option<(AccountId, xcm_builder::MintLocation)> = None;
1113				pub const TrustedReserve: Option<(Location, Asset)> = None;
1114			}
1115
1116			impl pallet_xcm_benchmarks::fungible::Config for Runtime {
1117				type TransactAsset = Balances;
1118
1119				type CheckedAccount = CheckedAccount;
1120				type TrustedTeleporter = TrustedTeleporter;
1121				type TrustedReserve = TrustedReserve;
1122
1123				fn get_asset() -> Asset {
1124					Asset {
1125						id: AssetId(TokenRelayLocation::get()),
1126						fun: Fungible(UNITS),
1127					}
1128				}
1129			}
1130
1131			impl pallet_xcm_benchmarks::generic::Config for Runtime {
1132				type RuntimeCall = RuntimeCall;
1133				type TransactAsset = Balances;
1134
1135				fn worst_case_response() -> (u64, Response) {
1136					(0u64, Response::Version(Default::default()))
1137				}
1138
1139				fn worst_case_asset_exchange() -> Result<(Assets, Assets), BenchmarkError> {
1140					Err(BenchmarkError::Skip)
1141				}
1142
1143				fn universal_alias() -> Result<(Location, Junction), BenchmarkError> {
1144					Err(BenchmarkError::Skip)
1145				}
1146
1147				fn transact_origin_and_runtime_call() -> Result<(Location, RuntimeCall), BenchmarkError> {
1148					Ok((TokenRelayLocation::get(), frame_system::Call::remark_with_event { remark: vec![] }.into()))
1149				}
1150
1151				fn subscribe_origin() -> Result<Location, BenchmarkError> {
1152					Ok(TokenRelayLocation::get())
1153				}
1154
1155				fn claimable_asset() -> Result<(Location, Location, Assets), BenchmarkError> {
1156					let origin = TokenRelayLocation::get();
1157					let assets: Assets = (AssetId(TokenRelayLocation::get()), 1_000 * UNITS).into();
1158					let ticket = Location { parents: 0, interior: Here };
1159					Ok((origin, ticket, assets))
1160				}
1161
1162				fn worst_case_for_trader() -> Result<(Asset, WeightLimit), BenchmarkError> {
1163					Ok((Asset {
1164						id: AssetId(TokenRelayLocation::get()),
1165						fun: Fungible(1_000_000 * UNITS),
1166					}, WeightLimit::Limited(Weight::from_parts(5000, 5000))))
1167				}
1168
1169				fn unlockable_asset() -> Result<(Location, Location, Asset), BenchmarkError> {
1170					Err(BenchmarkError::Skip)
1171				}
1172
1173				fn export_message_origin_and_destination(
1174				) -> Result<(Location, NetworkId, InteriorLocation), BenchmarkError> {
1175					Err(BenchmarkError::Skip)
1176				}
1177
1178				fn alias_origin() -> Result<(Location, Location), BenchmarkError> {
1179					let origin = Location::new(1, [Parachain(1000)]);
1180					let target = Location::new(1, [Parachain(1000), AccountId32 { id: [128u8; 32], network: None }]);
1181					Ok((origin, target))
1182				}
1183			}
1184
1185			type XcmBalances = pallet_xcm_benchmarks::fungible::Pallet::<Runtime>;
1186			type XcmGeneric = pallet_xcm_benchmarks::generic::Pallet::<Runtime>;
1187
1188			use frame_support::traits::WhitelistedStorageKeys;
1189			let whitelist: Vec<TrackedStorageKey> = AllPalletsWithSystem::whitelisted_storage_keys();
1190
1191			let mut batches = Vec::<BenchmarkBatch>::new();
1192			let params = (&config, &whitelist);
1193			add_benchmarks!(params, batches);
1194
1195			Ok(batches)
1196		}
1197	}
1198
1199	impl sp_genesis_builder::GenesisBuilder<Block> for Runtime {
1200		fn build_state(config: Vec<u8>) -> sp_genesis_builder::Result {
1201			build_state::<RuntimeGenesisConfig>(config)
1202		}
1203
1204		fn get_preset(id: &Option<sp_genesis_builder::PresetId>) -> Option<Vec<u8>> {
1205			get_preset::<RuntimeGenesisConfig>(id, &genesis_config_presets::get_preset)
1206		}
1207
1208		fn preset_names() -> Vec<sp_genesis_builder::PresetId> {
1209			genesis_config_presets::preset_names()
1210		}
1211	}
1212}
1213
1214cumulus_pallet_parachain_system::register_validate_block! {
1215	Runtime = Runtime,
1216	BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,
1217}