bridge_hub_rococo_runtime/
lib.rs

1// Copyright (C) Parity Technologies (UK) Ltd.
2// This file is part of Cumulus.
3// SPDX-License-Identifier: Apache-2.0
4
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8//
9// 	http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing, software
12// distributed under the License is distributed on an "AS IS" BASIS,
13// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14// See the License for the specific language governing permissions and
15// limitations under the License.
16
17//! # Bridge Hub Rococo Runtime
18//!
19//! This runtime currently supports bridging between:
20//! - Rococo <> Westend
21//! - Rococo <> Rococo Bulletin
22
23#![cfg_attr(not(feature = "std"), no_std)]
24// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256.
25#![recursion_limit = "256"]
26
27// Make the WASM binary available.
28#[cfg(feature = "std")]
29include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
30
31pub mod bridge_common_config;
32pub mod bridge_to_bulletin_config;
33pub mod bridge_to_ethereum_config;
34pub mod bridge_to_westend_config;
35mod genesis_config_presets;
36mod weights;
37pub mod xcm_config;
38
39extern crate alloc;
40
41use alloc::{vec, vec::Vec};
42use bridge_runtime_common::extensions::{
43	CheckAndBoostBridgeGrandpaTransactions, CheckAndBoostBridgeParachainsTransactions,
44};
45use cumulus_pallet_parachain_system::RelayNumberMonotonicallyIncreases;
46use pallet_bridge_messages::LaneIdOf;
47use sp_api::impl_runtime_apis;
48use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
49use sp_runtime::{
50	generic, impl_opaque_keys,
51	traits::Block as BlockT,
52	transaction_validity::{TransactionSource, TransactionValidity},
53	ApplyExtrinsicResult,
54};
55
56#[cfg(feature = "std")]
57use sp_version::NativeVersion;
58use sp_version::RuntimeVersion;
59
60use cumulus_primitives_core::{ClaimQueueOffset, CoreSelector, ParaId};
61use frame_support::{
62	construct_runtime, derive_impl,
63	dispatch::DispatchClass,
64	genesis_builder_helper::{build_state, get_preset},
65	parameter_types,
66	traits::{ConstBool, ConstU32, ConstU64, ConstU8, Get, TransformOrigin},
67	weights::{ConstantMultiplier, Weight, WeightToFee as _},
68	PalletId,
69};
70use frame_system::{
71	limits::{BlockLength, BlockWeights},
72	EnsureRoot,
73};
74use testnet_parachains_constants::rococo::{consensus::*, currency::*, fee::WeightToFee, time::*};
75
76use bp_runtime::HeaderId;
77use bridge_hub_common::{
78	message_queue::{NarrowOriginToSibling, ParaIdToSibling},
79	AggregateMessageOrigin,
80};
81pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;
82pub use sp_runtime::{MultiAddress, Perbill, Permill};
83
84#[cfg(feature = "runtime-benchmarks")]
85use xcm::latest::WESTEND_GENESIS_HASH;
86use xcm::VersionedLocation;
87use xcm_config::{TreasuryAccount, XcmOriginToTransactDispatchOrigin, XcmRouter};
88
89#[cfg(any(feature = "std", test))]
90pub use sp_runtime::BuildStorage;
91
92use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate};
93use rococo_runtime_constants::system_parachain::{ASSET_HUB_ID, BRIDGE_HUB_ID};
94use snowbridge_core::{AgentId, PricingParameters};
95pub use snowbridge_outbound_queue_primitives::v1::{Command, ConstantGasMeter, Fee};
96use xcm::{latest::prelude::*, prelude::*, Version as XcmVersion};
97use xcm_runtime_apis::{
98	dry_run::{CallDryRunEffects, Error as XcmDryRunApiError, XcmDryRunEffects},
99	fees::Error as XcmPaymentApiError,
100};
101
102use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight};
103
104use parachains_common::{
105	impls::DealWithFees, AccountId, Balance, BlockNumber, Hash, Header, Nonce, Signature,
106	AVERAGE_ON_INITIALIZE_RATIO, NORMAL_DISPATCH_RATIO,
107};
108
109#[cfg(feature = "runtime-benchmarks")]
110use alloc::boxed::Box;
111
112/// The address format for describing accounts.
113pub type Address = MultiAddress<AccountId, ()>;
114
115/// Block type as expected by this runtime.
116pub type Block = generic::Block<Header, UncheckedExtrinsic>;
117
118/// A Block signed with a Justification
119pub type SignedBlock = generic::SignedBlock<Block>;
120
121/// BlockId type as expected by this runtime.
122pub type BlockId = generic::BlockId<Block>;
123
124/// The TransactionExtension to the basic transaction logic.
125pub type TxExtension = cumulus_pallet_weight_reclaim::StorageWeightReclaim<
126	Runtime,
127	(
128		frame_system::CheckNonZeroSender<Runtime>,
129		frame_system::CheckSpecVersion<Runtime>,
130		frame_system::CheckTxVersion<Runtime>,
131		frame_system::CheckGenesis<Runtime>,
132		frame_system::CheckEra<Runtime>,
133		frame_system::CheckNonce<Runtime>,
134		frame_system::CheckWeight<Runtime>,
135		pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
136		BridgeRejectObsoleteHeadersAndMessages,
137		(bridge_to_westend_config::OnBridgeHubRococoRefundBridgeHubWestendMessages,),
138		frame_metadata_hash_extension::CheckMetadataHash<Runtime>,
139	),
140>;
141
142/// Unchecked extrinsic type as expected by this runtime.
143pub type UncheckedExtrinsic =
144	generic::UncheckedExtrinsic<Address, RuntimeCall, Signature, TxExtension>;
145
146/// Migrations to apply on runtime upgrade.
147pub type Migrations = (
148	pallet_collator_selection::migration::v2::MigrationToV2<Runtime>,
149	pallet_multisig::migrations::v1::MigrateToV1<Runtime>,
150	InitStorageVersions,
151	// unreleased
152	cumulus_pallet_xcmp_queue::migration::v4::MigrationToV4<Runtime>,
153	cumulus_pallet_xcmp_queue::migration::v5::MigrateV4ToV5<Runtime>,
154	snowbridge_pallet_system::migration::v0::InitializeOnUpgrade<
155		Runtime,
156		ConstU32<BRIDGE_HUB_ID>,
157		ConstU32<ASSET_HUB_ID>,
158	>,
159	snowbridge_pallet_system::migration::FeePerGasMigrationV0ToV1<Runtime>,
160	pallet_bridge_messages::migration::v1::MigrationToV1<
161		Runtime,
162		bridge_to_westend_config::WithBridgeHubWestendMessagesInstance,
163	>,
164	pallet_bridge_messages::migration::v1::MigrationToV1<
165		Runtime,
166		bridge_to_bulletin_config::WithRococoBulletinMessagesInstance,
167	>,
168	bridge_to_westend_config::migration::FixMessagesV1Migration<
169		Runtime,
170		bridge_to_westend_config::WithBridgeHubWestendMessagesInstance,
171	>,
172	bridge_to_westend_config::migration::StaticToDynamicLanes,
173	frame_support::migrations::RemoveStorage<
174		BridgeWestendMessagesPalletName,
175		OutboundLanesCongestedSignalsKey,
176		RocksDbWeight,
177	>,
178	frame_support::migrations::RemoveStorage<
179		BridgePolkadotBulletinMessagesPalletName,
180		OutboundLanesCongestedSignalsKey,
181		RocksDbWeight,
182	>,
183	pallet_bridge_relayers::migration::v1::MigrationToV1<
184		Runtime,
185		bridge_common_config::RelayersForLegacyLaneIdsMessagesInstance,
186		bp_messages::LegacyLaneId,
187	>,
188	pallet_session::migrations::v1::MigrateV0ToV1<
189		Runtime,
190		pallet_session::migrations::v1::InitOffenceSeverity<Runtime>,
191	>,
192	// permanent
193	pallet_xcm::migration::MigrateToLatestXcmVersion<Runtime>,
194	cumulus_pallet_aura_ext::migration::MigrateV0ToV1<Runtime>,
195);
196
197parameter_types! {
198	pub const BridgeWestendMessagesPalletName: &'static str = "BridgeWestendMessages";
199	pub const BridgePolkadotBulletinMessagesPalletName: &'static str = "BridgePolkadotBulletinMessages";
200	pub const OutboundLanesCongestedSignalsKey: &'static str = "OutboundLanesCongestedSignals";
201}
202
203/// Migration to initialize storage versions for pallets added after genesis.
204///
205/// Ideally this would be done automatically (see
206/// <https://github.com/paritytech/polkadot-sdk/pull/1297>), but it probably won't be ready for some
207/// time and it's beneficial to get try-runtime-cli on-runtime-upgrade checks into the CI, so we're
208/// doing it manually.
209pub struct InitStorageVersions;
210
211impl frame_support::traits::OnRuntimeUpgrade for InitStorageVersions {
212	fn on_runtime_upgrade() -> Weight {
213		use frame_support::traits::{GetStorageVersion, StorageVersion};
214		use sp_runtime::traits::Saturating;
215
216		let mut writes = 0;
217
218		if PolkadotXcm::on_chain_storage_version() == StorageVersion::new(0) {
219			PolkadotXcm::in_code_storage_version().put::<PolkadotXcm>();
220			writes.saturating_inc();
221		}
222
223		if Balances::on_chain_storage_version() == StorageVersion::new(0) {
224			Balances::in_code_storage_version().put::<Balances>();
225			writes.saturating_inc();
226		}
227
228		<Runtime as frame_system::Config>::DbWeight::get().reads_writes(2, writes)
229	}
230}
231
232/// Executive: handles dispatch to the various modules.
233pub type Executive = frame_executive::Executive<
234	Runtime,
235	Block,
236	frame_system::ChainContext<Runtime>,
237	Runtime,
238	AllPalletsWithSystem,
239	Migrations,
240>;
241
242impl_opaque_keys! {
243	pub struct SessionKeys {
244		pub aura: Aura,
245	}
246}
247
248#[sp_version::runtime_version]
249pub const VERSION: RuntimeVersion = RuntimeVersion {
250	spec_name: alloc::borrow::Cow::Borrowed("bridge-hub-rococo"),
251	impl_name: alloc::borrow::Cow::Borrowed("bridge-hub-rococo"),
252	authoring_version: 1,
253	spec_version: 1_018_001,
254	impl_version: 0,
255	apis: RUNTIME_API_VERSIONS,
256	transaction_version: 6,
257	system_version: 1,
258};
259
260/// The version information used to identify this runtime when compiled natively.
261#[cfg(feature = "std")]
262pub fn native_version() -> NativeVersion {
263	NativeVersion { runtime_version: VERSION, can_author_with: Default::default() }
264}
265
266parameter_types! {
267	pub const Version: RuntimeVersion = VERSION;
268	pub RuntimeBlockLength: BlockLength =
269		BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);
270	pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()
271		.base_block(BlockExecutionWeight::get())
272		.for_class(DispatchClass::all(), |weights| {
273			weights.base_extrinsic = ExtrinsicBaseWeight::get();
274		})
275		.for_class(DispatchClass::Normal, |weights| {
276			weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);
277		})
278		.for_class(DispatchClass::Operational, |weights| {
279			weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);
280			// Operational transactions have some extra reserved space, so that they
281			// are included even if block reached `MAXIMUM_BLOCK_WEIGHT`.
282			weights.reserved = Some(
283				MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT
284			);
285		})
286		.avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)
287		.build_or_panic();
288	pub const SS58Prefix: u16 = 42;
289}
290
291// Configure FRAME pallets to include in runtime.
292
293#[derive_impl(frame_system::config_preludes::ParaChainDefaultConfig)]
294impl frame_system::Config for Runtime {
295	/// The identifier used to distinguish between accounts.
296	type AccountId = AccountId;
297	/// The index type for storing how many extrinsics an account has signed.
298	type Nonce = Nonce;
299	/// The type for hashing blocks and tries.
300	type Hash = Hash;
301	/// The block type.
302	type Block = Block;
303	/// Maximum number of block number to block hash mappings to keep (oldest pruned first).
304	type BlockHashCount = BlockHashCount;
305	/// Runtime version.
306	type Version = Version;
307	/// The data to be stored in an account.
308	type AccountData = pallet_balances::AccountData<Balance>;
309	/// The weight of database operations that the runtime can invoke.
310	type DbWeight = RocksDbWeight;
311	/// Weight information for the extrinsics of this pallet.
312	type SystemWeightInfo = weights::frame_system::WeightInfo<Runtime>;
313	/// Weight information for the extensions of this pallet.
314	type ExtensionsWeightInfo = weights::frame_system_extensions::WeightInfo<Runtime>;
315	/// Block & extrinsics weights: base values and limits.
316	type BlockWeights = RuntimeBlockWeights;
317	/// The maximum length of a block (in bytes).
318	type BlockLength = RuntimeBlockLength;
319	/// This is used as an identifier of the chain. 42 is the generic substrate prefix.
320	type SS58Prefix = SS58Prefix;
321	/// The action to take on a Runtime Upgrade
322	type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;
323	type MaxConsumers = frame_support::traits::ConstU32<16>;
324}
325
326impl cumulus_pallet_weight_reclaim::Config for Runtime {
327	type WeightInfo = weights::cumulus_pallet_weight_reclaim::WeightInfo<Runtime>;
328}
329
330impl pallet_timestamp::Config for Runtime {
331	/// A timestamp: milliseconds since the unix epoch.
332	type Moment = u64;
333	type OnTimestampSet = Aura;
334	type MinimumPeriod = ConstU64<0>;
335	type WeightInfo = weights::pallet_timestamp::WeightInfo<Runtime>;
336}
337
338impl pallet_authorship::Config for Runtime {
339	type FindAuthor = pallet_session::FindAccountFromAuthorIndex<Self, Aura>;
340	type EventHandler = (CollatorSelection,);
341}
342
343parameter_types! {
344	pub const ExistentialDeposit: Balance = EXISTENTIAL_DEPOSIT;
345}
346
347impl pallet_balances::Config for Runtime {
348	/// The type for recording an account's balance.
349	type Balance = Balance;
350	type DustRemoval = ();
351	/// The ubiquitous event type.
352	type RuntimeEvent = RuntimeEvent;
353	type ExistentialDeposit = ExistentialDeposit;
354	type AccountStore = System;
355	type WeightInfo = weights::pallet_balances::WeightInfo<Runtime>;
356	type MaxLocks = ConstU32<50>;
357	type MaxReserves = ConstU32<50>;
358	type ReserveIdentifier = [u8; 8];
359	type RuntimeHoldReason = RuntimeHoldReason;
360	type RuntimeFreezeReason = RuntimeFreezeReason;
361	type FreezeIdentifier = ();
362	type MaxFreezes = ConstU32<0>;
363	type DoneSlashHandler = ();
364}
365
366parameter_types! {
367	/// Relay Chain `TransactionByteFee` / 10
368	pub const TransactionByteFee: Balance = MILLICENTS;
369}
370
371impl pallet_transaction_payment::Config for Runtime {
372	type RuntimeEvent = RuntimeEvent;
373	type OnChargeTransaction =
374		pallet_transaction_payment::FungibleAdapter<Balances, DealWithFees<Runtime>>;
375	type OperationalFeeMultiplier = ConstU8<5>;
376	type WeightToFee = WeightToFee;
377	type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;
378	type FeeMultiplierUpdate = SlowAdjustingFeeUpdate<Self>;
379	type WeightInfo = weights::pallet_transaction_payment::WeightInfo<Runtime>;
380}
381
382parameter_types! {
383	pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(4);
384	pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(4);
385}
386
387impl cumulus_pallet_parachain_system::Config for Runtime {
388	type WeightInfo = weights::cumulus_pallet_parachain_system::WeightInfo<Runtime>;
389	type RuntimeEvent = RuntimeEvent;
390	type OnSystemEvent = ();
391	type SelfParaId = parachain_info::Pallet<Runtime>;
392	type OutboundXcmpMessageSource = XcmpQueue;
393	type DmpQueue = frame_support::traits::EnqueueWithOrigin<MessageQueue, RelayOrigin>;
394	type ReservedDmpWeight = ReservedDmpWeight;
395	type XcmpMessageHandler = XcmpQueue;
396	type ReservedXcmpWeight = ReservedXcmpWeight;
397	type CheckAssociatedRelayNumber = RelayNumberMonotonicallyIncreases;
398	type ConsensusHook = ConsensusHook;
399	type SelectCore = cumulus_pallet_parachain_system::DefaultCoreSelector<Runtime>;
400}
401
402type ConsensusHook = cumulus_pallet_aura_ext::FixedVelocityConsensusHook<
403	Runtime,
404	RELAY_CHAIN_SLOT_DURATION_MILLIS,
405	BLOCK_PROCESSING_VELOCITY,
406	UNINCLUDED_SEGMENT_CAPACITY,
407>;
408
409impl parachain_info::Config for Runtime {}
410
411parameter_types! {
412	/// Amount of weight that can be spent per block to service messages. This was increased
413	/// from 35% to 60% of the max block weight to accommodate the Ethereum beacon light client
414	/// extrinsics. The force_checkpoint and submit extrinsics (for submit, optionally) includes
415	/// the sync committee's pubkeys (512 x 48 bytes)
416	pub MessageQueueServiceWeight: Weight = Perbill::from_percent(60) * RuntimeBlockWeights::get().max_block;
417}
418
419impl pallet_message_queue::Config for Runtime {
420	type RuntimeEvent = RuntimeEvent;
421	type WeightInfo = weights::pallet_message_queue::WeightInfo<Runtime>;
422	// Use the NoopMessageProcessor exclusively for benchmarks, not for tests with the
423	// runtime-benchmarks feature as tests require the BridgeHubMessageRouter to process messages.
424	// The "test" feature flag doesn't work, hence the reliance on the "std" feature, which is
425	// enabled during tests.
426	#[cfg(all(not(feature = "std"), feature = "runtime-benchmarks"))]
427	type MessageProcessor =
428		pallet_message_queue::mock_helpers::NoopMessageProcessor<AggregateMessageOrigin>;
429	#[cfg(not(all(not(feature = "std"), feature = "runtime-benchmarks")))]
430	type MessageProcessor = bridge_hub_common::BridgeHubMessageRouter<
431		xcm_builder::ProcessXcmMessage<
432			AggregateMessageOrigin,
433			xcm_executor::XcmExecutor<xcm_config::XcmConfig>,
434			RuntimeCall,
435		>,
436		EthereumOutboundQueue,
437	>;
438	type Size = u32;
439	// The XCMP queue pallet is only ever able to handle the `Sibling(ParaId)` origin:
440	type QueueChangeHandler = NarrowOriginToSibling<XcmpQueue>;
441	type QueuePausedQuery = NarrowOriginToSibling<XcmpQueue>;
442	type HeapSize = sp_core::ConstU32<{ 103 * 1024 }>;
443	type MaxStale = sp_core::ConstU32<8>;
444	type ServiceWeight = MessageQueueServiceWeight;
445	type IdleMaxServiceWeight = MessageQueueServiceWeight;
446}
447
448impl cumulus_pallet_aura_ext::Config for Runtime {}
449
450parameter_types! {
451	/// The asset ID for the asset that we use to pay for message delivery fees.
452	pub FeeAssetId: AssetId = AssetId(xcm_config::TokenLocation::get());
453	/// The base fee for the message delivery fees.
454	pub const BaseDeliveryFee: u128 = CENTS.saturating_mul(3);
455}
456
457pub type PriceForSiblingParachainDelivery = polkadot_runtime_common::xcm_sender::ExponentialPrice<
458	FeeAssetId,
459	BaseDeliveryFee,
460	TransactionByteFee,
461	XcmpQueue,
462>;
463
464impl cumulus_pallet_xcmp_queue::Config for Runtime {
465	type RuntimeEvent = RuntimeEvent;
466	type ChannelInfo = ParachainSystem;
467	type VersionWrapper = PolkadotXcm;
468	// Enqueue XCMP messages from siblings for later processing.
469	type XcmpQueue = TransformOrigin<MessageQueue, AggregateMessageOrigin, ParaId, ParaIdToSibling>;
470	type MaxInboundSuspended = ConstU32<1_000>;
471	type MaxActiveOutboundChannels = ConstU32<128>;
472	// Most on-chain HRMP channels are configured to use 102400 bytes of max message size, so we
473	// need to set the page size larger than that until we reduce the channel size on-chain.
474	type MaxPageSize = ConstU32<{ 103 * 1024 }>;
475	type ControllerOrigin = EnsureRoot<AccountId>;
476	type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;
477	type WeightInfo = weights::cumulus_pallet_xcmp_queue::WeightInfo<Runtime>;
478	type PriceForSiblingDelivery = PriceForSiblingParachainDelivery;
479}
480
481impl cumulus_pallet_xcmp_queue::migration::v5::V5Config for Runtime {
482	// This must be the same as the `ChannelInfo` from the `Config`:
483	type ChannelList = ParachainSystem;
484}
485
486parameter_types! {
487	pub const RelayOrigin: AggregateMessageOrigin = AggregateMessageOrigin::Parent;
488}
489
490pub const PERIOD: u32 = 6 * HOURS;
491pub const OFFSET: u32 = 0;
492
493impl pallet_session::Config for Runtime {
494	type RuntimeEvent = RuntimeEvent;
495	type ValidatorId = <Self as frame_system::Config>::AccountId;
496	// we don't have stash and controller, thus we don't need the convert as well.
497	type ValidatorIdOf = pallet_collator_selection::IdentityCollator;
498	type ShouldEndSession = pallet_session::PeriodicSessions<ConstU32<PERIOD>, ConstU32<OFFSET>>;
499	type NextSessionRotation = pallet_session::PeriodicSessions<ConstU32<PERIOD>, ConstU32<OFFSET>>;
500	type SessionManager = CollatorSelection;
501	// Essentially just Aura, but let's be pedantic.
502	type SessionHandler = <SessionKeys as sp_runtime::traits::OpaqueKeys>::KeyTypeIdProviders;
503	type Keys = SessionKeys;
504	type DisablingStrategy = ();
505	type WeightInfo = weights::pallet_session::WeightInfo<Runtime>;
506}
507
508impl pallet_aura::Config for Runtime {
509	type AuthorityId = AuraId;
510	type DisabledValidators = ();
511	type MaxAuthorities = ConstU32<100_000>;
512	type AllowMultipleBlocksPerSlot = ConstBool<true>;
513	type SlotDuration = ConstU64<SLOT_DURATION>;
514}
515
516parameter_types! {
517	pub const PotId: PalletId = PalletId(*b"PotStake");
518	pub const SessionLength: BlockNumber = 6 * HOURS;
519}
520
521pub type CollatorSelectionUpdateOrigin = EnsureRoot<AccountId>;
522
523impl pallet_collator_selection::Config for Runtime {
524	type RuntimeEvent = RuntimeEvent;
525	type Currency = Balances;
526	type UpdateOrigin = CollatorSelectionUpdateOrigin;
527	type PotId = PotId;
528	type MaxCandidates = ConstU32<100>;
529	type MinEligibleCollators = ConstU32<4>;
530	type MaxInvulnerables = ConstU32<20>;
531	// should be a multiple of session or things will get inconsistent
532	type KickThreshold = ConstU32<PERIOD>;
533	type ValidatorId = <Self as frame_system::Config>::AccountId;
534	type ValidatorIdOf = pallet_collator_selection::IdentityCollator;
535	type ValidatorRegistration = Session;
536	type WeightInfo = weights::pallet_collator_selection::WeightInfo<Runtime>;
537}
538
539parameter_types! {
540	// One storage item; key size is 32; value is size 4+4+16+32 bytes = 56 bytes.
541	pub const DepositBase: Balance = deposit(1, 88);
542	// Additional storage item size of 32 bytes.
543	pub const DepositFactor: Balance = deposit(0, 32);
544}
545
546impl pallet_multisig::Config for Runtime {
547	type RuntimeEvent = RuntimeEvent;
548	type RuntimeCall = RuntimeCall;
549	type Currency = Balances;
550	type DepositBase = DepositBase;
551	type DepositFactor = DepositFactor;
552	type MaxSignatories = ConstU32<100>;
553	type WeightInfo = weights::pallet_multisig::WeightInfo<Runtime>;
554	type BlockNumberProvider = frame_system::Pallet<Runtime>;
555}
556
557impl pallet_utility::Config for Runtime {
558	type RuntimeEvent = RuntimeEvent;
559	type RuntimeCall = RuntimeCall;
560	type PalletsOrigin = OriginCaller;
561	type WeightInfo = weights::pallet_utility::WeightInfo<Runtime>;
562}
563
564// Create the runtime by composing the FRAME pallets that were previously configured.
565construct_runtime!(
566	pub enum Runtime
567	{
568		// System support stuff.
569		System: frame_system = 0,
570		ParachainSystem: cumulus_pallet_parachain_system = 1,
571		Timestamp: pallet_timestamp = 2,
572		ParachainInfo: parachain_info = 3,
573		WeightReclaim: cumulus_pallet_weight_reclaim = 4,
574
575		// Monetary stuff.
576		Balances: pallet_balances = 10,
577		TransactionPayment: pallet_transaction_payment = 11,
578
579		// Collator support. The order of these 4 are important and shall not change.
580		Authorship: pallet_authorship = 20,
581		CollatorSelection: pallet_collator_selection = 21,
582		Session: pallet_session = 22,
583		Aura: pallet_aura = 23,
584		AuraExt: cumulus_pallet_aura_ext = 24,
585
586		// XCM helpers.
587		XcmpQueue: cumulus_pallet_xcmp_queue = 30,
588		PolkadotXcm: pallet_xcm = 31,
589		CumulusXcm: cumulus_pallet_xcm = 32,
590
591		// Handy utilities.
592		Utility: pallet_utility = 40,
593		Multisig: pallet_multisig = 36,
594
595		// Bridge relayers pallet, used by several bridges here.
596		BridgeRelayers: pallet_bridge_relayers = 47,
597
598		// With-Westend GRANDPA bridge module.
599		BridgeWestendGrandpa: pallet_bridge_grandpa::<Instance3> = 48,
600		// With-Westend parachain bridge module.
601		BridgeWestendParachains: pallet_bridge_parachains::<Instance3> = 49,
602		// With-Westend messaging bridge module.
603		BridgeWestendMessages: pallet_bridge_messages::<Instance3> = 51,
604		// With-Westend bridge hub pallet.
605		XcmOverBridgeHubWestend: pallet_xcm_bridge_hub::<Instance1> = 52,
606
607		// With-Rococo Bulletin GRANDPA bridge module.
608		//
609		// we can't use `BridgeRococoBulletinGrandpa` name here, because the same Bulletin runtime
610		// will be used for both Rococo and Polkadot Bulletin chains AND this name affects runtime
611		// storage keys, used by the relayer process.
612		BridgePolkadotBulletinGrandpa: pallet_bridge_grandpa::<Instance4> = 60,
613		// With-Rococo Bulletin messaging bridge module.
614		//
615		// we can't use `BridgeRococoBulletinMessages` name here, because the same Bulletin runtime
616		// will be used for both Rococo and Polkadot Bulletin chains AND this name affects runtime
617		// storage keys, used by this runtime and the relayer process.
618		BridgePolkadotBulletinMessages: pallet_bridge_messages::<Instance4> = 61,
619		// With-Rococo Bulletin bridge hub pallet.
620		XcmOverPolkadotBulletin: pallet_xcm_bridge_hub::<Instance2> = 62,
621
622		// Bridge relayers pallet, used by several bridges here (another instance).
623		BridgeRelayersForPermissionlessLanes: pallet_bridge_relayers::<Instance2> = 63,
624
625		EthereumInboundQueue: snowbridge_pallet_inbound_queue = 80,
626		EthereumOutboundQueue: snowbridge_pallet_outbound_queue = 81,
627		EthereumBeaconClient: snowbridge_pallet_ethereum_client = 82,
628		EthereumSystem: snowbridge_pallet_system = 83,
629
630		// Message Queue. Importantly, is registered last so that messages are processed after
631		// the `on_initialize` hooks of bridging pallets.
632		MessageQueue: pallet_message_queue = 175,
633	}
634);
635
636/// Proper alias for bridge GRANDPA pallet used to bridge with the bulletin chain.
637pub type BridgeRococoBulletinGrandpa = BridgePolkadotBulletinGrandpa;
638/// Proper alias for bridge messages pallet used to bridge with the bulletin chain.
639pub type BridgeRococoBulletinMessages = BridgePolkadotBulletinMessages;
640/// Proper alias for bridge messages pallet used to bridge with the bulletin chain.
641pub type XcmOverRococoBulletin = XcmOverPolkadotBulletin;
642
643bridge_runtime_common::generate_bridge_reject_obsolete_headers_and_messages! {
644	RuntimeCall, AccountId,
645	// Grandpa
646	CheckAndBoostBridgeGrandpaTransactions<
647		Runtime,
648		bridge_common_config::BridgeGrandpaWestendInstance,
649		bridge_to_westend_config::PriorityBoostPerRelayHeader,
650		xcm_config::TreasuryAccount,
651	>,
652	CheckAndBoostBridgeGrandpaTransactions<
653		Runtime,
654		bridge_common_config::BridgeGrandpaRococoBulletinInstance,
655		bridge_to_bulletin_config::PriorityBoostPerRelayHeader,
656		xcm_config::TreasuryAccount,
657	>,
658	// Parachains
659	CheckAndBoostBridgeParachainsTransactions<
660		Runtime,
661		bridge_common_config::BridgeParachainWestendInstance,
662		bp_bridge_hub_westend::BridgeHubWestend,
663		bridge_to_westend_config::PriorityBoostPerParachainHeader,
664		xcm_config::TreasuryAccount,
665	>,
666	// Messages
667	BridgeWestendMessages,
668	BridgeRococoBulletinMessages
669}
670
671#[cfg(feature = "runtime-benchmarks")]
672mod benches {
673	frame_benchmarking::define_benchmarks!(
674		[frame_system, SystemBench::<Runtime>]
675		[frame_system_extensions, SystemExtensionsBench::<Runtime>]
676		[pallet_balances, Balances]
677		[pallet_message_queue, MessageQueue]
678		[pallet_multisig, Multisig]
679		[pallet_session, SessionBench::<Runtime>]
680		[pallet_utility, Utility]
681		[pallet_timestamp, Timestamp]
682		[pallet_transaction_payment, TransactionPayment]
683		[pallet_collator_selection, CollatorSelection]
684		[cumulus_pallet_parachain_system, ParachainSystem]
685		[cumulus_pallet_xcmp_queue, XcmpQueue]
686		[cumulus_pallet_weight_reclaim, WeightReclaim]
687		// XCM
688		[pallet_xcm, PalletXcmExtrinsicsBenchmark::<Runtime>]
689		// NOTE: Make sure you point to the individual modules below.
690		[pallet_xcm_benchmarks::fungible, XcmBalances]
691		[pallet_xcm_benchmarks::generic, XcmGeneric]
692		// Bridge pallets
693		[pallet_bridge_grandpa, WestendFinality]
694		[pallet_bridge_parachains, WithinWestend]
695		[pallet_bridge_messages, RococoToWestend]
696		[pallet_bridge_messages, RococoToRococoBulletin]
697		[pallet_bridge_relayers, Legacy]
698		[pallet_bridge_relayers, PermissionlessLanes]
699		// Ethereum Bridge
700		[snowbridge_pallet_inbound_queue, EthereumInboundQueue]
701		[snowbridge_pallet_outbound_queue, EthereumOutboundQueue]
702		[snowbridge_pallet_system, EthereumSystem]
703		[snowbridge_pallet_ethereum_client, EthereumBeaconClient]
704	);
705}
706
707cumulus_pallet_parachain_system::register_validate_block! {
708	Runtime = Runtime,
709	BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,
710}
711
712impl_runtime_apis! {
713	impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {
714		fn slot_duration() -> sp_consensus_aura::SlotDuration {
715			sp_consensus_aura::SlotDuration::from_millis(SLOT_DURATION)
716		}
717
718		fn authorities() -> Vec<AuraId> {
719			pallet_aura::Authorities::<Runtime>::get().into_inner()
720		}
721	}
722
723	impl cumulus_primitives_aura::AuraUnincludedSegmentApi<Block> for Runtime {
724		fn can_build_upon(
725			included_hash: <Block as BlockT>::Hash,
726			slot: cumulus_primitives_aura::Slot,
727		) -> bool {
728			ConsensusHook::can_build_upon(included_hash, slot)
729		}
730	}
731
732	impl sp_api::Core<Block> for Runtime {
733		fn version() -> RuntimeVersion {
734			VERSION
735		}
736
737		fn execute_block(block: Block) {
738			Executive::execute_block(block)
739		}
740
741		fn initialize_block(header: &<Block as BlockT>::Header) -> sp_runtime::ExtrinsicInclusionMode {
742			Executive::initialize_block(header)
743		}
744	}
745
746	impl sp_api::Metadata<Block> for Runtime {
747		fn metadata() -> OpaqueMetadata {
748			OpaqueMetadata::new(Runtime::metadata().into())
749		}
750
751		fn metadata_at_version(version: u32) -> Option<OpaqueMetadata> {
752			Runtime::metadata_at_version(version)
753		}
754
755		fn metadata_versions() -> alloc::vec::Vec<u32> {
756			Runtime::metadata_versions()
757		}
758	}
759
760	impl sp_block_builder::BlockBuilder<Block> for Runtime {
761		fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {
762			Executive::apply_extrinsic(extrinsic)
763		}
764
765		fn finalize_block() -> <Block as BlockT>::Header {
766			Executive::finalize_block()
767		}
768
769		fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {
770			data.create_extrinsics()
771		}
772
773		fn check_inherents(
774			block: Block,
775			data: sp_inherents::InherentData,
776		) -> sp_inherents::CheckInherentsResult {
777			data.check_extrinsics(&block)
778		}
779	}
780
781	impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {
782		fn validate_transaction(
783			source: TransactionSource,
784			tx: <Block as BlockT>::Extrinsic,
785			block_hash: <Block as BlockT>::Hash,
786		) -> TransactionValidity {
787			Executive::validate_transaction(source, tx, block_hash)
788		}
789	}
790
791	impl sp_offchain::OffchainWorkerApi<Block> for Runtime {
792		fn offchain_worker(header: &<Block as BlockT>::Header) {
793			Executive::offchain_worker(header)
794		}
795	}
796
797	impl sp_session::SessionKeys<Block> for Runtime {
798		fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {
799			SessionKeys::generate(seed)
800		}
801
802		fn decode_session_keys(
803			encoded: Vec<u8>,
804		) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {
805			SessionKeys::decode_into_raw_public_keys(&encoded)
806		}
807	}
808
809	impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce> for Runtime {
810		fn account_nonce(account: AccountId) -> Nonce {
811			System::account_nonce(account)
812		}
813	}
814
815	impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {
816		fn query_info(
817			uxt: <Block as BlockT>::Extrinsic,
818			len: u32,
819		) -> pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo<Balance> {
820			TransactionPayment::query_info(uxt, len)
821		}
822		fn query_fee_details(
823			uxt: <Block as BlockT>::Extrinsic,
824			len: u32,
825		) -> pallet_transaction_payment::FeeDetails<Balance> {
826			TransactionPayment::query_fee_details(uxt, len)
827		}
828		fn query_weight_to_fee(weight: Weight) -> Balance {
829			TransactionPayment::weight_to_fee(weight)
830		}
831		fn query_length_to_fee(length: u32) -> Balance {
832			TransactionPayment::length_to_fee(length)
833		}
834	}
835
836	impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentCallApi<Block, Balance, RuntimeCall>
837		for Runtime
838	{
839		fn query_call_info(
840			call: RuntimeCall,
841			len: u32,
842		) -> pallet_transaction_payment::RuntimeDispatchInfo<Balance> {
843			TransactionPayment::query_call_info(call, len)
844		}
845		fn query_call_fee_details(
846			call: RuntimeCall,
847			len: u32,
848		) -> pallet_transaction_payment::FeeDetails<Balance> {
849			TransactionPayment::query_call_fee_details(call, len)
850		}
851		fn query_weight_to_fee(weight: Weight) -> Balance {
852			TransactionPayment::weight_to_fee(weight)
853		}
854		fn query_length_to_fee(length: u32) -> Balance {
855			TransactionPayment::length_to_fee(length)
856		}
857	}
858
859	impl xcm_runtime_apis::fees::XcmPaymentApi<Block> for Runtime {
860		fn query_acceptable_payment_assets(xcm_version: xcm::Version) -> Result<Vec<VersionedAssetId>, XcmPaymentApiError> {
861			let acceptable_assets = vec![AssetId(xcm_config::TokenLocation::get())];
862			PolkadotXcm::query_acceptable_payment_assets(xcm_version, acceptable_assets)
863		}
864
865		fn query_weight_to_asset_fee(weight: Weight, asset: VersionedAssetId) -> Result<u128, XcmPaymentApiError> {
866			let latest_asset_id: Result<AssetId, ()> = asset.clone().try_into();
867			match latest_asset_id {
868				Ok(asset_id) if asset_id.0 == xcm_config::TokenLocation::get() => {
869					// for native token
870					Ok(WeightToFee::weight_to_fee(&weight))
871				},
872				Ok(asset_id) => {
873					log::trace!(target: "xcm::xcm_runtime_apis", "query_weight_to_asset_fee - unhandled asset_id: {asset_id:?}!");
874					Err(XcmPaymentApiError::AssetNotFound)
875				},
876				Err(_) => {
877					log::trace!(target: "xcm::xcm_runtime_apis", "query_weight_to_asset_fee - failed to convert asset: {asset:?}!");
878					Err(XcmPaymentApiError::VersionedConversionFailed)
879				}
880			}
881		}
882
883		fn query_xcm_weight(message: VersionedXcm<()>) -> Result<Weight, XcmPaymentApiError> {
884			PolkadotXcm::query_xcm_weight(message)
885		}
886
887		fn query_delivery_fees(destination: VersionedLocation, message: VersionedXcm<()>) -> Result<VersionedAssets, XcmPaymentApiError> {
888			PolkadotXcm::query_delivery_fees(destination, message)
889		}
890	}
891
892	impl xcm_runtime_apis::dry_run::DryRunApi<Block, RuntimeCall, RuntimeEvent, OriginCaller> for Runtime {
893		fn dry_run_call(origin: OriginCaller, call: RuntimeCall, result_xcms_version: XcmVersion) -> Result<CallDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
894			PolkadotXcm::dry_run_call::<Runtime, xcm_config::XcmRouter, OriginCaller, RuntimeCall>(origin, call, result_xcms_version)
895		}
896
897		fn dry_run_xcm(origin_location: VersionedLocation, xcm: VersionedXcm<RuntimeCall>) -> Result<XcmDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
898			PolkadotXcm::dry_run_xcm::<Runtime, xcm_config::XcmRouter, RuntimeCall, xcm_config::XcmConfig>(origin_location, xcm)
899		}
900	}
901
902	impl xcm_runtime_apis::conversions::LocationToAccountApi<Block, AccountId> for Runtime {
903		fn convert_location(location: VersionedLocation) -> Result<
904			AccountId,
905			xcm_runtime_apis::conversions::Error
906		> {
907			xcm_runtime_apis::conversions::LocationToAccountHelper::<
908				AccountId,
909				xcm_config::LocationToAccountId,
910			>::convert_location(location)
911		}
912	}
913
914	impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {
915		fn collect_collation_info(header: &<Block as BlockT>::Header) -> cumulus_primitives_core::CollationInfo {
916			ParachainSystem::collect_collation_info(header)
917		}
918	}
919
920	impl cumulus_primitives_core::GetCoreSelectorApi<Block> for Runtime {
921		fn core_selector() -> (CoreSelector, ClaimQueueOffset) {
922			ParachainSystem::core_selector()
923		}
924	}
925
926	impl bp_westend::WestendFinalityApi<Block> for Runtime {
927		fn best_finalized() -> Option<HeaderId<bp_westend::Hash, bp_westend::BlockNumber>> {
928			BridgeWestendGrandpa::best_finalized()
929		}
930		fn free_headers_interval() -> Option<bp_westend::BlockNumber> {
931			<Runtime as pallet_bridge_grandpa::Config<
932				bridge_common_config::BridgeGrandpaWestendInstance
933			>>::FreeHeadersInterval::get()
934		}
935		fn synced_headers_grandpa_info(
936		) -> Vec<bp_header_chain::StoredHeaderGrandpaInfo<bp_westend::Header>> {
937			BridgeWestendGrandpa::synced_headers_grandpa_info()
938		}
939	}
940
941	impl bp_bridge_hub_westend::BridgeHubWestendFinalityApi<Block> for Runtime {
942		fn best_finalized() -> Option<HeaderId<Hash, BlockNumber>> {
943			BridgeWestendParachains::best_parachain_head_id::<
944				bp_bridge_hub_westend::BridgeHubWestend
945			>().unwrap_or(None)
946		}
947		fn free_headers_interval() -> Option<bp_bridge_hub_westend::BlockNumber> {
948			// "free interval" is not currently used for parachains
949			None
950		}
951	}
952
953	// This is exposed by BridgeHubRococo
954	impl bp_bridge_hub_westend::FromBridgeHubWestendInboundLaneApi<Block> for Runtime {
955		fn message_details(
956			lane: LaneIdOf<Runtime, bridge_to_westend_config::WithBridgeHubWestendMessagesInstance>,
957			messages: Vec<(bp_messages::MessagePayload, bp_messages::OutboundMessageDetails)>,
958		) -> Vec<bp_messages::InboundMessageDetails> {
959			bridge_runtime_common::messages_api::inbound_message_details::<
960				Runtime,
961				bridge_to_westend_config::WithBridgeHubWestendMessagesInstance,
962			>(lane, messages)
963		}
964	}
965
966	// This is exposed by BridgeHubRococo
967	impl bp_bridge_hub_westend::ToBridgeHubWestendOutboundLaneApi<Block> for Runtime {
968		fn message_details(
969			lane: LaneIdOf<Runtime, bridge_to_westend_config::WithBridgeHubWestendMessagesInstance>,
970			begin: bp_messages::MessageNonce,
971			end: bp_messages::MessageNonce,
972		) -> Vec<bp_messages::OutboundMessageDetails> {
973			bridge_runtime_common::messages_api::outbound_message_details::<
974				Runtime,
975				bridge_to_westend_config::WithBridgeHubWestendMessagesInstance,
976			>(lane, begin, end)
977		}
978	}
979
980	impl bp_polkadot_bulletin::PolkadotBulletinFinalityApi<Block> for Runtime {
981		fn best_finalized() -> Option<bp_runtime::HeaderId<bp_polkadot_bulletin::Hash, bp_polkadot_bulletin::BlockNumber>> {
982			BridgePolkadotBulletinGrandpa::best_finalized()
983		}
984
985		fn free_headers_interval() -> Option<bp_polkadot_bulletin::BlockNumber> {
986			<Runtime as pallet_bridge_grandpa::Config<
987				bridge_common_config::BridgeGrandpaRococoBulletinInstance
988			>>::FreeHeadersInterval::get()
989		}
990
991		fn synced_headers_grandpa_info(
992		) -> Vec<bp_header_chain::StoredHeaderGrandpaInfo<bp_polkadot_bulletin::Header>> {
993			BridgePolkadotBulletinGrandpa::synced_headers_grandpa_info()
994		}
995	}
996
997	impl bp_polkadot_bulletin::FromPolkadotBulletinInboundLaneApi<Block> for Runtime {
998		fn message_details(
999			lane: LaneIdOf<Runtime, bridge_to_bulletin_config::WithRococoBulletinMessagesInstance>,
1000			messages: Vec<(bp_messages::MessagePayload, bp_messages::OutboundMessageDetails)>,
1001		) -> Vec<bp_messages::InboundMessageDetails> {
1002			bridge_runtime_common::messages_api::inbound_message_details::<
1003				Runtime,
1004				bridge_to_bulletin_config::WithRococoBulletinMessagesInstance,
1005			>(lane, messages)
1006		}
1007	}
1008
1009	impl bp_polkadot_bulletin::ToPolkadotBulletinOutboundLaneApi<Block> for Runtime {
1010		fn message_details(
1011			lane: LaneIdOf<Runtime, bridge_to_bulletin_config::WithRococoBulletinMessagesInstance>,
1012			begin: bp_messages::MessageNonce,
1013			end: bp_messages::MessageNonce,
1014		) -> Vec<bp_messages::OutboundMessageDetails> {
1015			bridge_runtime_common::messages_api::outbound_message_details::<
1016				Runtime,
1017				bridge_to_bulletin_config::WithRococoBulletinMessagesInstance,
1018			>(lane, begin, end)
1019		}
1020	}
1021
1022	impl snowbridge_outbound_queue_runtime_api::OutboundQueueApi<Block, Balance> for Runtime {
1023		fn prove_message(leaf_index: u64) -> Option<snowbridge_merkle_tree::MerkleProof> {
1024			snowbridge_pallet_outbound_queue::api::prove_message::<Runtime>(leaf_index)
1025		}
1026
1027		fn calculate_fee(command: Command, parameters: Option<PricingParameters<Balance>>) -> Fee<Balance> {
1028			snowbridge_pallet_outbound_queue::api::calculate_fee::<Runtime>(command, parameters)
1029		}
1030	}
1031
1032	impl snowbridge_system_runtime_api::ControlApi<Block> for Runtime {
1033		fn agent_id(location: VersionedLocation) -> Option<AgentId> {
1034			snowbridge_pallet_system::api::agent_id::<Runtime>(location)
1035		}
1036	}
1037
1038	#[cfg(feature = "try-runtime")]
1039	impl frame_try_runtime::TryRuntime<Block> for Runtime {
1040		fn on_runtime_upgrade(checks: frame_try_runtime::UpgradeCheckSelect) -> (Weight, Weight) {
1041			let weight = Executive::try_runtime_upgrade(checks).unwrap();
1042			(weight, RuntimeBlockWeights::get().max_block)
1043		}
1044
1045		fn execute_block(
1046			block: Block,
1047			state_root_check: bool,
1048			signature_check: bool,
1049			select: frame_try_runtime::TryStateSelect,
1050		) -> Weight {
1051			// NOTE: intentional unwrap: we don't want to propagate the error backwards, and want to
1052			// have a backtrace here.
1053			Executive::try_execute_block(block, state_root_check, signature_check, select).unwrap()
1054		}
1055	}
1056
1057	#[cfg(feature = "runtime-benchmarks")]
1058	impl frame_benchmarking::Benchmark<Block> for Runtime {
1059		fn benchmark_metadata(extra: bool) -> (
1060			Vec<frame_benchmarking::BenchmarkList>,
1061			Vec<frame_support::traits::StorageInfo>,
1062		) {
1063			use frame_benchmarking::BenchmarkList;
1064			use frame_support::traits::StorageInfoTrait;
1065			use frame_system_benchmarking::Pallet as SystemBench;
1066			use frame_system_benchmarking::extensions::Pallet as SystemExtensionsBench;
1067			use cumulus_pallet_session_benchmarking::Pallet as SessionBench;
1068			use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsicsBenchmark;
1069
1070			// This is defined once again in dispatch_benchmark, because list_benchmarks!
1071			// and add_benchmarks! are macros exported by define_benchmarks! macros and those types
1072			// are referenced in that call.
1073			type XcmBalances = pallet_xcm_benchmarks::fungible::Pallet::<Runtime>;
1074			type XcmGeneric = pallet_xcm_benchmarks::generic::Pallet::<Runtime>;
1075
1076			use pallet_bridge_relayers::benchmarking::Pallet as BridgeRelayersBench;
1077			// Change weight file names.
1078			type WestendFinality = BridgeWestendGrandpa;
1079			type WithinWestend = pallet_bridge_parachains::benchmarking::Pallet::<Runtime, bridge_common_config::BridgeParachainWestendInstance>;
1080			type RococoToWestend = pallet_bridge_messages::benchmarking::Pallet ::<Runtime, bridge_to_westend_config::WithBridgeHubWestendMessagesInstance>;
1081			type RococoToRococoBulletin = pallet_bridge_messages::benchmarking::Pallet ::<Runtime, bridge_to_bulletin_config::WithRococoBulletinMessagesInstance>;
1082			type Legacy = BridgeRelayersBench::<Runtime, bridge_common_config::RelayersForLegacyLaneIdsMessagesInstance>;
1083			type PermissionlessLanes = BridgeRelayersBench::<Runtime, bridge_common_config::RelayersForPermissionlessLanesInstance>;
1084
1085			let mut list = Vec::<BenchmarkList>::new();
1086			list_benchmarks!(list, extra);
1087
1088			let storage_info = AllPalletsWithSystem::storage_info();
1089			(list, storage_info)
1090		}
1091
1092		#[allow(non_local_definitions)]
1093		fn dispatch_benchmark(
1094			config: frame_benchmarking::BenchmarkConfig
1095		) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, alloc::string::String> {
1096			use frame_benchmarking::{BenchmarkBatch, BenchmarkError};
1097			use sp_storage::TrackedStorageKey;
1098
1099			use frame_system_benchmarking::Pallet as SystemBench;
1100			use frame_system_benchmarking::extensions::Pallet as SystemExtensionsBench;
1101			impl frame_system_benchmarking::Config for Runtime {
1102				fn setup_set_code_requirements(code: &alloc::vec::Vec<u8>) -> Result<(), BenchmarkError> {
1103					ParachainSystem::initialize_for_set_code_benchmark(code.len() as u32);
1104					Ok(())
1105				}
1106
1107				fn verify_set_code() {
1108					System::assert_last_event(cumulus_pallet_parachain_system::Event::<Runtime>::ValidationFunctionStored.into());
1109				}
1110			}
1111
1112			use cumulus_pallet_session_benchmarking::Pallet as SessionBench;
1113			impl cumulus_pallet_session_benchmarking::Config for Runtime {}
1114
1115			use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsicsBenchmark;
1116			impl pallet_xcm::benchmarking::Config for Runtime {
1117				type DeliveryHelper = cumulus_primitives_utility::ToParentDeliveryHelper<
1118					xcm_config::XcmConfig,
1119					ExistentialDepositAsset,
1120					xcm_config::PriceForParentDelivery,
1121				>;
1122
1123				fn reachable_dest() -> Option<Location> {
1124					Some(Parent.into())
1125				}
1126
1127				fn teleportable_asset_and_dest() -> Option<(Asset, Location)> {
1128					// Relay/native token can be teleported between BH and Relay.
1129					Some((
1130						Asset {
1131							fun: Fungible(ExistentialDeposit::get()),
1132							id: AssetId(Parent.into())
1133						},
1134						Parent.into(),
1135					))
1136				}
1137
1138				fn reserve_transferable_asset_and_dest() -> Option<(Asset, Location)> {
1139					// Reserve transfers are disabled on BH.
1140					None
1141				}
1142
1143				fn set_up_complex_asset_transfer(
1144				) -> Option<(Assets, u32, Location, Box<dyn FnOnce()>)> {
1145					// BH only supports teleports to system parachain.
1146					// Relay/native token can be teleported between BH and Relay.
1147					let native_location = Parent.into();
1148					let dest = Parent.into();
1149					pallet_xcm::benchmarking::helpers::native_teleport_as_asset_transfer::<Runtime>(
1150						native_location,
1151						dest
1152					)
1153				}
1154
1155				fn get_asset() -> Asset {
1156					Asset {
1157						id: AssetId(Location::parent()),
1158						fun: Fungible(ExistentialDeposit::get()),
1159					}
1160				}
1161			}
1162
1163			use xcm::latest::prelude::*;
1164			use xcm_config::TokenLocation;
1165
1166			parameter_types! {
1167				pub ExistentialDepositAsset: Option<Asset> = Some((
1168					TokenLocation::get(),
1169					ExistentialDeposit::get()
1170				).into());
1171			}
1172
1173			impl pallet_xcm_benchmarks::Config for Runtime {
1174				type XcmConfig = xcm_config::XcmConfig;
1175				type AccountIdConverter = xcm_config::LocationToAccountId;
1176				type DeliveryHelper = cumulus_primitives_utility::ToParentDeliveryHelper<
1177					xcm_config::XcmConfig,
1178					ExistentialDepositAsset,
1179					xcm_config::PriceForParentDelivery,
1180				>;
1181				fn valid_destination() -> Result<Location, BenchmarkError> {
1182					Ok(TokenLocation::get())
1183				}
1184				fn worst_case_holding(_depositable_count: u32) -> Assets {
1185					// just concrete assets according to relay chain.
1186					let assets: Vec<Asset> = vec![
1187						Asset {
1188							id: AssetId(TokenLocation::get()),
1189							fun: Fungible(1_000_000 * UNITS),
1190						}
1191					];
1192					assets.into()
1193				}
1194			}
1195
1196			parameter_types! {
1197				pub const TrustedTeleporter: Option<(Location, Asset)> = Some((
1198					TokenLocation::get(),
1199					Asset { fun: Fungible(UNITS), id: AssetId(TokenLocation::get()) },
1200				));
1201				pub const CheckedAccount: Option<(AccountId, xcm_builder::MintLocation)> = None;
1202				pub const TrustedReserve: Option<(Location, Asset)> = None;
1203			}
1204
1205			impl pallet_xcm_benchmarks::fungible::Config for Runtime {
1206				type TransactAsset = Balances;
1207
1208				type CheckedAccount = CheckedAccount;
1209				type TrustedTeleporter = TrustedTeleporter;
1210				type TrustedReserve = TrustedReserve;
1211
1212				fn get_asset() -> Asset {
1213					Asset {
1214						id: AssetId(TokenLocation::get()),
1215						fun: Fungible(UNITS),
1216					}
1217				}
1218			}
1219
1220			impl pallet_xcm_benchmarks::generic::Config for Runtime {
1221				type TransactAsset = Balances;
1222				type RuntimeCall = RuntimeCall;
1223
1224				fn worst_case_response() -> (u64, Response) {
1225					(0u64, Response::Version(Default::default()))
1226				}
1227
1228				fn worst_case_asset_exchange() -> Result<(Assets, Assets), BenchmarkError> {
1229					Err(BenchmarkError::Skip)
1230				}
1231
1232				fn universal_alias() -> Result<(Location, Junction), BenchmarkError> {
1233					Err(BenchmarkError::Skip)
1234				}
1235
1236				fn transact_origin_and_runtime_call() -> Result<(Location, RuntimeCall), BenchmarkError> {
1237					Ok((TokenLocation::get(), frame_system::Call::remark_with_event { remark: vec![] }.into()))
1238				}
1239
1240				fn subscribe_origin() -> Result<Location, BenchmarkError> {
1241					Ok(TokenLocation::get())
1242				}
1243
1244				fn claimable_asset() -> Result<(Location, Location, Assets), BenchmarkError> {
1245					let origin = TokenLocation::get();
1246					let assets: Assets = (AssetId(TokenLocation::get()), 1_000 * UNITS).into();
1247					let ticket = Location { parents: 0, interior: Here };
1248					Ok((origin, ticket, assets))
1249				}
1250
1251				fn fee_asset() -> Result<Asset, BenchmarkError> {
1252					Ok(Asset {
1253						id: AssetId(TokenLocation::get()),
1254						fun: Fungible(1_000_000 * UNITS),
1255					})
1256				}
1257
1258				fn unlockable_asset() -> Result<(Location, Location, Asset), BenchmarkError> {
1259					Err(BenchmarkError::Skip)
1260				}
1261
1262				fn export_message_origin_and_destination(
1263				) -> Result<(Location, NetworkId, InteriorLocation), BenchmarkError> {
1264					// save XCM version for remote bridge hub
1265					let _ = PolkadotXcm::force_xcm_version(
1266						RuntimeOrigin::root(),
1267						Box::new(bridge_to_westend_config::BridgeHubWestendLocation::get()),
1268						XCM_VERSION,
1269					).map_err(|e| {
1270						log::error!(
1271							"Failed to dispatch `force_xcm_version({:?}, {:?}, {:?})`, error: {:?}",
1272							RuntimeOrigin::root(),
1273							bridge_to_westend_config::BridgeHubWestendLocation::get(),
1274							XCM_VERSION,
1275							e
1276						);
1277						BenchmarkError::Stop("XcmVersion was not stored!")
1278					})?;
1279
1280					let sibling_parachain_location = Location::new(1, [Parachain(5678)]);
1281
1282					// fund SA
1283					use frame_support::traits::fungible::Mutate;
1284					use xcm_executor::traits::ConvertLocation;
1285					frame_support::assert_ok!(
1286						Balances::mint_into(
1287							&xcm_config::LocationToAccountId::convert_location(&sibling_parachain_location).expect("valid AccountId"),
1288							bridge_to_westend_config::BridgeDeposit::get()
1289								.saturating_add(ExistentialDeposit::get())
1290								.saturating_add(UNITS * 5)
1291						)
1292					);
1293
1294					// open bridge
1295					let bridge_destination_universal_location: InteriorLocation = [GlobalConsensus(NetworkId::ByGenesis(WESTEND_GENESIS_HASH)), Parachain(8765)].into();
1296					let locations = XcmOverBridgeHubWestend::bridge_locations(
1297						sibling_parachain_location.clone(),
1298						bridge_destination_universal_location.clone(),
1299					)?;
1300					XcmOverBridgeHubWestend::do_open_bridge(
1301						locations,
1302						bp_messages::LegacyLaneId([1, 2, 3, 4]),
1303						true,
1304					).map_err(|e| {
1305						log::error!(
1306							"Failed to `XcmOverBridgeHubWestend::open_bridge`({:?}, {:?})`, error: {:?}",
1307							sibling_parachain_location,
1308							bridge_destination_universal_location,
1309							e
1310						);
1311						BenchmarkError::Stop("Bridge was not opened!")
1312					})?;
1313
1314					Ok(
1315						(
1316							sibling_parachain_location,
1317							NetworkId::ByGenesis(WESTEND_GENESIS_HASH),
1318							[Parachain(8765)].into()
1319						)
1320					)
1321				}
1322
1323				fn alias_origin() -> Result<(Location, Location), BenchmarkError> {
1324					Err(BenchmarkError::Skip)
1325				}
1326			}
1327
1328			type XcmBalances = pallet_xcm_benchmarks::fungible::Pallet::<Runtime>;
1329			type XcmGeneric = pallet_xcm_benchmarks::generic::Pallet::<Runtime>;
1330
1331			type WestendFinality = BridgeWestendGrandpa;
1332			type WithinWestend = pallet_bridge_parachains::benchmarking::Pallet::<Runtime, bridge_common_config::BridgeParachainWestendInstance>;
1333			type RococoToWestend = pallet_bridge_messages::benchmarking::Pallet ::<Runtime, bridge_to_westend_config::WithBridgeHubWestendMessagesInstance>;
1334			type RococoToRococoBulletin = pallet_bridge_messages::benchmarking::Pallet ::<Runtime, bridge_to_bulletin_config::WithRococoBulletinMessagesInstance>;
1335			type Legacy = BridgeRelayersBench::<Runtime, bridge_common_config::RelayersForLegacyLaneIdsMessagesInstance>;
1336			type PermissionlessLanes = BridgeRelayersBench::<Runtime, bridge_common_config::RelayersForPermissionlessLanesInstance>;
1337
1338			use bridge_runtime_common::messages_benchmarking::{
1339				prepare_message_delivery_proof_from_grandpa_chain,
1340				prepare_message_delivery_proof_from_parachain,
1341				prepare_message_proof_from_grandpa_chain,
1342				prepare_message_proof_from_parachain,
1343				generate_xcm_builder_bridge_message_sample,
1344			};
1345			use pallet_bridge_messages::benchmarking::{
1346				Config as BridgeMessagesConfig,
1347				MessageDeliveryProofParams,
1348				MessageProofParams,
1349			};
1350
1351			impl BridgeMessagesConfig<bridge_to_westend_config::WithBridgeHubWestendMessagesInstance> for Runtime {
1352				fn is_relayer_rewarded(relayer: &Self::AccountId) -> bool {
1353					let bench_lane_id = <Self as BridgeMessagesConfig<bridge_to_westend_config::WithBridgeHubWestendMessagesInstance>>::bench_lane_id();
1354					use bp_runtime::Chain;
1355					let bridged_chain_id =<Self as pallet_bridge_messages::Config<bridge_to_westend_config::WithBridgeHubWestendMessagesInstance>>::BridgedChain::ID;
1356					pallet_bridge_relayers::Pallet::<Runtime, bridge_common_config::RelayersForLegacyLaneIdsMessagesInstance>::relayer_reward(
1357						relayer,
1358						bp_relayers::RewardsAccountParams::new(
1359							bench_lane_id,
1360							bridged_chain_id,
1361							bp_relayers::RewardsAccountOwner::BridgedChain
1362						)
1363					).is_some()
1364				}
1365
1366				fn prepare_message_proof(
1367					params: MessageProofParams<LaneIdOf<Runtime, bridge_to_westend_config::WithBridgeHubWestendMessagesInstance>>,
1368				) -> (bridge_to_westend_config::FromWestendBridgeHubMessagesProof<bridge_to_westend_config::WithBridgeHubWestendMessagesInstance>, Weight) {
1369					use cumulus_primitives_core::XcmpMessageSource;
1370					assert!(XcmpQueue::take_outbound_messages(usize::MAX).is_empty());
1371					ParachainSystem::open_outbound_hrmp_channel_for_benchmarks_or_tests(42.into());
1372					let universal_source = bridge_to_westend_config::open_bridge_for_benchmarks::<
1373						Runtime,
1374						bridge_to_westend_config::XcmOverBridgeHubWestendInstance,
1375						xcm_config::LocationToAccountId,
1376					>(params.lane, 42);
1377					prepare_message_proof_from_parachain::<
1378						Runtime,
1379						bridge_common_config::BridgeGrandpaWestendInstance,
1380						bridge_to_westend_config::WithBridgeHubWestendMessagesInstance,
1381					>(params, generate_xcm_builder_bridge_message_sample(universal_source))
1382				}
1383
1384				fn prepare_message_delivery_proof(
1385					params: MessageDeliveryProofParams<AccountId, LaneIdOf<Runtime, bridge_to_westend_config::WithBridgeHubWestendMessagesInstance>>,
1386				) -> bridge_to_westend_config::ToWestendBridgeHubMessagesDeliveryProof<bridge_to_westend_config::WithBridgeHubWestendMessagesInstance> {
1387					let _ = bridge_to_westend_config::open_bridge_for_benchmarks::<
1388						Runtime,
1389						bridge_to_westend_config::XcmOverBridgeHubWestendInstance,
1390						xcm_config::LocationToAccountId,
1391					>(params.lane, 42);
1392					prepare_message_delivery_proof_from_parachain::<
1393						Runtime,
1394						bridge_common_config::BridgeGrandpaWestendInstance,
1395						bridge_to_westend_config::WithBridgeHubWestendMessagesInstance,
1396					>(params)
1397				}
1398
1399				fn is_message_successfully_dispatched(_nonce: bp_messages::MessageNonce) -> bool {
1400					use cumulus_primitives_core::XcmpMessageSource;
1401					!XcmpQueue::take_outbound_messages(usize::MAX).is_empty()
1402				}
1403			}
1404
1405			impl BridgeMessagesConfig<bridge_to_bulletin_config::WithRococoBulletinMessagesInstance> for Runtime {
1406				fn is_relayer_rewarded(_relayer: &Self::AccountId) -> bool {
1407					// we do not pay any rewards in this bridge
1408					true
1409				}
1410
1411				fn prepare_message_proof(
1412					params: MessageProofParams<LaneIdOf<Runtime, bridge_to_bulletin_config::WithRococoBulletinMessagesInstance>>,
1413				) -> (bridge_to_bulletin_config::FromRococoBulletinMessagesProof<bridge_to_bulletin_config::WithRococoBulletinMessagesInstance>, Weight) {
1414					use cumulus_primitives_core::XcmpMessageSource;
1415					assert!(XcmpQueue::take_outbound_messages(usize::MAX).is_empty());
1416					ParachainSystem::open_outbound_hrmp_channel_for_benchmarks_or_tests(42.into());
1417					let universal_source = bridge_to_bulletin_config::open_bridge_for_benchmarks::<
1418						Runtime,
1419						bridge_to_bulletin_config::XcmOverPolkadotBulletinInstance,
1420						xcm_config::LocationToAccountId,
1421					>(params.lane, 42);
1422					prepare_message_proof_from_grandpa_chain::<
1423						Runtime,
1424						bridge_common_config::BridgeGrandpaRococoBulletinInstance,
1425						bridge_to_bulletin_config::WithRococoBulletinMessagesInstance,
1426					>(params, generate_xcm_builder_bridge_message_sample(universal_source))
1427				}
1428
1429				fn prepare_message_delivery_proof(
1430					params: MessageDeliveryProofParams<AccountId, LaneIdOf<Runtime, bridge_to_bulletin_config::WithRococoBulletinMessagesInstance>>,
1431				) -> bridge_to_bulletin_config::ToRococoBulletinMessagesDeliveryProof<bridge_to_bulletin_config::WithRococoBulletinMessagesInstance> {
1432					let _ = bridge_to_bulletin_config::open_bridge_for_benchmarks::<
1433						Runtime,
1434						bridge_to_bulletin_config::XcmOverPolkadotBulletinInstance,
1435						xcm_config::LocationToAccountId,
1436					>(params.lane, 42);
1437					prepare_message_delivery_proof_from_grandpa_chain::<
1438						Runtime,
1439						bridge_common_config::BridgeGrandpaRococoBulletinInstance,
1440						bridge_to_bulletin_config::WithRococoBulletinMessagesInstance,
1441					>(params)
1442				}
1443
1444				fn is_message_successfully_dispatched(_nonce: bp_messages::MessageNonce) -> bool {
1445					use cumulus_primitives_core::XcmpMessageSource;
1446					!XcmpQueue::take_outbound_messages(usize::MAX).is_empty()
1447				}
1448			}
1449
1450			use bridge_runtime_common::parachains_benchmarking::prepare_parachain_heads_proof;
1451			use pallet_bridge_parachains::benchmarking::Config as BridgeParachainsConfig;
1452			use pallet_bridge_relayers::benchmarking::{
1453				Pallet as BridgeRelayersBench,
1454				Config as BridgeRelayersConfig,
1455			};
1456
1457			impl BridgeParachainsConfig<bridge_common_config::BridgeParachainWestendInstance> for Runtime {
1458				fn parachains() -> Vec<bp_polkadot_core::parachains::ParaId> {
1459					use bp_runtime::Parachain;
1460					vec![bp_polkadot_core::parachains::ParaId(bp_bridge_hub_westend::BridgeHubWestend::PARACHAIN_ID)]
1461				}
1462
1463				fn prepare_parachain_heads_proof(
1464					parachains: &[bp_polkadot_core::parachains::ParaId],
1465					parachain_head_size: u32,
1466					proof_params: bp_runtime::UnverifiedStorageProofParams,
1467				) -> (
1468					bp_parachains::RelayBlockNumber,
1469					bp_parachains::RelayBlockHash,
1470					bp_polkadot_core::parachains::ParaHeadsProof,
1471					Vec<(bp_polkadot_core::parachains::ParaId, bp_polkadot_core::parachains::ParaHash)>,
1472				) {
1473					prepare_parachain_heads_proof::<Runtime, bridge_common_config::BridgeParachainWestendInstance>(
1474						parachains,
1475						parachain_head_size,
1476						proof_params,
1477					)
1478				}
1479			}
1480
1481			impl BridgeRelayersConfig<bridge_common_config::RelayersForLegacyLaneIdsMessagesInstance> for Runtime {
1482				fn bench_reward() -> Self::Reward {
1483					bp_relayers::RewardsAccountParams::new(
1484						bp_messages::LegacyLaneId::default(),
1485						*b"test",
1486						bp_relayers::RewardsAccountOwner::ThisChain
1487					)
1488				}
1489
1490				fn prepare_rewards_account(
1491					reward_kind: Self::Reward,
1492					reward: Balance,
1493				) -> Option<AccountId> {
1494					let rewards_account = bp_relayers::PayRewardFromAccount::<
1495						Balances,
1496						AccountId,
1497						bp_messages::LegacyLaneId,
1498						Balance,
1499					>::rewards_account(reward_kind);
1500					<Runtime as BridgeRelayersConfig<bridge_common_config::RelayersForLegacyLaneIdsMessagesInstance>>::deposit_account(rewards_account, reward);
1501
1502					None
1503				}
1504
1505				fn deposit_account(account: AccountId, balance: Balance) {
1506					use frame_support::traits::fungible::Mutate;
1507					Balances::mint_into(&account, balance.saturating_add(ExistentialDeposit::get())).unwrap();
1508				}
1509			}
1510
1511			impl BridgeRelayersConfig<bridge_common_config::RelayersForPermissionlessLanesInstance> for Runtime {
1512				fn bench_reward() -> Self::Reward {
1513					bp_relayers::RewardsAccountParams::new(
1514						bp_messages::HashedLaneId::default(),
1515						*b"test",
1516						bp_relayers::RewardsAccountOwner::ThisChain
1517					)
1518				}
1519
1520				fn prepare_rewards_account(
1521					reward_kind: Self::Reward,
1522					reward: Balance,
1523				) -> Option<AccountId> {
1524					let rewards_account = bp_relayers::PayRewardFromAccount::<
1525						Balances,
1526						AccountId,
1527						bp_messages::HashedLaneId,
1528						Balance,
1529					>::rewards_account(reward_kind);
1530					<Runtime as BridgeRelayersConfig<bridge_common_config::RelayersForPermissionlessLanesInstance>>::deposit_account(rewards_account, reward);
1531
1532					None
1533				}
1534
1535				fn deposit_account(account: AccountId, balance: Balance) {
1536					use frame_support::traits::fungible::Mutate;
1537					Balances::mint_into(&account, balance.saturating_add(ExistentialDeposit::get())).unwrap();
1538				}
1539			}
1540
1541			use frame_support::traits::WhitelistedStorageKeys;
1542			let whitelist: Vec<TrackedStorageKey> = AllPalletsWithSystem::whitelisted_storage_keys();
1543
1544			let mut batches = Vec::<BenchmarkBatch>::new();
1545			let params = (&config, &whitelist);
1546			add_benchmarks!(params, batches);
1547
1548			Ok(batches)
1549		}
1550	}
1551
1552	impl sp_genesis_builder::GenesisBuilder<Block> for Runtime {
1553		fn build_state(config: Vec<u8>) -> sp_genesis_builder::Result {
1554			build_state::<RuntimeGenesisConfig>(config)
1555		}
1556
1557		fn get_preset(id: &Option<sp_genesis_builder::PresetId>) -> Option<Vec<u8>> {
1558			get_preset::<RuntimeGenesisConfig>(id, &genesis_config_presets::get_preset)
1559		}
1560
1561		fn preset_names() -> Vec<sp_genesis_builder::PresetId> {
1562			genesis_config_presets::preset_names()
1563		}
1564	}
1565
1566	impl xcm_runtime_apis::trusted_query::TrustedQueryApi<Block> for Runtime {
1567		fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult {
1568			PolkadotXcm::is_trusted_reserve(asset, location)
1569		}
1570		fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult {
1571			PolkadotXcm::is_trusted_teleporter(asset, location)
1572		}
1573	}
1574}
1575
1576#[cfg(test)]
1577mod tests {
1578	use super::*;
1579	use codec::Encode;
1580	use sp_runtime::{
1581		generic::Era,
1582		traits::{TransactionExtension, Zero},
1583	};
1584
1585	#[test]
1586	fn ensure_transaction_extension_definition_is_compatible_with_relay() {
1587		use bp_polkadot_core::SuffixedCommonTransactionExtensionExt;
1588
1589		sp_io::TestExternalities::default().execute_with(|| {
1590			frame_system::BlockHash::<Runtime>::insert(BlockNumber::zero(), Hash::default());
1591			let payload: TxExtension = (
1592				frame_system::CheckNonZeroSender::new(),
1593				frame_system::CheckSpecVersion::new(),
1594				frame_system::CheckTxVersion::new(),
1595				frame_system::CheckGenesis::new(),
1596				frame_system::CheckEra::from(Era::Immortal),
1597				frame_system::CheckNonce::from(10),
1598				frame_system::CheckWeight::new(),
1599				pallet_transaction_payment::ChargeTransactionPayment::from(10),
1600				BridgeRejectObsoleteHeadersAndMessages,
1601				(
1602					bridge_to_westend_config::OnBridgeHubRococoRefundBridgeHubWestendMessages::default(),
1603				),
1604				frame_metadata_hash_extension::CheckMetadataHash::new(false),
1605			).into();
1606
1607			// for BridgeHubRococo
1608			{
1609				let bhr_indirect_payload = bp_bridge_hub_rococo::TransactionExtension::from_params(
1610					VERSION.spec_version,
1611					VERSION.transaction_version,
1612					bp_runtime::TransactionEra::Immortal,
1613					System::block_hash(BlockNumber::zero()),
1614					10,
1615					10,
1616					(((), ()), ((), ())),
1617				);
1618				assert_eq!(payload.encode().split_last().unwrap().1, bhr_indirect_payload.encode());
1619				assert_eq!(
1620					TxExtension::implicit(&payload).unwrap().encode().split_last().unwrap().1,
1621					sp_runtime::traits::TransactionExtension::<RuntimeCall>::implicit(
1622						&bhr_indirect_payload
1623					)
1624					.unwrap()
1625					.encode()
1626				)
1627			}
1628		});
1629	}
1630}