From 5fa4ff0ad5ee3999ebb7f4e27933390f061b9ed0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Wed, 24 Jul 2024 12:44:33 +0200 Subject: [PATCH 1/2] Improve test names (#399) The name of the "All changelog tests passing" was clashing with the name of the "All tests passing" test. Give the check features test a name. Both changes are required to mark these tests as required in github. - [x] Does not require a CHANGELOG entry --- .github/workflows/changelog.yml | 2 +- .github/workflows/check-features.yaml | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml index 5e955521b8..ce214b022d 100644 --- a/.github/workflows/changelog.yml +++ b/.github/workflows/changelog.yml @@ -50,7 +50,7 @@ jobs: # If you add more jobs, remember to add them to the "needs" array. confirmChangelogChecksPassed: runs-on: ubuntu-latest - name: All tests passed + name: All changelog tests passed # If any new job gets added, be sure to add it to this list needs: - verify-changelog-updated diff --git a/.github/workflows/check-features.yaml b/.github/workflows/check-features.yaml index d5b72129d0..f816bcd37e 100644 --- a/.github/workflows/check-features.yaml +++ b/.github/workflows/check-features.yaml @@ -1,5 +1,5 @@ # Various checks to verify the cargo workspace and its crates are correctly configured. -name: "Workspace" +name: "Workspace features" on: push: @@ -13,6 +13,7 @@ concurrency: cancel-in-progress: true jobs: + name: Check workspace features check: runs-on: ubuntu-22.04 From c61e836f2e57e07258b13a8868c64cb8f2fc495c Mon Sep 17 00:00:00 2001 From: Branislav Kontur Date: Wed, 24 Jul 2024 14:35:03 +0200 Subject: [PATCH 2/2] Fix CI + one integration test for `bridge-hub-kusama` (#397) Closes: https://github.com/polkadot-fellows/runtimes/issues/396 This PR: - fixes CI test pipelines to block PRs when tests fail. See more details [here](https://github.com/polkadot-fellows/runtimes/issues/396). - Fixes an integration test for `bridge-hub-kusama-integration-tests` that was not caught due to a previous CI bug. - Includes some minor cleanup, changing `Versioned*::V4` to `Versioned*::from` to use the latest version (for easier migration to `xcm:v5`). ## TODO - [x] fix the integration tests - [X] Does not require a CHANGELOG entry --------- Co-authored-by: Javier Bullrich --- .github/workflows/changelog.yml | 9 +- .github/workflows/test.yml | 2 - integration-tests/emulated/helpers/src/lib.rs | 12 +- .../asset-hub-kusama/src/tests/treasury.rs | 13 ++- .../src/tests/xcm_fee_estimation.rs | 31 ++--- .../src/tests/xcm_fee_estimation.rs | 31 ++--- .../src/tests/asset_transfers.rs | 106 +++++------------- .../bridge-hub-kusama/src/tests/snowbridge.rs | 6 +- .../src/tests/snowbridge.rs | 6 +- .../src/tests/fellowship.rs | 4 +- .../src/tests/fellowship_treasury.rs | 15 +-- .../people-kusama/src/tests/governance.rs | 4 +- .../people-polkadot/src/tests/governance.rs | 4 +- relay/polkadot/src/impls.rs | 4 +- 14 files changed, 103 insertions(+), 144 deletions(-) diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml index ce214b022d..5dbb738b70 100644 --- a/.github/workflows/changelog.yml +++ b/.github/workflows/changelog.yml @@ -1,6 +1,6 @@ name: Verify Changelog -# If you modify more test jobs, ensure that you add them as required to the job "confirmTestPassed" +# If you modify more test jobs, ensure that you add them as required to the job "confirmChangelogChecksPassed" # which is located at the end of this file (more info in the job) on: @@ -16,7 +16,7 @@ concurrency: cancel-in-progress: true jobs: - + # Job required by "confirmChangelogChecksPassed" verify-changelog-updated: name: Verify that Changelog is Updated runs-on: ubuntu-latest @@ -32,6 +32,7 @@ jobs: if: steps.changed.outputs.matched != 'true' && !contains(github.event.pull_request.body, '[x] Does not require a CHANGELOG entry') run: echo "::error::CHANGELOG.md has not been modified. Either modify the file or check the checkbox in the body" && exit 1 + # Job required by "confirmChangelogChecksPassed" verify-changelog-valid: name: Verify that Changelog is valid runs-on: ubuntu-latest @@ -50,10 +51,10 @@ jobs: # If you add more jobs, remember to add them to the "needs" array. confirmChangelogChecksPassed: runs-on: ubuntu-latest - name: All changelog tests passed + name: All changelog checks passed # If any new job gets added, be sure to add it to this list needs: - verify-changelog-updated - verify-changelog-valid steps: - - run: echo '### Good job! All the tests passed 🚀' >> $GITHUB_STEP_SUMMARY + - run: echo '### Good job! All the changelog checks passed 🚀' >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 57135cf99f..547d17fe9b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -45,7 +45,6 @@ jobs: # Job required by "confirmTestPassed" runtime-test: needs: [runtime-matrix] - continue-on-error: true runs-on: ubuntu-22.04 strategy: matrix: @@ -97,7 +96,6 @@ jobs: # Job required by "confirmTestPassed" integration-test: needs: [integration-test-matrix] - continue-on-error: true runs-on: ubuntu-22.04 strategy: matrix: diff --git a/integration-tests/emulated/helpers/src/lib.rs b/integration-tests/emulated/helpers/src/lib.rs index 096e91b3b7..5e182829fc 100644 --- a/integration-tests/emulated/helpers/src/lib.rs +++ b/integration-tests/emulated/helpers/src/lib.rs @@ -63,7 +63,7 @@ macro_rules! test_relay_is_trusted_teleporter { weight_limit: weight_limit.clone(), }); let mut delivery_fees_amount = 0; - let mut remote_message = VersionedXcm::V4(Xcm(Vec::new())); + let mut remote_message = VersionedXcm::from(Xcm(Vec::new())); <$sender_relay>::execute_with(|| { type Runtime = <$sender_relay as Chain>::Runtime; type OriginCaller = <$sender_relay as Chain>::OriginCaller; @@ -75,7 +75,7 @@ macro_rules! test_relay_is_trusted_teleporter { .forwarded_xcms .iter() .find(|(destination, _)| { - *destination == VersionedLocation::V4(Location::new(0, [Parachain(<$receiver_para>::para_id().into())])) + *destination == VersionedLocation::from(Location::new(0, [Parachain(<$receiver_para>::para_id().into())])) }) .unwrap(); assert_eq!(messages_to_query.len(), 1); @@ -85,7 +85,7 @@ macro_rules! test_relay_is_trusted_teleporter { .unwrap(); let latest_delivery_fees: Assets = delivery_fees.clone().try_into().unwrap(); let Fungible(inner_delivery_fees_amount) = latest_delivery_fees.inner()[0].fun else { - unreachable!("asset is fungible"); + unreachable!("asset is non-fungible"); }; delivery_fees_amount = inner_delivery_fees_amount; }); @@ -201,7 +201,7 @@ macro_rules! test_parachain_is_trusted_teleporter_for_relay { }); // These will be filled in the closure. let mut delivery_fees_amount = 0; - let mut remote_message = VersionedXcm::V4(Xcm(Vec::new())); + let mut remote_message = VersionedXcm::from(Xcm(Vec::new())); <$sender_para>::execute_with(|| { type Runtime = <$sender_para as Chain>::Runtime; type OriginCaller = <$sender_para as Chain>::OriginCaller; @@ -213,7 +213,7 @@ macro_rules! test_parachain_is_trusted_teleporter_for_relay { .forwarded_xcms .iter() .find(|(destination, _)| { - *destination == VersionedLocation::V4(Location::new(1, [])) + *destination == VersionedLocation::from(Location::parent()) }) .unwrap(); assert_eq!(messages_to_query.len(), 1); @@ -224,7 +224,7 @@ macro_rules! test_parachain_is_trusted_teleporter_for_relay { let latest_delivery_fees: Assets = delivery_fees.clone().try_into().unwrap(); delivery_fees_amount = if let Some(first_asset) = latest_delivery_fees.inner().first() { let Fungible(inner_delivery_fees_amount) = first_asset.fun else { - unreachable!("asset is fungible"); + unreachable!("asset is non-fungible"); }; inner_delivery_fees_amount } else { diff --git a/integration-tests/emulated/tests/assets/asset-hub-kusama/src/tests/treasury.rs b/integration-tests/emulated/tests/assets/asset-hub-kusama/src/tests/treasury.rs index 4c7f4faabf..317b1a5f67 100644 --- a/integration-tests/emulated/tests/assets/asset-hub-kusama/src/tests/treasury.rs +++ b/integration-tests/emulated/tests/assets/asset-hub-kusama/src/tests/treasury.rs @@ -70,11 +70,12 @@ fn spend_ksm_on_asset_hub() { let teleport_call = RuntimeCall::Utility(pallet_utility::Call::::dispatch_as { as_origin: bx!(OriginCaller::system(RawOrigin::Signed(treasury_account))), call: bx!(RuntimeCall::XcmPallet(pallet_xcm::Call::::teleport_assets { - dest: bx!(VersionedLocation::V4(asset_hub_location.clone())), - beneficiary: bx!(VersionedLocation::V4(treasury_location)), - assets: bx!(VersionedAssets::V4( - Asset { id: native_asset.clone().into(), fun: treasury_balance.into() }.into() - )), + dest: bx!(VersionedLocation::from(asset_hub_location.clone())), + beneficiary: bx!(VersionedLocation::from(treasury_location)), + assets: bx!(VersionedAssets::from(Assets::from(Asset { + id: native_asset.clone().into(), + fun: treasury_balance.into() + }))), fee_asset_item: 0, })), }); @@ -114,7 +115,7 @@ fn spend_ksm_on_asset_hub() { asset_id: native_asset_on_asset_hub.into(), }), amount: treasury_spend_balance, - beneficiary: bx!(VersionedLocation::V4(alice_location)), + beneficiary: bx!(VersionedLocation::from(alice_location)), valid_from: None, }); diff --git a/integration-tests/emulated/tests/assets/asset-hub-kusama/src/tests/xcm_fee_estimation.rs b/integration-tests/emulated/tests/assets/asset-hub-kusama/src/tests/xcm_fee_estimation.rs index eebb6b9cb4..7202d45476 100644 --- a/integration-tests/emulated/tests/assets/asset-hub-kusama/src/tests/xcm_fee_estimation.rs +++ b/integration-tests/emulated/tests/assets/asset-hub-kusama/src/tests/xcm_fee_estimation.rs @@ -76,7 +76,7 @@ fn multi_hop_works() { // We get them from the PenpalA closure. let mut delivery_fees_amount = 0; - let mut remote_message = VersionedXcm::V4(Xcm(Vec::new())); + let mut remote_message = VersionedXcm::from(Xcm(Vec::new())); ::execute_with(|| { type Runtime = ::Runtime; type OriginCaller = ::OriginCaller; @@ -89,7 +89,7 @@ fn multi_hop_works() { .forwarded_xcms .iter() .find(|(destination, _)| { - *destination == VersionedLocation::V4(Location::new(1, [Parachain(1000)])) + *destination == VersionedLocation::from(Location::new(1, [Parachain(1000)])) }) .unwrap(); assert_eq!(messages_to_query.len(), 1); @@ -103,7 +103,7 @@ fn multi_hop_works() { // These are set in the AssetHub closure. let mut intermediate_execution_fees = 0; let mut intermediate_delivery_fees_amount = 0; - let mut intermediate_remote_message = VersionedXcm::V4(Xcm::<()>(Vec::new())); + let mut intermediate_remote_message = VersionedXcm::from(Xcm::<()>(Vec::new())); ::execute_with(|| { type Runtime = ::Runtime; type RuntimeCall = ::RuntimeCall; @@ -112,13 +112,14 @@ fn multi_hop_works() { let weight = Runtime::query_xcm_weight(remote_message.clone()).unwrap(); intermediate_execution_fees = Runtime::query_weight_to_asset_fee( weight, - VersionedAssetId::V4(Location::new(1, []).into()), + VersionedAssetId::from(AssetId(Location::parent())), ) .unwrap(); // We have to do this to turn `VersionedXcm<()>` into `VersionedXcm`. - let xcm_program = - VersionedXcm::V4(Xcm::::from(remote_message.clone().try_into().unwrap())); + let xcm_program = VersionedXcm::from(Xcm::::from( + remote_message.clone().try_into().unwrap(), + )); // Now we get the delivery fees to the final destination. let result = @@ -127,7 +128,7 @@ fn multi_hop_works() { .forwarded_xcms .iter() .find(|(destination, _)| { - *destination == VersionedLocation::V4(Location::new(1, [Parachain(2001)])) + *destination == VersionedLocation::from(Location::new(1, [Parachain(2001)])) }) .unwrap(); // There's actually two messages here. @@ -150,9 +151,11 @@ fn multi_hop_works() { type Runtime = ::Runtime; let weight = Runtime::query_xcm_weight(intermediate_remote_message.clone()).unwrap(); - final_execution_fees = - Runtime::query_weight_to_asset_fee(weight, VersionedAssetId::V4(Parent.into())) - .unwrap(); + final_execution_fees = Runtime::query_weight_to_asset_fee( + weight, + VersionedAssetId::from(AssetId(Parent.into())), + ) + .unwrap(); }); // Dry-running is done. @@ -220,7 +223,7 @@ fn sender_assertions(test: ParaToParaThroughAHTest) { RuntimeEvent::ForeignAssets( pallet_assets::Event::Burned { asset_id, owner, balance } ) => { - asset_id: *asset_id == Location::new(1, []), + asset_id: *asset_id == Location::parent(), owner: *owner == test.sender.account_id, balance: *balance == test.args.amount, }, @@ -254,7 +257,7 @@ fn receiver_assertions(test: ParaToParaThroughAHTest) { RuntimeEvent::ForeignAssets( pallet_assets::Event::Issued { asset_id, owner, .. } ) => { - asset_id: *asset_id == Location::new(1, []), + asset_id: *asset_id == Location::parent(), owner: *owner == test.receiver.account_id, }, ] @@ -264,7 +267,7 @@ fn receiver_assertions(test: ParaToParaThroughAHTest) { fn get_amount_from_versioned_assets(assets: VersionedAssets) -> u128 { let latest_assets: Assets = assets.try_into().unwrap(); let Fungible(amount) = latest_assets.inner()[0].fun else { - unreachable!("asset is fungible"); + unreachable!("asset is non-fungible"); }; amount } @@ -293,7 +296,7 @@ fn transfer_assets_para_to_para_through_ah_call( dest: bx!(test.args.dest.into()), assets: bx!(test.args.assets.clone().into()), assets_transfer_type: bx!(TransferType::RemoteReserve(asset_hub_location.clone().into())), - remote_fees_id: bx!(VersionedAssetId::V4(AssetId(Location::new(1, [])))), + remote_fees_id: bx!(VersionedAssetId::from(AssetId(Location::parent()))), fees_transfer_type: bx!(TransferType::RemoteReserve(asset_hub_location.into())), custom_xcm_on_dest: bx!(VersionedXcm::from(custom_xcm_on_dest)), weight_limit: test.args.weight_limit, diff --git a/integration-tests/emulated/tests/assets/asset-hub-polkadot/src/tests/xcm_fee_estimation.rs b/integration-tests/emulated/tests/assets/asset-hub-polkadot/src/tests/xcm_fee_estimation.rs index 8588e60846..2dea54bc6f 100644 --- a/integration-tests/emulated/tests/assets/asset-hub-polkadot/src/tests/xcm_fee_estimation.rs +++ b/integration-tests/emulated/tests/assets/asset-hub-polkadot/src/tests/xcm_fee_estimation.rs @@ -77,7 +77,7 @@ fn multi_hop_works() { // We get them from the PenpalB closure. let mut delivery_fees_amount = 0; - let mut remote_message = VersionedXcm::V4(Xcm(Vec::new())); + let mut remote_message = VersionedXcm::from(Xcm(Vec::new())); ::execute_with(|| { type Runtime = ::Runtime; type OriginCaller = ::OriginCaller; @@ -90,7 +90,7 @@ fn multi_hop_works() { .forwarded_xcms .iter() .find(|(destination, _)| { - *destination == VersionedLocation::V4(Location::new(1, [Parachain(1000)])) + *destination == VersionedLocation::from(Location::new(1, [Parachain(1000)])) }) .unwrap(); assert_eq!(messages_to_query.len(), 1); @@ -104,7 +104,7 @@ fn multi_hop_works() { // These are set in the AssetHub closure. let mut intermediate_execution_fees = 0; let mut intermediate_delivery_fees_amount = 0; - let mut intermediate_remote_message = VersionedXcm::V4(Xcm::<()>(Vec::new())); + let mut intermediate_remote_message = VersionedXcm::from(Xcm::<()>(Vec::new())); ::execute_with(|| { type Runtime = ::Runtime; type RuntimeCall = ::RuntimeCall; @@ -113,13 +113,14 @@ fn multi_hop_works() { let weight = Runtime::query_xcm_weight(remote_message.clone()).unwrap(); intermediate_execution_fees = Runtime::query_weight_to_asset_fee( weight, - VersionedAssetId::V4(Location::new(1, []).into()), + VersionedAssetId::from(AssetId(Location::parent())), ) .unwrap(); // We have to do this to turn `VersionedXcm<()>` into `VersionedXcm`. - let xcm_program = - VersionedXcm::V4(Xcm::::from(remote_message.clone().try_into().unwrap())); + let xcm_program = VersionedXcm::from(Xcm::::from( + remote_message.clone().try_into().unwrap(), + )); // Now we get the delivery fees to the final destination. let result = @@ -128,7 +129,7 @@ fn multi_hop_works() { .forwarded_xcms .iter() .find(|(destination, _)| { - *destination == VersionedLocation::V4(Location::new(1, [Parachain(2000)])) + *destination == VersionedLocation::from(Location::new(1, [Parachain(2000)])) }) .unwrap(); // There's actually two messages here. @@ -151,9 +152,11 @@ fn multi_hop_works() { type Runtime = ::Runtime; let weight = Runtime::query_xcm_weight(intermediate_remote_message.clone()).unwrap(); - final_execution_fees = - Runtime::query_weight_to_asset_fee(weight, VersionedAssetId::V4(Parent.into())) - .unwrap(); + final_execution_fees = Runtime::query_weight_to_asset_fee( + weight, + VersionedAssetId::from(AssetId(Location::parent())), + ) + .unwrap(); }); // Dry-running is done. @@ -221,7 +224,7 @@ fn sender_assertions(test: ParaToParaThroughAHTest) { RuntimeEvent::ForeignAssets( pallet_assets::Event::Burned { asset_id, owner, balance } ) => { - asset_id: *asset_id == Location::new(1, []), + asset_id: *asset_id == Location::parent(), owner: *owner == test.sender.account_id, balance: *balance == test.args.amount, }, @@ -255,7 +258,7 @@ fn receiver_assertions(test: ParaToParaThroughAHTest) { RuntimeEvent::ForeignAssets( pallet_assets::Event::Issued { asset_id, owner, .. } ) => { - asset_id: *asset_id == Location::new(1, []), + asset_id: *asset_id == Location::parent(), owner: *owner == test.receiver.account_id, }, ] @@ -265,7 +268,7 @@ fn receiver_assertions(test: ParaToParaThroughAHTest) { fn get_amount_from_versioned_assets(assets: VersionedAssets) -> u128 { let latest_assets: Assets = assets.try_into().unwrap(); let Fungible(amount) = latest_assets.inner()[0].fun else { - unreachable!("asset is fungible"); + unreachable!("asset is non-fungible"); }; amount } @@ -294,7 +297,7 @@ fn transfer_assets_para_to_para_through_ah_call( dest: bx!(test.args.dest.into()), assets: bx!(test.args.assets.clone().into()), assets_transfer_type: bx!(TransferType::RemoteReserve(asset_hub_location.clone().into())), - remote_fees_id: bx!(VersionedAssetId::V4(AssetId(Location::new(1, [])))), + remote_fees_id: bx!(VersionedAssetId::from(AssetId(Location::parent()))), fees_transfer_type: bx!(TransferType::RemoteReserve(asset_hub_location.into())), custom_xcm_on_dest: bx!(VersionedXcm::from(custom_xcm_on_dest)), weight_limit: test.args.weight_limit, diff --git a/integration-tests/emulated/tests/bridges/bridge-hub-kusama/src/tests/asset_transfers.rs b/integration-tests/emulated/tests/bridges/bridge-hub-kusama/src/tests/asset_transfers.rs index 9304093e39..25b160fbf8 100644 --- a/integration-tests/emulated/tests/bridges/bridge-hub-kusama/src/tests/asset_transfers.rs +++ b/integration-tests/emulated/tests/bridges/bridge-hub-kusama/src/tests/asset_transfers.rs @@ -14,11 +14,9 @@ // limitations under the License. use crate::tests::*; +use bridge_hub_kusama_runtime::RuntimeEvent; use frame_support::{dispatch::RawOrigin, traits::fungible::Mutate}; -use xcm_fee_payment_runtime_api::{ - dry_run::runtime_decl_for_dry_run_api::DryRunApiV1, - fees::runtime_decl_for_xcm_payment_api::XcmPaymentApiV1, -}; +use xcm_fee_payment_runtime_api::dry_run::runtime_decl_for_dry_run_api::DryRunApiV1; fn send_asset_from_asset_hub_kusama_to_asset_hub_polkadot(id: Location, amount: u128) { let destination = asset_hub_polkadot_location(); @@ -36,10 +34,7 @@ fn send_asset_from_asset_hub_kusama_to_asset_hub_polkadot(id: Location, amount: assert_bridge_hub_polkadot_message_received(); } -fn dry_run_send_asset_from_asset_hub_kusama_to_asset_hub_polkadot( - id: Location, - amount: u128, -) -> u128 { +fn dry_run_send_asset_from_asset_hub_kusama_to_asset_hub_polkadot(id: Location, amount: u128) { let destination = asset_hub_polkadot_location(); // fund the AHK's SA on BHK for paying bridge transport fees @@ -55,92 +50,56 @@ fn dry_run_send_asset_from_asset_hub_kusama_to_asset_hub_polkadot( let fee_asset_item = 0; let call = send_asset_from_asset_hub_kusama_call(destination, beneficiary, assets, fee_asset_item); - let mut delivery_fees_amount = 0; - let mut remote_message = VersionedXcm::V4(Xcm(Vec::new())); - AssetHubKusama::execute_with(|| { + + // `remote_message` should contain `ExportMessage` + let remote_message = AssetHubKusama::execute_with(|| { type Runtime = ::Runtime; type OriginCaller = ::OriginCaller; let origin = OriginCaller::system(RawOrigin::Signed(AssetHubKusamaSender::get())); let result = Runtime::dry_run_call(origin, call).unwrap(); + // We filter the result to get only the messages we are interested in. - let (destination_to_query, messages_to_query) = &result + let (_, messages_to_query) = result .forwarded_xcms - .iter() + .into_iter() .find(|(destination, _)| { - *destination == VersionedLocation::V4(Location::new(1, [Parachain(1002)])) + *destination == VersionedLocation::from(Location::new(1, [Parachain(1002)])) }) .unwrap(); - dbg!(&result.forwarded_xcms); assert_eq!(messages_to_query.len(), 1); - remote_message = messages_to_query[0].clone(); - let delivery_fees = - Runtime::query_delivery_fees(destination_to_query.clone(), remote_message.clone()) - .unwrap(); - let latest_delivery_fees: Assets = delivery_fees.clone().try_into().unwrap(); - let Fungible(inner_delivery_fees_amount) = latest_delivery_fees.inner()[0].fun else { - unreachable!("asset is fungible"); - }; - delivery_fees_amount = inner_delivery_fees_amount; + + messages_to_query[0].clone() }); - let mut intermediate_execution_fees = 0; - let mut intermediate_delivery_fees_amount = 0; - let mut intermediate_remote_message = VersionedXcm::V4(Xcm(Vec::new())); + // dry run extracted `remote_message` on local BridgeHub BridgeHubKusama::execute_with(|| { type Runtime = ::Runtime; type RuntimeCall = ::RuntimeCall; - // First we get the execution fees. - let weight = Runtime::query_xcm_weight(remote_message.clone()).unwrap(); - intermediate_execution_fees = - Runtime::query_weight_to_asset_fee(weight, VersionedAssetId::V4(Parent.into())) - .unwrap(); - // We have to do this to turn `VersionedXcm<()>` into `VersionedXcm`. - let xcm_program = - VersionedXcm::V4(Xcm::::from(remote_message.clone().try_into().unwrap())); + let xcm_program = VersionedXcm::from(Xcm::::from( + remote_message.clone().try_into().unwrap(), + )); - // Now we get the delivery fees to the final destination. + // dry run program let asset_hub_as_seen_by_bridge_hub: Location = Location::new(1, [Parachain(1000)]); let result = - Runtime::dry_run_xcm(asset_hub_as_seen_by_bridge_hub.clone().into(), xcm_program) - .unwrap(); - - // We filter the result to get only the messages we are interested in. - // dbg!(&result.forwarded_xcms); - let (destination_to_query, messages_to_query) = &result - .forwarded_xcms - .iter() - .find(|(destination, _)| { - *destination == VersionedLocation::V4(Location::new(1, [Parachain(1002)])) - }) - .unwrap(); - // There's actually two messages here. - // One created when the message we sent from PenpalA arrived and was executed. - // The second one when we dry-run the xcm. - // We could've gotten the message from the queue without having to dry-run, but - // offchain applications would have to dry-run, so we do it here as well. - intermediate_remote_message = messages_to_query[0].clone(); - let delivery_fees = - Runtime::query_delivery_fees(destination_to_query.clone(), remote_message.clone()) - .unwrap(); - let latest_delivery_fees: Assets = delivery_fees.clone().try_into().unwrap(); - let Fungible(inner_delivery_fees_amount) = latest_delivery_fees.inner()[0].fun else { - unreachable!("asset is fungible"); - }; - intermediate_delivery_fees_amount = inner_delivery_fees_amount; + Runtime::dry_run_xcm(asset_hub_as_seen_by_bridge_hub.into(), xcm_program).unwrap(); + + // check dry run result + assert_ok!(result.execution_result.ensure_complete()); + assert!(result.emitted_events.iter().any(|event| matches!( + event, + RuntimeEvent::BridgePolkadotMessages( + pallet_bridge_messages::Event::MessageAccepted { .. } + ) + ))); }); - dbg!(&delivery_fees_amount); - dbg!(&intermediate_execution_fees); - dbg!(&intermediate_delivery_fees_amount); - // After dry-running we reset. AssetHubKusama::reset_ext(); BridgeHubKusama::reset_ext(); - - delivery_fees_amount } #[test] @@ -173,7 +132,7 @@ fn send_ksms_from_asset_hub_kusama_to_asset_hub_polkadot() { let ksm_at_asset_hub_kusama_latest: Location = ksm_at_asset_hub_kusama.try_into().unwrap(); let amount = ASSET_HUB_KUSAMA_ED * 1_000; // First dry-run. - let delivery_fees = dry_run_send_asset_from_asset_hub_kusama_to_asset_hub_polkadot( + dry_run_send_asset_from_asset_hub_kusama_to_asset_hub_polkadot( ksm_at_asset_hub_kusama_latest.clone(), amount, ); @@ -206,15 +165,8 @@ fn send_ksms_from_asset_hub_kusama_to_asset_hub_polkadot() { let ksms_in_reserve_on_ahk_after = ::account_data_of(sov_ahp_on_ahk.clone()).free; - dbg!(&sender_ksms_after); - dbg!(&sender_ksms_before); - dbg!(&amount); - dbg!(&delivery_fees); - dbg!(&receiver_ksms_after); - dbg!(&receiver_ksms_before); - // Sender's balance is reduced - assert_eq!(sender_ksms_after, sender_ksms_before - amount - delivery_fees); + assert!(sender_ksms_before > sender_ksms_after); // Receiver's balance is increased assert!(receiver_ksms_after > receiver_ksms_before); // Reserve balance is reduced by sent amount diff --git a/integration-tests/emulated/tests/bridges/bridge-hub-kusama/src/tests/snowbridge.rs b/integration-tests/emulated/tests/bridges/bridge-hub-kusama/src/tests/snowbridge.rs index 48cc61a0e9..90d9d92537 100644 --- a/integration-tests/emulated/tests/bridges/bridge-hub-kusama/src/tests/snowbridge.rs +++ b/integration-tests/emulated/tests/bridges/bridge-hub-kusama/src/tests/snowbridge.rs @@ -584,14 +584,14 @@ fn send_weth_asset_from_asset_hub_to_ethereum() { )), fun: Fungible(WETH_AMOUNT), }]; - let multi_assets = VersionedAssets::V4(Assets::from(assets)); + let multi_assets = VersionedAssets::from(Assets::from(assets)); - let destination = VersionedLocation::V4(Location::new( + let destination = VersionedLocation::from(Location::new( 2, [GlobalConsensus(Ethereum { chain_id: CHAIN_ID })], )); - let beneficiary = VersionedLocation::V4(Location::new( + let beneficiary = VersionedLocation::from(Location::new( 0, [AccountKey20 { network: None, key: ETHEREUM_DESTINATION_ADDRESS }], )); diff --git a/integration-tests/emulated/tests/bridges/bridge-hub-polkadot/src/tests/snowbridge.rs b/integration-tests/emulated/tests/bridges/bridge-hub-polkadot/src/tests/snowbridge.rs index 3c14e2cc57..3b85c63595 100644 --- a/integration-tests/emulated/tests/bridges/bridge-hub-polkadot/src/tests/snowbridge.rs +++ b/integration-tests/emulated/tests/bridges/bridge-hub-polkadot/src/tests/snowbridge.rs @@ -588,14 +588,14 @@ fn send_weth_asset_from_asset_hub_to_ethereum() { )), fun: Fungible(WETH_AMOUNT), }]; - let multi_assets = VersionedAssets::V4(Assets::from(assets)); + let multi_assets = VersionedAssets::from(Assets::from(assets)); - let destination = VersionedLocation::V4(Location::new( + let destination = VersionedLocation::from(Location::new( 2, [GlobalConsensus(Ethereum { chain_id: CHAIN_ID })], )); - let beneficiary = VersionedLocation::V4(Location::new( + let beneficiary = VersionedLocation::from(Location::new( 0, [AccountKey20 { network: None, key: ETHEREUM_DESTINATION_ADDRESS }], )); diff --git a/integration-tests/emulated/tests/collectives/collectives-polkadot/src/tests/fellowship.rs b/integration-tests/emulated/tests/collectives/collectives-polkadot/src/tests/fellowship.rs index c7664de0a6..bdee6c87b7 100644 --- a/integration-tests/emulated/tests/collectives/collectives-polkadot/src/tests/fellowship.rs +++ b/integration-tests/emulated/tests/collectives/collectives-polkadot/src/tests/fellowship.rs @@ -31,8 +31,8 @@ fn fellows_whitelist_call() { let call_hash = [1u8; 32].into(); let whitelist_call = RuntimeCall::PolkadotXcm(pallet_xcm::Call::::send { - dest: bx!(VersionedLocation::V4(Parent.into())), - message: bx!(VersionedXcm::V4(Xcm(vec![ + dest: bx!(VersionedLocation::from(Location::parent())), + message: bx!(VersionedXcm::from(Xcm(vec![ UnpaidExecution { weight_limit: Unlimited, check_origin: None }, Transact { origin_kind: OriginKind::Xcm, diff --git a/integration-tests/emulated/tests/collectives/collectives-polkadot/src/tests/fellowship_treasury.rs b/integration-tests/emulated/tests/collectives/collectives-polkadot/src/tests/fellowship_treasury.rs index 03adf3dbbc..9671ff9a5a 100644 --- a/integration-tests/emulated/tests/collectives/collectives-polkadot/src/tests/fellowship_treasury.rs +++ b/integration-tests/emulated/tests/collectives/collectives-polkadot/src/tests/fellowship_treasury.rs @@ -67,11 +67,12 @@ fn fellowship_treasury_spend() { let teleport_call = RuntimeCall::Utility(pallet_utility::Call::::dispatch_as { as_origin: bx!(OriginCaller::system(RawOrigin::Signed(treasury_account))), call: bx!(RuntimeCall::XcmPallet(pallet_xcm::Call::::teleport_assets { - dest: bx!(VersionedLocation::V4(asset_hub_location.clone())), - beneficiary: bx!(VersionedLocation::V4(treasury_location)), - assets: bx!(VersionedAssets::V4( - Asset { id: native_asset.clone().into(), fun: treasury_balance.into() }.into() - )), + dest: bx!(VersionedLocation::from(asset_hub_location.clone())), + beneficiary: bx!(VersionedLocation::from(treasury_location)), + assets: bx!(VersionedAssets::from(Assets::from(Asset { + id: native_asset.clone().into(), + fun: treasury_balance.into() + }))), fee_asset_item: 0, })), }); @@ -109,7 +110,7 @@ fn fellowship_treasury_spend() { asset_id: native_asset_on_asset_hub.into(), }), amount: fellowship_treasury_balance, - beneficiary: bx!(VersionedLocation::V4(fellowship_treasury_location)), + beneficiary: bx!(VersionedLocation::from(fellowship_treasury_location)), valid_from: None, }); @@ -186,7 +187,7 @@ fn fellowship_treasury_spend() { asset_id: native_asset_on_asset_hub.into(), }), amount: fellowship_spend_balance, - beneficiary: bx!(VersionedLocation::V4(alice_location)), + beneficiary: bx!(VersionedLocation::from(alice_location)), valid_from: None, }); diff --git a/integration-tests/emulated/tests/people/people-kusama/src/tests/governance.rs b/integration-tests/emulated/tests/people/people-kusama/src/tests/governance.rs index 50b4bd5626..8d06089947 100644 --- a/integration-tests/emulated/tests/people/people-kusama/src/tests/governance.rs +++ b/integration-tests/emulated/tests/people/people-kusama/src/tests/governance.rs @@ -38,8 +38,8 @@ fn relay_commands_add_registrar() { }); let xcm_message = RuntimeCall::XcmPallet(pallet_xcm::Call::::send { - dest: bx!(VersionedLocation::V4(Location::new(0, [Parachain(1004)]))), - message: bx!(VersionedXcm::V4(Xcm(vec![ + dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), + message: bx!(VersionedXcm::from(Xcm(vec![ UnpaidExecution { weight_limit: Unlimited, check_origin: None }, Transact { origin_kind, diff --git a/integration-tests/emulated/tests/people/people-polkadot/src/tests/governance.rs b/integration-tests/emulated/tests/people/people-polkadot/src/tests/governance.rs index 8adba4ddd8..11ebf954a3 100644 --- a/integration-tests/emulated/tests/people/people-polkadot/src/tests/governance.rs +++ b/integration-tests/emulated/tests/people/people-polkadot/src/tests/governance.rs @@ -38,8 +38,8 @@ fn relay_commands_add_registrar() { }); let xcm_message = RuntimeCall::XcmPallet(pallet_xcm::Call::::send { - dest: bx!(VersionedLocation::V4(Location::new(0, [Parachain(1004)]))), - message: bx!(VersionedXcm::V4(Xcm(vec![ + dest: bx!(VersionedLocation::from(Location::new(0, [Parachain(1004)]))), + message: bx!(VersionedXcm::from(Xcm(vec![ UnpaidExecution { weight_limit: Unlimited, check_origin: None }, Transact { origin_kind, diff --git a/relay/polkadot/src/impls.rs b/relay/polkadot/src/impls.rs index fa690a1a8d..961a06c1d1 100644 --- a/relay/polkadot/src/impls.rs +++ b/relay/polkadot/src/impls.rs @@ -172,8 +172,8 @@ where // send >::send( RawOrigin::Root.into(), - Box::new(VersionedLocation::V4(destination)), - Box::new(VersionedXcm::V4(program)), + Box::new(VersionedLocation::from(destination)), + Box::new(VersionedXcm::from(program)), )?; Ok(()) }