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
@@ -21,8 +21,8 @@ use frame_support::traits::OnInitialize;
// Cumulus
use emulated_integration_tests_common::{
impl_accounts_helpers_for_parachain, impl_assert_events_helpers_for_parachain,
impl_assets_helpers_for_parachain, impl_foreign_assets_helpers_for_parachain, impls::Parachain,
xcm_emulator::decl_test_parachains,
impl_assets_helpers_for_parachain, impl_foreign_assets_helpers_for_parachain,
impl_xcm_helpers_for_parachain, impls::Parachain, xcm_emulator::decl_test_parachains,
};
use rococo_emulated_chain::Rococo;
@@ -55,3 +55,4 @@ impl_accounts_helpers_for_parachain!(AssetHubRococo);
impl_assert_events_helpers_for_parachain!(AssetHubRococo);
impl_assets_helpers_for_parachain!(AssetHubRococo, Rococo);
impl_foreign_assets_helpers_for_parachain!(AssetHubRococo, Rococo);
impl_xcm_helpers_for_parachain!(AssetHubRococo);
@@ -21,8 +21,8 @@ use frame_support::traits::OnInitialize;
// Cumulus
use emulated_integration_tests_common::{
impl_accounts_helpers_for_parachain, impl_assert_events_helpers_for_parachain,
impl_assets_helpers_for_parachain, impl_foreign_assets_helpers_for_parachain, impls::Parachain,
xcm_emulator::decl_test_parachains,
impl_assets_helpers_for_parachain, impl_foreign_assets_helpers_for_parachain,
impl_xcm_helpers_for_parachain, impls::Parachain, xcm_emulator::decl_test_parachains,
};
use westend_emulated_chain::Westend;
@@ -55,3 +55,4 @@ impl_accounts_helpers_for_parachain!(AssetHubWestend);
impl_assert_events_helpers_for_parachain!(AssetHubWestend);
impl_assets_helpers_for_parachain!(AssetHubWestend, Westend);
impl_foreign_assets_helpers_for_parachain!(AssetHubWestend, Westend);
impl_xcm_helpers_for_parachain!(AssetHubWestend);
@@ -21,7 +21,7 @@ use frame_support::traits::OnInitialize;
// Cumulus
use emulated_integration_tests_common::{
impl_accounts_helpers_for_parachain, impl_assert_events_helpers_for_parachain,
impls::Parachain, xcm_emulator::decl_test_parachains,
impl_xcm_helpers_for_parachain, impls::Parachain, xcm_emulator::decl_test_parachains,
};
// BridgeHubRococo Parachain declaration
@@ -47,3 +47,4 @@ decl_test_parachains! {
// BridgeHubRococo implementation
impl_accounts_helpers_for_parachain!(BridgeHubRococo);
impl_assert_events_helpers_for_parachain!(BridgeHubRococo);
impl_xcm_helpers_for_parachain!(BridgeHubRococo);
@@ -21,7 +21,7 @@ use frame_support::traits::OnInitialize;
// Cumulus
use emulated_integration_tests_common::{
impl_accounts_helpers_for_parachain, impl_assert_events_helpers_for_parachain,
impls::Parachain, xcm_emulator::decl_test_parachains,
impl_xcm_helpers_for_parachain, impls::Parachain, xcm_emulator::decl_test_parachains,
};
// BridgeHubWestend Parachain declaration
@@ -47,3 +47,4 @@ decl_test_parachains! {
// BridgeHubWestend implementation
impl_accounts_helpers_for_parachain!(BridgeHubWestend);
impl_assert_events_helpers_for_parachain!(BridgeHubWestend);
impl_xcm_helpers_for_parachain!(BridgeHubWestend);
@@ -38,7 +38,7 @@ pub use polkadot_runtime_parachains::{
inclusion::{AggregateMessageOrigin, UmpQueueId},
};
pub use xcm::{
prelude::{MultiLocation, OriginKind, Outcome, VersionedXcm},
prelude::{MultiLocation, OriginKind, Outcome, VersionedXcm, XcmVersion},
v3::Error,
DoubleEncoded,
};
@@ -173,10 +173,14 @@ macro_rules! impl_accounts_helpers_for_relay_chain {
pub fn fund_accounts(accounts: Vec<($crate::impls::AccountId, $crate::impls::Balance)>) {
<Self as $crate::impls::TestExt>::execute_with(|| {
for account in accounts {
let who = account.0;
let actual = <Self as [<$chain RelayPallet>]>::Balances::free_balance(&who);
let actual = actual.saturating_add(<Self as [<$chain RelayPallet>]>::Balances::reserved_balance(&who));
$crate::impls::assert_ok!(<Self as [<$chain RelayPallet>]>::Balances::force_set_balance(
<Self as $crate::impls::Chain>::RuntimeOrigin::root(),
account.0.into(),
account.1,
who.into(),
actual.saturating_add(account.1),
));
}
});
@@ -386,15 +390,26 @@ macro_rules! impl_accounts_helpers_for_parachain {
pub fn fund_accounts(accounts: Vec<($crate::impls::AccountId, $crate::impls::Balance)>) {
<Self as $crate::impls::TestExt>::execute_with(|| {
for account in accounts {
let who = account.0;
let actual = <Self as [<$chain ParaPallet>]>::Balances::free_balance(&who);
let actual = actual.saturating_add(<Self as [<$chain ParaPallet>]>::Balances::reserved_balance(&who));
$crate::impls::assert_ok!(<Self as [<$chain ParaPallet>]>::Balances::force_set_balance(
<Self as $crate::impls::Chain>::RuntimeOrigin::root(),
account.0.into(),
account.1,
who.into(),
actual.saturating_add(account.1),
));
}
});
}
/// Fund a sovereign account of sibling para.
pub fn fund_para_sovereign(sibling_para_id: $crate::impls::ParaId, balance: $crate::impls::Balance) {
let sibling_location = Self::sibling_location_of(sibling_para_id);
let sovereign_account = Self::sovereign_account_id_of(sibling_location);
Self::fund_accounts(vec![(sovereign_account.into(), balance)])
}
/// Return local sovereign account of `para_id` on other `network_id`
pub fn sovereign_account_of_parachain_on_other_global_consensus(
network_id: $crate::impls::NetworkId,
@@ -790,3 +805,33 @@ macro_rules! impl_foreign_assets_helpers_for_parachain {
}
};
}
#[macro_export]
macro_rules! impl_xcm_helpers_for_parachain {
( $chain:ident ) => {
$crate::impls::paste::paste! {
impl<N: $crate::impls::Network> $chain<N> {
/// Set XCM version for destination.
pub fn force_xcm_version(dest: $crate::impls::MultiLocation, version: $crate::impls::XcmVersion) {
<Self as $crate::impls::TestExt>::execute_with(|| {
$crate::impls::assert_ok!(<Self as [<$chain ParaPallet>]>::PolkadotXcm::force_xcm_version(
<Self as $crate::impls::Chain>::RuntimeOrigin::root(),
$crate::impls::bx!(dest),
version,
));
});
}
/// Set default/safe XCM version for runtime.
pub fn force_default_xcm_version(version: Option<$crate::impls::XcmVersion>) {
<Self as $crate::impls::TestExt>::execute_with(|| {
$crate::impls::assert_ok!(<Self as [<$chain ParaPallet>]>::PolkadotXcm::force_default_xcm_version(
<Self as $crate::impls::Chain>::RuntimeOrigin::root(),
version,
));
});
}
}
}
}
}
@@ -15,6 +15,7 @@ frame-support = { path = "../../../../../../../substrate/frame/support", default
pallet-assets = { path = "../../../../../../../substrate/frame/assets", default-features = false }
pallet-balances = { path = "../../../../../../../substrate/frame/balances", default-features = false }
pallet-message-queue = { path = "../../../../../../../substrate/frame/message-queue" }
sp-runtime = { path = "../../../../../../../substrate/primitives/runtime", default-features = false }
# Polkadot
xcm = { package = "staging-xcm", path = "../../../../../../../polkadot/xcm", default-features = false }
@@ -14,10 +14,12 @@
// limitations under the License.
// Substrate
pub use frame_support::assert_ok;
pub use frame_support::{assert_err, assert_ok, pallet_prelude::DispatchResult};
pub use sp_runtime::DispatchError;
// Polkadot
pub use xcm::{
latest::ParentThen,
prelude::{AccountId32 as AccountId32Junction, *},
v3::{
Error,
@@ -13,70 +13,22 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use crate::*;
use crate::tests::*;
fn send_asset_from_asset_hub_rococo_to_asset_hub_westend(id: MultiLocation, amount: u128) {
let signed_origin =
<AssetHubRococo as Chain>::RuntimeOrigin::signed(AssetHubRococoSender::get().into());
let asset_hub_westend_para_id = AssetHubWestend::para_id().into();
let destination = MultiLocation {
parents: 2,
interior: X2(GlobalConsensus(NetworkId::Westend), Parachain(asset_hub_westend_para_id)),
};
let beneficiary_id = AssetHubWestendReceiver::get();
let beneficiary: MultiLocation =
AccountId32Junction { network: None, id: beneficiary_id.into() }.into();
let assets: MultiAssets = (id, amount).into();
let fee_asset_item = 0;
let destination = asset_hub_westend_location();
// fund the AHR's SA on BHR for paying bridge transport fees
let ahr_as_seen_by_bhr = BridgeHubRococo::sibling_location_of(AssetHubRococo::para_id());
let sov_ahr_on_bhr = BridgeHubRococo::sovereign_account_id_of(ahr_as_seen_by_bhr);
BridgeHubRococo::fund_accounts(vec![(sov_ahr_on_bhr.into(), 10_000_000_000_000u128)]);
BridgeHubRococo::fund_para_sovereign(AssetHubRococo::para_id(), 10_000_000_000_000u128);
AssetHubRococo::execute_with(|| {
assert_ok!(
<AssetHubRococo as AssetHubRococoPallet>::PolkadotXcm::limited_reserve_transfer_assets(
signed_origin,
bx!(destination.into()),
bx!(beneficiary.into()),
bx!(assets.into()),
fee_asset_item,
WeightLimit::Unlimited,
)
);
});
// set XCM versions
AssetHubRococo::force_xcm_version(destination, XCM_VERSION);
BridgeHubRococo::force_xcm_version(bridge_hub_westend_location(), XCM_VERSION);
BridgeHubRococo::execute_with(|| {
type RuntimeEvent = <BridgeHubRococo as Chain>::RuntimeEvent;
assert_expected_events!(
BridgeHubRococo,
vec![
// pay for bridge fees
RuntimeEvent::Balances(pallet_balances::Event::Withdraw { .. }) => {},
// message exported
RuntimeEvent::BridgeWestendMessages(
pallet_bridge_messages::Event::MessageAccepted { .. }
) => {},
// message processed successfully
RuntimeEvent::MessageQueue(
pallet_message_queue::Event::Processed { success: true, .. }
) => {},
]
);
});
BridgeHubWestend::execute_with(|| {
type RuntimeEvent = <BridgeHubWestend as Chain>::RuntimeEvent;
assert_expected_events!(
BridgeHubWestend,
vec![
// message dispatched successfully
RuntimeEvent::XcmpQueue(
cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { .. }
) => {},
]
);
});
// send message over bridge
assert_ok!(send_asset_from_asset_hub_rococo(destination, (id, amount)));
assert_bridge_hub_rococo_message_accepted(true);
assert_bridge_hub_westend_message_received();
}
#[test]
@@ -13,6 +13,102 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use crate::*;
mod asset_transfers;
mod send_xcm;
mod teleport;
pub(crate) fn asset_hub_westend_location() -> MultiLocation {
MultiLocation {
parents: 2,
interior: X2(
GlobalConsensus(NetworkId::Westend),
Parachain(AssetHubWestend::para_id().into()),
),
}
}
pub(crate) fn bridge_hub_westend_location() -> MultiLocation {
MultiLocation {
parents: 2,
interior: X2(
GlobalConsensus(NetworkId::Westend),
Parachain(BridgeHubWestend::para_id().into()),
),
}
}
pub(crate) fn send_asset_from_asset_hub_rococo(
destination: MultiLocation,
(id, amount): (MultiLocation, u128),
) -> DispatchResult {
let signed_origin =
<AssetHubRococo as Chain>::RuntimeOrigin::signed(AssetHubRococoSender::get().into());
let beneficiary: MultiLocation =
AccountId32Junction { network: None, id: AssetHubWestendReceiver::get().into() }.into();
let assets: MultiAssets = (id, amount).into();
let fee_asset_item = 0;
AssetHubRococo::execute_with(|| {
<AssetHubRococo as AssetHubRococoPallet>::PolkadotXcm::limited_reserve_transfer_assets(
signed_origin,
bx!(destination.into()),
bx!(beneficiary.into()),
bx!(assets.into()),
fee_asset_item,
WeightLimit::Unlimited,
)
})
}
pub(crate) fn assert_bridge_hub_rococo_message_accepted(expected_processed: bool) {
BridgeHubRococo::execute_with(|| {
type RuntimeEvent = <BridgeHubRococo as Chain>::RuntimeEvent;
if expected_processed {
assert_expected_events!(
BridgeHubRococo,
vec![
// pay for bridge fees
RuntimeEvent::Balances(pallet_balances::Event::Withdraw { .. }) => {},
// message exported
RuntimeEvent::BridgeWestendMessages(
pallet_bridge_messages::Event::MessageAccepted { .. }
) => {},
// message processed successfully
RuntimeEvent::MessageQueue(
pallet_message_queue::Event::Processed { success: true, .. }
) => {},
]
);
} else {
assert_expected_events!(
BridgeHubRococo,
vec![
RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {
success: false,
..
}) => {},
]
);
}
});
}
pub(crate) fn assert_bridge_hub_westend_message_received() {
BridgeHubWestend::execute_with(|| {
type RuntimeEvent = <BridgeHubWestend as Chain>::RuntimeEvent;
assert_expected_events!(
BridgeHubWestend,
vec![
// message sent to destination
RuntimeEvent::XcmpQueue(
cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { .. }
) => {},
]
);
})
}
@@ -13,7 +13,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use crate::*;
use crate::tests::*;
#[test]
fn send_xcm_from_rococo_relay_to_westend_asset_hub_should_fail_on_not_applicable() {
@@ -55,17 +55,123 @@ fn send_xcm_from_rococo_relay_to_westend_asset_hub_should_fail_on_not_applicable
});
// Receive XCM message in Bridge Hub source Parachain, it should fail, because we don't have
// opened bridge/lane.
BridgeHubRococo::execute_with(|| {
type RuntimeEvent = <BridgeHubRococo as Chain>::RuntimeEvent;
assert_bridge_hub_rococo_message_accepted(false);
}
#[test]
fn send_xcm_through_opened_lane_with_different_xcm_version_on_hops_works() {
// Initially set only default version on all runtimes
AssetHubRococo::force_default_xcm_version(Some(xcm::v2::prelude::XCM_VERSION));
BridgeHubRococo::force_default_xcm_version(Some(xcm::v2::prelude::XCM_VERSION));
BridgeHubWestend::force_default_xcm_version(Some(xcm::v2::prelude::XCM_VERSION));
AssetHubWestend::force_default_xcm_version(Some(xcm::v2::prelude::XCM_VERSION));
// prepare data
let destination = asset_hub_westend_location();
let native_token = MultiLocation::parent();
let amount = ASSET_HUB_ROCOCO_ED * 1_000;
// fund the AHR's SA on BHR for paying bridge transport fees
BridgeHubRococo::fund_para_sovereign(AssetHubRococo::para_id(), 10_000_000_000_000u128);
// fund sender
AssetHubRococo::fund_accounts(vec![(AssetHubRococoSender::get().into(), amount * 10)]);
// send XCM from AssetHubRococo - fails - destination version not known
assert_err!(
send_asset_from_asset_hub_rococo(destination, (native_token, amount)),
DispatchError::Module(sp_runtime::ModuleError {
index: 31,
error: [1, 0, 0, 0],
message: Some("SendFailure")
})
);
// set destination version
AssetHubRococo::force_xcm_version(destination, xcm::v3::prelude::XCM_VERSION);
// TODO: remove this block, when removing `xcm:v2`
{
// send XCM from AssetHubRococo - fails - AssetHubRococo is set to the default/safe `2`
// version, which does not have the `ExportMessage` instruction. If the default `2` is
// changed to `3`, then this assert can go away"
assert_err!(
send_asset_from_asset_hub_rococo(destination, (native_token, amount)),
DispatchError::Module(sp_runtime::ModuleError {
index: 31,
error: [1, 0, 0, 0],
message: Some("SendFailure")
})
);
// set exact version for BridgeHubWestend to `2` without `ExportMessage` instruction
AssetHubRococo::force_xcm_version(
ParentThen(Parachain(BridgeHubRococo::para_id().into()).into()).into(),
xcm::v2::prelude::XCM_VERSION,
);
// send XCM from AssetHubRococo - fails - `ExportMessage` is not in `2`
assert_err!(
send_asset_from_asset_hub_rococo(destination, (native_token, amount)),
DispatchError::Module(sp_runtime::ModuleError {
index: 31,
error: [1, 0, 0, 0],
message: Some("SendFailure")
})
);
}
// set version with `ExportMessage` for BridgeHubRococo
AssetHubRococo::force_xcm_version(
ParentThen(Parachain(BridgeHubRococo::para_id().into()).into()).into(),
xcm::v3::prelude::XCM_VERSION,
);
// send XCM from AssetHubRococo - ok
assert_ok!(send_asset_from_asset_hub_rococo(destination, (native_token, amount)));
// `ExportMessage` on local BridgeHub - fails - remote BridgeHub version not known
assert_bridge_hub_rococo_message_accepted(false);
// set version for remote BridgeHub on BridgeHubRococo
BridgeHubRococo::force_xcm_version(
bridge_hub_westend_location(),
xcm::v3::prelude::XCM_VERSION,
);
// set version for AssetHubWestend on BridgeHubWestend
BridgeHubWestend::force_xcm_version(
ParentThen(Parachain(AssetHubWestend::para_id().into()).into()).into(),
xcm::v3::prelude::XCM_VERSION,
);
// send XCM from AssetHubRococo - ok
assert_ok!(send_asset_from_asset_hub_rococo(destination, (native_token, amount)));
assert_bridge_hub_rococo_message_accepted(true);
assert_bridge_hub_westend_message_received();
// message delivered and processed at destination
AssetHubWestend::execute_with(|| {
type RuntimeEvent = <AssetHubWestend as Chain>::RuntimeEvent;
assert_expected_events!(
BridgeHubRococo,
AssetHubWestend,
vec![
RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {
success: false,
..
}) => {},
// message processed with failure, but for this scenario it is ok, important is that was delivered
RuntimeEvent::MessageQueue(
pallet_message_queue::Event::Processed { success: false, .. }
) => {},
]
);
});
// TODO: remove this block, when removing `xcm:v2`
{
// set `2` version for remote BridgeHub on BridgeHubRococo, which does not have
// `UniversalOrigin` and `DescendOrigin`
BridgeHubRococo::force_xcm_version(
bridge_hub_westend_location(),
xcm::v2::prelude::XCM_VERSION,
);
// send XCM from AssetHubRococo - ok
assert_ok!(send_asset_from_asset_hub_rococo(destination, (native_token, amount)));
// message is not accepted on the local BridgeHub (`DestinationUnsupported`) because we
// cannot add `UniversalOrigin` and `DescendOrigin`
assert_bridge_hub_rococo_message_accepted(false);
}
}
@@ -15,6 +15,7 @@ frame-support = { path = "../../../../../../../substrate/frame/support", default
pallet-assets = { path = "../../../../../../../substrate/frame/assets", default-features = false }
pallet-balances = { path = "../../../../../../../substrate/frame/balances", default-features = false }
pallet-message-queue = { path = "../../../../../../../substrate/frame/message-queue" }
sp-runtime = { path = "../../../../../../../substrate/primitives/runtime", default-features = false }
# Polkadot
xcm = { package = "staging-xcm", path = "../../../../../../../polkadot/xcm", default-features = false }
@@ -14,10 +14,12 @@
// limitations under the License.
// Substrate
pub use frame_support::assert_ok;
pub use frame_support::{assert_err, assert_ok, pallet_prelude::DispatchResult};
pub use sp_runtime::DispatchError;
// Polkadot
pub use xcm::{
latest::ParentThen,
prelude::{AccountId32 as AccountId32Junction, *},
v3::{
Error,
@@ -12,70 +12,22 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
use crate::*;
use crate::tests::*;
fn send_asset_from_asset_hub_westend_to_asset_hub_rococo(id: MultiLocation, amount: u128) {
let signed_origin =
<AssetHubWestend as Chain>::RuntimeOrigin::signed(AssetHubWestendSender::get().into());
let asset_hub_rococo_para_id = AssetHubRococo::para_id().into();
let destination = MultiLocation {
parents: 2,
interior: X2(GlobalConsensus(NetworkId::Rococo), Parachain(asset_hub_rococo_para_id)),
};
let beneficiary_id = AssetHubRococoReceiver::get();
let beneficiary: MultiLocation =
AccountId32Junction { network: None, id: beneficiary_id.into() }.into();
let assets: MultiAssets = (id, amount).into();
let fee_asset_item = 0;
let destination = asset_hub_rococo_location();
// fund the AHW's SA on BHW for paying bridge transport fees
let ahw_as_seen_by_bhw = BridgeHubWestend::sibling_location_of(AssetHubWestend::para_id());
let sov_ahw_on_bhw = BridgeHubWestend::sovereign_account_id_of(ahw_as_seen_by_bhw);
BridgeHubWestend::fund_accounts(vec![(sov_ahw_on_bhw.into(), 10_000_000_000_000u128)]);
BridgeHubWestend::fund_para_sovereign(AssetHubWestend::para_id(), 10_000_000_000_000u128);
AssetHubWestend::execute_with(|| {
assert_ok!(
<AssetHubWestend as AssetHubWestendPallet>::PolkadotXcm::limited_reserve_transfer_assets(
signed_origin,
bx!(destination.into()),
bx!(beneficiary.into()),
bx!(assets.into()),
fee_asset_item,
WeightLimit::Unlimited,
)
);
});
// set XCM versions
AssetHubWestend::force_xcm_version(destination, XCM_VERSION);
BridgeHubWestend::force_xcm_version(bridge_hub_rococo_location(), XCM_VERSION);
BridgeHubWestend::execute_with(|| {
type RuntimeEvent = <BridgeHubWestend as Chain>::RuntimeEvent;
assert_expected_events!(
BridgeHubWestend,
vec![
// pay for bridge fees
RuntimeEvent::Balances(pallet_balances::Event::Withdraw { .. }) => {},
// message exported
RuntimeEvent::BridgeRococoMessages(
pallet_bridge_messages::Event::MessageAccepted { .. }
) => {},
// message processed successfully
RuntimeEvent::MessageQueue(
pallet_message_queue::Event::Processed { success: true, .. }
) => {},
]
);
});
BridgeHubRococo::execute_with(|| {
type RuntimeEvent = <BridgeHubRococo as Chain>::RuntimeEvent;
assert_expected_events!(
BridgeHubRococo,
vec![
// message dispatched successfully
RuntimeEvent::XcmpQueue(
cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { .. }
) => {},
]
);
});
// send message over bridge
assert_ok!(send_asset_from_asset_hub_westend(destination, (id, amount)));
assert_bridge_hub_westend_message_accepted(true);
assert_bridge_hub_rococo_message_received();
}
#[test]
@@ -13,6 +13,102 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use crate::*;
mod asset_transfers;
mod send_xcm;
mod teleport;
pub(crate) fn asset_hub_rococo_location() -> MultiLocation {
MultiLocation {
parents: 2,
interior: X2(
GlobalConsensus(NetworkId::Rococo),
Parachain(AssetHubRococo::para_id().into()),
),
}
}
pub(crate) fn bridge_hub_rococo_location() -> MultiLocation {
MultiLocation {
parents: 2,
interior: X2(
GlobalConsensus(NetworkId::Rococo),
Parachain(BridgeHubRococo::para_id().into()),
),
}
}
pub(crate) fn send_asset_from_asset_hub_westend(
destination: MultiLocation,
(id, amount): (MultiLocation, u128),
) -> DispatchResult {
let signed_origin =
<AssetHubWestend as Chain>::RuntimeOrigin::signed(AssetHubWestendSender::get().into());
let beneficiary: MultiLocation =
AccountId32Junction { network: None, id: AssetHubRococoReceiver::get().into() }.into();
let assets: MultiAssets = (id, amount).into();
let fee_asset_item = 0;
AssetHubWestend::execute_with(|| {
<AssetHubWestend as AssetHubWestendPallet>::PolkadotXcm::limited_reserve_transfer_assets(
signed_origin,
bx!(destination.into()),
bx!(beneficiary.into()),
bx!(assets.into()),
fee_asset_item,
WeightLimit::Unlimited,
)
})
}
pub(crate) fn assert_bridge_hub_westend_message_accepted(expected_processed: bool) {
BridgeHubWestend::execute_with(|| {
type RuntimeEvent = <BridgeHubWestend as Chain>::RuntimeEvent;
if expected_processed {
assert_expected_events!(
BridgeHubWestend,
vec![
// pay for bridge fees
RuntimeEvent::Balances(pallet_balances::Event::Withdraw { .. }) => {},
// message exported
RuntimeEvent::BridgeRococoMessages(
pallet_bridge_messages::Event::MessageAccepted { .. }
) => {},
// message processed successfully
RuntimeEvent::MessageQueue(
pallet_message_queue::Event::Processed { success: true, .. }
) => {},
]
);
} else {
assert_expected_events!(
BridgeHubWestend,
vec![
RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {
success: false,
..
}) => {},
]
);
}
});
}
pub(crate) fn assert_bridge_hub_rococo_message_received() {
BridgeHubRococo::execute_with(|| {
type RuntimeEvent = <BridgeHubRococo as Chain>::RuntimeEvent;
assert_expected_events!(
BridgeHubRococo,
vec![
// message sent to destination
RuntimeEvent::XcmpQueue(
cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { .. }
) => {},
]
);
})
}
@@ -13,7 +13,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use crate::*;
use crate::tests::*;
#[test]
fn send_xcm_from_westend_relay_to_rococo_asset_hub_should_fail_on_not_applicable() {
@@ -55,17 +55,123 @@ fn send_xcm_from_westend_relay_to_rococo_asset_hub_should_fail_on_not_applicable
});
// Receive XCM message in Bridge Hub source Parachain, it should fail, because we don't have
// opened bridge/lane.
BridgeHubWestend::execute_with(|| {
type RuntimeEvent = <BridgeHubWestend as Chain>::RuntimeEvent;
assert_bridge_hub_westend_message_accepted(false);
}
#[test]
fn send_xcm_through_opened_lane_with_different_xcm_version_on_hops_works() {
// Initially set only default version on all runtimes
AssetHubRococo::force_default_xcm_version(Some(xcm::v2::prelude::XCM_VERSION));
BridgeHubRococo::force_default_xcm_version(Some(xcm::v2::prelude::XCM_VERSION));
BridgeHubWestend::force_default_xcm_version(Some(xcm::v2::prelude::XCM_VERSION));
AssetHubWestend::force_default_xcm_version(Some(xcm::v2::prelude::XCM_VERSION));
// prepare data
let destination = asset_hub_rococo_location();
let native_token = MultiLocation::parent();
let amount = ASSET_HUB_WESTEND_ED * 1_000;
// fund the AHR's SA on BHR for paying bridge transport fees
BridgeHubWestend::fund_para_sovereign(AssetHubWestend::para_id(), 10_000_000_000_000u128);
// fund sender
AssetHubWestend::fund_accounts(vec![(AssetHubWestendSender::get().into(), amount * 10)]);
// send XCM from AssetHubWestend - fails - destination version not known
assert_err!(
send_asset_from_asset_hub_westend(destination, (native_token, amount)),
DispatchError::Module(sp_runtime::ModuleError {
index: 31,
error: [1, 0, 0, 0],
message: Some("SendFailure")
})
);
// set destination version
AssetHubWestend::force_xcm_version(destination, xcm::v3::prelude::XCM_VERSION);
// TODO: remove this block, when removing `xcm:v2`
{
// send XCM from AssetHubRococo - fails - AssetHubRococo is set to the default/safe `2`
// version, which does not have the `ExportMessage` instruction. If the default `2` is
// changed to `3`, then this assert can go away"
assert_err!(
send_asset_from_asset_hub_westend(destination, (native_token, amount)),
DispatchError::Module(sp_runtime::ModuleError {
index: 31,
error: [1, 0, 0, 0],
message: Some("SendFailure")
})
);
// set exact version for BridgeHubWestend to `2` without `ExportMessage` instruction
AssetHubWestend::force_xcm_version(
ParentThen(Parachain(BridgeHubWestend::para_id().into()).into()).into(),
xcm::v2::prelude::XCM_VERSION,
);
// send XCM from AssetHubWestend - fails - `ExportMessage` is not in `2`
assert_err!(
send_asset_from_asset_hub_westend(destination, (native_token, amount)),
DispatchError::Module(sp_runtime::ModuleError {
index: 31,
error: [1, 0, 0, 0],
message: Some("SendFailure")
})
);
}
// set version with `ExportMessage` for BridgeHubWestend
AssetHubWestend::force_xcm_version(
ParentThen(Parachain(BridgeHubWestend::para_id().into()).into()).into(),
xcm::v3::prelude::XCM_VERSION,
);
// send XCM from AssetHubWestend - ok
assert_ok!(send_asset_from_asset_hub_westend(destination, (native_token, amount)));
// `ExportMessage` on local BridgeHub - fails - remote BridgeHub version not known
assert_bridge_hub_westend_message_accepted(false);
// set version for remote BridgeHub on BridgeHubWestend
BridgeHubWestend::force_xcm_version(
bridge_hub_rococo_location(),
xcm::v3::prelude::XCM_VERSION,
);
// set version for AssetHubRococo on BridgeHubRococo
BridgeHubRococo::force_xcm_version(
ParentThen(Parachain(AssetHubRococo::para_id().into()).into()).into(),
xcm::v3::prelude::XCM_VERSION,
);
// send XCM from AssetHubWestend - ok
assert_ok!(send_asset_from_asset_hub_westend(destination, (native_token, amount)));
assert_bridge_hub_westend_message_accepted(true);
assert_bridge_hub_rococo_message_received();
// message delivered and processed at destination
AssetHubRococo::execute_with(|| {
type RuntimeEvent = <AssetHubRococo as Chain>::RuntimeEvent;
assert_expected_events!(
BridgeHubWestend,
AssetHubRococo,
vec![
RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {
success: false,
..
}) => {},
// message processed with failure, but for this scenario it is ok, important is that was delivered
RuntimeEvent::MessageQueue(
pallet_message_queue::Event::Processed { success: false, .. }
) => {},
]
);
});
// TODO: remove this block, when removing `xcm:v2`
{
// set `2` version for remote BridgeHub on BridgeHubRococo, which does not have
// `UniversalOrigin` and `DescendOrigin`
BridgeHubWestend::force_xcm_version(
bridge_hub_rococo_location(),
xcm::v2::prelude::XCM_VERSION,
);
// send XCM from AssetHubWestend - ok
assert_ok!(send_asset_from_asset_hub_westend(destination, (native_token, amount)));
// message is not accepted on the local BridgeHub (`DestinationUnsupported`) because we
// cannot add `UniversalOrigin` and `DescendOrigin`
assert_bridge_hub_westend_message_accepted(false);
}
}
@@ -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>,