referrerpolicy=no-referrer-when-downgrade

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