Skip to main content

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