diff --git a/Cargo.lock b/Cargo.lock
index 8b7d4020004c..da4cd0ff1eb5 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -855,6 +855,12 @@ dependencies = [
"bp-asset-hub-westend",
"bp-bridge-hub-rococo",
"bp-bridge-hub-westend",
+ "bp-header-chain 0.7.0",
+ "bp-messages 0.7.0",
+ "bp-runtime 0.7.0",
+ "bridge-hub-common 0.1.0",
+ "bridge-hub-test-utils 0.7.0",
+ "bridge-runtime-common 0.7.0",
"cumulus-pallet-aura-ext 0.7.0",
"cumulus-pallet-parachain-system 0.7.0",
"cumulus-pallet-session-benchmarking 9.0.0",
@@ -882,6 +888,8 @@ dependencies = [
"pallet-aura 27.0.0",
"pallet-authorship 28.0.0",
"pallet-balances 28.0.0",
+ "pallet-bridge-messages 0.7.0",
+ "pallet-bridge-relayers 0.7.0",
"pallet-collator-selection 9.0.0",
"pallet-message-queue 31.0.0",
"pallet-multisig 28.0.0",
@@ -897,6 +905,7 @@ dependencies = [
"pallet-utility 28.0.0",
"pallet-xcm 7.0.0",
"pallet-xcm-benchmarks 7.0.0",
+ "pallet-xcm-bridge-hub 0.2.0",
"pallet-xcm-bridge-hub-router 0.5.0",
"parachains-common 7.0.0",
"parachains-runtimes-test-utils 7.0.0",
@@ -1933,10 +1942,32 @@ dependencies = [
[[package]]
name = "bp-asset-hub-rococo"
version = "0.4.0"
+dependencies = [
+ "bp-bridge-hub-cumulus",
+ "bp-messages 0.7.0",
+ "bp-runtime 0.7.0",
+ "bp-xcm-bridge-hub 0.2.0",
+ "frame-support 28.0.0",
+ "parity-scale-codec",
+ "sp-api 26.0.0",
+ "sp-runtime 31.0.1",
+ "sp-std 14.0.0",
+]
[[package]]
name = "bp-asset-hub-westend"
version = "0.3.0"
+dependencies = [
+ "bp-bridge-hub-cumulus",
+ "bp-messages 0.7.0",
+ "bp-runtime 0.7.0",
+ "bp-xcm-bridge-hub 0.2.0",
+ "frame-support 28.0.0",
+ "parity-scale-codec",
+ "sp-api 26.0.0",
+ "sp-runtime 31.0.1",
+ "sp-std 14.0.0",
+]
[[package]]
name = "bp-beefy"
diff --git a/bridges/chains/chain-asset-hub-rococo/Cargo.toml b/bridges/chains/chain-asset-hub-rococo/Cargo.toml
index 7a83bba87481..ab5702c9e6f2 100644
--- a/bridges/chains/chain-asset-hub-rococo/Cargo.toml
+++ b/bridges/chains/chain-asset-hub-rococo/Cargo.toml
@@ -14,7 +14,30 @@ exclude-from-umbrella = true
workspace = true
[dependencies]
+codec = { features = ["derive"], workspace = true }
+
+# Bridge Dependencies
+bp-bridge-hub-cumulus = { workspace = true }
+bp-runtime = { workspace = true }
+bp-messages = { workspace = true }
+bp-xcm-bridge-hub = { workspace = true }
+
+# Substrate Based Dependencies
+frame-support = { workspace = true }
+sp-api = { workspace = true }
+sp-runtime = { workspace = true }
+sp-std = { workspace = true }
[features]
default = ["std"]
-std = []
+std = [
+ "bp-bridge-hub-cumulus/std",
+ "bp-messages/std",
+ "bp-runtime/std",
+ "bp-xcm-bridge-hub/std",
+ "codec/std",
+ "frame-support/std",
+ "sp-api/std",
+ "sp-runtime/std",
+ "sp-std/std",
+]
diff --git a/bridges/chains/chain-asset-hub-rococo/src/lib.rs b/bridges/chains/chain-asset-hub-rococo/src/lib.rs
index 3504be9bb0f8..3489a71b74c2 100644
--- a/bridges/chains/chain-asset-hub-rococo/src/lib.rs
+++ b/bridges/chains/chain-asset-hub-rococo/src/lib.rs
@@ -14,9 +14,114 @@
// You should have received a copy of the GNU General Public License
// along with Parity Bridges Common. If not, see .
-//! Module with configuration which reflects AssetHubRococo runtime setup.
+//! Module with configuration which reflects AssetHubRococo runtime setup (AccountId, Headers,
+//! Hashes...)
#![cfg_attr(not(feature = "std"), no_std)]
+pub use bp_bridge_hub_cumulus::*;
+use bp_messages::*;
+use bp_runtime::{
+ decl_bridge_finality_runtime_apis, decl_bridge_messages_runtime_apis, Chain, ChainId, Parachain,
+};
+use codec::{Decode, Encode};
+use frame_support::{
+ dispatch::DispatchClass,
+ sp_runtime::{MultiAddress, MultiSigner, RuntimeDebug, StateVersion},
+};
+
/// Identifier of AssetHubRococo in the Rococo relay chain.
pub const ASSET_HUB_ROCOCO_PARACHAIN_ID: u32 = 1000;
+
+/// AssetHubRococo parachain.
+#[derive(RuntimeDebug)]
+pub struct AssetHubRococo;
+
+impl Chain for AssetHubRococo {
+ const ID: ChainId = *b"ahro";
+
+ type BlockNumber = BlockNumber;
+ type Hash = Hash;
+ type Hasher = Hasher;
+ type Header = Header;
+
+ type AccountId = AccountId;
+ type Balance = Balance;
+ type Nonce = Nonce;
+ type Signature = Signature;
+
+ const STATE_VERSION: StateVersion = StateVersion::V1;
+
+ fn max_extrinsic_size() -> u32 {
+ *BlockLength::get().max.get(DispatchClass::Normal)
+ }
+
+ fn max_extrinsic_weight() -> Weight {
+ BlockWeightsForAsyncBacking::get()
+ .get(DispatchClass::Normal)
+ .max_extrinsic
+ .unwrap_or(Weight::MAX)
+ }
+}
+
+impl Parachain for AssetHubRococo {
+ const PARACHAIN_ID: u32 = ASSET_HUB_ROCOCO_PARACHAIN_ID;
+ const MAX_HEADER_SIZE: u32 = MAX_BRIDGE_HUB_HEADER_SIZE;
+}
+
+/// Describing permissionless lanes instance
+impl ChainWithMessages for AssetHubRococo {
+ const WITH_CHAIN_MESSAGES_PALLET_NAME: &'static str =
+ WITH_ASSET_HUB_ROCOCO_MESSAGES_PALLET_NAME;
+
+ const MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX: MessageNonce =
+ MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX;
+ const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce =
+ MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX;
+}
+
+/// Public key of the chain account that may be used to verify signatures.
+pub type AccountSigner = MultiSigner;
+
+/// The address format for describing accounts.
+pub type Address = MultiAddress;
+
+/// Identifier of AssetHubRococo in the Rococo relay chain.
+pub const BRIDGE_HUB_ROCOCO_PARACHAIN_ID: u32 = 1013;
+
+/// Name of the With-AssetHubRococo messages pallet instance that is deployed at bridged chains.
+pub const WITH_ASSET_HUB_ROCOCO_MESSAGES_PALLET_NAME: &str = "BridgeRococoMessages";
+
+/// Name of the With-AssetHubRococo bridge-relayers pallet instance that is deployed at bridged
+/// chains.
+pub const WITH_ASSET_HUB_ROCOCO_RELAYERS_PALLET_NAME: &str = "BridgeRelayers";
+
+/// Pallet index of `BridgeWestendMessages: pallet_bridge_messages::`.
+pub const WITH_BRIDGE_ROCOCO_TO_WESTEND_MESSAGES_PALLET_INDEX: u8 = 60;
+
+decl_bridge_finality_runtime_apis!(asset_hub_rococo);
+decl_bridge_messages_runtime_apis!(asset_hub_rococo, HashedLaneId);
+
+frame_support::parameter_types! {
+ /// TODO: FAIL-CI - probably not needed
+ /// The XCM fee that is paid for executing XCM program (with `ExportMessage` instruction) at the Rococo
+ /// BridgeHub.
+ /// (initially was calculated by test `AssetHubRococo::can_calculate_weight_for_paid_export_message_with_reserve_transfer` + `33%`)
+ pub const AssetHubRococoBaseXcmFeeInRocs: u128 = 57_325_000;
+
+ /// Transaction fee that is paid at the Rococo BridgeHub for delivering single inbound message.
+ /// (initially was calculated by test `AssetHubRococo::can_calculate_fee_for_standalone_message_delivery_transaction` + `33%`)
+ pub const AssetHubRococoBaseDeliveryFeeInRocs: u128 = 297_685_840;
+
+ /// Transaction fee that is paid at the Rococo BridgeHub for delivering single outbound message confirmation.
+ /// (initially was calculated by test `AssetHubRococo::can_calculate_fee_for_standalone_message_confirmation_transaction` + `33%`)
+ pub const AssetHubRococoBaseConfirmationFeeInRocs: u128 = 56_782_099;
+}
+
+/// Wrapper over `AssetHubRococo`'s `RuntimeCall` that can be used without a runtime.
+#[derive(Decode, Encode)]
+pub enum RuntimeCall {
+ /// Points to the `pallet_xcm_bridge_hub` pallet instance for `AssetHubWestend`.
+ #[codec(index = 62)]
+ XcmOverAssetHubWestend(bp_xcm_bridge_hub::XcmBridgeHubCall),
+}
diff --git a/bridges/chains/chain-asset-hub-westend/Cargo.toml b/bridges/chains/chain-asset-hub-westend/Cargo.toml
index ad8d2778a4bc..80c6c69d7aaa 100644
--- a/bridges/chains/chain-asset-hub-westend/Cargo.toml
+++ b/bridges/chains/chain-asset-hub-westend/Cargo.toml
@@ -14,7 +14,30 @@ exclude-from-umbrella = true
workspace = true
[dependencies]
+codec = { features = ["derive"], workspace = true }
+
+# Bridge Dependencies
+bp-bridge-hub-cumulus = { workspace = true }
+bp-runtime = { workspace = true }
+bp-messages = { workspace = true }
+bp-xcm-bridge-hub = { workspace = true }
+
+# Substrate Based Dependencies
+frame-support = { workspace = true }
+sp-api = { workspace = true }
+sp-runtime = { workspace = true }
+sp-std = { workspace = true }
[features]
default = ["std"]
-std = []
+std = [
+ "bp-bridge-hub-cumulus/std",
+ "bp-messages/std",
+ "bp-runtime/std",
+ "bp-xcm-bridge-hub/std",
+ "codec/std",
+ "frame-support/std",
+ "sp-api/std",
+ "sp-runtime/std",
+ "sp-std/std",
+]
diff --git a/bridges/chains/chain-asset-hub-westend/src/lib.rs b/bridges/chains/chain-asset-hub-westend/src/lib.rs
index c21bdff45934..54eda187179a 100644
--- a/bridges/chains/chain-asset-hub-westend/src/lib.rs
+++ b/bridges/chains/chain-asset-hub-westend/src/lib.rs
@@ -14,9 +14,111 @@
// You should have received a copy of the GNU General Public License
// along with Parity Bridges Common. If not, see .
-//! Module with configuration which reflects AssetHubWestend runtime setup.
+//! Module with configuration which reflects AssetHubWestend runtime setup (AccountId, Headers,
+//! Hashes...)
#![cfg_attr(not(feature = "std"), no_std)]
+pub use bp_bridge_hub_cumulus::*;
+use bp_messages::*;
+use bp_runtime::{
+ decl_bridge_finality_runtime_apis, decl_bridge_messages_runtime_apis, Chain, ChainId, Parachain,
+};
+use codec::{Decode, Encode};
+use frame_support::{
+ dispatch::DispatchClass,
+ sp_runtime::{MultiAddress, MultiSigner, RuntimeDebug, StateVersion},
+};
+
/// Identifier of AssetHubWestend in the Westend relay chain.
pub const ASSET_HUB_WESTEND_PARACHAIN_ID: u32 = 1000;
+
+/// Westend parachain.
+#[derive(RuntimeDebug)]
+pub struct AssetHubWestend;
+
+impl Chain for AssetHubWestend {
+ const ID: ChainId = *b"ahwd";
+
+ type BlockNumber = BlockNumber;
+ type Hash = Hash;
+ type Hasher = Hasher;
+ type Header = Header;
+
+ type AccountId = AccountId;
+ type Balance = Balance;
+ type Nonce = Nonce;
+ type Signature = Signature;
+
+ const STATE_VERSION: StateVersion = StateVersion::V1;
+
+ fn max_extrinsic_size() -> u32 {
+ *BlockLength::get().max.get(DispatchClass::Normal)
+ }
+
+ fn max_extrinsic_weight() -> Weight {
+ BlockWeightsForAsyncBacking::get()
+ .get(DispatchClass::Normal)
+ .max_extrinsic
+ .unwrap_or(Weight::MAX)
+ }
+}
+
+impl Parachain for AssetHubWestend {
+ const PARACHAIN_ID: u32 = ASSET_HUB_WESTEND_PARACHAIN_ID;
+ const MAX_HEADER_SIZE: u32 = MAX_BRIDGE_HUB_HEADER_SIZE;
+}
+
+/// Describing permissionless lanes instance
+impl ChainWithMessages for AssetHubWestend {
+ const WITH_CHAIN_MESSAGES_PALLET_NAME: &'static str =
+ WITH_ASSET_HUB_WESTEND_MESSAGES_PALLET_NAME;
+
+ const MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX: MessageNonce =
+ MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX;
+ const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce =
+ MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX;
+}
+
+/// Public key of the chain account that may be used to verify signatures.
+pub type AccountSigner = MultiSigner;
+
+/// The address format for describing accounts.
+pub type Address = MultiAddress;
+
+/// Name of the With-AssetHubWestend messages pallet instance that is deployed at bridged chains.
+pub const WITH_ASSET_HUB_WESTEND_MESSAGES_PALLET_NAME: &str = "BridgeWestendMessages";
+
+/// Name of the With-AssetHubWestend bridge-relayers pallet instance that is deployed at bridged
+/// chains.
+pub const WITH_ASSET_HUB_WESTEND_RELAYERS_PALLET_NAME: &str = "BridgeRelayers";
+
+/// Pallet index of `BridgeRococoMessages: pallet_bridge_messages::`.
+pub const WITH_BRIDGE_WESTEND_TO_ROCOCO_MESSAGES_PALLET_INDEX: u8 = 60; // TODO: FAIL-CI
+
+decl_bridge_finality_runtime_apis!(asset_hub_westend);
+decl_bridge_messages_runtime_apis!(asset_hub_westend, HashedLaneId);
+
+frame_support::parameter_types! {
+ /// TODO: FAIL-CI - probably not needed
+ /// The XCM fee that is paid for executing XCM program (with `ExportMessage` instruction) at the Westend
+ /// AssetHub.
+ /// (initially was calculated by test `AssetHubWestend::can_calculate_weight_for_paid_export_message_with_reserve_transfer` + `33%`)
+ pub const AssetHubWestendBaseXcmFeeInWnds: u128 = 57_325_000;
+
+ /// Transaction fee that is paid at the Westend AssetHub for delivering single inbound message.
+ /// (initially was calculated by test `AssetHubWestend::can_calculate_fee_for_standalone_message_delivery_transaction` + `33%`)
+ pub const AssetHubWestendBaseDeliveryFeeInWnds: u128 = 297_685_840;
+
+ /// Transaction fee that is paid at the Westend AssetHub for delivering single outbound message confirmation.
+ /// (initially was calculated by test `AssetHubWestend::can_calculate_fee_for_standalone_message_confirmation_transaction` + `33%`)
+ pub const AssetHubWestendBaseConfirmationFeeInWnds: u128 = 56_782_099;
+}
+
+/// Wrapper over `AssetHubWestend`'s `RuntimeCall` that can be used without a runtime.
+#[derive(Decode, Encode)]
+pub enum RuntimeCall {
+ /// Points to the `pallet_xcm_bridge_hub` pallet instance for `AssetHubRococo`.
+ #[codec(index = 62)] // TODO: FAIL-CI
+ XcmOverAssetHubRococo(bp_xcm_bridge_hub::XcmBridgeHubCall),
+}
diff --git a/bridges/modules/relayers/src/extension/mod.rs b/bridges/modules/relayers/src/extension/mod.rs
index bfabfe3c3ed5..871a964eb5a3 100644
--- a/bridges/modules/relayers/src/extension/mod.rs
+++ b/bridges/modules/relayers/src/extension/mod.rs
@@ -129,7 +129,7 @@ pub struct BridgeRelayersTransactionExtension(
impl BridgeRelayersTransactionExtension
where
Self: 'static + Send + Sync,
- R: RelayersConfig
+ R: RelayersConfig
+ BridgeMessagesConfig
+ TransactionPaymentConfig,
C: ExtensionConfig,
@@ -250,7 +250,7 @@ where
// let's also replace the weight of slashing relayer with the weight of rewarding relayer
if call_info.is_receive_messages_proof_call() {
post_info_weight = post_info_weight.saturating_sub(
- ::WeightInfo::extra_weight_of_successful_receive_messages_proof_call(),
+ >::WeightInfo::extra_weight_of_successful_receive_messages_proof_call(),
);
}
@@ -278,7 +278,7 @@ impl TransactionExtension
for BridgeRelayersTransactionExtension
where
Self: 'static + Send + Sync,
- R: RelayersConfig
+ R: RelayersConfig
+ BridgeMessagesConfig
+ TransactionPaymentConfig,
C: ExtensionConfig,
@@ -326,7 +326,9 @@ where
};
// we only boost priority if relayer has staked required balance
- if !RelayersPallet::::is_registration_active(&data.relayer) {
+ if !RelayersPallet::::is_registration_active(
+ &data.relayer,
+ ) {
return Ok((Default::default(), Some(data), origin))
}
@@ -382,7 +384,11 @@ where
match call_result {
RelayerAccountAction::None => (),
RelayerAccountAction::Reward(relayer, reward_account, reward) => {
- RelayersPallet::::register_relayer_reward(reward_account, &relayer, reward);
+ RelayersPallet::::register_relayer_reward(
+ reward_account,
+ &relayer,
+ reward,
+ );
log::trace!(
target: LOG_TARGET,
@@ -394,7 +400,7 @@ where
);
},
RelayerAccountAction::Slash(relayer, slash_account) =>
- RelayersPallet::::slash_and_deregister(
+ RelayersPallet::::slash_and_deregister(
&relayer,
ExplicitOrAccountParams::Params(slash_account),
),
diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/Cargo.toml b/cumulus/parachains/runtimes/assets/asset-hub-rococo/Cargo.toml
index bfe8ed869758..957ece97d503 100644
--- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/Cargo.toml
+++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/Cargo.toml
@@ -90,16 +90,26 @@ testnet-parachains-constants = { features = ["rococo"], workspace = true }
assets-common = { workspace = true }
# Bridges
+pallet-bridge-messages = { workspace = true }
+pallet-bridge-relayers = { workspace = true }
+pallet-xcm-bridge-hub = { workspace = true }
pallet-xcm-bridge-hub-router = { workspace = true }
bp-asset-hub-rococo = { workspace = true }
bp-asset-hub-westend = { workspace = true }
bp-bridge-hub-rococo = { workspace = true }
bp-bridge-hub-westend = { workspace = true }
+bp-header-chain = { workspace = true }
+bp-messages = { workspace = true }
+bp-runtime = { workspace = true }
+bridge-hub-common = { workspace = true }
snowbridge-router-primitives = { workspace = true }
[dev-dependencies]
asset-test-utils = { workspace = true, default-features = true }
parachains-runtimes-test-utils = { workspace = true, default-features = true }
+bridge-hub-test-utils = { workspace = true, default-features = true }
+bridge-runtime-common = { features = ["integrity-test"], workspace = true }
+pallet-bridge-relayers = { features = ["integrity-test"], workspace = true }
[build-dependencies]
substrate-wasm-builder = { optional = true, workspace = true, default-features = true }
@@ -108,6 +118,7 @@ substrate-wasm-builder = { optional = true, workspace = true, default-features =
default = ["std"]
runtime-benchmarks = [
"assets-common/runtime-benchmarks",
+ "bridge-hub-common/runtime-benchmarks",
"cumulus-pallet-parachain-system/runtime-benchmarks",
"cumulus-pallet-session-benchmarking/runtime-benchmarks",
"cumulus-pallet-xcmp-queue/runtime-benchmarks",
@@ -123,6 +134,8 @@ runtime-benchmarks = [
"pallet-assets-freezer/runtime-benchmarks",
"pallet-assets/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
+ "pallet-bridge-messages/runtime-benchmarks",
+ "pallet-bridge-relayers/runtime-benchmarks",
"pallet-collator-selection/runtime-benchmarks",
"pallet-message-queue/runtime-benchmarks",
"pallet-multisig/runtime-benchmarks",
@@ -135,6 +148,7 @@ runtime-benchmarks = [
"pallet-utility/runtime-benchmarks",
"pallet-xcm-benchmarks/runtime-benchmarks",
"pallet-xcm-bridge-hub-router/runtime-benchmarks",
+ "pallet-xcm-bridge-hub/runtime-benchmarks",
"pallet-xcm/runtime-benchmarks",
"parachains-common/runtime-benchmarks",
"polkadot-parachain-primitives/runtime-benchmarks",
@@ -162,6 +176,8 @@ try-runtime = [
"pallet-aura/try-runtime",
"pallet-authorship/try-runtime",
"pallet-balances/try-runtime",
+ "pallet-bridge-messages/try-runtime",
+ "pallet-bridge-relayers/try-runtime",
"pallet-collator-selection/try-runtime",
"pallet-message-queue/try-runtime",
"pallet-multisig/try-runtime",
@@ -174,6 +190,7 @@ try-runtime = [
"pallet-uniques/try-runtime",
"pallet-utility/try-runtime",
"pallet-xcm-bridge-hub-router/try-runtime",
+ "pallet-xcm-bridge-hub/try-runtime",
"pallet-xcm/try-runtime",
"parachain-info/try-runtime",
"polkadot-runtime-common/try-runtime",
@@ -185,6 +202,10 @@ std = [
"bp-asset-hub-westend/std",
"bp-bridge-hub-rococo/std",
"bp-bridge-hub-westend/std",
+ "bp-header-chain/std",
+ "bp-messages/std",
+ "bp-runtime/std",
+ "bridge-hub-common/std",
"codec/std",
"cumulus-pallet-aura-ext/std",
"cumulus-pallet-parachain-system/std",
@@ -212,6 +233,8 @@ std = [
"pallet-aura/std",
"pallet-authorship/std",
"pallet-balances/std",
+ "pallet-bridge-messages/std",
+ "pallet-bridge-relayers/std",
"pallet-collator-selection/std",
"pallet-message-queue/std",
"pallet-multisig/std",
@@ -227,6 +250,7 @@ std = [
"pallet-utility/std",
"pallet-xcm-benchmarks?/std",
"pallet-xcm-bridge-hub-router/std",
+ "pallet-xcm-bridge-hub/std",
"pallet-xcm/std",
"parachain-info/std",
"parachains-common/std",
diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/bridge_common_config.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/bridge_common_config.rs
new file mode 100644
index 000000000000..c0c1b4057c15
--- /dev/null
+++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/bridge_common_config.rs
@@ -0,0 +1,45 @@
+// Copyright (C) Parity Technologies (UK) Ltd.
+// This file is part of Cumulus.
+
+// Cumulus is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// Cumulus is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Cumulus. If not, see .
+
+//! Bridge definitions that can be used by multiple bridges.
+
+use super::{weights, AccountId, Balance, Balances, BlockNumber, Runtime, RuntimeEvent};
+
+frame_support::parameter_types! {
+ pub storage RequiredStakeForStakeAndSlash: Balance = 1_000_000;
+ pub const RelayerStakeLease: u32 = 8;
+ pub const RelayerStakeReserveId: [u8; 8] = *b"brdgrlrs";
+ pub storage DeliveryRewardInBalance: u64 = 1_000_000;
+}
+
+/// Allows collect and claim rewards for the relayers
+pub type BridgeRelayersInstance = pallet_bridge_relayers::Instance1;
+impl pallet_bridge_relayers::Config for Runtime {
+ type RuntimeEvent = RuntimeEvent;
+ type Reward = Balance;
+ type PaymentProcedure =
+ pallet_bridge_relayers::PayRewardFromAccount;
+ type StakeAndSlash = pallet_bridge_relayers::StakeAndSlashNamed<
+ AccountId,
+ BlockNumber,
+ Balances,
+ RelayerStakeReserveId,
+ RequiredStakeForStakeAndSlash,
+ RelayerStakeLease,
+ >;
+ type WeightInfo = weights::pallet_bridge_relayers::WeightInfo;
+ type LaneId = bp_messages::HashedLaneId;
+}
diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/bridge_to_westend_config.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/bridge_to_westend_config.rs
new file mode 100644
index 000000000000..18b803becaa1
--- /dev/null
+++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/bridge_to_westend_config.rs
@@ -0,0 +1,303 @@
+// Copyright (C) Parity Technologies (UK) Ltd.
+// This file is part of Cumulus.
+
+// Cumulus is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// Cumulus is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Cumulus. If not, see .
+
+//! Bridge definitions used on BridgeHubRococo for bridging to BridgeHubWestend.
+
+use crate::{
+ bridge_common_config::{BridgeRelayersInstance, DeliveryRewardInBalance},
+ weights, xcm_config,
+ xcm_config::UniversalLocation,
+ AccountId, Balance, Balances, PolkadotXcm, Runtime, RuntimeEvent, RuntimeHoldReason,
+ ToWestendXcmRouter, XcmOverAssetHubWestend,
+};
+use alloc::{vec, vec::Vec};
+use bp_messages::HashedLaneId;
+use bp_runtime::HashOf;
+use bridge_hub_common::xcm_version::XcmVersionOfDestAndRemoteBridge;
+use pallet_xcm_bridge_hub::XcmAsPlainPayload;
+
+use frame_support::{
+ parameter_types,
+ traits::{EitherOf, Equals},
+};
+use frame_system::{EnsureRoot, EnsureRootWithSuccess};
+use pallet_bridge_messages::LaneIdOf;
+use pallet_bridge_relayers::extension::{
+ BridgeRelayersTransactionExtension, WithMessagesExtensionConfig,
+};
+use pallet_xcm::EnsureXcm;
+use pallet_xcm_bridge_hub::congestion::{
+ BlobDispatcherWithChannelStatus, HereOrLocalConsensusXcmChannelManager,
+ UpdateBridgeStatusXcmChannelManager,
+};
+use parachains_common::xcm_config::{
+ AllSiblingSystemParachains, ParentRelayOrSiblingParachains, RelayOrOtherSystemParachains,
+};
+use polkadot_parachain_primitives::primitives::Sibling;
+use sp_runtime::traits::Convert;
+use testnet_parachains_constants::rococo::currency::UNITS as ROC;
+use xcm::{
+ latest::{prelude::*, WESTEND_GENESIS_HASH},
+ prelude::NetworkId,
+};
+use xcm_builder::{
+ BridgeBlobDispatcher, ParentIsPreset, SiblingParachainConvertsVia, UnpaidLocalExporter,
+};
+
+parameter_types! {
+ pub const HereLocation: Location = Location::here();
+ pub WestendGlobalConsensusNetwork: NetworkId = NetworkId::ByGenesis(WESTEND_GENESIS_HASH);
+ pub WestendGlobalConsensusNetworkLocation: Location = Location::new(
+ 2,
+ [GlobalConsensus(WestendGlobalConsensusNetwork::get())]
+ );
+ // see the `FEE_BOOST_PER_MESSAGE` constant to get the meaning of this value
+ pub PriorityBoostPerMessage: u64 = 182_044_444_444_444;
+
+ // The other side of the bridge
+ pub AssetHubWestendLocation: Location = Location::new(
+ 2,
+ [
+ GlobalConsensus(WestendGlobalConsensusNetwork::get()),
+ Parachain(::PARACHAIN_ID)
+ ]
+ );
+
+ pub storage BridgeDeposit: Balance = 5 * ROC;
+}
+
+/// Transaction extension that refunds relayers that are delivering messages from the Westend
+/// parachain.
+pub type OnAssetHubRococoRefundAssetHubWestendMessages = BridgeRelayersTransactionExtension<
+ Runtime,
+ WithMessagesExtensionConfig<
+ StrOnAssetHubRococoRefundAssetHubWestendMessages,
+ Runtime,
+ WithAssetHubWestendMessagesInstance,
+ BridgeRelayersInstance,
+ PriorityBoostPerMessage,
+ >,
+ LaneIdOf,
+>;
+bp_runtime::generate_static_str_provider!(OnAssetHubRococoRefundAssetHubWestendMessages);
+
+/// Add XCM messages support for AssetHubRococo to support Rococo->Westend XCM messages
+pub type WithAssetHubWestendMessagesInstance = pallet_bridge_messages::Instance1;
+impl pallet_bridge_messages::Config for Runtime {
+ type RuntimeEvent = RuntimeEvent;
+ type WeightInfo = weights::pallet_bridge_messages::WeightInfo;
+
+ type ThisChain = bp_asset_hub_rococo::AssetHubRococo;
+ type BridgedChain = bp_asset_hub_westend::AssetHubWestend;
+ type BridgedHeaderChain = ParachainHeaderProofs;
+
+ type OutboundPayload = XcmAsPlainPayload;
+ type InboundPayload = XcmAsPlainPayload;
+ type LaneId = HashedLaneId;
+
+ type DeliveryPayments = ();
+ type DeliveryConfirmationPayments = pallet_bridge_relayers::DeliveryConfirmationPaymentsAdapter<
+ Runtime,
+ WithAssetHubWestendMessagesInstance,
+ BridgeRelayersInstance,
+ DeliveryRewardInBalance,
+ >;
+
+ type MessageDispatch = XcmOverAssetHubWestend;
+ type OnMessagesDelivered = XcmOverAssetHubWestend;
+}
+
+/// TODO: doc + FAIL-CI - implement storage for synced proofs from BridgeHub
+pub struct ParachainHeaderProofs(core::marker::PhantomData);
+impl bp_header_chain::HeaderChain for ParachainHeaderProofs {
+ fn finalized_header_state_root(header_hash: HashOf) -> Option> {
+ todo!("TODO: FAIL-CI - implement storage for synced proofs from BridgeHub")
+ }
+}
+
+/// Converts encoded call to the unpaid XCM `Transact`.
+pub struct UpdateBridgeStatusXcmProvider;
+impl Convert, Xcm<()>> for UpdateBridgeStatusXcmProvider {
+ fn convert(encoded_call: Vec) -> Xcm<()> {
+ Xcm(vec![
+ UnpaidExecution { weight_limit: Unlimited, check_origin: None },
+ Transact { origin_kind: OriginKind::Xcm, call: encoded_call.into() },
+ ExpectTransactStatus(MaybeErrorCode::Success),
+ ])
+ }
+}
+
+/// Add support for the export and dispatch of XCM programs withing
+/// `WithAssetHubWestendMessagesInstance`.
+pub type XcmOverAssetHubWestendInstance = pallet_xcm_bridge_hub::Instance1;
+impl pallet_xcm_bridge_hub::Config for Runtime {
+ type RuntimeEvent = RuntimeEvent;
+ type WeightInfo = weights::pallet_xcm_bridge_hub::WeightInfo;
+
+ type UniversalLocation = UniversalLocation;
+ type BridgedNetwork = WestendGlobalConsensusNetworkLocation;
+ type BridgeMessagesPalletInstance = WithAssetHubWestendMessagesInstance;
+
+ // TODO: FAIL-CI: we need to setup some price or configure per location?
+ type MessageExportPrice = ();
+ type DestinationVersion = XcmVersionOfDestAndRemoteBridge;
+
+ type ForceOrigin = EnsureRoot;
+ // We allow creating bridges for the runtime itself and for other local consensus chains (relay,
+ // paras).
+ type OpenBridgeOrigin = EitherOf<
+ // We want to translate `RuntimeOrigin::root()` to the `Location::here()`, e.g. for
+ // governance calls.
+ EnsureRootWithSuccess,
+ // For relay or sibling chains
+ EnsureXcm,
+ >;
+ // Converter aligned with `OpenBridgeOrigin`.
+ type BridgeOriginAccountIdConverter =
+ (ParentIsPreset, SiblingParachainConvertsVia);
+
+ type BridgeDeposit = BridgeDeposit;
+ type Currency = Balances;
+ type RuntimeHoldReason = RuntimeHoldReason;
+ // Do not require deposit from system parachains (including itself) or relay chain
+ type AllowWithoutBridgeDeposit =
+ (RelayOrOtherSystemParachains, Equals);
+
+ // This pallet is deployed on AH, so we expect a remote router with `ExportMessage`. We handle
+ // congestion with XCM using `udpate_bridge_status` sent to the sending chain. (congestion with
+ // local sending chain)
+ type LocalXcmChannelManager = HereOrLocalConsensusXcmChannelManager<
+ pallet_xcm_bridge_hub::BridgeId,
+ // handles congestion for local chain router for local AH's bridges
+ ToWestendXcmRouter,
+ // handles congestion for other local chains with XCM using `update_bridge_status` sent to
+ // the sending chain.
+ UpdateBridgeStatusXcmChannelManager<
+ Runtime,
+ XcmOverAssetHubWestendInstance,
+ UpdateBridgeStatusXcmProvider,
+ xcm_config::LocalXcmRouter,
+ >,
+ >;
+ // Dispatching inbound messages from the bridge and managing congestion with the local
+ // receiving/destination chain
+ type BlobDispatcher = BlobDispatcherWithChannelStatus<
+ // Dispatches received XCM messages from other bridge
+ BridgeBlobDispatcher<
+ // TODO: FAIL-CI wait for https://github.com/paritytech/polkadot-sdk/pull/6002#issuecomment-2469892343
+ xcm_config::LocalXcmRouter,
+ UniversalLocation,
+ (),
+ >,
+ // Provides the status of the XCMP queue's outbound queue, indicating whether messages can
+ // be dispatched to the sibling.
+ cumulus_pallet_xcmp_queue::bridging::OutXcmpChannelStatusProvider,
+ >;
+ type CongestionLimits = ();
+}
+
+/// XCM router instance to the local `pallet_xcm_bridge_hub::` with
+/// direct bridging capabilities for `Westend` global consensus with dynamic fees and back-pressure.
+pub type ToWestendXcmRouterInstance = pallet_xcm_bridge_hub_router::Instance1;
+impl pallet_xcm_bridge_hub_router::Config for Runtime {
+ type RuntimeEvent = RuntimeEvent;
+ type WeightInfo = weights::pallet_xcm_bridge_hub_router_to_westend::WeightInfo;
+
+ type DestinationVersion = PolkadotXcm;
+
+ // We use `UnpaidLocalExporter` with `ViaLocalBridgeHubExporter` ensures that
+ // `pallet_xcm_bridge_hub_router` can trigger directly `pallet_xcm_bridge_hub` as exporter.
+ type ToBridgeHubSender = pallet_xcm_bridge_hub_router::impls::ViaLocalBridgeHubExporter<
+ Runtime,
+ ToWestendXcmRouterInstance,
+ UnpaidLocalExporter,
+ >;
+
+ // For congestion - resolves `BridgeId` using the same algorithm as `pallet_xcm_bridge_hub` on
+ // the BH.
+ type BridgeIdResolver =
+ pallet_xcm_bridge_hub_router::impls::EnsureIsRemoteBridgeIdResolver;
+ // We don't expect here `update_bridge_status` calls from the local BridgeHub or any other local
+ // chain.
+ type BridgeHubOrigin = frame_system::EnsureNever<()>;
+
+ // For adding message size fees
+ type ByteFee = xcm_config::bridging::XcmBridgeHubRouterByteFee;
+ // For adding message size fees
+ type FeeAsset = xcm_config::bridging::XcmBridgeHubRouterFeeAssetId;
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use bridge_runtime_common::{
+ assert_complete_bridge_types,
+ integrity::{
+ assert_standalone_messages_bridge_constants, check_message_lane_weights,
+ AssertChainConstants, AssertCompleteBridgeConstants,
+ },
+ };
+
+ /// Every additional message in the message delivery transaction boosts its priority.
+ /// So the priority of transaction with `N+1` messages is larger than priority of
+ /// transaction with `N` messages by the `PriorityBoostPerMessage`.
+ ///
+ /// Economically, it is an equivalent of adding tip to the transaction with `N` messages.
+ /// The `FEE_BOOST_PER_MESSAGE` constant is the value of this tip.
+ ///
+ /// We want this tip to be large enough (delivery transactions with more messages = less
+ /// operational costs and a faster bridge), so this value should be significant.
+ const FEE_BOOST_PER_MESSAGE: Balance = 2 * ROC;
+
+ #[test]
+ fn ensure_bridge_hub_rococo_message_lane_weights_are_correct() {
+ check_message_lane_weights::<
+ bp_asset_hub_rococo::AssetHubRococo,
+ Runtime,
+ WithAssetHubWestendMessagesInstance,
+ >(
+ bp_asset_hub_westend::EXTRA_STORAGE_PROOF_SIZE,
+ bp_asset_hub_rococo::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX,
+ bp_asset_hub_rococo::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX,
+ true,
+ );
+ }
+
+ #[test]
+ fn ensure_bridge_integrity() {
+ assert_complete_bridge_types!(
+ runtime: Runtime,
+ with_bridged_chain_messages_instance: WithAssetHubWestendMessagesInstance,
+ this_chain: bp_asset_hub_rococo::AssetHubRococo,
+ bridged_chain: bp_asset_hub_westend::AssetHubWestend,
+ );
+
+ assert_standalone_messages_bridge_constants::(
+ AssertCompleteBridgeConstants {
+ this_chain_constants: AssertChainConstants {
+ block_length: bp_bridge_hub_rococo::BlockLength::get(),
+ block_weights: bp_bridge_hub_rococo::BlockWeightsForAsyncBacking::get(),
+ },
+ },
+ );
+
+ pallet_bridge_relayers::extension::per_message::ensure_priority_boost_is_sane::<
+ Runtime,
+ WithAssetHubWestendMessagesInstance,
+ PriorityBoostPerMessage,
+ >(FEE_BOOST_PER_MESSAGE);
+ }
+}
diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs
index 76de887c13c0..0cee042413ca 100644
--- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs
+++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs
@@ -24,6 +24,8 @@
#[cfg(feature = "std")]
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
+pub mod bridge_common_config;
+pub mod bridge_to_westend_config;
mod genesis_config_presets;
mod weights;
pub mod xcm_config;
@@ -100,7 +102,7 @@ use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate};
#[cfg(feature = "runtime-benchmarks")]
use xcm::latest::prelude::{
Asset, Assets as XcmAssets, Fungible, Here, InteriorLocation, Junction, Junction::*, Location,
- NetworkId, NonFungible, Parent, ParentThen, Response,
+ NetworkId, NonFungible, Parent, ParentThen, Response, XCM_VERSION,
};
use xcm::{
latest::prelude::{AssetId, BodyId},
@@ -927,10 +929,14 @@ impl pallet_nfts::Config for Runtime {
/// XCM router instance to BridgeHub with bridging capabilities for `Westend` global
/// consensus with dynamic fees and back-pressure.
-pub type ToWestendXcmRouterInstance = pallet_xcm_bridge_hub_router::Instance3;
-impl pallet_xcm_bridge_hub_router::Config for Runtime {
+/// (legacy routing with `ExportMessage` over BridgeHub)
+pub type ToWestendOverBridgeHubLegacyXcmRouterInstance = pallet_xcm_bridge_hub_router::Instance3;
+impl pallet_xcm_bridge_hub_router::Config
+ for Runtime
+{
type RuntimeEvent = RuntimeEvent;
- type WeightInfo = weights::pallet_xcm_bridge_hub_router::WeightInfo;
+ type WeightInfo =
+ weights::pallet_xcm_bridge_hub_router_to_westend_over_bridge_hub::WeightInfo;
type DestinationVersion = PolkadotXcm;
@@ -940,7 +946,7 @@ impl pallet_xcm_bridge_hub_router::Config for Runtim
// `ExporterFor` wrapper handling dynamic fees for congestion.
pallet_xcm_bridge_hub_router::impls::ViaRemoteBridgeHubExporter<
Runtime,
- ToWestendXcmRouterInstance,
+ ToWestendOverBridgeHubLegacyXcmRouterInstance,
NetworkExportTable,
xcm_config::bridging::to_westend::WestendNetwork,
xcm_config::bridging::SiblingBridgeHub,
@@ -998,7 +1004,7 @@ construct_runtime!(
Proxy: pallet_proxy = 42,
// Bridge utilities.
- ToWestendXcmRouter: pallet_xcm_bridge_hub_router:: = 45,
+ ToWestendOverBridgeHubLegacyXcmRouter: pallet_xcm_bridge_hub_router:: = 45,
// The main stage.
Assets: pallet_assets:: = 50,
@@ -1011,6 +1017,10 @@ construct_runtime!(
AssetsFreezer: pallet_assets_freezer:: = 57,
ForeignAssetsFreezer: pallet_assets_freezer:: = 58,
PoolAssetsFreezer: pallet_assets_freezer:: = 59,
+ BridgeWestendMessages: pallet_bridge_messages:: = 60,
+ BridgeRelayers: pallet_bridge_relayers:: = 61,
+ XcmOverAssetHubWestend: pallet_xcm_bridge_hub:: = 62,
+ ToWestendXcmRouter: pallet_xcm_bridge_hub_router:: = 63,
// TODO: the pallet instance should be removed once all pools have migrated
// to the new account IDs.
@@ -1038,6 +1048,7 @@ pub type TxExtension = (
pallet_asset_conversion_tx_payment::ChargeAssetTxPayment,
cumulus_primitives_storage_weight_reclaim::StorageWeightReclaim,
frame_metadata_hash_extension::CheckMetadataHash,
+ (bridge_to_westend_config::OnAssetHubRococoRefundAssetHubWestendMessages,),
);
/// Unchecked extrinsic type as expected by this runtime.
pub type UncheckedExtrinsic =
@@ -1215,8 +1226,13 @@ mod benches {
[pallet_collator_selection, CollatorSelection]
[cumulus_pallet_parachain_system, ParachainSystem]
[cumulus_pallet_xcmp_queue, XcmpQueue]
- [pallet_xcm_bridge_hub_router, ToWestend]
[pallet_asset_conversion_ops, AssetConversionMigration]
+ // Bridge pallets
+ [pallet_xcm_bridge_hub_router, ToWestendOverBridgeHub]
+ [pallet_xcm_bridge_hub_router, ToWestend]
+ [pallet_bridge_messages, RococoToWestend]
+ [pallet_bridge_relayers, BridgeRelayersBench::]
+ [pallet_xcm_bridge_hub, OverWestend]
// XCM
[pallet_xcm, PalletXcmExtrinsicsBenchmark::]
// NOTE: Make sure you point to the individual modules below.
@@ -1547,6 +1563,7 @@ impl_runtime_apis! {
use cumulus_pallet_session_benchmarking::Pallet as SessionBench;
use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsicsBenchmark;
use pallet_xcm_bridge_hub_router::benchmarking::Pallet as XcmBridgeHubRouterBench;
+ use pallet_bridge_relayers::benchmarking::Pallet as BridgeRelayersBench;
// This is defined once again in dispatch_benchmark, because list_benchmarks!
// and add_benchmarks! are macros exported by define_benchmarks! macros and those types
@@ -1562,7 +1579,10 @@ impl_runtime_apis! {
type Foreign = pallet_assets::Pallet::;
type Pool = pallet_assets::Pallet::;
- type ToWestend = XcmBridgeHubRouterBench;
+ type ToWestendOverBridgeHub = XcmBridgeHubRouterBench;
+ type ToWestend = XcmBridgeHubRouterBench;
+ type OverWestend = pallet_xcm_bridge_hub::benchmarking::Pallet::;
+ type RococoToWestend = pallet_bridge_messages::benchmarking::Pallet::;
let mut list = Vec::::new();
list_benchmarks!(list, extra);
@@ -1706,7 +1726,7 @@ impl_runtime_apis! {
}
}
- impl XcmBridgeHubRouterConfig for Runtime {
+ impl XcmBridgeHubRouterConfig for Runtime {
fn ensure_bridged_target_destination() -> Result {
Ok(xcm_config::bridging::to_westend::AssetHubWestend::get())
}
@@ -1714,6 +1734,14 @@ impl_runtime_apis! {
Some(pallet_xcm::Origin::Xcm(xcm_config::bridging::SiblingBridgeHub::get()).into())
}
}
+ impl XcmBridgeHubRouterConfig for Runtime {
+ fn ensure_bridged_target_destination() -> Result {
+ Ok(xcm_config::bridging::to_westend::AssetHubWestend::get())
+ }
+ fn update_bridge_status_origin() -> Option {
+ None
+ }
+ }
use xcm_config::{TokenLocation, MaxAssetsIntoHolding};
use pallet_xcm_benchmarks::asset_instance_from;
@@ -1827,7 +1855,50 @@ impl_runtime_apis! {
fn export_message_origin_and_destination(
) -> Result<(Location, NetworkId, InteriorLocation), BenchmarkError> {
- Err(BenchmarkError::Skip)
+ // save XCM version for remote permissionless lanes on bridged asset hub
+ let _ = PolkadotXcm::force_xcm_version(
+ RuntimeOrigin::root(),
+ alloc::boxed::Box::new(bridge_to_westend_config::AssetHubWestendLocation::get()),
+ XCM_VERSION,
+ ).map_err(|e| {
+ log::error!(
+ "Failed to dispatch `force_xcm_version({:?}, {:?}, {:?})`, error: {:?}",
+ RuntimeOrigin::root(),
+ bridge_to_westend_config::AssetHubWestendLocation::get(),
+ XCM_VERSION,
+ e
+ );
+ BenchmarkError::Stop("XcmVersion was not stored!")
+ })?;
+
+ // open bridge
+ let westend = bridge_to_westend_config::WestendGlobalConsensusNetwork::get();
+ let sibling_parachain_location = Location::new(1, [Parachain(5678)]);
+ let bridge_destination_universal_location: InteriorLocation = [GlobalConsensus(westend), Parachain(8765)].into();
+ let _ = XcmOverAssetHubWestend::open_bridge_for_benchmarks(
+ ::try_new(1, 2).unwrap(),
+ sibling_parachain_location.clone(),
+ bridge_destination_universal_location.clone(),
+ true,
+ None,
+ || ExistentialDeposit::get(),
+ ).map_err(|e| {
+ log::error!(
+ "Failed to `XcmOverAssetHubWestend::open_bridge`({:?}, {:?})`, error: {:?}",
+ sibling_parachain_location,
+ bridge_destination_universal_location,
+ e
+ );
+ BenchmarkError::Stop("Bridge was not opened!")
+ })?;
+
+ Ok(
+ (
+ sibling_parachain_location,
+ westend,
+ [Parachain(8765)].into()
+ )
+ )
}
fn alias_origin() -> Result<(Location, Location), BenchmarkError> {
@@ -1847,7 +1918,124 @@ impl_runtime_apis! {
type Foreign = pallet_assets::Pallet::;
type Pool = pallet_assets::Pallet::;
- type ToWestend = XcmBridgeHubRouterBench;
+ type ToWestendOverBridgeHub = XcmBridgeHubRouterBench;
+ type ToWestend = XcmBridgeHubRouterBench;
+ type OverWestend = pallet_xcm_bridge_hub::benchmarking::Pallet::;
+ type RococoToWestend = pallet_bridge_messages::benchmarking::Pallet::;
+
+ use pallet_bridge_relayers::benchmarking::{
+ Config as BridgeRelayersConfig,
+ Pallet as BridgeRelayersBench
+ };
+
+ impl BridgeRelayersConfig for Runtime {
+ fn prepare_rewards_account(
+ account_params: pallet_bridge_relayers::RewardsAccountParams<>::LaneId>,
+ reward: Balance,
+ ) {
+ let rewards_account = pallet_bridge_relayers::PayRewardFromAccount::<
+ Balances,
+ AccountId,
+ >::LaneId,
+ >::rewards_account(account_params);
+ >::deposit_account(rewards_account, reward);
+ }
+
+ fn deposit_account(account: AccountId, balance: Balance) {
+ use frame_support::traits::fungible::Mutate;
+ Balances::mint_into(&account, balance.saturating_add(ExistentialDeposit::get())).unwrap();
+ }
+ }
+
+ impl pallet_xcm_bridge_hub::benchmarking::Config for Runtime {
+ fn open_bridge_origin() -> Option<(RuntimeOrigin, Balance)> {
+ // We allow bridges to be opened for sibling parachains.
+ Some((
+ pallet_xcm::Origin::Xcm(Location::new(1, [Parachain(42)])).into(),
+ ExistentialDeposit::get(),
+ ))
+ }
+ }
+
+ use pallet_bridge_messages::{BridgedChainOf, LaneIdOf};
+ use pallet_bridge_messages::benchmarking::{
+ Config as BridgeMessagesConfig,
+ MessageDeliveryProofParams,
+ MessageProofParams,
+ };
+
+ impl BridgeMessagesConfig for Runtime {
+ fn is_relayer_rewarded(relayer: &Self::AccountId) -> bool {
+ let bench_lane_id = >::bench_lane_id();
+ use bp_runtime::Chain;
+ let bridged_chain_id =>::BridgedChain::ID;
+ pallet_bridge_relayers::Pallet::::relayer_reward(
+ relayer,
+ pallet_bridge_relayers::RewardsAccountParams::new(
+ bench_lane_id,
+ bridged_chain_id,
+ pallet_bridge_relayers::RewardsAccountOwner::BridgedChain
+ )
+ ).is_some()
+ }
+
+ fn prepare_message_proof(
+ params: MessageProofParams>,
+ ) -> (
+ bp_messages::target_chain::FromBridgedChainMessagesProof<
+ bp_runtime::HashOf>,
+ LaneIdOf
+ >,
+ Weight
+ ) {
+ use cumulus_primitives_core::XcmpMessageSource;
+ assert!(XcmpQueue::take_outbound_messages(usize::MAX).is_empty());
+ ParachainSystem::open_outbound_hrmp_channel_for_benchmarks_or_tests(42.into());
+ let bridge_locations = XcmOverAssetHubWestend::open_bridge_for_benchmarks(
+ params.lane,
+ Location::new(1, [Parachain(42)]),
+ [GlobalConsensus(bridge_to_westend_config::WestendGlobalConsensusNetwork::get()), Parachain(2075)].into(),
+ // do not create lanes, because they are already created `params.lane`
+ false,
+ None,
+ || ExistentialDeposit::get(),
+ ).expect("valid bridge opened");
+ todo!("TODO: FAIL-CI - prepare storage proof for synced proof")
+ // prepare_message_proof_from_parachain::<
+ // Runtime,
+ // bridge_common_config::BridgeGrandpaWestendInstance,
+ // bridge_to_westend_config::WithAssetHubWestendMessagesInstance,
+ // >(params, generate_xcm_builder_bridge_message_sample(bridge_locations.bridge_origin_universal_location().clone()))
+ }
+
+ fn prepare_message_delivery_proof(
+ params: MessageDeliveryProofParams>,
+ ) -> bp_messages::source_chain::FromBridgedChainMessagesDeliveryProof<
+ bp_runtime::HashOf>,
+ LaneIdOf
+ > {
+ let _ = XcmOverAssetHubWestend::open_bridge_for_benchmarks(
+ params.lane,
+ Location::new(1, [Parachain(42)]),
+ [GlobalConsensus(bridge_to_westend_config::WestendGlobalConsensusNetwork::get()), Parachain(2075)].into(),
+ // do not create lanes, because they are already created `params.lane`
+ false,
+ None,
+ || ExistentialDeposit::get(),
+ );
+ todo!("TODO: FAIL-CI - prepare storage proof for synced proof")
+ // prepare_message_delivery_proof_from_parachain::<
+ // Runtime,
+ // bridge_common_config::BridgeGrandpaWestendInstance,
+ // bridge_to_westend_config::WithAssetHubWestendMessagesInstance,
+ // >(params)
+ }
+
+ fn is_message_successfully_dispatched(_nonce: bp_messages::MessageNonce) -> bool {
+ use cumulus_primitives_core::XcmpMessageSource;
+ !XcmpQueue::take_outbound_messages(usize::MAX).is_empty()
+ }
+ }
let whitelist: Vec = vec![
// Block Number
diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/mod.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/mod.rs
index 33f111009ed0..ec937667edb7 100644
--- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/mod.rs
+++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/mod.rs
@@ -27,6 +27,8 @@ pub mod pallet_assets_foreign;
pub mod pallet_assets_local;
pub mod pallet_assets_pool;
pub mod pallet_balances;
+pub mod pallet_bridge_messages;
+pub mod pallet_bridge_relayers;
pub mod pallet_collator_selection;
pub mod pallet_message_queue;
pub mod pallet_multisig;
@@ -39,7 +41,9 @@ pub mod pallet_transaction_payment;
pub mod pallet_uniques;
pub mod pallet_utility;
pub mod pallet_xcm;
-pub mod pallet_xcm_bridge_hub_router;
+pub mod pallet_xcm_bridge_hub;
+pub mod pallet_xcm_bridge_hub_router_to_westend;
+pub mod pallet_xcm_bridge_hub_router_to_westend_over_bridge_hub;
pub mod paritydb_weights;
pub mod rocksdb_weights;
pub mod xcm;
@@ -47,3 +51,23 @@ pub mod xcm;
pub use block_weights::constants::BlockExecutionWeight;
pub use extrinsic_weights::constants::ExtrinsicBaseWeight;
pub use rocksdb_weights::constants::RocksDbWeight;
+
+use ::pallet_bridge_messages::WeightInfoExt as MessagesWeightInfoExt;
+use ::pallet_bridge_relayers::WeightInfoExt as _;
+
+use crate::{Runtime, Weight};
+
+impl MessagesWeightInfoExt for pallet_bridge_messages::WeightInfo {
+ fn expected_extra_storage_proof_size() -> u32 {
+ bp_bridge_hub_westend::EXTRA_STORAGE_PROOF_SIZE
+ }
+
+ fn receive_messages_proof_overhead_from_runtime() -> Weight {
+ pallet_bridge_relayers::WeightInfo::::receive_messages_proof_overhead_from_runtime(
+ )
+ }
+
+ fn receive_messages_delivery_proof_overhead_from_runtime() -> Weight {
+ pallet_bridge_relayers::WeightInfo::::receive_messages_delivery_proof_overhead_from_runtime()
+ }
+}
diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_bridge_messages.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_bridge_messages.rs
new file mode 100644
index 000000000000..dbe246534237
--- /dev/null
+++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_bridge_messages.rs
@@ -0,0 +1,273 @@
+// Copyright (C) Parity Technologies (UK) Ltd.
+// This file is part of Cumulus.
+
+// Cumulus is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// Cumulus is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Cumulus. If not, see .
+
+//! Autogenerated weights for `pallet_bridge_messages`
+//!
+//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
+//! DATE: 2024-11-09, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
+//! WORST CASE MAP SIZE: `1000000`
+//! HOSTNAME: `runner-wiukf8gn-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
+//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("bridge-hub-rococo-dev")`, DB CACHE: 1024
+
+// Executed Command:
+// target/production/polkadot-parachain
+// benchmark
+// pallet
+// --steps=50
+// --repeat=20
+// --extrinsic=*
+// --wasm-execution=compiled
+// --heap-pages=4096
+// --json-file=/builds/parity/mirrors/polkadot-sdk/.git/.artifacts/bench.json
+// --pallet=pallet_bridge_messages
+// --chain=bridge-hub-rococo-dev TODO: FAIL-CI regenerate
+// --header=./cumulus/file_header.txt
+// --output=./cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/
+
+#![cfg_attr(rustfmt, rustfmt_skip)]
+#![allow(unused_parens)]
+#![allow(unused_imports)]
+#![allow(missing_docs)]
+
+use frame_support::{traits::Get, weights::Weight};
+use core::marker::PhantomData;
+
+/// Weight functions for `pallet_bridge_messages`.
+pub struct WeightInfo(PhantomData);
+impl pallet_bridge_messages::WeightInfo for WeightInfo {
+ /// Storage: `BridgeWestendMessages::PalletOperatingMode` (r:1 w:0)
+ /// Proof: `BridgeWestendMessages::PalletOperatingMode` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`)
+ /// Storage: `BridgeWestendParachains::ImportedParaHeads` (r:1 w:0)
+ /// Proof: `BridgeWestendParachains::ImportedParaHeads` (`max_values`: Some(64), `max_size`: Some(196), added: 1186, mode: `MaxEncodedLen`)
+ /// Storage: `BridgeWestendMessages::InboundLanes` (r:1 w:1)
+ /// Proof: `BridgeWestendMessages::InboundLanes` (`max_values`: None, `max_size`: Some(49180), added: 51655, mode: `MaxEncodedLen`)
+ /// Storage: `XcmOverBridgeHubWestend::LaneToBridge` (r:1 w:0)
+ /// Proof: `XcmOverBridgeHubWestend::LaneToBridge` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`)
+ /// Storage: `XcmOverBridgeHubWestend::Bridges` (r:1 w:0)
+ /// Proof: `XcmOverBridgeHubWestend::Bridges` (`max_values`: None, `max_size`: Some(1893), added: 4368, mode: `MaxEncodedLen`)
+ /// Storage: `XcmpQueue::OutboundXcmpStatus` (r:1 w:0)
+ /// Proof: `XcmpQueue::OutboundXcmpStatus` (`max_values`: Some(1), `max_size`: Some(1282), added: 1777, mode: `MaxEncodedLen`)
+ /// Storage: `ParachainInfo::ParachainId` (r:1 w:0)
+ /// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
+ fn receive_single_message_proof() -> Weight {
+ // Proof Size summary in bytes:
+ // Measured: `940`
+ // Estimated: `52645`
+ // Minimum execution time: 62_868_000 picoseconds.
+ Weight::from_parts(65_210_000, 0)
+ .saturating_add(Weight::from_parts(0, 52645))
+ .saturating_add(T::DbWeight::get().reads(7))
+ .saturating_add(T::DbWeight::get().writes(1))
+ }
+ /// Storage: `BridgeWestendMessages::PalletOperatingMode` (r:1 w:0)
+ /// Proof: `BridgeWestendMessages::PalletOperatingMode` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`)
+ /// Storage: `BridgeWestendParachains::ImportedParaHeads` (r:1 w:0)
+ /// Proof: `BridgeWestendParachains::ImportedParaHeads` (`max_values`: Some(64), `max_size`: Some(196), added: 1186, mode: `MaxEncodedLen`)
+ /// Storage: `BridgeWestendMessages::InboundLanes` (r:1 w:1)
+ /// Proof: `BridgeWestendMessages::InboundLanes` (`max_values`: None, `max_size`: Some(49180), added: 51655, mode: `MaxEncodedLen`)
+ /// Storage: `XcmOverBridgeHubWestend::LaneToBridge` (r:1 w:0)
+ /// Proof: `XcmOverBridgeHubWestend::LaneToBridge` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`)
+ /// Storage: `XcmOverBridgeHubWestend::Bridges` (r:1 w:0)
+ /// Proof: `XcmOverBridgeHubWestend::Bridges` (`max_values`: None, `max_size`: Some(1893), added: 4368, mode: `MaxEncodedLen`)
+ /// Storage: `XcmpQueue::OutboundXcmpStatus` (r:1 w:0)
+ /// Proof: `XcmpQueue::OutboundXcmpStatus` (`max_values`: Some(1), `max_size`: Some(1282), added: 1777, mode: `MaxEncodedLen`)
+ /// Storage: `ParachainInfo::ParachainId` (r:1 w:0)
+ /// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
+ /// The range of component `n` is `[1, 4076]`.
+ /// The range of component `n` is `[1, 4076]`.
+ fn receive_n_messages_proof(n: u32, ) -> Weight {
+ // Proof Size summary in bytes:
+ // Measured: `940`
+ // Estimated: `52645`
+ // Minimum execution time: 62_893_000 picoseconds.
+ Weight::from_parts(63_992_000, 0)
+ .saturating_add(Weight::from_parts(0, 52645))
+ // Standard Error: 13_856
+ .saturating_add(Weight::from_parts(12_332_627, 0).saturating_mul(n.into()))
+ .saturating_add(T::DbWeight::get().reads(7))
+ .saturating_add(T::DbWeight::get().writes(1))
+ }
+ /// Storage: `BridgeWestendMessages::PalletOperatingMode` (r:1 w:0)
+ /// Proof: `BridgeWestendMessages::PalletOperatingMode` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`)
+ /// Storage: `BridgeWestendParachains::ImportedParaHeads` (r:1 w:0)
+ /// Proof: `BridgeWestendParachains::ImportedParaHeads` (`max_values`: Some(64), `max_size`: Some(196), added: 1186, mode: `MaxEncodedLen`)
+ /// Storage: `BridgeWestendMessages::InboundLanes` (r:1 w:1)
+ /// Proof: `BridgeWestendMessages::InboundLanes` (`max_values`: None, `max_size`: Some(49180), added: 51655, mode: `MaxEncodedLen`)
+ /// Storage: `XcmOverBridgeHubWestend::LaneToBridge` (r:1 w:0)
+ /// Proof: `XcmOverBridgeHubWestend::LaneToBridge` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`)
+ /// Storage: `XcmOverBridgeHubWestend::Bridges` (r:1 w:0)
+ /// Proof: `XcmOverBridgeHubWestend::Bridges` (`max_values`: None, `max_size`: Some(1893), added: 4368, mode: `MaxEncodedLen`)
+ /// Storage: `XcmpQueue::OutboundXcmpStatus` (r:1 w:0)
+ /// Proof: `XcmpQueue::OutboundXcmpStatus` (`max_values`: Some(1), `max_size`: Some(1282), added: 1777, mode: `MaxEncodedLen`)
+ /// Storage: `ParachainInfo::ParachainId` (r:1 w:0)
+ /// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
+ fn receive_single_message_proof_with_outbound_lane_state() -> Weight {
+ // Proof Size summary in bytes:
+ // Measured: `940`
+ // Estimated: `52645`
+ // Minimum execution time: 68_193_000 picoseconds.
+ Weight::from_parts(70_799_000, 0)
+ .saturating_add(Weight::from_parts(0, 52645))
+ .saturating_add(T::DbWeight::get().reads(7))
+ .saturating_add(T::DbWeight::get().writes(1))
+ }
+ /// Storage: `BridgeWestendMessages::PalletOperatingMode` (r:1 w:0)
+ /// Proof: `BridgeWestendMessages::PalletOperatingMode` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`)
+ /// Storage: `BridgeWestendParachains::ImportedParaHeads` (r:1 w:0)
+ /// Proof: `BridgeWestendParachains::ImportedParaHeads` (`max_values`: Some(64), `max_size`: Some(196), added: 1186, mode: `MaxEncodedLen`)
+ /// Storage: `BridgeWestendMessages::InboundLanes` (r:1 w:1)
+ /// Proof: `BridgeWestendMessages::InboundLanes` (`max_values`: None, `max_size`: Some(49180), added: 51655, mode: `MaxEncodedLen`)
+ /// Storage: `XcmOverBridgeHubWestend::LaneToBridge` (r:1 w:0)
+ /// Proof: `XcmOverBridgeHubWestend::LaneToBridge` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`)
+ /// Storage: `XcmOverBridgeHubWestend::Bridges` (r:1 w:0)
+ /// Proof: `XcmOverBridgeHubWestend::Bridges` (`max_values`: None, `max_size`: Some(1893), added: 4368, mode: `MaxEncodedLen`)
+ /// Storage: `XcmpQueue::OutboundXcmpStatus` (r:1 w:0)
+ /// Proof: `XcmpQueue::OutboundXcmpStatus` (`max_values`: Some(1), `max_size`: Some(1282), added: 1777, mode: `MaxEncodedLen`)
+ /// Storage: `ParachainInfo::ParachainId` (r:1 w:0)
+ /// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
+ /// The range of component `n` is `[1, 16384]`.
+ /// The range of component `n` is `[1, 16384]`.
+ fn receive_single_n_bytes_message_proof(n: u32, ) -> Weight {
+ // Proof Size summary in bytes:
+ // Measured: `940`
+ // Estimated: `52645`
+ // Minimum execution time: 61_230_000 picoseconds.
+ Weight::from_parts(65_437_770, 0)
+ .saturating_add(Weight::from_parts(0, 52645))
+ // Standard Error: 9
+ .saturating_add(Weight::from_parts(2_168, 0).saturating_mul(n.into()))
+ .saturating_add(T::DbWeight::get().reads(7))
+ .saturating_add(T::DbWeight::get().writes(1))
+ }
+ /// Storage: `BridgeWestendMessages::PalletOperatingMode` (r:1 w:0)
+ /// Proof: `BridgeWestendMessages::PalletOperatingMode` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`)
+ /// Storage: `BridgeWestendParachains::ImportedParaHeads` (r:1 w:0)
+ /// Proof: `BridgeWestendParachains::ImportedParaHeads` (`max_values`: Some(64), `max_size`: Some(196), added: 1186, mode: `MaxEncodedLen`)
+ /// Storage: `BridgeWestendMessages::OutboundLanes` (r:1 w:1)
+ /// Proof: `BridgeWestendMessages::OutboundLanes` (`max_values`: None, `max_size`: Some(45), added: 2520, mode: `MaxEncodedLen`)
+ /// Storage: UNKNOWN KEY `0x6e0a18b62a1de81c5f519181cc611e18` (r:1 w:0)
+ /// Proof: UNKNOWN KEY `0x6e0a18b62a1de81c5f519181cc611e18` (r:1 w:0)
+ /// Storage: `BridgeRelayers::RelayerRewards` (r:1 w:1)
+ /// Proof: `BridgeRelayers::RelayerRewards` (`max_values`: None, `max_size`: Some(73), added: 2548, mode: `MaxEncodedLen`)
+ /// Storage: `XcmOverBridgeHubWestend::LaneToBridge` (r:1 w:0)
+ /// Proof: `XcmOverBridgeHubWestend::LaneToBridge` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`)
+ /// Storage: `XcmOverBridgeHubWestend::Bridges` (r:1 w:0)
+ /// Proof: `XcmOverBridgeHubWestend::Bridges` (`max_values`: None, `max_size`: Some(1893), added: 4368, mode: `MaxEncodedLen`)
+ /// Storage: `BridgeWestendMessages::OutboundMessages` (r:0 w:1)
+ /// Proof: `BridgeWestendMessages::OutboundMessages` (`max_values`: None, `max_size`: Some(65568), added: 68043, mode: `MaxEncodedLen`)
+ fn receive_delivery_proof_for_single_message() -> Weight {
+ // Proof Size summary in bytes:
+ // Measured: `711`
+ // Estimated: `5358`
+ // Minimum execution time: 51_650_000 picoseconds.
+ Weight::from_parts(53_190_000, 0)
+ .saturating_add(Weight::from_parts(0, 5358))
+ .saturating_add(T::DbWeight::get().reads(7))
+ .saturating_add(T::DbWeight::get().writes(3))
+ }
+ /// Storage: `BridgeWestendMessages::PalletOperatingMode` (r:1 w:0)
+ /// Proof: `BridgeWestendMessages::PalletOperatingMode` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`)
+ /// Storage: `BridgeWestendParachains::ImportedParaHeads` (r:1 w:0)
+ /// Proof: `BridgeWestendParachains::ImportedParaHeads` (`max_values`: Some(64), `max_size`: Some(196), added: 1186, mode: `MaxEncodedLen`)
+ /// Storage: `BridgeWestendMessages::OutboundLanes` (r:1 w:1)
+ /// Proof: `BridgeWestendMessages::OutboundLanes` (`max_values`: None, `max_size`: Some(45), added: 2520, mode: `MaxEncodedLen`)
+ /// Storage: UNKNOWN KEY `0x6e0a18b62a1de81c5f519181cc611e18` (r:1 w:0)
+ /// Proof: UNKNOWN KEY `0x6e0a18b62a1de81c5f519181cc611e18` (r:1 w:0)
+ /// Storage: `BridgeRelayers::RelayerRewards` (r:1 w:1)
+ /// Proof: `BridgeRelayers::RelayerRewards` (`max_values`: None, `max_size`: Some(73), added: 2548, mode: `MaxEncodedLen`)
+ /// Storage: `XcmOverBridgeHubWestend::LaneToBridge` (r:1 w:0)
+ /// Proof: `XcmOverBridgeHubWestend::LaneToBridge` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`)
+ /// Storage: `XcmOverBridgeHubWestend::Bridges` (r:1 w:0)
+ /// Proof: `XcmOverBridgeHubWestend::Bridges` (`max_values`: None, `max_size`: Some(1893), added: 4368, mode: `MaxEncodedLen`)
+ /// Storage: `BridgeWestendMessages::OutboundMessages` (r:0 w:2)
+ /// Proof: `BridgeWestendMessages::OutboundMessages` (`max_values`: None, `max_size`: Some(65568), added: 68043, mode: `MaxEncodedLen`)
+ fn receive_delivery_proof_for_two_messages_by_single_relayer() -> Weight {
+ // Proof Size summary in bytes:
+ // Measured: `711`
+ // Estimated: `5358`
+ // Minimum execution time: 51_836_000 picoseconds.
+ Weight::from_parts(53_960_000, 0)
+ .saturating_add(Weight::from_parts(0, 5358))
+ .saturating_add(T::DbWeight::get().reads(7))
+ .saturating_add(T::DbWeight::get().writes(4))
+ }
+ /// Storage: `BridgeWestendMessages::PalletOperatingMode` (r:1 w:0)
+ /// Proof: `BridgeWestendMessages::PalletOperatingMode` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`)
+ /// Storage: `BridgeWestendParachains::ImportedParaHeads` (r:1 w:0)
+ /// Proof: `BridgeWestendParachains::ImportedParaHeads` (`max_values`: Some(64), `max_size`: Some(196), added: 1186, mode: `MaxEncodedLen`)
+ /// Storage: `BridgeWestendMessages::OutboundLanes` (r:1 w:1)
+ /// Proof: `BridgeWestendMessages::OutboundLanes` (`max_values`: None, `max_size`: Some(45), added: 2520, mode: `MaxEncodedLen`)
+ /// Storage: UNKNOWN KEY `0x6e0a18b62a1de81c5f519181cc611e18` (r:1 w:0)
+ /// Proof: UNKNOWN KEY `0x6e0a18b62a1de81c5f519181cc611e18` (r:1 w:0)
+ /// Storage: `BridgeRelayers::RelayerRewards` (r:2 w:2)
+ /// Proof: `BridgeRelayers::RelayerRewards` (`max_values`: None, `max_size`: Some(73), added: 2548, mode: `MaxEncodedLen`)
+ /// Storage: `XcmOverBridgeHubWestend::LaneToBridge` (r:1 w:0)
+ /// Proof: `XcmOverBridgeHubWestend::LaneToBridge` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`)
+ /// Storage: `XcmOverBridgeHubWestend::Bridges` (r:1 w:0)
+ /// Proof: `XcmOverBridgeHubWestend::Bridges` (`max_values`: None, `max_size`: Some(1893), added: 4368, mode: `MaxEncodedLen`)
+ /// Storage: `BridgeWestendMessages::OutboundMessages` (r:0 w:2)
+ /// Proof: `BridgeWestendMessages::OutboundMessages` (`max_values`: None, `max_size`: Some(65568), added: 68043, mode: `MaxEncodedLen`)
+ fn receive_delivery_proof_for_two_messages_by_two_relayers() -> Weight {
+ // Proof Size summary in bytes:
+ // Measured: `711`
+ // Estimated: `6086`
+ // Minimum execution time: 56_606_000 picoseconds.
+ Weight::from_parts(58_528_000, 0)
+ .saturating_add(Weight::from_parts(0, 6086))
+ .saturating_add(T::DbWeight::get().reads(8))
+ .saturating_add(T::DbWeight::get().writes(5))
+ }
+ /// Storage: `BridgeWestendMessages::PalletOperatingMode` (r:1 w:0)
+ /// Proof: `BridgeWestendMessages::PalletOperatingMode` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`)
+ /// Storage: `BridgeWestendParachains::ImportedParaHeads` (r:1 w:0)
+ /// Proof: `BridgeWestendParachains::ImportedParaHeads` (`max_values`: Some(64), `max_size`: Some(196), added: 1186, mode: `MaxEncodedLen`)
+ /// Storage: `BridgeWestendMessages::InboundLanes` (r:1 w:1)
+ /// Proof: `BridgeWestendMessages::InboundLanes` (`max_values`: None, `max_size`: Some(49180), added: 51655, mode: `MaxEncodedLen`)
+ /// Storage: `XcmOverBridgeHubWestend::LaneToBridge` (r:1 w:0)
+ /// Proof: `XcmOverBridgeHubWestend::LaneToBridge` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`)
+ /// Storage: `XcmOverBridgeHubWestend::Bridges` (r:1 w:0)
+ /// Proof: `XcmOverBridgeHubWestend::Bridges` (`max_values`: None, `max_size`: Some(1893), added: 4368, mode: `MaxEncodedLen`)
+ /// Storage: `XcmpQueue::OutboundXcmpStatus` (r:1 w:1)
+ /// Proof: `XcmpQueue::OutboundXcmpStatus` (`max_values`: Some(1), `max_size`: Some(1282), added: 1777, mode: `MaxEncodedLen`)
+ /// Storage: `ParachainInfo::ParachainId` (r:1 w:0)
+ /// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
+ /// Storage: `XcmpQueue::DeliveryFeeFactor` (r:1 w:0)
+ /// Proof: `XcmpQueue::DeliveryFeeFactor` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`)
+ /// Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0)
+ /// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`)
+ /// Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1)
+ /// Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
+ /// Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0)
+ /// Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
+ /// Storage: `ParachainSystem::RelevantMessagingState` (r:1 w:0)
+ /// Proof: `ParachainSystem::RelevantMessagingState` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
+ /// Storage: `XcmpQueue::OutboundXcmpMessages` (r:0 w:1)
+ /// Proof: `XcmpQueue::OutboundXcmpMessages` (`max_values`: None, `max_size`: Some(105506), added: 107981, mode: `MaxEncodedLen`)
+ /// The range of component `n` is `[1, 16384]`.
+ /// The range of component `n` is `[1, 16384]`.
+ fn receive_single_n_bytes_message_proof_with_dispatch(n: u32, ) -> Weight {
+ // Proof Size summary in bytes:
+ // Measured: `1071`
+ // Estimated: `52645`
+ // Minimum execution time: 85_179_000 picoseconds.
+ Weight::from_parts(91_600_892, 0)
+ .saturating_add(Weight::from_parts(0, 52645))
+ // Standard Error: 11
+ .saturating_add(Weight::from_parts(7_210, 0).saturating_mul(n.into()))
+ .saturating_add(T::DbWeight::get().reads(12))
+ .saturating_add(T::DbWeight::get().writes(4))
+ }
+}
diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_bridge_relayers.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_bridge_relayers.rs
new file mode 100644
index 000000000000..913bb3ab2487
--- /dev/null
+++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_bridge_relayers.rs
@@ -0,0 +1,123 @@
+// Copyright (C) Parity Technologies (UK) Ltd.
+// This file is part of Cumulus.
+
+// Cumulus is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// Cumulus is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Cumulus. If not, see .
+
+//! Autogenerated weights for `pallet_bridge_relayers`
+//!
+//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
+//! DATE: 2024-08-15, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
+//! WORST CASE MAP SIZE: `1000000`
+//! HOSTNAME: `runner-696hpswk-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
+//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("bridge-hub-rococo-dev")`, DB CACHE: 1024
+
+// Executed Command:
+// target/production/polkadot-parachain
+// benchmark
+// pallet
+// --steps=50
+// --repeat=20
+// --extrinsic=*
+// --wasm-execution=compiled
+// --heap-pages=4096
+// --json-file=/builds/parity/mirrors/polkadot-sdk/.git/.artifacts/bench.json
+// --pallet=pallet_bridge_relayers
+// --chain=bridge-hub-rococo-dev TODO: FAIL-CI regenerate
+// --header=./cumulus/file_header.txt
+// --output=./cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/
+
+#![cfg_attr(rustfmt, rustfmt_skip)]
+#![allow(unused_parens)]
+#![allow(unused_imports)]
+#![allow(missing_docs)]
+
+use frame_support::{traits::Get, weights::Weight};
+use core::marker::PhantomData;
+
+/// Weight functions for `pallet_bridge_relayers`.
+pub struct WeightInfo(PhantomData);
+impl pallet_bridge_relayers::WeightInfo for WeightInfo {
+ /// Storage: `BridgeRelayers::RelayerRewards` (r:1 w:1)
+ /// Proof: `BridgeRelayers::RelayerRewards` (`max_values`: None, `max_size`: Some(102), added: 2577, mode: `MaxEncodedLen`)
+ /// Storage: `System::Account` (r:1 w:1)
+ /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
+ fn claim_rewards() -> Weight {
+ // Proof Size summary in bytes:
+ // Measured: `306`
+ // Estimated: `3593`
+ // Minimum execution time: 53_924_000 picoseconds.
+ Weight::from_parts(54_736_000, 0)
+ .saturating_add(Weight::from_parts(0, 3593))
+ .saturating_add(T::DbWeight::get().reads(2))
+ .saturating_add(T::DbWeight::get().writes(2))
+ }
+ /// Storage: `BridgeRelayers::RegisteredRelayers` (r:1 w:1)
+ /// Proof: `BridgeRelayers::RegisteredRelayers` (`max_values`: None, `max_size`: Some(68), added: 2543, mode: `MaxEncodedLen`)
+ /// Storage: UNKNOWN KEY `0x1e8445dc201eeb8560e5579a5dd54655` (r:1 w:0)
+ /// Proof: UNKNOWN KEY `0x1e8445dc201eeb8560e5579a5dd54655` (r:1 w:0)
+ /// Storage: `Balances::Reserves` (r:1 w:1)
+ /// Proof: `Balances::Reserves` (`max_values`: None, `max_size`: Some(1249), added: 3724, mode: `MaxEncodedLen`)
+ fn register() -> Weight {
+ // Proof Size summary in bytes:
+ // Measured: `131`
+ // Estimated: `4714`
+ // Minimum execution time: 28_608_000 picoseconds.
+ Weight::from_parts(29_081_000, 0)
+ .saturating_add(Weight::from_parts(0, 4714))
+ .saturating_add(T::DbWeight::get().reads(3))
+ .saturating_add(T::DbWeight::get().writes(2))
+ }
+ /// Storage: `BridgeRelayers::RegisteredRelayers` (r:1 w:1)
+ /// Proof: `BridgeRelayers::RegisteredRelayers` (`max_values`: None, `max_size`: Some(68), added: 2543, mode: `MaxEncodedLen`)
+ /// Storage: `Balances::Reserves` (r:1 w:1)
+ /// Proof: `Balances::Reserves` (`max_values`: None, `max_size`: Some(1249), added: 3724, mode: `MaxEncodedLen`)
+ fn deregister() -> Weight {
+ // Proof Size summary in bytes:
+ // Measured: `231`
+ // Estimated: `4714`
+ // Minimum execution time: 29_738_000 picoseconds.
+ Weight::from_parts(30_242_000, 0)
+ .saturating_add(Weight::from_parts(0, 4714))
+ .saturating_add(T::DbWeight::get().reads(2))
+ .saturating_add(T::DbWeight::get().writes(2))
+ }
+ /// Storage: `BridgeRelayers::RegisteredRelayers` (r:1 w:1)
+ /// Proof: `BridgeRelayers::RegisteredRelayers` (`max_values`: None, `max_size`: Some(68), added: 2543, mode: `MaxEncodedLen`)
+ /// Storage: `Balances::Reserves` (r:1 w:1)
+ /// Proof: `Balances::Reserves` (`max_values`: None, `max_size`: Some(1249), added: 3724, mode: `MaxEncodedLen`)
+ /// Storage: `System::Account` (r:1 w:1)
+ /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
+ fn slash_and_deregister() -> Weight {
+ // Proof Size summary in bytes:
+ // Measured: `334`
+ // Estimated: `4714`
+ // Minimum execution time: 33_174_000 picoseconds.
+ Weight::from_parts(33_992_000, 0)
+ .saturating_add(Weight::from_parts(0, 4714))
+ .saturating_add(T::DbWeight::get().reads(3))
+ .saturating_add(T::DbWeight::get().writes(3))
+ }
+ /// Storage: `BridgeRelayers::RelayerRewards` (r:1 w:1)
+ /// Proof: `BridgeRelayers::RelayerRewards` (`max_values`: None, `max_size`: Some(102), added: 2577, mode: `MaxEncodedLen`)
+ fn register_relayer_reward() -> Weight {
+ // Proof Size summary in bytes:
+ // Measured: `76`
+ // Estimated: `3567`
+ // Minimum execution time: 7_950_000 picoseconds.
+ Weight::from_parts(8_123_000, 0)
+ .saturating_add(Weight::from_parts(0, 3567))
+ .saturating_add(T::DbWeight::get().reads(1))
+ .saturating_add(T::DbWeight::get().writes(1))
+ }
+}
diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_xcm_bridge_hub.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_xcm_bridge_hub.rs
new file mode 100644
index 000000000000..36b3e0a1fd1a
--- /dev/null
+++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_xcm_bridge_hub.rs
@@ -0,0 +1,110 @@
+// Copyright (C) Parity Technologies (UK) Ltd.
+// This file is part of Cumulus.
+
+// Cumulus is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// Cumulus is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Cumulus. If not, see .
+
+//! Autogenerated weights for `pallet_xcm_bridge_hub`
+//!
+//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
+//! DATE: 2024-11-18, STEPS: `2`, REPEAT: `1`, LOW RANGE: `[]`, HIGH RANGE: `[]`
+//! WORST CASE MAP SIZE: `1000000`
+//! HOSTNAME: `toaster1`, CPU: `AMD Ryzen Threadripper 7980X 64-Cores`
+//! WASM-EXECUTION: `Compiled`, CHAIN: `None`, DB CACHE: 1024
+
+// Executed Command:
+// ./target/release/frame-omni-bencher
+// v1
+// benchmark
+// pallet
+// --runtime
+// ./target/debug/wbuild/asset-hub-rococo-runtime/asset_hub_rococo_runtime.wasm
+// --pallet
+// pallet_xcm_bridge_hub
+// --extrinsic
+// *
+// --steps
+// 2
+// --repeat
+// 1
+// --output
+// ./remote-builds -- TODO: FAIL-CI new weights
+
+#![cfg_attr(rustfmt, rustfmt_skip)]
+#![allow(unused_parens)]
+#![allow(unused_imports)]
+#![allow(missing_docs)]
+
+use frame_support::{traits::Get, weights::Weight};
+use core::marker::PhantomData;
+
+/// Weight functions for `pallet_xcm_bridge_hub`.
+pub struct WeightInfo(PhantomData);
+impl pallet_xcm_bridge_hub::WeightInfo for WeightInfo {
+ /// Storage: `ParachainInfo::ParachainId` (r:1 w:0)
+ /// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
+ /// Storage: `XcmOverAssetHubWestend::Bridges` (r:1 w:1)
+ /// Proof: `XcmOverAssetHubWestend::Bridges` (`max_values`: None, `max_size`: Some(1922), added: 4397, mode: `MaxEncodedLen`)
+ /// Storage: `XcmOverAssetHubWestend::LaneToBridge` (r:1 w:1)
+ /// Proof: `XcmOverAssetHubWestend::LaneToBridge` (`max_values`: None, `max_size`: Some(64), added: 2539, mode: `MaxEncodedLen`)
+ /// Storage: `BridgeWestendMessages::InboundLanes` (r:1 w:1)
+ /// Proof: `BridgeWestendMessages::InboundLanes` (`max_values`: None, `max_size`: Some(49208), added: 51683, mode: `MaxEncodedLen`)
+ /// Storage: `XcmpQueue::OutboundXcmpStatus` (r:1 w:0)
+ /// Proof: `XcmpQueue::OutboundXcmpStatus` (`max_values`: Some(1), `max_size`: Some(1282), added: 1777, mode: `MaxEncodedLen`)
+ /// Storage: `BridgeWestendMessages::OutboundLanes` (r:1 w:1)
+ /// Proof: `BridgeWestendMessages::OutboundLanes` (`max_values`: None, `max_size`: Some(73), added: 2548, mode: `MaxEncodedLen`)
+ fn open_bridge() -> Weight {
+ // Proof Size summary in bytes:
+ // Measured: `214`
+ // Estimated: `52673`
+ // Minimum execution time: 40_171_000 picoseconds.
+ Weight::from_parts(40_171_000, 0)
+ .saturating_add(Weight::from_parts(0, 52673))
+ .saturating_add(T::DbWeight::get().reads(6))
+ .saturating_add(T::DbWeight::get().writes(4))
+ }
+ /// Storage: `ParachainInfo::ParachainId` (r:1 w:0)
+ /// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
+ /// Storage: `XcmOverAssetHubWestend::Bridges` (r:1 w:1)
+ /// Proof: `XcmOverAssetHubWestend::Bridges` (`max_values`: None, `max_size`: Some(1922), added: 4397, mode: `MaxEncodedLen`)
+ /// Storage: `BridgeWestendMessages::InboundLanes` (r:1 w:1)
+ /// Proof: `BridgeWestendMessages::InboundLanes` (`max_values`: None, `max_size`: Some(49208), added: 51683, mode: `MaxEncodedLen`)
+ /// Storage: `BridgeWestendMessages::OutboundLanes` (r:1 w:1)
+ /// Proof: `BridgeWestendMessages::OutboundLanes` (`max_values`: None, `max_size`: Some(73), added: 2548, mode: `MaxEncodedLen`)
+ /// Storage: `XcmOverAssetHubWestend::LaneToBridge` (r:0 w:1)
+ /// Proof: `XcmOverAssetHubWestend::LaneToBridge` (`max_values`: None, `max_size`: Some(64), added: 2539, mode: `MaxEncodedLen`)
+ fn close_bridge() -> Weight {
+ // Proof Size summary in bytes:
+ // Measured: `488`
+ // Estimated: `52673`
+ // Minimum execution time: 30_096_000 picoseconds.
+ Weight::from_parts(30_096_000, 0)
+ .saturating_add(Weight::from_parts(0, 52673))
+ .saturating_add(T::DbWeight::get().reads(4))
+ .saturating_add(T::DbWeight::get().writes(4))
+ }
+ /// Storage: `ParachainInfo::ParachainId` (r:1 w:0)
+ /// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
+ /// Storage: `XcmOverAssetHubWestend::Bridges` (r:1 w:1)
+ /// Proof: `XcmOverAssetHubWestend::Bridges` (`max_values`: None, `max_size`: Some(1922), added: 4397, mode: `MaxEncodedLen`)
+ fn update_notification_receiver() -> Weight {
+ // Proof Size summary in bytes:
+ // Measured: `212`
+ // Estimated: `5387`
+ // Minimum execution time: 15_994_000 picoseconds.
+ Weight::from_parts(15_994_000, 0)
+ .saturating_add(Weight::from_parts(0, 5387))
+ .saturating_add(T::DbWeight::get().reads(2))
+ .saturating_add(T::DbWeight::get().writes(1))
+ }
+}
diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_xcm_bridge_hub_router.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_xcm_bridge_hub_router_to_westend.rs
similarity index 97%
rename from cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_xcm_bridge_hub_router.rs
rename to cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_xcm_bridge_hub_router_to_westend.rs
index 8aee137ee50b..9559104b117c 100644
--- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_xcm_bridge_hub_router.rs
+++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_xcm_bridge_hub_router_to_westend.rs
@@ -48,7 +48,7 @@ use core::marker::PhantomData;
/// Weight functions for `pallet_xcm_bridge_hub_router`.
pub struct WeightInfo(PhantomData);
impl pallet_xcm_bridge_hub_router::WeightInfo for WeightInfo {
- /// Storage: `ToWestendXcmRouter::Bridges` (r:2 w:1)
+ /// Storage: `ToWestendXcmRouter::Bridges` (r:2 w:1) TODO: FAIL-CI new weights
/// Proof: `ToWestendXcmRouter::Bridges` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`)
fn on_idle_when_bridge_state_removed() -> Weight {
// Proof Size summary in bytes:
diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_xcm_bridge_hub_router_to_westend_over_bridge_hub.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_xcm_bridge_hub_router_to_westend_over_bridge_hub.rs
new file mode 100644
index 000000000000..9559104b117c
--- /dev/null
+++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_xcm_bridge_hub_router_to_westend_over_bridge_hub.rs
@@ -0,0 +1,87 @@
+// Copyright (C) Parity Technologies (UK) Ltd.
+// This file is part of Cumulus.
+
+// Cumulus is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// Cumulus is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Cumulus. If not, see .
+
+//! Autogenerated weights for `pallet_xcm_bridge_hub_router`
+//!
+//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
+//! DATE: 2024-11-09, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
+//! WORST CASE MAP SIZE: `1000000`
+//! HOSTNAME: `runner-wiukf8gn-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
+//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("asset-hub-rococo-dev")`, DB CACHE: 1024
+
+// Executed Command:
+// target/production/polkadot-parachain
+// benchmark
+// pallet
+// --steps=50
+// --repeat=20
+// --extrinsic=*
+// --wasm-execution=compiled
+// --heap-pages=4096
+// --json-file=/builds/parity/mirrors/polkadot-sdk/.git/.artifacts/bench.json
+// --pallet=pallet_xcm_bridge_hub_router
+// --chain=asset-hub-rococo-dev
+// --header=./cumulus/file_header.txt
+// --output=./cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/
+
+#![cfg_attr(rustfmt, rustfmt_skip)]
+#![allow(unused_parens)]
+#![allow(unused_imports)]
+#![allow(missing_docs)]
+
+use frame_support::{traits::Get, weights::Weight};
+use core::marker::PhantomData;
+
+/// Weight functions for `pallet_xcm_bridge_hub_router`.
+pub struct WeightInfo(PhantomData);
+impl pallet_xcm_bridge_hub_router::WeightInfo for WeightInfo {
+ /// Storage: `ToWestendXcmRouter::Bridges` (r:2 w:1) TODO: FAIL-CI new weights
+ /// Proof: `ToWestendXcmRouter::Bridges` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`)
+ fn on_idle_when_bridge_state_removed() -> Weight {
+ // Proof Size summary in bytes:
+ // Measured: `204`
+ // Estimated: `6070`
+ // Minimum execution time: 19_038_000 picoseconds.
+ Weight::from_parts(19_659_000, 0)
+ .saturating_add(Weight::from_parts(0, 6070))
+ .saturating_add(T::DbWeight::get().reads(2))
+ .saturating_add(T::DbWeight::get().writes(1))
+ }
+ /// Storage: `ToWestendXcmRouter::Bridges` (r:2 w:1)
+ /// Proof: `ToWestendXcmRouter::Bridges` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`)
+ fn on_idle_when_bridge_state_updated() -> Weight {
+ // Proof Size summary in bytes:
+ // Measured: `204`
+ // Estimated: `6070`
+ // Minimum execution time: 20_051_000 picoseconds.
+ Weight::from_parts(20_698_000, 0)
+ .saturating_add(Weight::from_parts(0, 6070))
+ .saturating_add(T::DbWeight::get().reads(2))
+ .saturating_add(T::DbWeight::get().writes(1))
+ }
+ /// Storage: `ToWestendXcmRouter::Bridges` (r:1 w:1)
+ /// Proof: `ToWestendXcmRouter::Bridges` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`)
+ fn update_bridge_status() -> Weight {
+ // Proof Size summary in bytes:
+ // Measured: `109`
+ // Estimated: `3530`
+ // Minimum execution time: 12_193_000 picoseconds.
+ Weight::from_parts(12_658_000, 0)
+ .saturating_add(Weight::from_parts(0, 3530))
+ .saturating_add(T::DbWeight::get().reads(1))
+ .saturating_add(T::DbWeight::get().writes(1))
+ }
+}
diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/mod.rs
index 025c39bcee07..b434d76cab63 100644
--- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/mod.rs
+++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/mod.rs
@@ -19,6 +19,7 @@ mod pallet_xcm_benchmarks_generic;
use crate::{xcm_config::MaxAssetsIntoHolding, Runtime};
use alloc::vec::Vec;
+use codec::Encode;
use frame_support::weights::Weight;
use pallet_xcm_benchmarks_fungible::WeightInfo as XcmFungibleWeight;
use pallet_xcm_benchmarks_generic::WeightInfo as XcmGeneric;
@@ -223,8 +224,9 @@ impl XcmWeightInfo for AssetHubRococoXcmWeight {
fn universal_origin(_: &Junction) -> Weight {
XcmGeneric::::universal_origin()
}
- fn export_message(_: &NetworkId, _: &Junctions, _: &Xcm<()>) -> Weight {
- Weight::MAX
+ fn export_message(_: &NetworkId, _: &Junctions, inner: &Xcm<()>) -> Weight {
+ let inner_encoded_len = inner.encode().len() as u32;
+ XcmGeneric::::export_message(inner_encoded_len)
}
fn lock_asset(_: &Asset, _: &Location) -> Weight {
Weight::MAX
diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs
index b69c136b29d9..c56b2ca1d776 100644
--- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs
+++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs
@@ -352,6 +352,29 @@ impl WeightInfo {
Weight::from_parts(2_715_000, 1489)
.saturating_add(T::DbWeight::get().reads(1))
}
+ /// Storage: `ParachainInfo::ParachainId` (r:1 w:0)
+ /// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
+ /// Storage: `XcmOverAssetHubWestend::Bridges` (r:1 w:0)
+ /// Proof: `XcmOverAssetHubWestend::Bridges` (`max_values`: None, `max_size`: Some(1922), added: 4397, mode: `MaxEncodedLen`)
+ /// Storage: `PolkadotXcm::SupportedVersion` (r:2 w:0)
+ /// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`)
+ /// Storage: `BridgeWestendMessages::PalletOperatingMode` (r:1 w:0)
+ /// Proof: `BridgeWestendMessages::PalletOperatingMode` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`)
+ /// Storage: `BridgeWestendMessages::OutboundLanes` (r:1 w:1)
+ /// Proof: `BridgeWestendMessages::OutboundLanes` (`max_values`: None, `max_size`: Some(73), added: 2548, mode: `MaxEncodedLen`)
+ /// Storage: `BridgeWestendMessages::OutboundMessages` (r:0 w:1)
+ /// Proof: `BridgeWestendMessages::OutboundMessages` (`max_values`: None, `max_size`: Some(65596), added: 68071, mode: `MaxEncodedLen`)
+ /// The range of component `x` is `[1, 1000]`.
+ pub fn export_message(_x: u32, ) -> Weight {
+ // Proof Size summary in bytes:
+ // Measured: `692`
+ // Estimated: `6632`
+ // Minimum execution time: 64_317_000 picoseconds.
+ Weight::from_parts(115_635_000, 0)
+ .saturating_add(Weight::from_parts(0, 6632))
+ .saturating_add(T::DbWeight::get().reads(6))
+ .saturating_add(T::DbWeight::get().writes(2))
+ }
pub fn set_fees_mode() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/xcm_config.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/xcm_config.rs
index 1e3ad688072e..16fbdcd67020 100644
--- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/xcm_config.rs
+++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/xcm_config.rs
@@ -17,8 +17,8 @@ use super::{
AccountId, AllPalletsWithSystem, Assets, Authorship, Balance, Balances, BaseDeliveryFee,
CollatorSelection, FeeAssetId, ForeignAssets, ForeignAssetsInstance, ParachainInfo,
ParachainSystem, PolkadotXcm, PoolAssets, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin,
- ToWestendXcmRouter, TransactionByteFee, TrustBackedAssetsInstance, Uniques, WeightToFee,
- XcmpQueue,
+ ToWestendOverBridgeHubLegacyXcmRouter, ToWestendXcmRouter, TransactionByteFee,
+ TrustBackedAssetsInstance, Uniques, WeightToFee, XcmOverAssetHubWestend, XcmpQueue,
};
use assets_common::{
matching::{FromNetwork, FromSiblingParachain, IsForeignConcreteAsset, ParentLocation},
@@ -438,7 +438,10 @@ impl xcm_executor::Config for XcmConfig {
WaivedLocations,
SendXcmFeeToAccount,
>;
- type MessageExporter = ();
+ type MessageExporter = (
+ // AH's permissionless lanes support exporting to Westend.
+ XcmOverAssetHubWestend,
+ );
type UniversalAliases =
(bridging::to_westend::UniversalAliases, bridging::to_ethereum::UniversalAliases);
type CallDispatcher = RuntimeCall;
@@ -460,7 +463,7 @@ pub type PriceForParentDelivery =
ExponentialPrice;
/// For routing XCM messages which do not cross local consensus boundary.
-type LocalXcmRouter = (
+pub(crate) type LocalXcmRouter = (
// Two routers - use UMP to communicate with the relay chain:
cumulus_primitives_utility::ParentAsUmp,
// ..and XCMP to communicate with the sibling chains.
@@ -471,9 +474,12 @@ type LocalXcmRouter = (
/// queues.
pub type XcmRouter = WithUniqueTopic<(
LocalXcmRouter,
- // Router which wraps and sends xcm to BridgeHub to be delivered to the Westend
- // GlobalConsensus
+ // Router that exports messages to be delivered to the Westend GlobalConsensus,
+ // when a permissionless lane is created between the origin and destination.
ToWestendXcmRouter,
+ // Router which wraps (`ExportMessage`) and sends xcm to BridgeHub to be delivered to the
+ // Westend GlobalConsensus
+ ToWestendOverBridgeHubLegacyXcmRouter,
// Router which wraps and sends xcm to BridgeHub to be delivered to the Ethereum
// GlobalConsensus
SovereignPaidRemoteExporter,
diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/tests/tests.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/tests/tests.rs
index 4147dd84c85f..a356817016b0 100644
--- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/tests/tests.rs
+++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/tests/tests.rs
@@ -27,8 +27,7 @@ use asset_hub_rococo_runtime::{
AllPalletsWithoutSystem, AssetConversion, AssetDeposit, Assets, Balances, Block,
CollatorSelection, ExistentialDeposit, ForeignAssets, ForeignAssetsInstance,
MetadataDepositBase, MetadataDepositPerByte, ParachainSystem, Runtime, RuntimeCall,
- RuntimeEvent, RuntimeOrigin, SessionKeys, ToWestendXcmRouterInstance,
- TrustBackedAssetsInstance, XcmpQueue,
+ RuntimeEvent, RuntimeOrigin, SessionKeys, TrustBackedAssetsInstance, XcmpQueue,
};
use asset_test_utils::{
test_cases_over_bridge::TestBridgingConfig, CollatorSessionKey, CollatorSessionKeys,
@@ -1078,8 +1077,10 @@ fn limited_reserve_transfer_assets_for_native_asset_over_bridge_works(
mod asset_hub_rococo_tests {
use super::*;
- use asset_hub_rococo_runtime::PolkadotXcm;
- use xcm::latest::WESTEND_GENESIS_HASH;
+ use asset_hub_rococo_runtime::{
+ bridge_to_westend_config::WestendGlobalConsensusNetwork, PolkadotXcm,
+ ToWestendOverBridgeHubLegacyXcmRouterInstance,
+ };
use xcm_executor::traits::ConvertLocation;
fn bridging_to_asset_hub_westend() -> TestBridgingConfig {
@@ -1110,10 +1111,8 @@ mod asset_hub_rococo_tests {
let block_author_account = AccountId::from(BLOCK_AUTHOR_ACCOUNT);
let staking_pot = StakingPot::get();
- let foreign_asset_id_location = Location::new(
- 2,
- [Junction::GlobalConsensus(NetworkId::ByGenesis(WESTEND_GENESIS_HASH))],
- );
+ let foreign_asset_id_location =
+ Location::new(2, [GlobalConsensus(WestendGlobalConsensusNetwork::get())]);
let foreign_asset_id_minimum_balance = 1_000_000_000;
// sovereign account as foreign asset owner (can be whoever for this scenario)
let foreign_asset_owner =
@@ -1147,7 +1146,7 @@ mod asset_hub_rococo_tests {
},
(
[PalletInstance(bp_bridge_hub_rococo::WITH_BRIDGE_ROCOCO_TO_WESTEND_MESSAGES_PALLET_INDEX)].into(),
- GlobalConsensus(ByGenesis(WESTEND_GENESIS_HASH)),
+ GlobalConsensus(WestendGlobalConsensusNetwork::get()),
[Parachain(1000)].into()
),
|| {
@@ -1186,10 +1185,8 @@ mod asset_hub_rococo_tests {
let block_author_account = AccountId::from(BLOCK_AUTHOR_ACCOUNT);
let staking_pot = StakingPot::get();
- let foreign_asset_id_location = Location::new(
- 2,
- [Junction::GlobalConsensus(NetworkId::ByGenesis(WESTEND_GENESIS_HASH))],
- );
+ let foreign_asset_id_location =
+ Location::new(2, [Junction::GlobalConsensus(WestendGlobalConsensusNetwork::get())]);
let foreign_asset_id_minimum_balance = 1_000_000_000;
// sovereign account as foreign asset owner (can be whoever for this scenario)
let foreign_asset_owner =
@@ -1216,7 +1213,7 @@ mod asset_hub_rococo_tests {
bridging_to_asset_hub_westend,
(
[PalletInstance(bp_bridge_hub_rococo::WITH_BRIDGE_ROCOCO_TO_WESTEND_MESSAGES_PALLET_INDEX)].into(),
- GlobalConsensus(ByGenesis(WESTEND_GENESIS_HASH)),
+ GlobalConsensus(WestendGlobalConsensusNetwork::get()),
[Parachain(1000)].into()
),
|| {
@@ -1280,13 +1277,13 @@ mod asset_hub_rococo_tests {
AllPalletsWithoutSystem,
XcmConfig,
LocationToAccountId,
- ToWestendXcmRouterInstance,
+ ToWestendOverBridgeHubLegacyXcmRouterInstance,
>(collator_session_keys(), bridging_to_asset_hub_westend, |bridge_id, is_congested| {
vec![
UnpaidExecution { weight_limit: Unlimited, check_origin: None },
Transact {
origin_kind: OriginKind::Xcm,
- call: RuntimeCall::ToWestendXcmRouter(
+ call: RuntimeCall::ToWestendOverBridgeHubLegacyXcmRouter(
pallet_xcm_bridge_hub_router::Call::update_bridge_status {
bridge_id,
is_congested,
@@ -1516,3 +1513,331 @@ fn xcm_payment_api_works() {
Block,
>();
}
+
+mod bridge_to_westend_tests {
+ use super::{collator_session_keys, slot_durations, AccountId, ExtBuilder, RuntimeHelper};
+ use asset_hub_rococo_runtime::{
+ bridge_common_config::DeliveryRewardInBalance,
+ bridge_to_westend_config::{
+ AssetHubWestendLocation, WestendGlobalConsensusNetwork,
+ WithAssetHubWestendMessagesInstance, XcmOverAssetHubWestendInstance,
+ },
+ xcm_config::{bridging, LocationToAccountId, RelayNetwork, TokenLocation, XcmConfig},
+ AllPalletsWithoutSystem, ExistentialDeposit, ParachainSystem, PolkadotXcm, Runtime,
+ RuntimeCall, RuntimeEvent, RuntimeOrigin,
+ };
+ use bp_runtime::RangeInclusiveExt;
+ use bridge_hub_test_utils::mock_open_hrmp_channel;
+ use codec::{Decode, Encode};
+ use frame_support::traits::{ConstU8, ProcessMessageError};
+ use xcm::latest::prelude::*;
+ use xcm_builder::{CreateMatcher, MatchXcm};
+
+ // Random para id of sibling chain used in tests.
+ pub const SIBLING_PARACHAIN_ID: u32 = 2053;
+ // Random para id of bridged chain from different global consensus used in tests.
+ pub const BRIDGED_LOCATION_PARACHAIN_ID: u32 = 1075;
+ const RUNTIME_PARA_ID: u32 = bp_asset_hub_rococo::ASSET_HUB_ROCOCO_PARACHAIN_ID;
+
+ frame_support::parameter_types! {
+ pub SiblingParachainLocation: Location = Location::new(1, [Parachain(SIBLING_PARACHAIN_ID)]);
+ pub BridgedUniversalLocation: InteriorLocation = [GlobalConsensus(WestendGlobalConsensusNetwork::get()), Parachain(BRIDGED_LOCATION_PARACHAIN_ID)].into();
+ }
+
+ #[test]
+ fn change_bridge_messages_pallet_mode_by_governance_works() {
+ bridge_hub_test_utils::test_cases::change_bridge_messages_pallet_mode_by_governance_works::<
+ Runtime,
+ WithAssetHubWestendMessagesInstance,
+ >(collator_session_keys(), bp_asset_hub_rococo::ASSET_HUB_ROCOCO_PARACHAIN_ID)
+ }
+
+ #[test]
+ fn change_delivery_reward_by_governance_works() {
+ bridge_hub_test_utils::test_cases::change_storage_constant_by_governance_works::<
+ Runtime,
+ DeliveryRewardInBalance,
+ u64,
+ >(
+ collator_session_keys(),
+ RUNTIME_PARA_ID,
+ Box::new(|call| RuntimeCall::System(call).encode()),
+ || (DeliveryRewardInBalance::key().to_vec(), DeliveryRewardInBalance::get()),
+ |old_value| old_value.checked_mul(2).unwrap(),
+ )
+ }
+
+ #[test]
+ fn handle_export_message_from_sibling_parachain_and_add_to_outbound_queue_works() {
+ // for Westend
+ bridge_hub_test_utils::test_cases::handle_export_message_from_system_parachain_to_outbound_queue_works::<
+ Runtime,
+ XcmConfig,
+ WithAssetHubWestendMessagesInstance,
+ >(
+ collator_session_keys(),
+ RUNTIME_PARA_ID,
+ SIBLING_PARACHAIN_ID,
+ Box::new(|runtime_event_encoded: Vec| {
+ match RuntimeEvent::decode(&mut &runtime_event_encoded[..]) {
+ Ok(RuntimeEvent::BridgeWestendMessages(event)) => Some(event),
+ _ => None,
+ }
+ }),
+ || ExportMessage { network: WestendGlobalConsensusNetwork::get(), destination: [Parachain(BRIDGED_LOCATION_PARACHAIN_ID)].into(), xcm: Xcm(vec![]) },
+ Some((TokenLocation::get(), ExistentialDeposit::get()).into()),
+ // value should be >= than value generated by `can_calculate_weight_for_paid_export_message_with_reserve_transfer`
+ Some((TokenLocation::get(), bp_bridge_hub_rococo::BridgeHubRococoBaseXcmFeeInRocs::get()).into()),
+ || {
+ PolkadotXcm::force_xcm_version(RuntimeOrigin::root(), Box::new(AssetHubWestendLocation::get()), XCM_VERSION).expect("version saved!");
+
+ // we need to create lane between sibling parachain and remote destination
+ bridge_hub_test_utils::ensure_opened_bridge::<
+ Runtime,
+ XcmOverAssetHubWestendInstance,
+ LocationToAccountId,
+ TokenLocation,
+ >(
+ SiblingParachainLocation::get(),
+ BridgedUniversalLocation::get(),
+ true,
+ |locations, fee| {
+ bridge_hub_test_utils::open_bridge_with_extrinsic::<
+ Runtime,
+ XcmOverAssetHubWestendInstance
+ >((locations.bridge_origin_relative_location().clone(), OriginKind::Xcm), locations.bridge_destination_universal_location().clone(), fee)
+ }
+ ).1
+ },
+ )
+ }
+
+ #[test]
+ fn message_dispatch_routing_works() {
+ // from Westend
+ bridge_hub_test_utils::test_cases::message_dispatch_routing_works::<
+ Runtime,
+ AllPalletsWithoutSystem,
+ XcmConfig,
+ ParachainSystem,
+ WithAssetHubWestendMessagesInstance,
+ RelayNetwork,
+ WestendGlobalConsensusNetwork,
+ ConstU8<2>,
+ >(
+ collator_session_keys(),
+ slot_durations(),
+ RUNTIME_PARA_ID,
+ SIBLING_PARACHAIN_ID,
+ Box::new(|runtime_event_encoded: Vec| {
+ match RuntimeEvent::decode(&mut &runtime_event_encoded[..]) {
+ Ok(RuntimeEvent::ParachainSystem(event)) => Some(event),
+ _ => None,
+ }
+ }),
+ Box::new(|runtime_event_encoded: Vec| {
+ match RuntimeEvent::decode(&mut &runtime_event_encoded[..]) {
+ Ok(RuntimeEvent::XcmpQueue(event)) => Some(event),
+ _ => None,
+ }
+ }),
+ || (),
+ )
+ }
+
+ #[test]
+ fn open_and_close_bridge_for_sibling_parachain_works() {
+ bridge_hub_test_utils::test_cases::open_and_close_bridge_works::<
+ Runtime,
+ XcmOverAssetHubWestendInstance,
+ LocationToAccountId,
+ TokenLocation,
+ >(
+ collator_session_keys(),
+ RUNTIME_PARA_ID,
+ SiblingParachainLocation::get(),
+ BridgedUniversalLocation::get(),
+ (SiblingParachainLocation::get(), OriginKind::Xcm),
+ true,
+ )
+ }
+
+ #[test]
+ fn open_and_close_bridge_for_relay_works() {
+ bridge_hub_test_utils::test_cases::open_and_close_bridge_works::<
+ Runtime,
+ XcmOverAssetHubWestendInstance,
+ LocationToAccountId,
+ TokenLocation,
+ >(
+ collator_session_keys(),
+ RUNTIME_PARA_ID,
+ Location::parent(),
+ BridgedUniversalLocation::get(),
+ (Location::parent(), OriginKind::Xcm),
+ false,
+ )
+ }
+
+ #[test]
+ fn open_and_close_bridge_for_local_works() {
+ bridge_hub_test_utils::test_cases::open_and_close_bridge_works::<
+ Runtime,
+ XcmOverAssetHubWestendInstance,
+ LocationToAccountId,
+ TokenLocation,
+ >(
+ collator_session_keys(),
+ RUNTIME_PARA_ID,
+ // The source is `here` as the local chain, e.g., AssetHub itself can open its lanes.
+ Location::here(),
+ BridgedUniversalLocation::get(),
+ // This should represent `RuntimeOrigin::root()` which represents `Location::here()`
+ // for `OpenBridgeOrigin`
+ (Location::parent(), OriginKind::Superuser),
+ false,
+ )
+ }
+
+ #[test]
+ fn westend_xcm_routing_works() {
+ let runtime_para_id = 1000;
+ ExtBuilder::::default()
+ .with_collators(collator_session_keys().collators())
+ .with_session_keys(collator_session_keys().session_keys())
+ .with_para_id(runtime_para_id.into())
+ .build()
+ .execute_with(|| {
+ frame_support::__private::sp_tracing::try_init_simple();
+ let sibling_bridge_hub_para_id = bridging::SiblingBridgeHubParaId::get();
+ let bridged_destination = bridging::to_westend::AssetHubWestend::get();
+ let bridged_universal_destination = bridged_destination.interior().clone();
+
+ // Common setup
+ frame_support::assert_ok!(PolkadotXcm::force_xcm_version(
+ RuntimeOrigin::root(),
+ Box::new(bridging::to_westend::AssetHubWestend::get()),
+ XCM_VERSION,
+ ));
+
+ // Setup for `ExportMessage` to the `BridgeHub`
+ let mut alice = [0u8; 32];
+ alice[0] = 1;
+ let included_head = RuntimeHelper::run_to_block(2, AccountId::from(alice));
+ mock_open_hrmp_channel::(
+ runtime_para_id.into(),
+ sibling_bridge_hub_para_id.into(),
+ included_head,
+ &alice,
+ &slot_durations(),
+ );
+ frame_support::assert_ok!(PolkadotXcm::force_xcm_version(
+ RuntimeOrigin::root(),
+ Box::new(bridging::SiblingBridgeHub::get()),
+ XCM_VERSION,
+ ));
+
+ // check no bridge/lane exists
+ assert_eq!(
+ 0,
+ pallet_bridge_messages::OutboundLanes::<
+ Runtime,
+ WithAssetHubWestendMessagesInstance,
+ >::iter()
+ .count()
+ );
+
+ // send to the `bridged_destination`
+ frame_support::assert_ok!(PolkadotXcm::send_xcm(
+ Here,
+ bridged_destination.clone(),
+ Xcm::<()>::default()
+ ));
+
+ // check HRMP message contains `ExportMessage`.
+ assert!(asset_test_utils::RuntimeHelper::<
+ cumulus_pallet_xcmp_queue::Pallet,
+ AllPalletsWithoutSystem,
+ >::take_xcm(sibling_bridge_hub_para_id.into())
+ .map(|m| {
+ let mut m: Xcm<()> = m.try_into().expect("valid XCM version");
+ m.0.matcher()
+ .skip_inst_while(|inst| !matches!(inst, ExportMessage { .. }))
+ .expect("no instruction ExportMessage?")
+ .match_next_inst(|instr| match instr {
+ ExportMessage { ref network, .. } => {
+ assert_eq!(
+ network,
+ &bridged_destination
+ .interior
+ .global_consensus()
+ .expect("valid NetworkId")
+ );
+ Ok(())
+ },
+ _ => Err(ProcessMessageError::BadFormat),
+ })
+ .is_ok()
+ })
+ .unwrap_or(false));
+
+ // open permissionless lane between this AH and bridged AH
+ let (_, lane_id) = bridge_hub_test_utils::ensure_opened_bridge::<
+ Runtime,
+ XcmOverAssetHubWestendInstance,
+ LocationToAccountId,
+ TokenLocation,
+ >(
+ Here.into(),
+ bridged_universal_destination,
+ false,
+ |locations, maybe_paid_execution| {
+ bridge_hub_test_utils::open_bridge_with_extrinsic::<
+ Runtime,
+ XcmOverAssetHubWestendInstance,
+ >(
+ // This should represent `RuntimeOrigin::root()` which represents
+ // `Location::here()` for `OpenBridgeOrigin`
+ (Location::parent(), OriginKind::Superuser),
+ locations.bridge_destination_universal_location().clone(),
+ maybe_paid_execution,
+ )
+ },
+ );
+ // lane created
+ assert_eq!(
+ 1,
+ pallet_bridge_messages::OutboundLanes::<
+ Runtime,
+ WithAssetHubWestendMessagesInstance,
+ >::iter()
+ .count()
+ );
+
+ // send to the `bridged_destination` again
+ frame_support::assert_ok!(PolkadotXcm::send_xcm(
+ Here,
+ bridged_destination.clone(),
+ Xcm::<()>::default()
+ ));
+
+ // messages pallet holds outbound message for expected lane_id
+ assert_eq!(
+ 1,
+ pallet_bridge_messages::OutboundLanes::<
+ Runtime,
+ WithAssetHubWestendMessagesInstance,
+ >::get(lane_id)
+ .map(|d| d.queued_messages().saturating_len())
+ .unwrap_or(0)
+ );
+
+ // no hrmp message was fired
+ assert!(asset_test_utils::RuntimeHelper::<
+ cumulus_pallet_xcmp_queue::Pallet,
+ AllPalletsWithoutSystem,
+ >::take_xcm(sibling_bridge_hub_para_id.into())
+ .is_none());
+ });
+ }
+}