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