From 0a74c6e9084a042fb517c86f0334aa4846619e60 Mon Sep 17 00:00:00 2001 From: Francisco Aguirre Date: Thu, 3 Oct 2024 08:49:51 +0200 Subject: [PATCH 01/10] fix(parachain-system): not include messages if empty --- cumulus/pallets/parachain-system/src/lib.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cumulus/pallets/parachain-system/src/lib.rs b/cumulus/pallets/parachain-system/src/lib.rs index 21af35fe3de3..d5f30a97ba7a 100644 --- a/cumulus/pallets/parachain-system/src/lib.rs +++ b/cumulus/pallets/parachain-system/src/lib.rs @@ -1582,7 +1582,11 @@ impl InspectMessageQueues for Pallet { .map(|encoded_message| VersionedXcm::<()>::decode(&mut &encoded_message[..]).unwrap()) .collect(); - vec![(VersionedLocation::V4(Parent.into()), messages)] + if messages.is_empty() { + vec![] + } else { + vec![(VersionedLocation::from(Location::parent()), messages)] + } } } From 4ba98830a3371aaf35782013e07b73f7bcd0d3b1 Mon Sep 17 00:00:00 2001 From: Francisco Aguirre Date: Thu, 3 Oct 2024 12:56:20 +0200 Subject: [PATCH 02/10] fix: exporters already add their message to xcmp-queue --- bridges/modules/xcm-bridge-hub-router/src/lib.rs | 8 +++----- polkadot/xcm/xcm-builder/src/universal_exports.rs | 8 +++----- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/bridges/modules/xcm-bridge-hub-router/src/lib.rs b/bridges/modules/xcm-bridge-hub-router/src/lib.rs index 7ba524e95b1d..e60621d8641c 100644 --- a/bridges/modules/xcm-bridge-hub-router/src/lib.rs +++ b/bridges/modules/xcm-bridge-hub-router/src/lib.rs @@ -99,7 +99,7 @@ pub mod pallet { type DestinationVersion: GetVersion; /// Actual message sender (`HRMP` or `DMP`) to the sibling bridge hub location. - type ToBridgeHubSender: SendXcm + InspectMessageQueues; + type ToBridgeHubSender: SendXcm; /// Local XCM channel manager. type LocalXcmChannelManager: XcmChannelStatusProvider; @@ -408,12 +408,10 @@ impl, I: 'static> SendXcm for Pallet { } impl, I: 'static> InspectMessageQueues for Pallet { - fn clear_messages() { - ViaBridgeHubExporter::::clear_messages() - } + fn clear_messages() {} fn get_messages() -> Vec<(VersionedLocation, Vec>)> { - ViaBridgeHubExporter::::get_messages() + Vec::new() } } diff --git a/polkadot/xcm/xcm-builder/src/universal_exports.rs b/polkadot/xcm/xcm-builder/src/universal_exports.rs index 30e0b7c72b03..4842a82596fc 100644 --- a/polkadot/xcm/xcm-builder/src/universal_exports.rs +++ b/polkadot/xcm/xcm-builder/src/universal_exports.rs @@ -337,15 +337,13 @@ impl InspectMessageQueues +impl InspectMessageQueues for SovereignPaidRemoteExporter { - fn clear_messages() { - Router::clear_messages() - } + fn clear_messages() {} fn get_messages() -> Vec<(VersionedLocation, Vec>)> { - Router::get_messages() + Vec::new() } } From b9755bf93668ed8fb76e789aa215618f86631532 Mon Sep 17 00:00:00 2001 From: Francisco Aguirre Date: Thu, 3 Oct 2024 13:06:48 +0200 Subject: [PATCH 03/10] doc: prdoc --- prdoc/pr_5913.prdoc | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 prdoc/pr_5913.prdoc diff --git a/prdoc/pr_5913.prdoc b/prdoc/pr_5913.prdoc new file mode 100644 index 000000000000..211cdc932fe5 --- /dev/null +++ b/prdoc/pr_5913.prdoc @@ -0,0 +1,18 @@ +# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0 +# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json + +title: Remove redundant XCMs from dry run's forwarded xcms + +doc: + - audience: Runtime User + description: | + The DryRunApi was returning the same message repeated multiple times in the + `forwarded_xcms` field. This is no longer the case. + +crates: + - name: pallet-xcm-bridge-hub-router + bump: patch + - name: cumulus-pallet-parachain-system + bump: patch + - name: staging-xcm-builder + bump: patch From 08dad22a41655c5c6b72764ddbde35bff21f0ac7 Mon Sep 17 00:00:00 2001 From: Francisco Aguirre Date: Fri, 4 Oct 2024 11:33:11 +0200 Subject: [PATCH 04/10] test(bridge-hub-westend-integration-tests): add dry run test --- Cargo.lock | 1 + .../bridges/bridge-hub-westend/Cargo.toml | 1 + .../src/tests/asset_transfers.rs | 44 +++++++++++++++++++ 3 files changed, 46 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index db33c59f803c..52df4d011852 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2422,6 +2422,7 @@ dependencies = [ "staging-xcm", "staging-xcm-executor", "testnet-parachains-constants", + "xcm-runtime-apis", ] [[package]] diff --git a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-westend/Cargo.toml b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-westend/Cargo.toml index 44121cbfdafb..b87f25ac0f01 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-westend/Cargo.toml +++ b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-westend/Cargo.toml @@ -29,6 +29,7 @@ sp-runtime = { workspace = true } xcm = { workspace = true } pallet-xcm = { workspace = true } xcm-executor = { workspace = true } +xcm-runtime-apis = { workspace = true } # Bridges pallet-bridge-messages = { workspace = true } diff --git a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-westend/src/tests/asset_transfers.rs b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-westend/src/tests/asset_transfers.rs index 6492c520234f..61f9fd4f33ee 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-westend/src/tests/asset_transfers.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-westend/src/tests/asset_transfers.rs @@ -554,3 +554,47 @@ fn send_back_rocs_from_penpal_westend_through_asset_hub_westend_to_asset_hub_roc assert!(receiver_rocs_after > receiver_rocs_before); assert!(receiver_rocs_after <= receiver_rocs_before + amount); } + +#[test] +fn dry_run_transfer_to_rococo_sends_xcm_to_bridge_hub() { + use frame_support::{dispatch::RawOrigin, traits::fungible}; + use sp_runtime::AccountId32; + use xcm::prelude::*; + use xcm_runtime_apis::dry_run::runtime_decl_for_dry_run_api::DryRunApiV1; + + let who = AccountId32::new([1u8; 32]); + let transfer_amount = 10_000_000_000_000u128; + let initial_balance = transfer_amount * 10; + + // Bridge setup. + AssetHubWestend::force_xcm_version(asset_hub_rococo_location(), XCM_VERSION); + open_bridge_between_asset_hub_rococo_and_asset_hub_westend(); + + ::execute_with(|| { + type Runtime = ::Runtime; + type RuntimeCall = ::RuntimeCall; + type OriginCaller = ::OriginCaller; + type Balances = ::Balances; + + // Give some initial funds. + >::set_balance(&who, initial_balance); + + let call = RuntimeCall::PolkadotXcm(pallet_xcm::Call::limited_reserve_transfer_assets { + dest: Box::new(VersionedLocation::from(asset_hub_rococo_location())), + beneficiary: Box::new(VersionedLocation::from(Junction::AccountId32 { + id: who.clone().into(), + network: None, + })), + assets: Box::new(VersionedAssets::from(vec![ + (Parent, transfer_amount).into(), + ])), + fee_asset_item: 0, + weight_limit: Unlimited, + }); + let result = Runtime::dry_run_call(OriginCaller::system(RawOrigin::Signed(who)), call).unwrap(); + // We assert the dry run succeeds and sends only one message to the local bridge hub. + assert!(result.execution_result.is_ok()); + assert_eq!(result.forwarded_xcms.len(), 1); + assert_eq!(result.forwarded_xcms[0].0, VersionedLocation::from(Location::new(1, [Parachain(BridgeHubWestend::para_id().into())]))); + }); +} From 5914f23cf7b6595f821a469e0486add4aad76877 Mon Sep 17 00:00:00 2001 From: Francisco Aguirre Date: Fri, 4 Oct 2024 11:47:10 +0200 Subject: [PATCH 05/10] test(bridge-hub-rococo-integration-tests): add same test as in westend --- Cargo.lock | 1 + .../bridges/bridge-hub-rococo/Cargo.toml | 1 + .../src/tests/asset_transfers.rs | 44 +++++++++++++++++++ .../src/tests/asset_transfers.rs | 2 +- 4 files changed, 47 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index d34b1458ad06..27b95e8e3158 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2229,6 +2229,7 @@ dependencies = [ "staging-xcm", "staging-xcm-executor", "testnet-parachains-constants", + "xcm-runtime-apis", ] [[package]] diff --git a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/Cargo.toml b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/Cargo.toml index 86ace7d564e8..9f6fe78a33ee 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/Cargo.toml +++ b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/Cargo.toml @@ -28,6 +28,7 @@ sp-runtime = { workspace = true } xcm = { workspace = true } pallet-xcm = { workspace = true } xcm-executor = { workspace = true } +xcm-runtime-apis = { workspace = true } # Bridges pallet-bridge-messages = { workspace = true } diff --git a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/asset_transfers.rs b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/asset_transfers.rs index 11930798da44..46bcc29fe006 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/asset_transfers.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/asset_transfers.rs @@ -534,3 +534,47 @@ fn send_back_wnds_from_penpal_rococo_through_asset_hub_rococo_to_asset_hub_weste assert!(receiver_wnds_after > receiver_wnds_before); assert!(receiver_wnds_after <= receiver_wnds_before + amount); } + +#[test] +fn dry_run_transfer_to_westend_sends_xcm_to_bridge_hub() { + use frame_support::{dispatch::RawOrigin, traits::fungible}; + use sp_runtime::AccountId32; + use xcm::prelude::*; + use xcm_runtime_apis::dry_run::runtime_decl_for_dry_run_api::DryRunApiV1; + + let who = AccountId32::new([1u8; 32]); + let transfer_amount = 10_000_000_000_000u128; + let initial_balance = transfer_amount * 10; + + // Bridge setup. + AssetHubRococo::force_xcm_version(asset_hub_westend_location(), XCM_VERSION); + open_bridge_between_asset_hub_rococo_and_asset_hub_westend(); + + ::execute_with(|| { + type Runtime = ::Runtime; + type RuntimeCall = ::RuntimeCall; + type OriginCaller = ::OriginCaller; + type Balances = ::Balances; + + // Give some initial funds. + >::set_balance(&who, initial_balance); + + let call = RuntimeCall::PolkadotXcm(pallet_xcm::Call::transfer_assets { + dest: Box::new(VersionedLocation::from(asset_hub_westend_location())), + beneficiary: Box::new(VersionedLocation::from(Junction::AccountId32 { + id: who.clone().into(), + network: None, + })), + assets: Box::new(VersionedAssets::from(vec![ + (Parent, transfer_amount).into(), + ])), + fee_asset_item: 0, + weight_limit: Unlimited, + }); + let result = Runtime::dry_run_call(OriginCaller::system(RawOrigin::Signed(who)), call).unwrap(); + // We assert the dry run succeeds and sends only one message to the local bridge hub. + assert!(result.execution_result.is_ok()); + assert_eq!(result.forwarded_xcms.len(), 1); + assert_eq!(result.forwarded_xcms[0].0, VersionedLocation::from(Location::new(1, [Parachain(BridgeHubRococo::para_id().into())]))); + }); +} diff --git a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-westend/src/tests/asset_transfers.rs b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-westend/src/tests/asset_transfers.rs index 61f9fd4f33ee..5966fcf23b0a 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-westend/src/tests/asset_transfers.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-westend/src/tests/asset_transfers.rs @@ -579,7 +579,7 @@ fn dry_run_transfer_to_rococo_sends_xcm_to_bridge_hub() { // Give some initial funds. >::set_balance(&who, initial_balance); - let call = RuntimeCall::PolkadotXcm(pallet_xcm::Call::limited_reserve_transfer_assets { + let call = RuntimeCall::PolkadotXcm(pallet_xcm::Call::transfer_assets { dest: Box::new(VersionedLocation::from(asset_hub_rococo_location())), beneficiary: Box::new(VersionedLocation::from(Junction::AccountId32 { id: who.clone().into(), From 84e60a08376a0d12492040043c7dd209ec07e4b1 Mon Sep 17 00:00:00 2001 From: Francisco Aguirre Date: Fri, 4 Oct 2024 11:59:42 +0200 Subject: [PATCH 06/10] test(emulated-integration-tests-common): refactor rococo and westend tests to a macro --- .../emulated/common/src/macros.rs | 48 +++++++++++++++++++ .../bridges/bridge-hub-rococo/src/lib.rs | 2 +- .../src/tests/asset_transfers.rs | 41 +--------------- .../bridges/bridge-hub-westend/src/lib.rs | 2 +- .../src/tests/asset_transfers.rs | 41 +--------------- 5 files changed, 52 insertions(+), 82 deletions(-) diff --git a/cumulus/parachains/integration-tests/emulated/common/src/macros.rs b/cumulus/parachains/integration-tests/emulated/common/src/macros.rs index 578bca84ce5a..68926b04bfe6 100644 --- a/cumulus/parachains/integration-tests/emulated/common/src/macros.rs +++ b/cumulus/parachains/integration-tests/emulated/common/src/macros.rs @@ -403,3 +403,51 @@ macro_rules! test_chain_can_claim_assets { } }; } + +#[macro_export] +macro_rules! test_dry_run_transfer_across_pk_bridge { + ( $sender_asset_hub:ty, $sender_bridge_hub:ty, $destination:expr ) => { + $crate::macros::paste::paste! { + use frame_support::{dispatch::RawOrigin, traits::fungible}; + use sp_runtime::AccountId32; + use xcm::prelude::*; + use xcm_runtime_apis::dry_run::runtime_decl_for_dry_run_api::DryRunApiV1; + + let who = AccountId32::new([1u8; 32]); + let transfer_amount = 10_000_000_000_000u128; + let initial_balance = transfer_amount * 10; + + // Bridge setup. + $sender_asset_hub::force_xcm_version($destination, XCM_VERSION); + open_bridge_between_asset_hub_rococo_and_asset_hub_westend(); + + <$sender_asset_hub as TestExt>::execute_with(|| { + type Runtime = <$sender_asset_hub as Chain>::Runtime; + type RuntimeCall = <$sender_asset_hub as Chain>::RuntimeCall; + type OriginCaller = <$sender_asset_hub as Chain>::OriginCaller; + type Balances = <$sender_asset_hub as [<$sender_asset_hub Pallet>]>::Balances; + + // Give some initial funds. + >::set_balance(&who, initial_balance); + + let call = RuntimeCall::PolkadotXcm(pallet_xcm::Call::transfer_assets { + dest: Box::new(VersionedLocation::from($destination)), + beneficiary: Box::new(VersionedLocation::from(Junction::AccountId32 { + id: who.clone().into(), + network: None, + })), + assets: Box::new(VersionedAssets::from(vec![ + (Parent, transfer_amount).into(), + ])), + fee_asset_item: 0, + weight_limit: Unlimited, + }); + let result = Runtime::dry_run_call(OriginCaller::system(RawOrigin::Signed(who)), call).unwrap(); + // We assert the dry run succeeds and sends only one message to the local bridge hub. + assert!(result.execution_result.is_ok()); + assert_eq!(result.forwarded_xcms.len(), 1); + assert_eq!(result.forwarded_xcms[0].0, VersionedLocation::from(Location::new(1, [Parachain($sender_bridge_hub::para_id().into())]))); + }); + } + }; +} diff --git a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/lib.rs b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/lib.rs index e83b28076789..3b7d0db605c0 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/lib.rs @@ -34,7 +34,7 @@ mod imports { accounts::ALICE, impls::Inspect, test_parachain_is_trusted_teleporter, test_parachain_is_trusted_teleporter_for_relay, - test_relay_is_trusted_teleporter, + test_relay_is_trusted_teleporter, test_dry_run_transfer_across_pk_bridge, xcm_emulator::{ assert_expected_events, bx, Chain, Parachain as Para, RelayChain as Relay, TestExt, }, diff --git a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/asset_transfers.rs b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/asset_transfers.rs index 46bcc29fe006..e32084a38db3 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/asset_transfers.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/asset_transfers.rs @@ -537,44 +537,5 @@ fn send_back_wnds_from_penpal_rococo_through_asset_hub_rococo_to_asset_hub_weste #[test] fn dry_run_transfer_to_westend_sends_xcm_to_bridge_hub() { - use frame_support::{dispatch::RawOrigin, traits::fungible}; - use sp_runtime::AccountId32; - use xcm::prelude::*; - use xcm_runtime_apis::dry_run::runtime_decl_for_dry_run_api::DryRunApiV1; - - let who = AccountId32::new([1u8; 32]); - let transfer_amount = 10_000_000_000_000u128; - let initial_balance = transfer_amount * 10; - - // Bridge setup. - AssetHubRococo::force_xcm_version(asset_hub_westend_location(), XCM_VERSION); - open_bridge_between_asset_hub_rococo_and_asset_hub_westend(); - - ::execute_with(|| { - type Runtime = ::Runtime; - type RuntimeCall = ::RuntimeCall; - type OriginCaller = ::OriginCaller; - type Balances = ::Balances; - - // Give some initial funds. - >::set_balance(&who, initial_balance); - - let call = RuntimeCall::PolkadotXcm(pallet_xcm::Call::transfer_assets { - dest: Box::new(VersionedLocation::from(asset_hub_westend_location())), - beneficiary: Box::new(VersionedLocation::from(Junction::AccountId32 { - id: who.clone().into(), - network: None, - })), - assets: Box::new(VersionedAssets::from(vec![ - (Parent, transfer_amount).into(), - ])), - fee_asset_item: 0, - weight_limit: Unlimited, - }); - let result = Runtime::dry_run_call(OriginCaller::system(RawOrigin::Signed(who)), call).unwrap(); - // We assert the dry run succeeds and sends only one message to the local bridge hub. - assert!(result.execution_result.is_ok()); - assert_eq!(result.forwarded_xcms.len(), 1); - assert_eq!(result.forwarded_xcms[0].0, VersionedLocation::from(Location::new(1, [Parachain(BridgeHubRococo::para_id().into())]))); - }); + test_dry_run_transfer_across_pk_bridge!(AssetHubRococo, BridgeHubRococo, asset_hub_westend_location()); } diff --git a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-westend/src/lib.rs b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-westend/src/lib.rs index d9b92cb11e92..2f741494841c 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-westend/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-westend/src/lib.rs @@ -33,7 +33,7 @@ mod imports { accounts::ALICE, impls::Inspect, test_parachain_is_trusted_teleporter, test_parachain_is_trusted_teleporter_for_relay, - test_relay_is_trusted_teleporter, + test_relay_is_trusted_teleporter, test_dry_run_transfer_across_pk_bridge, xcm_emulator::{ assert_expected_events, bx, Chain, Parachain as Para, RelayChain as Relay, TestExt, }, diff --git a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-westend/src/tests/asset_transfers.rs b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-westend/src/tests/asset_transfers.rs index 5966fcf23b0a..1d405e66e28e 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-westend/src/tests/asset_transfers.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-westend/src/tests/asset_transfers.rs @@ -557,44 +557,5 @@ fn send_back_rocs_from_penpal_westend_through_asset_hub_westend_to_asset_hub_roc #[test] fn dry_run_transfer_to_rococo_sends_xcm_to_bridge_hub() { - use frame_support::{dispatch::RawOrigin, traits::fungible}; - use sp_runtime::AccountId32; - use xcm::prelude::*; - use xcm_runtime_apis::dry_run::runtime_decl_for_dry_run_api::DryRunApiV1; - - let who = AccountId32::new([1u8; 32]); - let transfer_amount = 10_000_000_000_000u128; - let initial_balance = transfer_amount * 10; - - // Bridge setup. - AssetHubWestend::force_xcm_version(asset_hub_rococo_location(), XCM_VERSION); - open_bridge_between_asset_hub_rococo_and_asset_hub_westend(); - - ::execute_with(|| { - type Runtime = ::Runtime; - type RuntimeCall = ::RuntimeCall; - type OriginCaller = ::OriginCaller; - type Balances = ::Balances; - - // Give some initial funds. - >::set_balance(&who, initial_balance); - - let call = RuntimeCall::PolkadotXcm(pallet_xcm::Call::transfer_assets { - dest: Box::new(VersionedLocation::from(asset_hub_rococo_location())), - beneficiary: Box::new(VersionedLocation::from(Junction::AccountId32 { - id: who.clone().into(), - network: None, - })), - assets: Box::new(VersionedAssets::from(vec![ - (Parent, transfer_amount).into(), - ])), - fee_asset_item: 0, - weight_limit: Unlimited, - }); - let result = Runtime::dry_run_call(OriginCaller::system(RawOrigin::Signed(who)), call).unwrap(); - // We assert the dry run succeeds and sends only one message to the local bridge hub. - assert!(result.execution_result.is_ok()); - assert_eq!(result.forwarded_xcms.len(), 1); - assert_eq!(result.forwarded_xcms[0].0, VersionedLocation::from(Location::new(1, [Parachain(BridgeHubWestend::para_id().into())]))); - }); + test_dry_run_transfer_across_pk_bridge!(AssetHubWestend, BridgeHubWestend, asset_hub_rococo_location()); } From aab1b1d77786bd43ecf0a60e63ded598f8f8664a Mon Sep 17 00:00:00 2001 From: Francisco Aguirre Date: Fri, 4 Oct 2024 12:03:07 +0200 Subject: [PATCH 07/10] doc: update prdoc --- prdoc/pr_5913.prdoc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/prdoc/pr_5913.prdoc b/prdoc/pr_5913.prdoc index 211cdc932fe5..f50cd722c714 100644 --- a/prdoc/pr_5913.prdoc +++ b/prdoc/pr_5913.prdoc @@ -16,3 +16,5 @@ crates: bump: patch - name: staging-xcm-builder bump: patch + - name: emulated-integration-tests-common + bump: minor From 4cddc771f8a6fd01fd8276384a259eec4c2ecb3b Mon Sep 17 00:00:00 2001 From: Francisco Aguirre Date: Fri, 4 Oct 2024 12:07:59 +0200 Subject: [PATCH 08/10] doc: add a note of why some impls are empty --- bridges/modules/xcm-bridge-hub-router/src/lib.rs | 2 ++ polkadot/xcm/xcm-builder/src/universal_exports.rs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/bridges/modules/xcm-bridge-hub-router/src/lib.rs b/bridges/modules/xcm-bridge-hub-router/src/lib.rs index e60621d8641c..8ab6ac91e94f 100644 --- a/bridges/modules/xcm-bridge-hub-router/src/lib.rs +++ b/bridges/modules/xcm-bridge-hub-router/src/lib.rs @@ -410,6 +410,8 @@ impl, I: 'static> SendXcm for Pallet { impl, I: 'static> InspectMessageQueues for Pallet { fn clear_messages() {} + /// This router needs to implement `InspectMessageQueues` but doesn't have to + /// return any messages, since it just reuses the `XcmpQueue` router. fn get_messages() -> Vec<(VersionedLocation, Vec>)> { Vec::new() } diff --git a/polkadot/xcm/xcm-builder/src/universal_exports.rs b/polkadot/xcm/xcm-builder/src/universal_exports.rs index 4842a82596fc..5c754f01ec0a 100644 --- a/polkadot/xcm/xcm-builder/src/universal_exports.rs +++ b/polkadot/xcm/xcm-builder/src/universal_exports.rs @@ -342,6 +342,8 @@ impl InspectMessageQueues { fn clear_messages() {} + /// This router needs to implement `InspectMessageQueues` but doesn't have to + /// return any messages, since it just reuses the `XcmpQueue` router. fn get_messages() -> Vec<(VersionedLocation, Vec>)> { Vec::new() } From 250c98762a2dc31649bc081d79790617c5d7372e Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Fri, 4 Oct 2024 10:09:20 +0000 Subject: [PATCH 09/10] ".git/.scripts/commands/fmt/fmt.sh" --- .../emulated/tests/bridges/bridge-hub-rococo/src/lib.rs | 4 ++-- .../bridges/bridge-hub-rococo/src/tests/asset_transfers.rs | 6 +++++- .../emulated/tests/bridges/bridge-hub-westend/src/lib.rs | 4 ++-- .../bridges/bridge-hub-westend/src/tests/asset_transfers.rs | 6 +++++- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/lib.rs b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/lib.rs index 3b7d0db605c0..a542de16de5f 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/lib.rs @@ -33,8 +33,8 @@ mod imports { pub use emulated_integration_tests_common::{ accounts::ALICE, impls::Inspect, - test_parachain_is_trusted_teleporter, test_parachain_is_trusted_teleporter_for_relay, - test_relay_is_trusted_teleporter, test_dry_run_transfer_across_pk_bridge, + test_dry_run_transfer_across_pk_bridge, test_parachain_is_trusted_teleporter, + test_parachain_is_trusted_teleporter_for_relay, test_relay_is_trusted_teleporter, xcm_emulator::{ assert_expected_events, bx, Chain, Parachain as Para, RelayChain as Relay, TestExt, }, diff --git a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/asset_transfers.rs b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/asset_transfers.rs index e32084a38db3..f1e2a6dcca61 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/asset_transfers.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/asset_transfers.rs @@ -537,5 +537,9 @@ fn send_back_wnds_from_penpal_rococo_through_asset_hub_rococo_to_asset_hub_weste #[test] fn dry_run_transfer_to_westend_sends_xcm_to_bridge_hub() { - test_dry_run_transfer_across_pk_bridge!(AssetHubRococo, BridgeHubRococo, asset_hub_westend_location()); + test_dry_run_transfer_across_pk_bridge!( + AssetHubRococo, + BridgeHubRococo, + asset_hub_westend_location() + ); } diff --git a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-westend/src/lib.rs b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-westend/src/lib.rs index 2f741494841c..9228700c0198 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-westend/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-westend/src/lib.rs @@ -32,8 +32,8 @@ mod imports { pub use emulated_integration_tests_common::{ accounts::ALICE, impls::Inspect, - test_parachain_is_trusted_teleporter, test_parachain_is_trusted_teleporter_for_relay, - test_relay_is_trusted_teleporter, test_dry_run_transfer_across_pk_bridge, + test_dry_run_transfer_across_pk_bridge, test_parachain_is_trusted_teleporter, + test_parachain_is_trusted_teleporter_for_relay, test_relay_is_trusted_teleporter, xcm_emulator::{ assert_expected_events, bx, Chain, Parachain as Para, RelayChain as Relay, TestExt, }, diff --git a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-westend/src/tests/asset_transfers.rs b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-westend/src/tests/asset_transfers.rs index 1d405e66e28e..7def637a66e4 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-westend/src/tests/asset_transfers.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-westend/src/tests/asset_transfers.rs @@ -557,5 +557,9 @@ fn send_back_rocs_from_penpal_westend_through_asset_hub_westend_to_asset_hub_roc #[test] fn dry_run_transfer_to_rococo_sends_xcm_to_bridge_hub() { - test_dry_run_transfer_across_pk_bridge!(AssetHubWestend, BridgeHubWestend, asset_hub_rococo_location()); + test_dry_run_transfer_across_pk_bridge!( + AssetHubWestend, + BridgeHubWestend, + asset_hub_rococo_location() + ); } From 3367dd0b695afa673818f3812de5dd3178e62d21 Mon Sep 17 00:00:00 2001 From: Francisco Aguirre Date: Thu, 10 Oct 2024 10:12:02 +0200 Subject: [PATCH 10/10] fix(pallet-xcm-bridge-hub-router): update test --- .../modules/xcm-bridge-hub-router/src/lib.rs | 25 ++----------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/bridges/modules/xcm-bridge-hub-router/src/lib.rs b/bridges/modules/xcm-bridge-hub-router/src/lib.rs index 8ab6ac91e94f..fe8f5a2efdfb 100644 --- a/bridges/modules/xcm-bridge-hub-router/src/lib.rs +++ b/bridges/modules/xcm-bridge-hub-router/src/lib.rs @@ -646,34 +646,13 @@ mod tests { } #[test] - fn get_messages_works() { + fn get_messages_does_not_return_anything() { run_test(|| { assert_ok!(send_xcm::( (Parent, Parent, GlobalConsensus(BridgedNetworkId::get()), Parachain(1000)).into(), vec![ClearOrigin].into() )); - assert_eq!( - XcmBridgeHubRouter::get_messages(), - vec![( - VersionedLocation::V4((Parent, Parachain(1002)).into()), - vec![VersionedXcm::V4( - Xcm::builder() - .withdraw_asset((Parent, 1_002_000)) - .buy_execution((Parent, 1_002_000), Unlimited) - .set_appendix( - Xcm::builder_unsafe() - .deposit_asset(AllCounted(1), (Parent, Parachain(1000))) - .build() - ) - .export_message( - Kusama, - Parachain(1000), - Xcm::builder_unsafe().clear_origin().build() - ) - .build() - )], - ),], - ); + assert_eq!(XcmBridgeHubRouter::get_messages(), vec![]); }); } }