Skip to main content

coretime_westend_runtime/
lib.rs

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