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