Ensure xcm versions over bridge (on sending chains) (#2481)

## Summary

This pull request proposes a solution for improved control of the
versioned XCM flow over the bridge (across different consensus chains)
and resolves the situation where the sending chain/consensus has already
migrated to a higher XCM version than the receiving chain/consensus.

## Problem/Motivation

The current flow over the bridge involves a transfer from AssetHubRococo
(AHR) to BridgeHubRococo (BHR) to BridgeHubWestend (BHW) and finally to
AssetHubWestend (AHW), beginning with a reserve-backed transfer on AHR.

In this process:
1. AHR sends XCM `ExportMessage` through `XcmpQueue`, incorporating XCM
version checks using the `WrapVersion` feature, influenced by
`pallet_xcm::SupportedVersion` (managed by
`pallet_xcm::force_xcm_version` or version discovery).

2. BHR handles the `ExportMessage` instruction, utilizing the latest XCM
version. The `HaulBlobExporter` converts the inner XCM to
[`VersionedXcm::from`](https://github.com/paritytech/polkadot-sdk/blob/63ac2471aa0210f0ac9903bdd7d8f9351f9a635f/polkadot/xcm/xcm-builder/src/universal_exports.rs#L465-L467),
also using the latest XCM version.

However, challenges arise:
- Incompatibility when BHW uses a different version than BHR. For
instance, if BHR migrates to **XCMv4** while BHW remains on **XCMv3**,
BHR's `VersionedXcm::from` uses `VersionedXcm::V4` variant, causing
encoding issues for BHW.
  ```
	/// Just a simulation of possible error, which could happen on BHW
	/// (this code is based on actual master without XCMv4)
	let encoded = hex_literal::hex!("0400");
	println!("{:?}", VersionedXcm::<()>::decode(&mut &encoded[..]));

Err(Error { cause: None, desc: "Could not decode `VersionedXcm`, variant
doesn't exist" })
  ``` 
- Similar compatibility issues exist between AHR and AHW.

## Solution

This pull request introduces the following solutions:

1. **New trait `CheckVersion`** - added to the `xcm` module and exposing
`pallet_xcm::SupportedVersion`. This enhancement allows checking the
actual XCM version for desired destinations outside of the `pallet_xcm`
module.

2. **Version Check in `HaulBlobExporter`** uses `CheckVersion` to check
known/configured destination versions, ensuring compatibility. For
example, in the scenario mentioned, BHR can store the version `3` for
BHW. If BHR is on XCMv4, it will attempt to downgrade the message to
version `3` instead of using the latest version `4`.

3. **Version Check in `pallet-xcm-bridge-hub-router`** - this check
ensures compatibility with the real destination's XCM version,
preventing the unnecessary sending of messages to the local bridge hub
if versions are incompatible.

These additions aim to improve the control and compatibility of XCM
flows over the bridge and addressing issues related to version
mismatches.

## Possible alternative solution

_(More investigation is needed, and at the very least, it should extend
to XCMv4/5. If this proves to be a viable option, I can open an RFC for
XCM.)._

Add the `XcmVersion` attribute to the `ExportMessage` so that the
sending chain can determine, based on what is stored in
`pallet_xcm::SupportedVersion`, the version the destination is using.
This way, we may not need to handle the version in `HaulBlobExporter`.

```
ExportMessage {
	network: NetworkId,
	destination: InteriorMultiLocation,
	xcm: Xcm<()>
	destination_xcm_version: Version, // <- new attritbute
},
```

```
pub trait ExportXcm {
        fn validate(
		network: NetworkId,
		channel: u32,
		universal_source: &mut Option<InteriorMultiLocation>,
		destination: &mut Option<InteriorMultiLocation>,
		message: &mut Option<Xcm<()>>,
                destination_xcm_version: Version, , // <- new attritbute
	) -> SendResult<Self::Ticket>;
```

## Future Directions

This PR does not fix version discovery over bridge, further
investigation will be conducted here:
https://github.com/paritytech/polkadot-sdk/issues/2417.

## TODO

- [x] `pallet_xcm` mock for tests uses hard-coded XCM version `2` -
change to 3 or lastest?
- [x] fix `pallet-xcm-bridge-hub-router`
- [x] fix HaulBlobExporter with version determination
[here](https://github.com/paritytech/polkadot-sdk/blob/2183669d05f9b510f979a0cc3c7847707bacba2e/polkadot/xcm/xcm-builder/src/universal_exports.rs#L465)
- [x] add unit-tests to the runtimes
- [x] run benchmarks for `ExportMessage`
- [x] extend local run scripts about `force_xcm_version(dest, version)`
- [ ] when merged, prepare governance calls for Rococo/Westend
- [ ] add PRDoc

Part of: https://github.com/paritytech/parity-bridges-common/issues/2719

---------

Co-authored-by: command-bot <>
This commit is contained in:
Branislav Kontur
2023-12-12 16:04:26 +01:00
committed by GitHub
parent 42a3afba94
commit 575b8f8d15
55 changed files with 1277 additions and 488 deletions
@@ -846,6 +846,7 @@ impl pallet_xcm_bridge_hub_router::Config<ToWestendXcmRouterInstance> for Runtim
type UniversalLocation = xcm_config::UniversalLocation;
type BridgedNetworkId = xcm_config::bridging::to_westend::WestendNetwork;
type Bridges = xcm_config::bridging::NetworkExportTable;
type DestinationVersion = PolkadotXcm;
#[cfg(not(feature = "runtime-benchmarks"))]
type BridgeHubOrigin = EnsureXcm<Equals<xcm_config::bridging::SiblingBridgeHub>>;
@@ -1416,11 +1417,26 @@ impl_runtime_apis! {
xcm_config::bridging::SiblingBridgeHubParaId::get().into()
);
}
fn ensure_bridged_target_destination() -> MultiLocation {
fn ensure_bridged_target_destination() -> Result<MultiLocation, BenchmarkError> {
ParachainSystem::open_outbound_hrmp_channel_for_benchmarks_or_tests(
xcm_config::bridging::SiblingBridgeHubParaId::get().into()
);
xcm_config::bridging::to_westend::AssetHubWestend::get()
let bridged_asset_hub = xcm_config::bridging::to_westend::AssetHubWestend::get();
let _ = PolkadotXcm::force_xcm_version(
RuntimeOrigin::root(),
Box::new(bridged_asset_hub),
XCM_VERSION,
).map_err(|e| {
log::error!(
"Failed to dispatch `force_xcm_version({:?}, {:?}, {:?})`, error: {:?}",
RuntimeOrigin::root(),
bridged_asset_hub,
XCM_VERSION,
e
);
BenchmarkError::Stop("XcmVersion was not stored!")
})?;
Ok(bridged_asset_hub)
}
}
@@ -1439,7 +1455,7 @@ impl_runtime_apis! {
type XcmConfig = xcm_config::XcmConfig;
type AccountIdConverter = xcm_config::LocationToAccountId;
type DeliveryHelper = cumulus_primitives_utility::ToParentDeliveryHelper<
xcm_config::XcmConfig,
xcm_config::XcmConfig,
ExistentialDepositMultiAsset,
xcm_config::PriceForParentDelivery,
>;
@@ -17,9 +17,9 @@
//! Autogenerated weights for `pallet_xcm_bridge_hub_router`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2023-11-15, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! DATE: 2023-11-29, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `runner-yprdrvc7-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
//! HOSTNAME: `runner-r43aesjn-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:
@@ -58,8 +58,8 @@ impl<T: frame_system::Config> pallet_xcm_bridge_hub_router::WeightInfo for Weigh
// Proof Size summary in bytes:
// Measured: `154`
// Estimated: `1639`
// Minimum execution time: 7_924_000 picoseconds.
Weight::from_parts(8_199_000, 0)
// Minimum execution time: 8_110_000 picoseconds.
Weight::from_parts(8_373_000, 0)
.saturating_add(Weight::from_parts(0, 1639))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1))
@@ -72,8 +72,8 @@ impl<T: frame_system::Config> pallet_xcm_bridge_hub_router::WeightInfo for Weigh
// Proof Size summary in bytes:
// Measured: `144`
// Estimated: `1629`
// Minimum execution time: 4_265_000 picoseconds.
Weight::from_parts(4_417_000, 0)
// Minimum execution time: 4_459_000 picoseconds.
Weight::from_parts(4_663_000, 0)
.saturating_add(Weight::from_parts(0, 1629))
.saturating_add(T::DbWeight::get().reads(2))
}
@@ -83,12 +83,14 @@ impl<T: frame_system::Config> pallet_xcm_bridge_hub_router::WeightInfo for Weigh
// Proof Size summary in bytes:
// Measured: `150`
// Estimated: `1502`
// Minimum execution time: 10_292_000 picoseconds.
Weight::from_parts(10_797_000, 0)
// Minimum execution time: 10_153_000 picoseconds.
Weight::from_parts(10_737_000, 0)
.saturating_add(Weight::from_parts(0, 1502))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `PolkadotXcm::SupportedVersion` (r:2 w:0)
/// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `ParachainInfo::ParachainId` (r:1 w:0)
/// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
/// Storage: UNKNOWN KEY `0x3302afcb67e838a3f960251b417b9a4f` (r:1 w:0)
@@ -99,8 +101,6 @@ impl<T: frame_system::Config> pallet_xcm_bridge_hub_router::WeightInfo for Weigh
/// Proof: `ToWestendXcmRouter::Bridge` (`max_values`: Some(1), `max_size`: Some(17), added: 512, mode: `MaxEncodedLen`)
/// Storage: `XcmpQueue::DeliveryFeeFactor` (r:1 w:0)
/// Proof: `XcmpQueue::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// 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)
@@ -115,12 +115,12 @@ impl<T: frame_system::Config> pallet_xcm_bridge_hub_router::WeightInfo for Weigh
/// Proof: `XcmpQueue::OutboundXcmpMessages` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn send_message() -> Weight {
// Proof Size summary in bytes:
// Measured: `387`
// Estimated: `3852`
// Minimum execution time: 61_995_000 picoseconds.
Weight::from_parts(65_137_000, 0)
.saturating_add(Weight::from_parts(0, 3852))
.saturating_add(T::DbWeight::get().reads(11))
// Measured: `448`
// Estimated: `6388`
// Minimum execution time: 61_258_000 picoseconds.
Weight::from_parts(63_679_000, 0)
.saturating_add(Weight::from_parts(0, 6388))
.saturating_add(T::DbWeight::get().reads(12))
.saturating_add(T::DbWeight::get().writes(4))
}
}
@@ -673,9 +673,16 @@ fn limited_reserve_transfer_assets_for_native_asset_over_bridge_works(
mod asset_hub_rococo_tests {
use super::*;
use asset_hub_rococo_runtime::{PolkadotXcm, RuntimeOrigin};
fn bridging_to_asset_hub_westend() -> TestBridgingConfig {
asset_test_utils::test_cases_over_bridge::TestBridgingConfig {
let _ = PolkadotXcm::force_xcm_version(
RuntimeOrigin::root(),
Box::new(bridging::to_westend::AssetHubWestend::get()),
XCM_VERSION,
)
.expect("version saved!");
TestBridgingConfig {
bridged_network: bridging::to_westend::WestendNetwork::get(),
local_bridge_hub_para_id: bridging::SiblingBridgeHubParaId::get(),
local_bridge_hub_location: bridging::SiblingBridgeHub::get(),
@@ -822,6 +822,7 @@ impl pallet_xcm_bridge_hub_router::Config<ToRococoXcmRouterInstance> for Runtime
type UniversalLocation = xcm_config::UniversalLocation;
type BridgedNetworkId = xcm_config::bridging::to_rococo::RococoNetwork;
type Bridges = xcm_config::bridging::NetworkExportTable;
type DestinationVersion = PolkadotXcm;
#[cfg(not(feature = "runtime-benchmarks"))]
type BridgeHubOrigin = EnsureXcm<Equals<xcm_config::bridging::SiblingBridgeHub>>;
@@ -1493,11 +1494,26 @@ impl_runtime_apis! {
xcm_config::bridging::SiblingBridgeHubParaId::get().into()
);
}
fn ensure_bridged_target_destination() -> MultiLocation {
fn ensure_bridged_target_destination() -> Result<MultiLocation, BenchmarkError> {
ParachainSystem::open_outbound_hrmp_channel_for_benchmarks_or_tests(
xcm_config::bridging::SiblingBridgeHubParaId::get().into()
);
xcm_config::bridging::to_rococo::AssetHubRococo::get()
let bridged_asset_hub = xcm_config::bridging::to_rococo::AssetHubRococo::get();
let _ = PolkadotXcm::force_xcm_version(
RuntimeOrigin::root(),
Box::new(bridged_asset_hub),
XCM_VERSION,
).map_err(|e| {
log::error!(
"Failed to dispatch `force_xcm_version({:?}, {:?}, {:?})`, error: {:?}",
RuntimeOrigin::root(),
bridged_asset_hub,
XCM_VERSION,
e
);
BenchmarkError::Stop("XcmVersion was not stored!")
})?;
Ok(bridged_asset_hub)
}
}
@@ -17,9 +17,9 @@
//! Autogenerated weights for `pallet_xcm_bridge_hub_router`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2023-10-26, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! DATE: 2023-11-29, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `runner-vmdtonbz-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
//! HOSTNAME: `runner-r43aesjn-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("asset-hub-westend-dev")`, DB CACHE: 1024
// Executed Command:
@@ -48,8 +48,8 @@ use core::marker::PhantomData;
/// Weight functions for `pallet_xcm_bridge_hub_router`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_xcm_bridge_hub_router::WeightInfo for WeightInfo<T> {
/// Storage: `XcmpQueue::InboundXcmpStatus` (r:1 w:0)
/// Proof: `XcmpQueue::InboundXcmpStatus` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `XcmpQueue::InboundXcmpSuspended` (r:1 w:0)
/// Proof: `XcmpQueue::InboundXcmpSuspended` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `XcmpQueue::OutboundXcmpStatus` (r:1 w:0)
/// Proof: `XcmpQueue::OutboundXcmpStatus` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `ToRococoXcmRouter::Bridge` (r:1 w:1)
@@ -58,22 +58,22 @@ impl<T: frame_system::Config> pallet_xcm_bridge_hub_router::WeightInfo for Weigh
// Proof Size summary in bytes:
// Measured: `193`
// Estimated: `1678`
// Minimum execution time: 8_157_000 picoseconds.
Weight::from_parts(8_481_000, 0)
// Minimum execution time: 8_460_000 picoseconds.
Weight::from_parts(8_730_000, 0)
.saturating_add(Weight::from_parts(0, 1678))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `XcmpQueue::InboundXcmpStatus` (r:1 w:0)
/// Proof: `XcmpQueue::InboundXcmpStatus` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `XcmpQueue::InboundXcmpSuspended` (r:1 w:0)
/// Proof: `XcmpQueue::InboundXcmpSuspended` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `XcmpQueue::OutboundXcmpStatus` (r:1 w:0)
/// Proof: `XcmpQueue::OutboundXcmpStatus` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
fn on_initialize_when_congested() -> Weight {
// Proof Size summary in bytes:
// Measured: `111`
// Estimated: `1596`
// Minimum execution time: 3_319_000 picoseconds.
Weight::from_parts(3_445_000, 0)
// Minimum execution time: 3_469_000 picoseconds.
Weight::from_parts(3_696_000, 0)
.saturating_add(Weight::from_parts(0, 1596))
.saturating_add(T::DbWeight::get().reads(2))
}
@@ -83,22 +83,24 @@ impl<T: frame_system::Config> pallet_xcm_bridge_hub_router::WeightInfo for Weigh
// Proof Size summary in bytes:
// Measured: `117`
// Estimated: `1502`
// Minimum execution time: 10_396_000 picoseconds.
Weight::from_parts(10_914_000, 0)
// Minimum execution time: 10_315_000 picoseconds.
Weight::from_parts(10_651_000, 0)
.saturating_add(Weight::from_parts(0, 1502))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `PolkadotXcm::SupportedVersion` (r:2 w:0)
/// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `ParachainInfo::ParachainId` (r:1 w:0)
/// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
/// Storage: UNKNOWN KEY `0x3302afcb67e838a3f960251b417b9a4f` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x3302afcb67e838a3f960251b417b9a4f` (r:1 w:0)
/// Storage: UNKNOWN KEY `0x0973fe64c85043ba1c965cbc38eb63c7` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x0973fe64c85043ba1c965cbc38eb63c7` (r:1 w:0)
/// Storage: `ToRococoXcmRouter::Bridge` (r:1 w:1)
/// Proof: `ToRococoXcmRouter::Bridge` (`max_values`: Some(1), `max_size`: Some(17), added: 512, mode: `MaxEncodedLen`)
/// Storage: `XcmpQueue::DeliveryFeeFactor` (r:1 w:0)
/// Proof: `XcmpQueue::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// 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)
@@ -107,18 +109,18 @@ impl<T: frame_system::Config> pallet_xcm_bridge_hub_router::WeightInfo for Weigh
/// Proof: `ParachainSystem::RelevantMessagingState` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `XcmpQueue::OutboundXcmpStatus` (r:1 w:1)
/// Proof: `XcmpQueue::OutboundXcmpStatus` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `XcmpQueue::InboundXcmpStatus` (r:1 w:0)
/// Proof: `XcmpQueue::InboundXcmpStatus` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `XcmpQueue::InboundXcmpSuspended` (r:1 w:0)
/// Proof: `XcmpQueue::InboundXcmpSuspended` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `XcmpQueue::OutboundXcmpMessages` (r:0 w:1)
/// Proof: `XcmpQueue::OutboundXcmpMessages` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn send_message() -> Weight {
// Proof Size summary in bytes:
// Measured: `426`
// Estimated: `3891`
// Minimum execution time: 45_902_000 picoseconds.
Weight::from_parts(46_887_000, 0)
.saturating_add(Weight::from_parts(0, 3891))
.saturating_add(T::DbWeight::get().reads(10))
// Measured: `487`
// Estimated: `6427`
// Minimum execution time: 64_532_000 picoseconds.
Weight::from_parts(66_901_000, 0)
.saturating_add(Weight::from_parts(0, 6427))
.saturating_add(T::DbWeight::get().reads(12))
.saturating_add(T::DbWeight::get().writes(4))
}
}
@@ -24,9 +24,9 @@ use asset_hub_westend_runtime::{
WestendLocation, XcmConfig,
},
AllPalletsWithoutSystem, AssetDeposit, Assets, Balances, ExistentialDeposit, ForeignAssets,
ForeignAssetsInstance, MetadataDepositBase, MetadataDepositPerByte, ParachainSystem, Runtime,
RuntimeCall, RuntimeEvent, SessionKeys, ToRococoXcmRouterInstance, TrustBackedAssetsInstance,
XcmpQueue,
ForeignAssetsInstance, MetadataDepositBase, MetadataDepositPerByte, ParachainSystem,
PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, SessionKeys,
ToRococoXcmRouterInstance, TrustBackedAssetsInstance, XcmpQueue,
};
use asset_test_utils::{
test_cases_over_bridge::TestBridgingConfig, CollatorSessionKey, CollatorSessionKeys, ExtBuilder,
@@ -635,6 +635,12 @@ asset_test_utils::include_create_and_manage_foreign_assets_for_local_consensus_p
);
fn bridging_to_asset_hub_rococo() -> TestBridgingConfig {
let _ = PolkadotXcm::force_xcm_version(
RuntimeOrigin::root(),
Box::new(bridging::to_rococo::AssetHubRococo::get()),
XCM_VERSION,
)
.expect("version saved!");
TestBridgingConfig {
bridged_network: bridging::to_rococo::RococoNetwork::get(),
local_bridge_hub_para_id: bridging::SiblingBridgeHubParaId::get(),
@@ -20,7 +20,7 @@ use crate::{
bridge_common_config::{BridgeParachainWestendInstance, DeliveryRewardInBalance},
weights,
xcm_config::UniversalLocation,
AccountId, BridgeWestendMessages, Runtime, RuntimeEvent, RuntimeOrigin,
AccountId, BridgeWestendMessages, PolkadotXcm, Runtime, RuntimeEvent, RuntimeOrigin,
XcmOverBridgeHubWestend, XcmRouter,
};
use bp_messages::LaneId;
@@ -33,7 +33,7 @@ use bridge_runtime_common::{
},
messages_xcm_extension::{
SenderAndLane, XcmAsPlainPayload, XcmBlobHauler, XcmBlobHaulerAdapter,
XcmBlobMessageDispatch,
XcmBlobMessageDispatch, XcmVersionOfDestAndRemoteBridge,
},
refund_relayer_extension::{
ActualFeeRefund, RefundBridgedParachainMessages, RefundSignedExtensionAdapter,
@@ -58,6 +58,10 @@ parameter_types! {
pub const BridgeHubWestendChainId: bp_runtime::ChainId = bp_runtime::BRIDGE_HUB_WESTEND_CHAIN_ID;
pub BridgeRococoToWestendMessagesPalletInstance: InteriorMultiLocation = X1(PalletInstance(<BridgeWestendMessages as PalletInfoAccess>::index() as u8));
pub WestendGlobalConsensusNetwork: NetworkId = NetworkId::Westend;
pub WestendGlobalConsensusNetworkLocation: MultiLocation = MultiLocation {
parents: 2,
interior: X1(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;
@@ -80,6 +84,14 @@ parameter_types! {
pub CongestedMessage: Xcm<()> = build_congestion_message(true).into();
pub UncongestedMessage: Xcm<()> = build_congestion_message(false).into();
pub BridgeHubWestendLocation: MultiLocation = MultiLocation {
parents: 2,
interior: X2(
GlobalConsensus(WestendGlobalConsensusNetwork::get()),
Parachain(<bp_bridge_hub_westend::BridgeHubWestend as bp_runtime::Parachain>::PARACHAIN_ID)
)
};
}
pub const XCM_LANE_FOR_ASSET_HUB_ROCOCO_TO_ASSET_HUB_WESTEND: LaneId = LaneId([0, 0, 0, 2]);
@@ -120,7 +132,6 @@ pub struct ToBridgeHubWestendXcmBlobHauler;
impl XcmBlobHauler for ToBridgeHubWestendXcmBlobHauler {
type Runtime = Runtime;
type MessagesInstance = WithBridgeHubWestendMessagesInstance;
type ToSourceChainSender = XcmRouter;
type CongestedMessage = CongestedMessage;
type UncongestedMessage = UncongestedMessage;
@@ -234,9 +245,11 @@ impl pallet_bridge_messages::Config<WithBridgeHubWestendMessagesInstance> for Ru
pub type XcmOverBridgeHubWestendInstance = pallet_xcm_bridge_hub::Instance1;
impl pallet_xcm_bridge_hub::Config<XcmOverBridgeHubWestendInstance> for Runtime {
type UniversalLocation = UniversalLocation;
type BridgedNetworkId = WestendGlobalConsensusNetwork;
type BridgedNetwork = WestendGlobalConsensusNetworkLocation;
type BridgeMessagesPalletInstance = WithBridgeHubWestendMessagesInstance;
type MessageExportPrice = ();
type DestinationVersion =
XcmVersionOfDestAndRemoteBridge<PolkadotXcm, BridgeHubWestendLocation>;
type Lanes = ActiveLanes;
type LanesSupport = ToBridgeHubWestendXcmBlobHauler;
}
@@ -853,7 +853,7 @@ impl_runtime_apis! {
type XcmConfig = xcm_config::XcmConfig;
type AccountIdConverter = xcm_config::LocationToAccountId;
type DeliveryHelper = cumulus_primitives_utility::ToParentDeliveryHelper<
xcm_config::XcmConfig,
xcm_config::XcmConfig,
ExistentialDepositMultiAsset,
xcm_config::PriceForParentDelivery,
>;
@@ -933,6 +933,21 @@ impl_runtime_apis! {
fn export_message_origin_and_destination(
) -> Result<(MultiLocation, NetworkId, InteriorMultiLocation), BenchmarkError> {
// save XCM version for remote bridge hub
let _ = PolkadotXcm::force_xcm_version(
RuntimeOrigin::root(),
Box::new(bridge_to_westend_config::BridgeHubWestendLocation::get()),
XCM_VERSION,
).map_err(|e| {
log::error!(
"Failed to dispatch `force_xcm_version({:?}, {:?}, {:?})`, error: {:?}",
RuntimeOrigin::root(),
bridge_to_westend_config::BridgeHubWestendLocation::get(),
XCM_VERSION,
e
);
BenchmarkError::Stop("XcmVersion was not stored!")
})?;
Ok(
(
bridge_to_westend_config::FromAssetHubRococoToAssetHubWestendRoute::get().location,
@@ -17,9 +17,9 @@
//! Autogenerated weights for `pallet_xcm_benchmarks::generic`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2023-11-14, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! DATE: 2023-11-29, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `runner-yprdrvc7-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
//! HOSTNAME: `runner-r43aesjn-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:
@@ -68,8 +68,8 @@ impl<T: frame_system::Config> WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `171`
// Estimated: `6196`
// Minimum execution time: 63_453_000 picoseconds.
Weight::from_parts(64_220_000, 6196)
// Minimum execution time: 61_049_000 picoseconds.
Weight::from_parts(62_672_000, 6196)
.saturating_add(T::DbWeight::get().reads(9))
.saturating_add(T::DbWeight::get().writes(4))
}
@@ -77,8 +77,8 @@ impl<T: frame_system::Config> WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 2_238_000 picoseconds.
Weight::from_parts(2_351_000, 0)
// Minimum execution time: 1_972_000 picoseconds.
Weight::from_parts(2_095_000, 0)
}
// Storage: `PolkadotXcm::Queries` (r:1 w:0)
// Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`)
@@ -86,58 +86,58 @@ impl<T: frame_system::Config> WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `32`
// Estimated: `3497`
// Minimum execution time: 7_953_000 picoseconds.
Weight::from_parts(8_162_000, 3497)
// Minimum execution time: 7_541_000 picoseconds.
Weight::from_parts(7_875_000, 3497)
.saturating_add(T::DbWeight::get().reads(1))
}
pub fn transact() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 9_080_000 picoseconds.
Weight::from_parts(9_333_000, 0)
// Minimum execution time: 8_467_000 picoseconds.
Weight::from_parts(8_653_000, 0)
}
pub fn refund_surplus() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 2_415_000 picoseconds.
Weight::from_parts(2_519_000, 0)
// Minimum execution time: 2_141_000 picoseconds.
Weight::from_parts(2_231_000, 0)
}
pub fn set_error_handler() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 2_045_000 picoseconds.
Weight::from_parts(2_184_000, 0)
// Minimum execution time: 1_881_000 picoseconds.
Weight::from_parts(1_941_000, 0)
}
pub fn set_appendix() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 2_065_000 picoseconds.
Weight::from_parts(2_125_000, 0)
// Minimum execution time: 1_846_000 picoseconds.
Weight::from_parts(1_916_000, 0)
}
pub fn clear_error() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 2_077_000 picoseconds.
Weight::from_parts(2_164_000, 0)
// Minimum execution time: 1_857_000 picoseconds.
Weight::from_parts(1_910_000, 0)
}
pub fn descend_origin() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 2_868_000 picoseconds.
Weight::from_parts(2_933_000, 0)
// Minimum execution time: 2_493_000 picoseconds.
Weight::from_parts(2_570_000, 0)
}
pub fn clear_origin() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 2_058_000 picoseconds.
Weight::from_parts(2_164_000, 0)
// Minimum execution time: 1_857_000 picoseconds.
Weight::from_parts(1_930_000, 0)
}
// Storage: `ParachainInfo::ParachainId` (r:1 w:0)
// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
@@ -159,8 +159,8 @@ impl<T: frame_system::Config> WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `171`
// Estimated: `6196`
// Minimum execution time: 55_971_000 picoseconds.
Weight::from_parts(56_869_000, 6196)
// Minimum execution time: 54_805_000 picoseconds.
Weight::from_parts(55_690_000, 6196)
.saturating_add(T::DbWeight::get().reads(9))
.saturating_add(T::DbWeight::get().writes(4))
}
@@ -170,8 +170,8 @@ impl<T: frame_system::Config> WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `90`
// Estimated: `3555`
// Minimum execution time: 11_382_000 picoseconds.
Weight::from_parts(11_672_000, 3555)
// Minimum execution time: 11_062_000 picoseconds.
Weight::from_parts(11_505_000, 3555)
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
@@ -179,8 +179,8 @@ impl<T: frame_system::Config> WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 2_071_000 picoseconds.
Weight::from_parts(2_193_000, 0)
// Minimum execution time: 1_873_000 picoseconds.
Weight::from_parts(1_962_000, 0)
}
// Storage: `PolkadotXcm::VersionNotifyTargets` (r:1 w:1)
// Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`)
@@ -200,8 +200,8 @@ impl<T: frame_system::Config> WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `38`
// Estimated: `3503`
// Minimum execution time: 22_573_000 picoseconds.
Weight::from_parts(23_423_000, 3503)
// Minimum execution time: 22_356_000 picoseconds.
Weight::from_parts(23_066_000, 3503)
.saturating_add(T::DbWeight::get().reads(7))
.saturating_add(T::DbWeight::get().writes(3))
}
@@ -211,44 +211,44 @@ impl<T: frame_system::Config> WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 3_870_000 picoseconds.
Weight::from_parts(3_993_000, 0)
// Minimum execution time: 3_819_000 picoseconds.
Weight::from_parts(3_992_000, 0)
.saturating_add(T::DbWeight::get().writes(1))
}
pub fn burn_asset() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 3_483_000 picoseconds.
Weight::from_parts(3_598_000, 0)
// Minimum execution time: 3_033_000 picoseconds.
Weight::from_parts(3_157_000, 0)
}
pub fn expect_asset() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 2_241_000 picoseconds.
Weight::from_parts(2_297_000, 0)
// Minimum execution time: 1_994_000 picoseconds.
Weight::from_parts(2_056_000, 0)
}
pub fn expect_origin() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 2_230_000 picoseconds.
Weight::from_parts(2_318_000, 0)
// Minimum execution time: 1_978_000 picoseconds.
Weight::from_parts(2_069_000, 0)
}
pub fn expect_error() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 2_051_000 picoseconds.
Weight::from_parts(2_153_000, 0)
// Minimum execution time: 1_894_000 picoseconds.
Weight::from_parts(1_977_000, 0)
}
pub fn expect_transact_status() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 2_306_000 picoseconds.
Weight::from_parts(2_380_000, 0)
// Minimum execution time: 2_114_000 picoseconds.
Weight::from_parts(2_223_000, 0)
}
// Storage: `ParachainInfo::ParachainId` (r:1 w:0)
// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
@@ -270,8 +270,8 @@ impl<T: frame_system::Config> WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `171`
// Estimated: `6196`
// Minimum execution time: 60_201_000 picoseconds.
Weight::from_parts(61_132_000, 6196)
// Minimum execution time: 58_704_000 picoseconds.
Weight::from_parts(59_677_000, 6196)
.saturating_add(T::DbWeight::get().reads(9))
.saturating_add(T::DbWeight::get().writes(4))
}
@@ -279,8 +279,8 @@ impl<T: frame_system::Config> WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 4_554_000 picoseconds.
Weight::from_parts(4_704_000, 0)
// Minimum execution time: 4_506_000 picoseconds.
Weight::from_parts(4_672_000, 0)
}
// Storage: `ParachainInfo::ParachainId` (r:1 w:0)
// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
@@ -302,8 +302,8 @@ impl<T: frame_system::Config> WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `171`
// Estimated: `6196`
// Minimum execution time: 56_071_000 picoseconds.
Weight::from_parts(56_889_000, 6196)
// Minimum execution time: 54_896_000 picoseconds.
Weight::from_parts(56_331_000, 6196)
.saturating_add(T::DbWeight::get().reads(9))
.saturating_add(T::DbWeight::get().writes(4))
}
@@ -311,25 +311,29 @@ impl<T: frame_system::Config> WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 2_093_000 picoseconds.
Weight::from_parts(2_169_000, 0)
// Minimum execution time: 1_946_000 picoseconds.
Weight::from_parts(2_002_000, 0)
}
pub fn set_topic() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 2_027_000 picoseconds.
Weight::from_parts(2_172_000, 0)
// Minimum execution time: 1_898_000 picoseconds.
Weight::from_parts(1_961_000, 0)
}
pub fn clear_topic() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 2_035_000 picoseconds.
Weight::from_parts(2_164_000, 0)
// Minimum execution time: 1_895_000 picoseconds.
Weight::from_parts(1_964_000, 0)
}
// Storage: `ParachainInfo::ParachainId` (r:1 w:0)
// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
// Storage: `PolkadotXcm::SupportedVersion` (r:2 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: `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)
@@ -341,27 +345,27 @@ impl<T: frame_system::Config> WeightInfo<T> {
/// The range of component `x` is `[1, 1000]`.
pub fn export_message(x: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `96`
// Estimated: `1529`
// Minimum execution time: 25_636_000 picoseconds.
Weight::from_parts(25_405_640, 1529)
// Standard Error: 321
.saturating_add(Weight::from_parts(365_002, 0).saturating_mul(x.into()))
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().writes(2))
// Measured: `190`
// Estimated: `6130`
// Minimum execution time: 36_547_000 picoseconds.
Weight::from_parts(37_623_117, 6130)
// Standard Error: 735
.saturating_add(Weight::from_parts(315_274, 0).saturating_mul(x.into()))
.saturating_add(T::DbWeight::get().reads(7))
.saturating_add(T::DbWeight::get().writes(3))
}
pub fn set_fees_mode() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 2_036_000 picoseconds.
Weight::from_parts(2_136_000, 0)
// Minimum execution time: 1_868_000 picoseconds.
Weight::from_parts(1_910_000, 0)
}
pub fn unpaid_execution() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 2_147_000 picoseconds.
Weight::from_parts(2_276_000, 0)
// Minimum execution time: 1_998_000 picoseconds.
Weight::from_parts(2_069_000, 0)
}
}
@@ -21,11 +21,11 @@ use bridge_hub_rococo_runtime::{
bridge_common_config, bridge_to_westend_config,
xcm_config::{RelayNetwork, TokenLocation, XcmConfig},
AllPalletsWithoutSystem, BridgeRejectObsoleteHeadersAndMessages, Executive, ExistentialDeposit,
ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, SessionKeys, SignedExtra,
TransactionPayment, UncheckedExtrinsic,
ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, SessionKeys,
SignedExtra, TransactionPayment, UncheckedExtrinsic,
};
use codec::{Decode, Encode};
use frame_support::{dispatch::GetDispatchInfo, parameter_types};
use frame_support::{dispatch::GetDispatchInfo, parameter_types, traits::ConstU8};
use frame_system::pallet_prelude::HeaderFor;
use parachains_common::{rococo::fee::WeightToFee, AccountId, AuraId, Balance};
use sp_keyring::AccountKeyring::Alice;
@@ -104,8 +104,9 @@ mod bridge_hub_rococo_tests {
RequiredStakeForStakeAndSlash,
};
use bridge_to_westend_config::{
BridgeHubWestendChainId, WestendGlobalConsensusNetwork, WithBridgeHubWestendMessageBridge,
WithBridgeHubWestendMessagesInstance, XCM_LANE_FOR_ASSET_HUB_ROCOCO_TO_ASSET_HUB_WESTEND,
BridgeHubWestendChainId, BridgeHubWestendLocation, WestendGlobalConsensusNetwork,
WithBridgeHubWestendMessageBridge, WithBridgeHubWestendMessagesInstance,
XCM_LANE_FOR_ASSET_HUB_ROCOCO_TO_ASSET_HUB_WESTEND,
};
bridge_hub_test_utils::test_cases::include_teleports_for_native_asset_works!(
@@ -196,7 +197,7 @@ mod bridge_hub_rococo_tests {
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(BridgeHubWestendLocation::get()), XCM_VERSION).expect("version saved!"),
)
}
@@ -211,6 +212,7 @@ mod bridge_hub_rococo_tests {
WithBridgeHubWestendMessagesInstance,
RelayNetwork,
WestendGlobalConsensusNetwork,
ConstU8<2>,
>(
collator_session_keys(),
bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID,
@@ -18,8 +18,8 @@
use crate::{
bridge_common_config::DeliveryRewardInBalance, weights, xcm_config::UniversalLocation,
AccountId, BridgeRococoMessages, Runtime, RuntimeEvent, RuntimeOrigin, XcmOverBridgeHubRococo,
XcmRouter,
AccountId, BridgeRococoMessages, PolkadotXcm, Runtime, RuntimeEvent, RuntimeOrigin,
XcmOverBridgeHubRococo, XcmRouter,
};
use bp_messages::LaneId;
use bp_parachains::SingleParaStoredHeaderDataBuilder;
@@ -32,7 +32,7 @@ use bridge_runtime_common::{
},
messages_xcm_extension::{
SenderAndLane, XcmAsPlainPayload, XcmBlobHauler, XcmBlobHaulerAdapter,
XcmBlobMessageDispatch,
XcmBlobMessageDispatch, XcmVersionOfDestAndRemoteBridge,
},
refund_relayer_extension::{
ActualFeeRefund, RefundBridgedParachainMessages, RefundSignedExtensionAdapter,
@@ -65,6 +65,10 @@ parameter_types! {
pub const BridgeHubRococoChainId: bp_runtime::ChainId = bp_runtime::BRIDGE_HUB_ROCOCO_CHAIN_ID;
pub BridgeWestendToRococoMessagesPalletInstance: InteriorMultiLocation = X1(PalletInstance(<BridgeRococoMessages as PalletInfoAccess>::index() as u8));
pub RococoGlobalConsensusNetwork: NetworkId = NetworkId::Rococo;
pub RococoGlobalConsensusNetworkLocation: MultiLocation = MultiLocation {
parents: 2,
interior: X1(GlobalConsensus(RococoGlobalConsensusNetwork::get()))
};
// see the `FEE_BOOST_PER_MESSAGE` constant to get the meaning of this value
pub PriorityBoostPerMessage: u64 = 182_044_444_444_444;
@@ -87,6 +91,14 @@ parameter_types! {
pub CongestedMessage: Xcm<()> = build_congestion_message(true).into();
pub UncongestedMessage: Xcm<()> = build_congestion_message(false).into();
pub BridgeHubRococoLocation: MultiLocation = MultiLocation {
parents: 2,
interior: X2(
GlobalConsensus(RococoGlobalConsensusNetwork::get()),
Parachain(<bp_bridge_hub_rococo::BridgeHubRococo as bp_runtime::Parachain>::PARACHAIN_ID)
)
};
}
pub const XCM_LANE_FOR_ASSET_HUB_WESTEND_TO_ASSET_HUB_ROCOCO: LaneId = LaneId([0, 0, 0, 2]);
@@ -260,9 +272,10 @@ impl pallet_bridge_messages::Config<WithBridgeHubRococoMessagesInstance> for Run
pub type XcmOverBridgeHubRococoInstance = pallet_xcm_bridge_hub::Instance1;
impl pallet_xcm_bridge_hub::Config<XcmOverBridgeHubRococoInstance> for Runtime {
type UniversalLocation = UniversalLocation;
type BridgedNetworkId = RococoGlobalConsensusNetwork;
type BridgedNetwork = RococoGlobalConsensusNetworkLocation;
type BridgeMessagesPalletInstance = WithBridgeHubRococoMessagesInstance;
type MessageExportPrice = ();
type DestinationVersion = XcmVersionOfDestAndRemoteBridge<PolkadotXcm, BridgeHubRococoLocation>;
type Lanes = ActiveLanes;
type LanesSupport = ToBridgeHubRococoXcmBlobHauler;
}
@@ -922,6 +922,21 @@ impl_runtime_apis! {
fn export_message_origin_and_destination(
) -> Result<(MultiLocation, NetworkId, InteriorMultiLocation), BenchmarkError> {
// save XCM version for remote bridge hub
let _ = PolkadotXcm::force_xcm_version(
RuntimeOrigin::root(),
Box::new(bridge_to_rococo_config::BridgeHubRococoLocation::get()),
XCM_VERSION,
).map_err(|e| {
log::error!(
"Failed to dispatch `force_xcm_version({:?}, {:?}, {:?})`, error: {:?}",
RuntimeOrigin::root(),
bridge_to_rococo_config::BridgeHubRococoLocation::get(),
XCM_VERSION,
e
);
BenchmarkError::Stop("XcmVersion was not stored!")
})?;
Ok(
(
bridge_to_rococo_config::FromAssetHubWestendToAssetHubRococoRoute::get().location,
@@ -17,10 +17,10 @@
//! Autogenerated weights for `pallet_xcm_benchmarks::generic`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2023-10-26, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! DATE: 2023-11-29, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `runner-vmdtonbz-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
//! WASM-EXECUTION: Compiled, CHAIN: Some("bridge-hub-rococo-dev"), DB CACHE: 1024
//! HOSTNAME: `runner-r43aesjn-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
//! WASM-EXECUTION: Compiled, CHAIN: Some("bridge-hub-westend-dev"), DB CACHE: 1024
// Executed Command:
// target/production/polkadot-parachain
@@ -33,10 +33,10 @@
// --heap-pages=4096
// --json-file=/builds/parity/mirrors/polkadot-sdk/.git/.artifacts/bench.json
// --pallet=pallet_xcm_benchmarks::generic
// --chain=bridge-hub-rococo-dev
// --chain=bridge-hub-westend-dev
// --header=./cumulus/file_header.txt
// --template=./cumulus/templates/xcm-bench-template.hbs
// --output=./cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/
// --output=./cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
@@ -48,8 +48,6 @@ use sp_std::marker::PhantomData;
/// Weights for `pallet_xcm_benchmarks::generic`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> WeightInfo<T> {
// Storage: UNKNOWN KEY `0x48297505634037ef48c848c99c0b1f1b` (r:1 w:0)
// Proof: UNKNOWN KEY `0x48297505634037ef48c848c99c0b1f1b` (r:1 w:0)
// Storage: `ParachainInfo::ParachainId` (r:1 w:0)
// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
// Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0)
@@ -68,81 +66,79 @@ impl<T: frame_system::Config> WeightInfo<T> {
// Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
pub fn report_holding() -> Weight {
// Proof Size summary in bytes:
// Measured: `242`
// Measured: `171`
// Estimated: `6196`
// Minimum execution time: 62_732_000 picoseconds.
Weight::from_parts(64_581_000, 6196)
.saturating_add(T::DbWeight::get().reads(10))
// Minimum execution time: 61_383_000 picoseconds.
Weight::from_parts(62_382_000, 6196)
.saturating_add(T::DbWeight::get().reads(9))
.saturating_add(T::DbWeight::get().writes(4))
}
pub fn buy_execution() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 1_987_000 picoseconds.
Weight::from_parts(2_107_000, 0)
// Minimum execution time: 2_057_000 picoseconds.
Weight::from_parts(2_153_000, 0)
}
// Storage: `PolkadotXcm::Queries` (r:1 w:0)
// Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`)
pub fn query_response() -> Weight {
// Proof Size summary in bytes:
// Measured: `103`
// Estimated: `3568`
// Minimum execution time: 8_098_000 picoseconds.
Weight::from_parts(8_564_000, 3568)
// Measured: `32`
// Estimated: `3497`
// Minimum execution time: 7_949_000 picoseconds.
Weight::from_parts(8_250_000, 3497)
.saturating_add(T::DbWeight::get().reads(1))
}
pub fn transact() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 8_539_000 picoseconds.
Weight::from_parts(9_085_000, 0)
// Minimum execution time: 8_608_000 picoseconds.
Weight::from_parts(9_086_000, 0)
}
pub fn refund_surplus() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 2_205_000 picoseconds.
Weight::from_parts(2_369_000, 0)
// Minimum execution time: 2_240_000 picoseconds.
Weight::from_parts(2_348_000, 0)
}
pub fn set_error_handler() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 1_828_000 picoseconds.
Weight::from_parts(1_994_000, 0)
// Minimum execution time: 1_969_000 picoseconds.
Weight::from_parts(2_017_000, 0)
}
pub fn set_appendix() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 1_869_000 picoseconds.
Weight::from_parts(1_946_000, 0)
// Minimum execution time: 1_907_000 picoseconds.
Weight::from_parts(2_001_000, 0)
}
pub fn clear_error() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 1_842_000 picoseconds.
Weight::from_parts(1_949_000, 0)
// Minimum execution time: 1_880_000 picoseconds.
Weight::from_parts(1_975_000, 0)
}
pub fn descend_origin() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 2_460_000 picoseconds.
Weight::from_parts(2_593_000, 0)
// Minimum execution time: 2_549_000 picoseconds.
Weight::from_parts(2_624_000, 0)
}
pub fn clear_origin() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 1_868_000 picoseconds.
Weight::from_parts(2_003_000, 0)
// Minimum execution time: 1_895_000 picoseconds.
Weight::from_parts(1_963_000, 0)
}
// Storage: UNKNOWN KEY `0x48297505634037ef48c848c99c0b1f1b` (r:1 w:0)
// Proof: UNKNOWN KEY `0x48297505634037ef48c848c99c0b1f1b` (r:1 w:0)
// Storage: `ParachainInfo::ParachainId` (r:1 w:0)
// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
// Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0)
@@ -161,21 +157,21 @@ impl<T: frame_system::Config> WeightInfo<T> {
// Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
pub fn report_error() -> Weight {
// Proof Size summary in bytes:
// Measured: `242`
// Measured: `171`
// Estimated: `6196`
// Minimum execution time: 56_813_000 picoseconds.
Weight::from_parts(57_728_000, 6196)
.saturating_add(T::DbWeight::get().reads(10))
// Minimum execution time: 54_447_000 picoseconds.
Weight::from_parts(55_629_000, 6196)
.saturating_add(T::DbWeight::get().reads(9))
.saturating_add(T::DbWeight::get().writes(4))
}
// Storage: `PolkadotXcm::AssetTraps` (r:1 w:1)
// Proof: `PolkadotXcm::AssetTraps` (`max_values`: None, `max_size`: None, mode: `Measured`)
pub fn claim_asset() -> Weight {
// Proof Size summary in bytes:
// Measured: `160`
// Estimated: `3625`
// Minimum execution time: 11_364_000 picoseconds.
Weight::from_parts(11_872_000, 3625)
// Measured: `90`
// Estimated: `3555`
// Minimum execution time: 11_597_000 picoseconds.
Weight::from_parts(11_809_000, 3555)
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
@@ -183,8 +179,8 @@ impl<T: frame_system::Config> WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 1_821_000 picoseconds.
Weight::from_parts(1_936_000, 0)
// Minimum execution time: 1_895_000 picoseconds.
Weight::from_parts(1_977_000, 0)
}
// Storage: `PolkadotXcm::VersionNotifyTargets` (r:1 w:1)
// Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`)
@@ -202,10 +198,10 @@ impl<T: frame_system::Config> WeightInfo<T> {
// Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
pub fn subscribe_version() -> Weight {
// Proof Size summary in bytes:
// Measured: `109`
// Estimated: `3574`
// Minimum execution time: 23_081_000 picoseconds.
Weight::from_parts(23_512_000, 3574)
// Measured: `38`
// Estimated: `3503`
// Minimum execution time: 23_314_000 picoseconds.
Weight::from_parts(23_905_000, 3503)
.saturating_add(T::DbWeight::get().reads(7))
.saturating_add(T::DbWeight::get().writes(3))
}
@@ -215,47 +211,45 @@ impl<T: frame_system::Config> WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 3_747_000 picoseconds.
Weight::from_parts(4_068_000, 0)
// Minimum execution time: 3_948_000 picoseconds.
Weight::from_parts(4_084_000, 0)
.saturating_add(T::DbWeight::get().writes(1))
}
pub fn burn_asset() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 3_045_000 picoseconds.
Weight::from_parts(3_208_000, 0)
// Minimum execution time: 3_196_000 picoseconds.
Weight::from_parts(3_285_000, 0)
}
pub fn expect_asset() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 1_962_000 picoseconds.
Weight::from_parts(2_284_000, 0)
// Minimum execution time: 2_040_000 picoseconds.
Weight::from_parts(2_162_000, 0)
}
pub fn expect_origin() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 1_951_000 picoseconds.
Weight::from_parts(2_026_000, 0)
// Minimum execution time: 1_980_000 picoseconds.
Weight::from_parts(2_082_000, 0)
}
pub fn expect_error() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 1_837_000 picoseconds.
Weight::from_parts(2_084_000, 0)
// Minimum execution time: 1_890_000 picoseconds.
Weight::from_parts(1_971_000, 0)
}
pub fn expect_transact_status() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 2_042_000 picoseconds.
Weight::from_parts(2_145_000, 0)
// Minimum execution time: 2_131_000 picoseconds.
Weight::from_parts(2_187_000, 0)
}
// Storage: UNKNOWN KEY `0x48297505634037ef48c848c99c0b1f1b` (r:1 w:0)
// Proof: UNKNOWN KEY `0x48297505634037ef48c848c99c0b1f1b` (r:1 w:0)
// Storage: `ParachainInfo::ParachainId` (r:1 w:0)
// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
// Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0)
@@ -274,22 +268,20 @@ impl<T: frame_system::Config> WeightInfo<T> {
// Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
pub fn query_pallet() -> Weight {
// Proof Size summary in bytes:
// Measured: `242`
// Measured: `171`
// Estimated: `6196`
// Minimum execution time: 61_350_000 picoseconds.
Weight::from_parts(62_440_000, 6196)
.saturating_add(T::DbWeight::get().reads(10))
// Minimum execution time: 59_548_000 picoseconds.
Weight::from_parts(60_842_000, 6196)
.saturating_add(T::DbWeight::get().reads(9))
.saturating_add(T::DbWeight::get().writes(4))
}
pub fn expect_pallet() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 4_993_000 picoseconds.
Weight::from_parts(5_309_000, 0)
// Minimum execution time: 4_665_000 picoseconds.
Weight::from_parts(4_844_000, 0)
}
// Storage: UNKNOWN KEY `0x48297505634037ef48c848c99c0b1f1b` (r:1 w:0)
// Proof: UNKNOWN KEY `0x48297505634037ef48c848c99c0b1f1b` (r:1 w:0)
// Storage: `ParachainInfo::ParachainId` (r:1 w:0)
// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
// Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0)
@@ -308,70 +300,72 @@ impl<T: frame_system::Config> WeightInfo<T> {
// Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
pub fn report_transact_status() -> Weight {
// Proof Size summary in bytes:
// Measured: `242`
// Measured: `171`
// Estimated: `6196`
// Minimum execution time: 57_133_000 picoseconds.
Weight::from_parts(58_100_000, 6196)
.saturating_add(T::DbWeight::get().reads(10))
// Minimum execution time: 55_044_000 picoseconds.
Weight::from_parts(56_103_000, 6196)
.saturating_add(T::DbWeight::get().reads(9))
.saturating_add(T::DbWeight::get().writes(4))
}
pub fn clear_transact_status() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 1_899_000 picoseconds.
Weight::from_parts(2_153_000, 0)
// Minimum execution time: 1_904_000 picoseconds.
Weight::from_parts(1_984_000, 0)
}
pub fn set_topic() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 1_880_000 picoseconds.
Weight::from_parts(1_960_000, 0)
// Minimum execution time: 1_889_000 picoseconds.
Weight::from_parts(1_950_000, 0)
}
pub fn clear_topic() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 1_825_000 picoseconds.
Weight::from_parts(1_960_000, 0)
// Minimum execution time: 1_878_000 picoseconds.
Weight::from_parts(1_963_000, 0)
}
// Storage: UNKNOWN KEY `0x48297505634037ef48c848c99c0b1f1b` (r:1 w:0)
// Proof: UNKNOWN KEY `0x48297505634037ef48c848c99c0b1f1b` (r:1 w:0)
// Storage: `ParachainInfo::ParachainId` (r:1 w:0)
// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
// Storage: `BridgeRococoToWococoMessages::PalletOperatingMode` (r:1 w:0)
// Proof: `BridgeRococoToWococoMessages::PalletOperatingMode` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`)
// Storage: `BridgeRococoToWococoMessages::OutboundLanes` (r:1 w:1)
// Proof: `BridgeRococoToWococoMessages::OutboundLanes` (`max_values`: Some(1), `max_size`: Some(44), added: 539, mode: `MaxEncodedLen`)
// Storage: `BridgeRococoToWococoMessages::OutboundLanesCongestedSignals` (r:1 w:0)
// Proof: `BridgeRococoToWococoMessages::OutboundLanesCongestedSignals` (`max_values`: Some(1), `max_size`: Some(21), added: 516, mode: `MaxEncodedLen`)
// Storage: `BridgeRococoToWococoMessages::OutboundMessages` (r:0 w:1)
// Proof: `BridgeRococoToWococoMessages::OutboundMessages` (`max_values`: None, `max_size`: Some(2621472), added: 2623947, mode: `MaxEncodedLen`)
// Storage: `PolkadotXcm::SupportedVersion` (r:2 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: `BridgeRococoMessages::PalletOperatingMode` (r:1 w:0)
// Proof: `BridgeRococoMessages::PalletOperatingMode` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`)
// Storage: `BridgeRococoMessages::OutboundLanes` (r:1 w:1)
// Proof: `BridgeRococoMessages::OutboundLanes` (`max_values`: Some(1), `max_size`: Some(44), added: 539, mode: `MaxEncodedLen`)
// Storage: `BridgeRococoMessages::OutboundLanesCongestedSignals` (r:1 w:0)
// Proof: `BridgeRococoMessages::OutboundLanesCongestedSignals` (`max_values`: Some(1), `max_size`: Some(21), added: 516, mode: `MaxEncodedLen`)
// Storage: `BridgeRococoMessages::OutboundMessages` (r:0 w:1)
// Proof: `BridgeRococoMessages::OutboundMessages` (`max_values`: None, `max_size`: Some(2621472), added: 2623947, mode: `MaxEncodedLen`)
/// The range of component `x` is `[1, 1000]`.
pub fn export_message(x: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `139`
// Estimated: `3604`
// Minimum execution time: 28_419_000 picoseconds.
Weight::from_parts(29_387_791, 3604)
// Standard Error: 552
.saturating_add(Weight::from_parts(316_277, 0).saturating_mul(x.into()))
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(2))
// Measured: `188`
// Estimated: `6128`
// Minimum execution time: 36_960_000 picoseconds.
Weight::from_parts(38_104_333, 6128)
// Standard Error: 510
.saturating_add(Weight::from_parts(316_499, 0).saturating_mul(x.into()))
.saturating_add(T::DbWeight::get().reads(7))
.saturating_add(T::DbWeight::get().writes(3))
}
pub fn set_fees_mode() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 1_903_000 picoseconds.
Weight::from_parts(2_023_000, 0)
// Minimum execution time: 1_833_000 picoseconds.
Weight::from_parts(1_950_000, 0)
}
pub fn unpaid_execution() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 1_963_000 picoseconds.
Weight::from_parts(2_143_000, 0)
// Minimum execution time: 1_980_000 picoseconds.
Weight::from_parts(2_065_000, 0)
}
}
@@ -22,16 +22,16 @@ use bridge_hub_westend_runtime::{
bridge_common_config, bridge_to_rococo_config,
xcm_config::{RelayNetwork, WestendLocation, XcmConfig},
AllPalletsWithoutSystem, BridgeRejectObsoleteHeadersAndMessages, Executive, ExistentialDeposit,
ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, SessionKeys, SignedExtra,
TransactionPayment, UncheckedExtrinsic,
ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, SessionKeys,
SignedExtra, TransactionPayment, UncheckedExtrinsic,
};
use bridge_to_rococo_config::{
BridgeGrandpaRococoInstance, BridgeHubRococoChainId, BridgeParachainRococoInstance,
WithBridgeHubRococoMessageBridge, WithBridgeHubRococoMessagesInstance,
XCM_LANE_FOR_ASSET_HUB_WESTEND_TO_ASSET_HUB_ROCOCO,
BridgeGrandpaRococoInstance, BridgeHubRococoChainId, BridgeHubRococoLocation,
BridgeParachainRococoInstance, WithBridgeHubRococoMessageBridge,
WithBridgeHubRococoMessagesInstance, XCM_LANE_FOR_ASSET_HUB_WESTEND_TO_ASSET_HUB_ROCOCO,
};
use codec::{Decode, Encode};
use frame_support::{dispatch::GetDispatchInfo, parameter_types};
use frame_support::{dispatch::GetDispatchInfo, parameter_types, traits::ConstU8};
use frame_system::pallet_prelude::HeaderFor;
use parachains_common::{westend::fee::WeightToFee, AccountId, AuraId, Balance};
use sp_keyring::AccountKeyring::Alice;
@@ -184,7 +184,7 @@ fn handle_export_message_from_system_parachain_add_to_outbound_queue_works() {
Some((WestendLocation::get(), ExistentialDeposit::get()).into()),
// value should be >= than value generated by `can_calculate_weight_for_paid_export_message_with_reserve_transfer`
Some((WestendLocation::get(), bp_bridge_hub_westend::BridgeHubWestendBaseXcmFeeInWnds::get()).into()),
|| (),
|| PolkadotXcm::force_xcm_version(RuntimeOrigin::root(), Box::new(BridgeHubRococoLocation::get()), XCM_VERSION).expect("version saved!"),
)
}
@@ -198,6 +198,7 @@ fn message_dispatch_routing_works() {
WithBridgeHubRococoMessagesInstance,
RelayNetwork,
bridge_to_rococo_config::RococoGlobalConsensusNetwork,
ConstU8<2>,
>(
collator_session_keys(),
bp_bridge_hub_westend::BRIDGE_HUB_WESTEND_PARACHAIN_ID,
@@ -55,7 +55,10 @@ use sp_runtime::{
traits::{Header as HeaderT, Zero},
AccountId32,
};
use xcm::latest::prelude::*;
use xcm::{
latest::prelude::*,
prelude::{AlwaysLatest, GetVersion},
};
use xcm_builder::DispatchBlobError;
use xcm_executor::{
traits::{TransactAsset, WeightBounds},
@@ -258,6 +261,7 @@ pub fn message_dispatch_routing_works<
MessagesPalletInstance,
RuntimeNetwork,
BridgedNetwork,
NetworkDistanceAsParentCount,
>(
collator_session_key: CollatorSessionKeys<Runtime>,
runtime_para_id: u32,
@@ -291,13 +295,19 @@ pub fn message_dispatch_routing_works<
HrmpChannelOpener: frame_support::inherent::ProvideInherent<
Call = cumulus_pallet_parachain_system::Call<Runtime>,
>,
// MessageDispatcher: MessageDispatch<AccountIdOf<Runtime>, DispatchLevelResult =
// XcmBlobMessageDispatchResult, DispatchPayload = XcmAsPlainPayload>,
RuntimeNetwork: Get<NetworkId>,
BridgedNetwork: Get<NetworkId>,
NetworkDistanceAsParentCount: Get<u8>,
{
assert_ne!(runtime_para_id, sibling_parachain_id);
struct NetworkWithParentCount<N, C>(core::marker::PhantomData<(N, C)>);
impl<N: Get<NetworkId>, C: Get<u8>> Get<MultiLocation> for NetworkWithParentCount<N, C> {
fn get() -> MultiLocation {
MultiLocation { parents: C::get(), interior: X1(GlobalConsensus(N::get())) }
}
}
ExtBuilder::<Runtime>::default()
.with_collators(collator_session_key.collators())
.with_session_keys(collator_session_key.session_keys())
@@ -317,7 +327,11 @@ pub fn message_dispatch_routing_works<
);
// 1. this message is sent from other global consensus with destination of this Runtime relay chain (UMP)
let bridging_message =
test_data::simulate_message_exporter_on_bridged_chain::<BridgedNetwork, RuntimeNetwork>(
test_data::simulate_message_exporter_on_bridged_chain::<
BridgedNetwork,
NetworkWithParentCount<RuntimeNetwork, NetworkDistanceAsParentCount>,
AlwaysLatest,
>(
(RuntimeNetwork::get(), Here)
);
let result = <<Runtime as pallet_bridge_messages::Config<MessagesPalletInstance>>::MessageDispatch>::dispatch(
@@ -335,7 +349,11 @@ pub fn message_dispatch_routing_works<
// 2. this message is sent from other global consensus with destination of this Runtime sibling parachain (HRMP)
let bridging_message =
test_data::simulate_message_exporter_on_bridged_chain::<BridgedNetwork, RuntimeNetwork>(
test_data::simulate_message_exporter_on_bridged_chain::<
BridgedNetwork,
NetworkWithParentCount<RuntimeNetwork, NetworkDistanceAsParentCount>,
AlwaysLatest,
>(
(RuntimeNetwork::get(), X1(Parachain(sibling_parachain_id))),
);
@@ -1524,7 +1542,8 @@ pub mod test_data {
/// which are transferred over bridge.
pub(crate) fn simulate_message_exporter_on_bridged_chain<
SourceNetwork: Get<NetworkId>,
DestinationNetwork: Get<NetworkId>,
DestinationNetwork: Get<MultiLocation>,
DestinationVersion: GetVersion,
>(
(destination_network, destination_junctions): (NetworkId, Junctions),
) -> Vec<u8> {
@@ -1536,23 +1555,28 @@ pub mod test_data {
let channel = 1_u32;
// simulate XCM message export
let (ticket, fee) =
validate_export::<HaulBlobExporter<GrabbingHaulBlob, DestinationNetwork, ()>>(
destination_network,
channel,
universal_source_on_bridged_chain,
destination_junctions,
dummy_xcm(),
)
.expect("validate_export to pass");
let (ticket, fee) = validate_export::<
HaulBlobExporter<GrabbingHaulBlob, DestinationNetwork, DestinationVersion, ()>,
>(
destination_network,
channel,
universal_source_on_bridged_chain,
destination_junctions,
dummy_xcm(),
)
.expect("validate_export to pass");
log::info!(
target: "simulate_message_exporter_on_bridged_chain",
"HaulBlobExporter::validate fee: {:?}",
fee
);
let xcm_hash =
HaulBlobExporter::<GrabbingHaulBlob, DestinationNetwork, ()>::deliver(ticket)
.expect("deliver to pass");
let xcm_hash = HaulBlobExporter::<
GrabbingHaulBlob,
DestinationNetwork,
DestinationVersion,
(),
>::deliver(ticket)
.expect("deliver to pass");
log::info!(
target: "simulate_message_exporter_on_bridged_chain",
"HaulBlobExporter::deliver xcm_hash: {:?}",
@@ -128,7 +128,7 @@ pub struct ExtBuilder<
collators: Vec<AccountIdOf<Runtime>>,
// keys added to pallet session
keys: Vec<(AccountIdOf<Runtime>, ValidatorIdOf<Runtime>, SessionKeysOf<Runtime>)>,
// safe xcm version for pallet_xcm
// safe XCM version for pallet_xcm
safe_xcm_version: Option<XcmVersion>,
// para id
para_id: Option<ParaId>,