From ff35ea473bb76ebeb2d0fe5ba05eb5c7bbee44dc Mon Sep 17 00:00:00 2001 From: Adrian Catangiu Date: Fri, 28 Jun 2024 14:51:13 +0300 Subject: [PATCH 1/5] bridge tests: send bridged assets from random parachain to bridged asset hub Send bridged WNDs: Penpal Rococo -> AH Rococo -> AH Westend Send bridged ROCs: Penpal Westend -> AH Westend -> AH Rococo The tests send both ROCs and WNDs, for each direction the native asset is only used to pay for the transport fees on the local AssetHub, and are not sent over the bridge. Including the native asset won't be necessary anymore once we get #4375. Signed-off-by: Adrian Catangiu --- Cargo.lock | 1 + .../bridges/bridge-hub-rococo/Cargo.toml | 5 +- .../bridges/bridge-hub-rococo/src/lib.rs | 1 + .../src/tests/asset_transfers.rs | 329 ++++++++++++------ 4 files changed, 237 insertions(+), 99 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 91d604d6fa3c..1b04ced266d7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2077,6 +2077,7 @@ dependencies = [ "pallet-xcm", "parachains-common", "parity-scale-codec", + "penpal-runtime", "rococo-system-emulated-network", "rococo-westend-system-emulated-network", "scale-info", 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 23dee370bf33..12ae785f0eef 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 @@ -36,11 +36,12 @@ pallet-bridge-messages = { workspace = true } parachains-common = { workspace = true, default-features = true } testnet-parachains-constants = { features = ["rococo"], workspace = true, default-features = true } cumulus-pallet-xcmp-queue = { workspace = true } -bridge-hub-rococo-runtime = { workspace = true } emulated-integration-tests-common = { workspace = true } +asset-hub-rococo-runtime = { workspace = true } +bridge-hub-rococo-runtime = { workspace = true } +penpal-runtime = { workspace = true } rococo-westend-system-emulated-network = { workspace = true } rococo-system-emulated-network = { workspace = true } -asset-hub-rococo-runtime = { workspace = true } # Snowbridge snowbridge-core = { workspace = true } 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 abfbd9b45a98..43ea0524d55d 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 @@ -38,6 +38,7 @@ mod imports { ASSETS_PALLET_ID, USDT_ID, }; pub use parachains_common::AccountId; + pub use penpal_runtime::xcm_config::UniversalLocation as PenpalUniversalLocation; pub use rococo_westend_system_emulated_network::{ asset_hub_rococo_emulated_chain::{ genesis::{AssetHubRococoAssetOwner, ED as ASSET_HUB_ROCOCO_ED}, 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 995c992c70f4..70c9e0889483 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 @@ -15,91 +15,98 @@ use crate::tests::*; -fn send_assets_from_asset_hub_rococo_to_asset_hub_westend(assets: Assets, fee_idx: u32) { - let destination = asset_hub_westend_location(); - +fn send_assets_over_bridge(send_fn: F) { // fund the AHR's SA on BHR for paying bridge transport fees BridgeHubRococo::fund_para_sovereign(AssetHubRococo::para_id(), 10_000_000_000_000u128); // set XCM versions - AssetHubRococo::force_xcm_version(destination.clone(), XCM_VERSION); + let local_asset_hub = PenpalA::sibling_location_of(AssetHubRococo::para_id()); + PenpalA::force_xcm_version(local_asset_hub.clone(), XCM_VERSION); + AssetHubRococo::force_xcm_version(asset_hub_westend_location(), XCM_VERSION); BridgeHubRococo::force_xcm_version(bridge_hub_westend_location(), XCM_VERSION); // send message over bridge - assert_ok!(send_assets_from_asset_hub_rococo(destination, assets, fee_idx)); + send_fn(); + + // process and verify intermediary hops assert_bridge_hub_rococo_message_accepted(true); assert_bridge_hub_westend_message_received(); } -fn send_asset_from_penpal_rococo_through_local_asset_hub_to_westend_asset_hub( - id: Location, - transfer_amount: u128, -) { - let destination = asset_hub_westend_location(); - let local_asset_hub: Location = PenpalA::sibling_location_of(AssetHubRococo::para_id()); - let sov_penpal_on_ahr = AssetHubRococo::sovereign_account_id_of( - AssetHubRococo::sibling_location_of(PenpalA::para_id()), - ); - let sov_ahw_on_ahr = AssetHubRococo::sovereign_account_of_parachain_on_other_global_consensus( - Westend, - AssetHubWestend::para_id(), - ); - - // fund the AHR's SA on BHR for paying bridge transport fees - BridgeHubRococo::fund_para_sovereign(AssetHubRococo::para_id(), 10_000_000_000_000u128); - - // set XCM versions - PenpalA::force_xcm_version(local_asset_hub.clone(), XCM_VERSION); - AssetHubRococo::force_xcm_version(destination.clone(), XCM_VERSION); - BridgeHubRococo::force_xcm_version(bridge_hub_westend_location(), XCM_VERSION); +fn set_up_rocs_for_penpal_rococo_through_ahr_to_ahw( + sender: &AccountId, + amount: u128, +) -> (Location, v3::Location) { + let roc_at_rococo_parachains = roc_at_ah_rococo(); + let roc_at_asset_hub_westend = bridged_roc_at_ah_westend().try_into().unwrap(); + create_foreign_on_ah_westend(roc_at_asset_hub_westend, true); - // send message over bridge - assert_ok!(PenpalA::execute_with(|| { - let signed_origin = ::RuntimeOrigin::signed(PenpalASender::get()); - let beneficiary: Location = - AccountId32Junction { network: None, id: AssetHubWestendReceiver::get().into() }.into(); - let assets: Assets = (id.clone(), transfer_amount).into(); - let fees_id: AssetId = id.into(); - let custom_xcm_on_dest = Xcm::<()>(vec![DepositAsset { - assets: Wild(AllCounted(assets.len() as u32)), - beneficiary, - }]); + let penpal_location = AssetHubRococo::sibling_location_of(PenpalA::para_id()); + let sov_penpal_on_ahr = AssetHubRococo::sovereign_account_id_of(penpal_location); + // fund Penpal's sovereign account on AssetHub + AssetHubRococo::fund_accounts(vec![(sov_penpal_on_ahr.into(), amount * 2)]); + // fund Penpal's sender account + PenpalA::mint_foreign_asset( + ::RuntimeOrigin::signed(PenpalAssetOwner::get()), + roc_at_rococo_parachains.clone(), + sender.clone(), + amount * 2, + ); + (roc_at_rococo_parachains, roc_at_asset_hub_westend) +} - ::PolkadotXcm::transfer_assets_using_type_and_then( - signed_origin, - bx!(destination.into()), - bx!(assets.clone().into()), - bx!(TransferType::RemoteReserve(local_asset_hub.clone().into())), - bx!(fees_id.into()), - bx!(TransferType::RemoteReserve(local_asset_hub.into())), - bx!(VersionedXcm::from(custom_xcm_on_dest)), - WeightLimit::Unlimited, - ) - })); - AssetHubRococo::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - assert_expected_events!( - AssetHubRococo, - vec![ - // Amount to reserve transfer is withdrawn from Penpal's sovereign account - RuntimeEvent::Balances( - pallet_balances::Event::Burned { who, amount } - ) => { - who: *who == sov_penpal_on_ahr.clone().into(), - amount: *amount == transfer_amount, - }, - // Amount deposited in AHW's sovereign account - RuntimeEvent::Balances(pallet_balances::Event::Minted { who, .. }) => { - who: *who == sov_ahw_on_ahr.clone().into(), - }, - RuntimeEvent::XcmpQueue( - cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { .. } - ) => {}, - ] +fn send_assets_from_penpal_rococo_through_rococo_ah_to_westend_ah( + destination: Location, + assets: (Assets, TransferType), + fees: (AssetId, TransferType), + custom_xcm_on_dest: Xcm<()>, +) { + send_assets_over_bridge(|| { + let sov_penpal_on_ahr = AssetHubRococo::sovereign_account_id_of( + AssetHubRococo::sibling_location_of(PenpalA::para_id()), ); + let sov_ahw_on_ahr = + AssetHubRococo::sovereign_account_of_parachain_on_other_global_consensus( + Westend, + AssetHubWestend::para_id(), + ); + // send message over bridge + assert_ok!(PenpalA::execute_with(|| { + let signed_origin = ::RuntimeOrigin::signed(PenpalASender::get()); + ::PolkadotXcm::transfer_assets_using_type_and_then( + signed_origin, + bx!(destination.into()), + bx!(assets.0.into()), + bx!(assets.1), + bx!(fees.0.into()), + bx!(fees.1), + bx!(VersionedXcm::from(custom_xcm_on_dest)), + WeightLimit::Unlimited, + ) + })); + // verify intermediary AH Rococo hop + AssetHubRococo::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + assert_expected_events!( + AssetHubRococo, + vec![ + // Amount to reserve transfer is withdrawn from Penpal's sovereign account + RuntimeEvent::Balances( + pallet_balances::Event::Burned { who, .. } + ) => { + who: *who == sov_penpal_on_ahr.clone().into(), + }, + // Amount deposited in AHW's sovereign account + RuntimeEvent::Balances(pallet_balances::Event::Minted { who, .. }) => { + who: *who == sov_ahw_on_ahr.clone().into(), + }, + RuntimeEvent::XcmpQueue( + cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { .. } + ) => {}, + ] + ); + }); }); - assert_bridge_hub_rococo_message_accepted(true); - assert_bridge_hub_westend_message_received(); } #[test] @@ -134,9 +141,12 @@ fn send_roc_usdt_and_weth_from_asset_hub_rococo_to_asset_hub_westend() { foreign_balance_on_ah_westend(bridged_roc_at_asset_hub_westend, &receiver); // send ROCs, use them for fees - let assets: Assets = (Location::try_from(roc_at_asset_hub_rococo).unwrap(), amount).into(); - let fee_index = 0; - send_assets_from_asset_hub_rococo_to_asset_hub_westend(assets, fee_index); + send_assets_over_bridge(|| { + let destination = asset_hub_westend_location(); + let assets: Assets = (Location::try_from(roc_at_asset_hub_rococo).unwrap(), amount).into(); + let fee_idx = 0; + assert_ok!(send_assets_from_asset_hub_rococo(destination, assets, fee_idx)); + }); // verify expected events on final destination AssetHubWestend::execute_with(|| { @@ -244,6 +254,7 @@ fn send_roc_usdt_and_weth_from_asset_hub_rococo_to_asset_hub_westend() { /// Send bridged WNDs "back" from AssetHub Rococo to AssetHub Westend. fn send_back_wnds_from_asset_hub_rococo_to_asset_hub_westend() { let prefund_amount = 10_000_000_000_000u128; + let amount_to_send = ASSET_HUB_WESTEND_ED * 1_000; let sender = AssetHubRococoSender::get(); let receiver = AssetHubWestendReceiver::get(); let wnd_at_asset_hub_rococo = bridged_wnd_at_ah_rococo(); @@ -266,11 +277,13 @@ fn send_back_wnds_from_asset_hub_rococo_to_asset_hub_westend() { assert_eq!(sender_wnds_before, prefund_amount); let receiver_wnds_before = ::account_data_of(receiver.clone()).free; - let amount_to_send = ASSET_HUB_WESTEND_ED * 1_000; - send_assets_from_asset_hub_rococo_to_asset_hub_westend( - (wnd_at_asset_hub_rococo, amount_to_send).into(), - 0, - ); + // send WNDs, use them for fees + send_assets_over_bridge(|| { + let destination = asset_hub_westend_location(); + let assets: Assets = (wnd_at_asset_hub_rococo, amount_to_send).into(); + let fee_idx = 0; + assert_ok!(send_assets_from_asset_hub_rococo(destination, assets, fee_idx)); + }); AssetHubWestend::execute_with(|| { type RuntimeEvent = ::RuntimeEvent; @@ -311,24 +324,12 @@ fn send_back_wnds_from_asset_hub_rococo_to_asset_hub_westend() { #[test] fn send_rocs_from_penpal_rococo_through_asset_hub_rococo_to_asset_hub_westend() { - let roc_at_rococo_parachains = roc_at_ah_rococo(); - let roc_at_asset_hub_westend = bridged_roc_at_ah_westend().try_into().unwrap(); - create_foreign_on_ah_westend(roc_at_asset_hub_westend, true); - let amount = ASSET_HUB_ROCOCO_ED * 10_000_000; let sender = PenpalASender::get(); let receiver = AssetHubWestendReceiver::get(); - let penpal_location = AssetHubRococo::sibling_location_of(PenpalA::para_id()); - let sov_penpal_on_ahr = AssetHubRococo::sovereign_account_id_of(penpal_location); - // fund Penpal's sovereign account on AssetHub - AssetHubRococo::fund_accounts(vec![(sov_penpal_on_ahr.into(), amount * 2)]); - // fund Penpal's sender account - PenpalA::mint_foreign_asset( - ::RuntimeOrigin::signed(PenpalAssetOwner::get()), - roc_at_rococo_parachains.clone(), - sender.clone(), - amount * 2, - ); + let local_asset_hub = PenpalA::sibling_location_of(AssetHubRococo::para_id()); + let (roc_at_rococo_parachains, roc_at_asset_hub_westend) = + set_up_rocs_for_penpal_rococo_through_ahr_to_ahw(&sender, amount); let sov_ahw_on_ahr = AssetHubRococo::sovereign_account_of_parachain_on_other_global_consensus( Westend, @@ -343,11 +344,27 @@ fn send_rocs_from_penpal_rococo_through_asset_hub_rococo_to_asset_hub_westend() let receiver_rocs_before = foreign_balance_on_ah_westend(roc_at_asset_hub_westend, &receiver); // Send ROCs over bridge - send_asset_from_penpal_rococo_through_local_asset_hub_to_westend_asset_hub( - roc_at_rococo_parachains.clone(), - amount, - ); + { + let destination = asset_hub_westend_location(); + let assets: Assets = (roc_at_rococo_parachains.clone(), amount).into(); + let asset_transfer_type = TransferType::RemoteReserve(local_asset_hub.clone().into()); + let fees_id: AssetId = roc_at_rococo_parachains.clone().into(); + let fees_transfer_type = TransferType::RemoteReserve(local_asset_hub.into()); + let beneficiary: Location = + AccountId32Junction { network: None, id: AssetHubWestendReceiver::get().into() }.into(); + let custom_xcm_on_dest = Xcm::<()>(vec![DepositAsset { + assets: Wild(AllCounted(assets.len() as u32)), + beneficiary, + }]); + send_assets_from_penpal_rococo_through_rococo_ah_to_westend_ah( + destination, + (assets, asset_transfer_type), + (fees_id, fees_transfer_type), + custom_xcm_on_dest, + ); + } + // process AHW incoming message and check events AssetHubWestend::execute_with(|| { type RuntimeEvent = ::RuntimeEvent; assert_expected_events!( @@ -382,3 +399,121 @@ fn send_rocs_from_penpal_rococo_through_asset_hub_rococo_to_asset_hub_westend() assert!(rocs_in_reserve_on_ahr_after > rocs_in_reserve_on_ahr_before); assert!(rocs_in_reserve_on_ahr_after <= rocs_in_reserve_on_ahr_before + amount); } + +#[test] +fn send_back_wnds_from_penpal_rococo_through_asset_hub_rococo_to_asset_hub_westend() { + let wnd_at_rococo_parachains = bridged_wnd_at_ah_rococo(); + let wnd_at_rococo_parachains_v3 = wnd_at_rococo_parachains.clone().try_into().unwrap(); + let amount = ASSET_HUB_ROCOCO_ED * 10_000_000; + let sender = PenpalASender::get(); + let receiver = AssetHubWestendReceiver::get(); + + // set up ROCs for transfer + let (roc_at_rococo_parachains, _) = + set_up_rocs_for_penpal_rococo_through_ahr_to_ahw(&sender, amount); + + // set up WNDs for transfer + let penpal_location = AssetHubRococo::sibling_location_of(PenpalA::para_id()); + let sov_penpal_on_ahr = AssetHubRococo::sovereign_account_id_of(penpal_location); + let prefund_accounts = vec![(sov_penpal_on_ahr, amount * 2)]; + create_foreign_on_ah_rococo(wnd_at_rococo_parachains_v3, true, prefund_accounts); + let asset_owner: AccountId = AssetHubRococo::account_id_of(ALICE); + PenpalA::force_create_foreign_asset( + wnd_at_rococo_parachains.clone(), + asset_owner.clone(), + true, + ASSET_MIN_BALANCE, + vec![(sender.clone(), amount * 2)], + ); + + // fund the AHR's SA on AHW with the WND tokens held in reserve + let sov_ahr_on_ahw = AssetHubWestend::sovereign_account_of_parachain_on_other_global_consensus( + NetworkId::Rococo, + AssetHubRococo::para_id(), + ); + AssetHubWestend::fund_accounts(vec![(sov_ahr_on_ahw.clone(), amount * 2)]); + + // balances before + let sender_wnds_before = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(wnd_at_rococo_parachains.clone().into(), &sender) + }); + let receiver_wnds_before = ::account_data_of(receiver.clone()).free; + + // send WNDs over the bridge, ROCs only used to pay fees on local AH, pay with WND on remote AH + { + let final_destination = asset_hub_westend_location(); + let intermediary_hop = PenpalA::sibling_location_of(AssetHubRococo::para_id()); + let context = PenpalA::execute_with(|| PenpalUniversalLocation::get()); + + // what happens at final destination + let beneficiary = AccountId32Junction { network: None, id: receiver.clone().into() }.into(); + // use WND as fees on the final destination (AHW) + let remote_fees: Asset = (wnd_at_rococo_parachains.clone(), amount).into(); + let remote_fees = remote_fees.reanchored(&final_destination, &context).unwrap(); + // buy execution using WNDs, then deposit all remaining WNDs + let xcm_on_final_dest = Xcm::<()>(vec![ + BuyExecution { fees: remote_fees, weight_limit: WeightLimit::Unlimited }, + DepositAsset { assets: Wild(AllCounted(1)), beneficiary }, + ]); + + // what happens at intermediary hop + // reanchor final dest (Asset Hub Westend) to the view of hop (Asset Hub Rococo) + let mut final_destination = final_destination.clone(); + final_destination.reanchor(&intermediary_hop, &context).unwrap(); + // reanchor WNDs to the view of hop (Asset Hub Rococo) + let asset: Asset = (wnd_at_rococo_parachains.clone(), amount).into(); + let asset = asset.reanchored(&intermediary_hop, &context).unwrap(); + // on Asset Hub Rococo, forward a request to withdraw WNDs from reserve on Asset Hub Westend + let xcm_on_hop = Xcm::<()>(vec![InitiateReserveWithdraw { + assets: Definite(asset.into()), // WNDs + reserve: final_destination, // AHW + xcm: xcm_on_final_dest, // XCM to execute on AHW + }]); + // assets to send from Penpal and how they reach the intermediary hop + let assets: Assets = vec![ + (wnd_at_rococo_parachains.clone(), amount).into(), + (roc_at_rococo_parachains.clone(), amount).into(), + ] + .into(); + let asset_transfer_type = TransferType::DestinationReserve; + let fees_id: AssetId = roc_at_rococo_parachains.into(); + let fees_transfer_type = TransferType::DestinationReserve; + + // initiate the transfer + send_assets_from_penpal_rococo_through_rococo_ah_to_westend_ah( + intermediary_hop, + (assets, asset_transfer_type), + (fees_id, fees_transfer_type), + xcm_on_hop, + ); + } + + // process AHW incoming message and check events + AssetHubWestend::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + assert_expected_events!( + AssetHubWestend, + vec![ + // issue ROCs on AHW + RuntimeEvent::Balances(pallet_balances::Event::Issued { .. }) => {}, + // message processed successfully + RuntimeEvent::MessageQueue( + pallet_message_queue::Event::Processed { success: true, .. } + ) => {}, + ] + ); + }); + + let sender_wnds_after = PenpalA::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(wnd_at_rococo_parachains.into(), &sender) + }); + let receiver_wnds_after = ::account_data_of(receiver).free; + + // Sender's balance is reduced by sent "amount" + assert_eq!(sender_wnds_after, sender_wnds_before - amount); + // Receiver's balance is increased by no more than "amount" + assert!(receiver_wnds_after > receiver_wnds_before); + assert!(receiver_wnds_after <= receiver_wnds_before + amount); +} From 5e3d7ac509d094bfa806e74e89812cf6c0689ea9 Mon Sep 17 00:00:00 2001 From: Adrian Catangiu Date: Fri, 28 Jun 2024 17:24:15 +0300 Subject: [PATCH 2/5] clean up dependency tree --- Cargo.lock | 17 --------- .../assets/asset-hub-rococo/src/lib.rs | 2 ++ .../assets/asset-hub-westend/src/lib.rs | 2 ++ .../bridges/bridge-hub-rococo/src/lib.rs | 5 +++ .../bridges/bridge-hub-westend/src/lib.rs | 2 ++ .../collectives-westend/src/lib.rs | 2 ++ .../people/people-rococo/src/lib.rs | 1 + .../people/people-westend/src/lib.rs | 1 + .../parachains/testing/penpal/src/lib.rs | 5 ++- .../emulated/chains/relays/rococo/src/lib.rs | 1 + .../emulated/chains/relays/westend/src/lib.rs | 1 + .../tests/assets/asset-hub-rococo/Cargo.toml | 3 -- .../tests/assets/asset-hub-rococo/src/lib.rs | 36 ++++++++++++------- .../src/tests/hybrid_transfers.rs | 6 ++-- .../assets/asset-hub-rococo/src/tests/swap.rs | 19 ++++------ .../asset-hub-rococo/src/tests/treasury.rs | 10 ++---- .../tests/assets/asset-hub-westend/Cargo.toml | 3 -- .../tests/assets/asset-hub-westend/src/lib.rs | 32 ++++++++++------- .../src/tests/fellowship_treasury.rs | 5 +-- .../src/tests/hybrid_transfers.rs | 6 ++-- .../asset-hub-westend/src/tests/swap.rs | 16 ++++----- .../asset-hub-westend/src/tests/treasury.rs | 5 +-- .../bridges/bridge-hub-rococo/Cargo.toml | 9 ++--- .../bridges/bridge-hub-rococo/src/lib.rs | 14 ++++++-- .../bridge-hub-rococo/src/tests/snowbridge.rs | 8 ++--- .../bridge-hub-rococo/src/tests/teleport.rs | 9 +++-- .../bridges/bridge-hub-westend/Cargo.toml | 3 +- .../bridges/bridge-hub-westend/src/lib.rs | 2 +- .../bridge-hub-westend/src/tests/teleport.rs | 9 +++-- .../collectives-westend/Cargo.toml | 3 -- .../collectives-westend/src/lib.rs | 15 ++++++-- .../src/tests/fellowship_treasury.rs | 9 ++--- .../tests/people/people-rococo/Cargo.toml | 10 +++--- .../tests/people/people-rococo/src/lib.rs | 14 ++++++-- .../people-rococo/src/tests/reap_identity.rs | 6 +--- .../people-rococo/src/tests/teleport.rs | 14 +++++--- .../tests/people/people-westend/Cargo.toml | 10 +++--- .../tests/people/people-westend/src/lib.rs | 15 ++++++-- .../people-westend/src/tests/reap_identity.rs | 6 +--- .../people-westend/src/tests/teleport.rs | 14 +++++--- 40 files changed, 180 insertions(+), 170 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1b04ced266d7..7b08e96f4bbe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -805,7 +805,6 @@ name = "asset-hub-rococo-integration-tests" version = "1.0.0" dependencies = [ "assert_matches", - "asset-hub-rococo-runtime", "asset-test-utils", "cumulus-pallet-parachain-system", "emulated-integration-tests-common", @@ -819,9 +818,7 @@ dependencies = [ "pallet-xcm", "parachains-common", "parity-scale-codec", - "penpal-runtime", "polkadot-runtime-common", - "rococo-runtime", "rococo-runtime-constants", "rococo-system-emulated-network", "sp-runtime", @@ -933,7 +930,6 @@ name = "asset-hub-westend-integration-tests" version = "1.0.0" dependencies = [ "assert_matches", - "asset-hub-westend-runtime", "asset-test-utils", "cumulus-pallet-parachain-system", "cumulus-pallet-xcmp-queue", @@ -951,14 +947,12 @@ dependencies = [ "pallet-xcm", "parachains-common", "parity-scale-codec", - "penpal-runtime", "polkadot-runtime-common", "sp-core", "sp-keyring", "sp-runtime", "staging-xcm", "staging-xcm-executor", - "westend-runtime", "westend-system-emulated-network", "xcm-runtime-apis", ] @@ -2063,8 +2057,6 @@ dependencies = [ name = "bridge-hub-rococo-integration-tests" version = "1.0.0" dependencies = [ - "asset-hub-rococo-runtime", - "bridge-hub-rococo-runtime", "cumulus-pallet-xcmp-queue", "emulated-integration-tests-common", "frame-support", @@ -2077,7 +2069,6 @@ dependencies = [ "pallet-xcm", "parachains-common", "parity-scale-codec", - "penpal-runtime", "rococo-system-emulated-network", "rococo-westend-system-emulated-network", "scale-info", @@ -2249,7 +2240,6 @@ dependencies = [ name = "bridge-hub-westend-integration-tests" version = "1.0.0" dependencies = [ - "bridge-hub-westend-runtime", "cumulus-pallet-xcmp-queue", "emulated-integration-tests-common", "frame-support", @@ -2894,8 +2884,6 @@ name = "collectives-westend-integration-tests" version = "1.0.0" dependencies = [ "assert_matches", - "asset-hub-westend-runtime", - "collectives-westend-runtime", "cumulus-pallet-parachain-system", "cumulus-pallet-xcmp-queue", "emulated-integration-tests-common", @@ -2914,7 +2902,6 @@ dependencies = [ "staging-xcm", "staging-xcm-executor", "testnet-parachains-constants", - "westend-runtime", "westend-runtime-constants", "westend-system-emulated-network", ] @@ -12572,9 +12559,7 @@ dependencies = [ "pallet-message-queue", "parachains-common", "parity-scale-codec", - "people-rococo-runtime", "polkadot-runtime-common", - "rococo-runtime", "rococo-runtime-constants", "rococo-system-emulated-network", "sp-runtime", @@ -12673,12 +12658,10 @@ dependencies = [ "pallet-message-queue", "parachains-common", "parity-scale-codec", - "people-westend-runtime", "polkadot-runtime-common", "sp-runtime", "staging-xcm", "staging-xcm-executor", - "westend-runtime", "westend-runtime-constants", "westend-system-emulated-network", ] diff --git a/cumulus/parachains/integration-tests/emulated/chains/parachains/assets/asset-hub-rococo/src/lib.rs b/cumulus/parachains/integration-tests/emulated/chains/parachains/assets/asset-hub-rococo/src/lib.rs index 202d02b250bb..80d2376c6811 100644 --- a/cumulus/parachains/integration-tests/emulated/chains/parachains/assets/asset-hub-rococo/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/chains/parachains/assets/asset-hub-rococo/src/lib.rs @@ -13,6 +13,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +pub use asset_hub_rococo_runtime; + pub mod genesis; // Substrate diff --git a/cumulus/parachains/integration-tests/emulated/chains/parachains/assets/asset-hub-westend/src/lib.rs b/cumulus/parachains/integration-tests/emulated/chains/parachains/assets/asset-hub-westend/src/lib.rs index 6043a6aeda48..608690218d2f 100644 --- a/cumulus/parachains/integration-tests/emulated/chains/parachains/assets/asset-hub-westend/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/chains/parachains/assets/asset-hub-westend/src/lib.rs @@ -13,6 +13,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +pub use asset_hub_westend_runtime; + pub mod genesis; // Substrate diff --git a/cumulus/parachains/integration-tests/emulated/chains/parachains/bridges/bridge-hub-rococo/src/lib.rs b/cumulus/parachains/integration-tests/emulated/chains/parachains/bridges/bridge-hub-rococo/src/lib.rs index 8c18d112bc12..d8b8edaf2409 100644 --- a/cumulus/parachains/integration-tests/emulated/chains/parachains/bridges/bridge-hub-rococo/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/chains/parachains/bridges/bridge-hub-rococo/src/lib.rs @@ -15,6 +15,11 @@ pub mod genesis; +pub use bridge_hub_rococo_runtime::{ + xcm_config::XcmConfig as BridgeHubRococoXcmConfig, EthereumBeaconClient, EthereumInboundQueue, + RuntimeOrigin as BridgeHubRococoRuntimeOrigin, +}; + // Substrate use frame_support::traits::OnInitialize; diff --git a/cumulus/parachains/integration-tests/emulated/chains/parachains/bridges/bridge-hub-westend/src/lib.rs b/cumulus/parachains/integration-tests/emulated/chains/parachains/bridges/bridge-hub-westend/src/lib.rs index b0dddc9dbf9a..f701b3096994 100644 --- a/cumulus/parachains/integration-tests/emulated/chains/parachains/bridges/bridge-hub-westend/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/chains/parachains/bridges/bridge-hub-westend/src/lib.rs @@ -15,6 +15,8 @@ pub mod genesis; +pub use bridge_hub_westend_runtime::xcm_config::XcmConfig as BridgeHubWestendXcmConfig; + // Substrate use frame_support::traits::OnInitialize; diff --git a/cumulus/parachains/integration-tests/emulated/chains/parachains/collectives/collectives-westend/src/lib.rs b/cumulus/parachains/integration-tests/emulated/chains/parachains/collectives/collectives-westend/src/lib.rs index a32e865dd9ce..f90d82231a3b 100644 --- a/cumulus/parachains/integration-tests/emulated/chains/parachains/collectives/collectives-westend/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/chains/parachains/collectives/collectives-westend/src/lib.rs @@ -13,6 +13,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +pub use collectives_westend_runtime; + pub mod genesis; // Substrate diff --git a/cumulus/parachains/integration-tests/emulated/chains/parachains/people/people-rococo/src/lib.rs b/cumulus/parachains/integration-tests/emulated/chains/parachains/people/people-rococo/src/lib.rs index fa818bf81bf6..c8da97cc3e8b 100644 --- a/cumulus/parachains/integration-tests/emulated/chains/parachains/people/people-rococo/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/chains/parachains/people/people-rococo/src/lib.rs @@ -12,6 +12,7 @@ // 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. +pub use people_rococo_runtime; pub mod genesis; diff --git a/cumulus/parachains/integration-tests/emulated/chains/parachains/people/people-westend/src/lib.rs b/cumulus/parachains/integration-tests/emulated/chains/parachains/people/people-westend/src/lib.rs index 775b89ac208b..904ce34d8c08 100644 --- a/cumulus/parachains/integration-tests/emulated/chains/parachains/people/people-westend/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/chains/parachains/people/people-westend/src/lib.rs @@ -12,6 +12,7 @@ // 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. +pub use people_westend_runtime; pub mod genesis; diff --git a/cumulus/parachains/integration-tests/emulated/chains/parachains/testing/penpal/src/lib.rs b/cumulus/parachains/integration-tests/emulated/chains/parachains/testing/penpal/src/lib.rs index c268b014bfa3..91793d33f304 100644 --- a/cumulus/parachains/integration-tests/emulated/chains/parachains/testing/penpal/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/chains/parachains/testing/penpal/src/lib.rs @@ -13,11 +13,10 @@ // See the License for the specific language governing permissions and // limitations under the License. +pub use penpal_runtime::{self, xcm_config::RelayNetworkId as PenpalRelayNetworkId}; + mod genesis; pub use genesis::{genesis, PenpalAssetOwner, PenpalSudoAccount, ED, PARA_ID_A, PARA_ID_B}; -pub use penpal_runtime::xcm_config::{ - CustomizableAssetFromSystemAssetHub, RelayNetworkId as PenpalRelayNetworkId, -}; // Substrate use frame_support::traits::OnInitialize; diff --git a/cumulus/parachains/integration-tests/emulated/chains/relays/rococo/src/lib.rs b/cumulus/parachains/integration-tests/emulated/chains/relays/rococo/src/lib.rs index 7a3a936ec972..bd637a5f7965 100644 --- a/cumulus/parachains/integration-tests/emulated/chains/relays/rococo/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/chains/relays/rococo/src/lib.rs @@ -12,6 +12,7 @@ // 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. +pub use rococo_runtime; pub mod genesis; diff --git a/cumulus/parachains/integration-tests/emulated/chains/relays/westend/src/lib.rs b/cumulus/parachains/integration-tests/emulated/chains/relays/westend/src/lib.rs index 83af58f61732..ce9fafcd5bda 100644 --- a/cumulus/parachains/integration-tests/emulated/chains/relays/westend/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/chains/relays/westend/src/lib.rs @@ -12,6 +12,7 @@ // 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. +pub use westend_runtime; pub mod genesis; diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-rococo/Cargo.toml b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-rococo/Cargo.toml index 19d3bb3cb29e..b4579da94cbf 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-rococo/Cargo.toml +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-rococo/Cargo.toml @@ -28,7 +28,6 @@ pallet-utility = { workspace = true } xcm = { workspace = true } pallet-xcm = { workspace = true } xcm-executor = { workspace = true } -rococo-runtime = { workspace = true } polkadot-runtime-common = { workspace = true, default-features = true } rococo-runtime-constants = { workspace = true, default-features = true } @@ -36,7 +35,5 @@ rococo-runtime-constants = { workspace = true, default-features = true } asset-test-utils = { workspace = true, default-features = true } cumulus-pallet-parachain-system = { workspace = true } parachains-common = { workspace = true, default-features = true } -asset-hub-rococo-runtime = { workspace = true, default-features = true } -penpal-runtime = { workspace = true } emulated-integration-tests-common = { workspace = true } rococo-system-emulated-network = { workspace = true } diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-rococo/src/lib.rs b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-rococo/src/lib.rs index 2bd388bee400..f00945926963 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-rococo/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-rococo/src/lib.rs @@ -46,14 +46,36 @@ mod imports { pub use parachains_common::Balance; pub use rococo_system_emulated_network::{ asset_hub_rococo_emulated_chain::{ + asset_hub_rococo_runtime::{ + xcm_config::{ + self as ahr_xcm_config, TokenLocation as RelayLocation, + XcmConfig as AssetHubRococoXcmConfig, + }, + AssetConversionOrigin as AssetHubRococoAssetConversionOrigin, + }, genesis::{AssetHubRococoAssetOwner, ED as ASSET_HUB_ROCOCO_ED}, AssetHubRococoParaPallet as AssetHubRococoPallet, }, penpal_emulated_chain::{ + penpal_runtime::xcm_config::{ + CustomizableAssetFromSystemAssetHub as PenpalCustomizableAssetFromSystemAssetHub, + LocalReservableFromAssetHub as PenpalLocalReservableFromAssetHub, + LocalTeleportableToAssetHub as PenpalLocalTeleportableToAssetHub, + }, PenpalAParaPallet as PenpalAPallet, PenpalAssetOwner, PenpalBParaPallet as PenpalBPallet, ED as PENPAL_ED, }, - rococo_emulated_chain::{genesis::ED as ROCOCO_ED, RococoRelayPallet as RococoPallet}, + rococo_emulated_chain::{ + genesis::ED as ROCOCO_ED, + rococo_runtime::{ + governance as rococo_governance, + xcm_config::{ + UniversalLocation as RococoUniversalLocation, XcmConfig as RococoXcmConfig, + }, + OriginCaller as RococoOriginCaller, + }, + RococoRelayPallet as RococoPallet, + }, AssetHubRococoPara as AssetHubRococo, AssetHubRococoParaReceiver as AssetHubRococoReceiver, AssetHubRococoParaSender as AssetHubRococoSender, BridgeHubRococoPara as BridgeHubRococo, BridgeHubRococoParaReceiver as BridgeHubRococoReceiver, PenpalAPara as PenpalA, @@ -62,18 +84,6 @@ mod imports { RococoRelayReceiver as RococoReceiver, RococoRelaySender as RococoSender, }; - // Runtimes - pub use asset_hub_rococo_runtime::xcm_config::{ - TokenLocation as RelayLocation, XcmConfig as AssetHubRococoXcmConfig, - }; - pub use penpal_runtime::xcm_config::{ - LocalReservableFromAssetHub as PenpalLocalReservableFromAssetHub, - LocalTeleportableToAssetHub as PenpalLocalTeleportableToAssetHub, - }; - pub use rococo_runtime::xcm_config::{ - UniversalLocation as RococoUniversalLocation, XcmConfig as RococoXcmConfig, - }; - pub const ASSET_ID: u32 = 3; pub const ASSET_MIN_BALANCE: u128 = 1000; diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-rococo/src/tests/hybrid_transfers.rs b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-rococo/src/tests/hybrid_transfers.rs index edaaa998a9ca..7ff6d6c193c9 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-rococo/src/tests/hybrid_transfers.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-rococo/src/tests/hybrid_transfers.rs @@ -170,7 +170,7 @@ fn transfer_foreign_assets_from_asset_hub_to_para() { assert_ok!(::System::set_storage( ::RuntimeOrigin::root(), vec![( - penpal_runtime::xcm_config::CustomizableAssetFromSystemAssetHub::key().to_vec(), + PenpalCustomizableAssetFromSystemAssetHub::key().to_vec(), Location::new(2, [GlobalConsensus(Westend)]).encode(), )], )); @@ -300,7 +300,7 @@ fn transfer_foreign_assets_from_para_to_asset_hub() { assert_ok!(::System::set_storage( ::RuntimeOrigin::root(), vec![( - penpal_runtime::xcm_config::CustomizableAssetFromSystemAssetHub::key().to_vec(), + PenpalCustomizableAssetFromSystemAssetHub::key().to_vec(), Location::new(2, [GlobalConsensus(Westend)]).encode(), )], )); @@ -454,7 +454,7 @@ fn transfer_foreign_assets_from_para_to_para_through_asset_hub() { assert_ok!(::System::set_storage( ::RuntimeOrigin::root(), vec![( - penpal_runtime::xcm_config::CustomizableAssetFromSystemAssetHub::key().to_vec(), + PenpalCustomizableAssetFromSystemAssetHub::key().to_vec(), Location::new(2, [GlobalConsensus(Westend)]).encode(), )], )); diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-rococo/src/tests/swap.rs b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-rococo/src/tests/swap.rs index ec48e400ff54..16e0512da960 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-rococo/src/tests/swap.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-rococo/src/tests/swap.rs @@ -17,10 +17,7 @@ use crate::imports::*; #[test] fn swap_locally_on_chain_using_local_assets() { - let asset_native = Box::new( - v3::Location::try_from(asset_hub_rococo_runtime::xcm_config::TokenLocation::get()) - .expect("conversion works"), - ); + let asset_native = Box::new(v3::Location::try_from(RelayLocation::get()).unwrap()); let asset_one = Box::new(v3::Location::new( 0, [ @@ -230,12 +227,12 @@ fn swap_locally_on_chain_using_foreign_assets() { #[test] fn cannot_create_pool_from_pool_assets() { - let asset_native = asset_hub_rococo_runtime::xcm_config::TokenLocation::get(); - let mut asset_one = asset_hub_rococo_runtime::xcm_config::PoolAssetsPalletLocation::get(); + let asset_native = RelayLocation::get(); + let mut asset_one = ahr_xcm_config::PoolAssetsPalletLocation::get(); asset_one.append_with(GeneralIndex(ASSET_ID.into())).expect("pool assets"); AssetHubRococo::execute_with(|| { - let pool_owner_account_id = asset_hub_rococo_runtime::AssetConversionOrigin::get(); + let pool_owner_account_id = AssetHubRococoAssetConversionOrigin::get(); assert_ok!(::PoolAssets::create( ::RuntimeOrigin::signed(pool_owner_account_id.clone()), @@ -255,8 +252,8 @@ fn cannot_create_pool_from_pool_assets() { assert_matches::assert_matches!( ::AssetConversion::create_pool( ::RuntimeOrigin::signed(AssetHubRococoSender::get()), - Box::new(v3::Location::try_from(asset_native).expect("conversion works")), - Box::new(v3::Location::try_from(asset_one).expect("conversion works")), + Box::new(v3::Location::try_from(asset_native).unwrap()), + Box::new(v3::Location::try_from(asset_one).unwrap()), ), Err(DispatchError::Module(ModuleError{index: _, error: _, message})) => assert_eq!(message, Some("Unknown")) ); @@ -265,9 +262,7 @@ fn cannot_create_pool_from_pool_assets() { #[test] fn pay_xcm_fee_with_some_asset_swapped_for_native() { - let asset_native = - v3::Location::try_from(asset_hub_rococo_runtime::xcm_config::TokenLocation::get()) - .expect("conversion works"); + let asset_native = v3::Location::try_from(RelayLocation::get()).unwrap(); let asset_one = xcm::v3::Location { parents: 0, interior: [ diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-rococo/src/tests/treasury.rs b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-rococo/src/tests/treasury.rs index 809641c626fa..f8190e11c51c 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-rococo/src/tests/treasury.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-rococo/src/tests/treasury.rs @@ -25,7 +25,6 @@ use frame_support::{ }; use parachains_common::AccountId; use polkadot_runtime_common::impls::VersionedLocatableAsset; -use rococo_runtime::OriginCaller; use rococo_runtime_constants::currency::GRAND; use xcm_executor::traits::ConvertLocation; @@ -67,7 +66,7 @@ fn spend_roc_on_asset_hub() { let treasury_location: Location = (Parent, PalletInstance(18)).into(); let teleport_call = RuntimeCall::Utility(pallet_utility::Call::::dispatch_as { - as_origin: bx!(OriginCaller::system(RawOrigin::Signed(treasury_account))), + as_origin: bx!(RococoOriginCaller::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)), @@ -99,7 +98,7 @@ fn spend_roc_on_asset_hub() { // Fund Alice account from Rococo Treasury account on Asset Hub. let treasury_origin: RuntimeOrigin = - rococo_runtime::governance::pallet_custom_origins::Origin::Treasurer.into(); + rococo_governance::pallet_custom_origins::Origin::Treasurer.into(); let alice_location: Location = [Junction::AccountId32 { network: None, id: Rococo::account_id_of(ALICE).into() }] @@ -168,10 +167,7 @@ fn create_and_claim_treasury_spend_in_usdt() { let treasury_location: Location = Location::new(1, PalletInstance(18)); // treasury account on a sibling parachain. let treasury_account = - asset_hub_rococo_runtime::xcm_config::LocationToAccountId::convert_location( - &treasury_location, - ) - .unwrap(); + ahr_xcm_config::LocationToAccountId::convert_location(&treasury_location).unwrap(); let asset_hub_location = v3::Location::new(0, v3::Junction::Parachain(AssetHubRococo::para_id().into())); let root = ::RuntimeOrigin::root(); diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/Cargo.toml b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/Cargo.toml index 2f4cc5ea39c1..6b50b6f473ed 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/Cargo.toml +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/Cargo.toml @@ -35,12 +35,9 @@ xcm = { workspace = true } xcm-executor = { workspace = true } pallet-xcm = { workspace = true } xcm-runtime-apis = { workspace = true } -westend-runtime = { workspace = true } # Cumulus parachains-common = { workspace = true, default-features = true } -penpal-runtime = { workspace = true } -asset-hub-westend-runtime = { workspace = true } asset-test-utils = { workspace = true, default-features = true } cumulus-pallet-xcmp-queue = { workspace = true } cumulus-pallet-parachain-system = { workspace = true } diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/lib.rs b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/lib.rs index 1c4a0ef4c8d2..db8ada3f4ea2 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/lib.rs @@ -46,15 +46,33 @@ mod imports { pub use parachains_common::{AccountId, Balance}; pub use westend_system_emulated_network::{ asset_hub_westend_emulated_chain::{ + asset_hub_westend_runtime::{ + xcm_config::{ + self as ahw_xcm_config, WestendLocation as RelayLocation, + XcmConfig as AssetHubWestendXcmConfig, + }, + AssetConversionOrigin as AssetHubWestendAssetConversionOrigin, + }, genesis::{AssetHubWestendAssetOwner, ED as ASSET_HUB_WESTEND_ED}, AssetHubWestendParaPallet as AssetHubWestendPallet, }, collectives_westend_emulated_chain::CollectivesWestendParaPallet as CollectivesWestendPallet, penpal_emulated_chain::{ + penpal_runtime::xcm_config::{ + CustomizableAssetFromSystemAssetHub as PenpalCustomizableAssetFromSystemAssetHub, + LocalReservableFromAssetHub as PenpalLocalReservableFromAssetHub, + LocalTeleportableToAssetHub as PenpalLocalTeleportableToAssetHub, + }, PenpalAParaPallet as PenpalAPallet, PenpalAssetOwner, PenpalBParaPallet as PenpalBPallet, }, - westend_emulated_chain::{genesis::ED as WESTEND_ED, WestendRelayPallet as WestendPallet}, + westend_emulated_chain::{ + genesis::ED as WESTEND_ED, + westend_runtime::xcm_config::{ + UniversalLocation as WestendUniversalLocation, XcmConfig as WestendXcmConfig, + }, + WestendRelayPallet as WestendPallet, + }, AssetHubWestendPara as AssetHubWestend, AssetHubWestendParaReceiver as AssetHubWestendReceiver, AssetHubWestendParaSender as AssetHubWestendSender, @@ -66,18 +84,6 @@ mod imports { WestendRelayReceiver as WestendReceiver, WestendRelaySender as WestendSender, }; - // Runtimes - pub use asset_hub_westend_runtime::xcm_config::{ - WestendLocation as RelayLocation, XcmConfig as AssetHubWestendXcmConfig, - }; - pub use penpal_runtime::xcm_config::{ - LocalReservableFromAssetHub as PenpalLocalReservableFromAssetHub, - LocalTeleportableToAssetHub as PenpalLocalTeleportableToAssetHub, - }; - pub use westend_runtime::xcm_config::{ - UniversalLocation as WestendUniversalLocation, XcmConfig as WestendXcmConfig, - }; - pub const ASSET_ID: u32 = 3; pub const ASSET_MIN_BALANCE: u128 = 1000; diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/fellowship_treasury.rs b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/fellowship_treasury.rs index 2d02e90f47fb..15f4fe33bddc 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/fellowship_treasury.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/fellowship_treasury.rs @@ -28,10 +28,7 @@ fn create_and_claim_treasury_spend() { Location::new(1, [Parachain(CollectivesWestend::para_id().into()), PalletInstance(65)]); // treasury account on a sibling parachain. let treasury_account = - asset_hub_westend_runtime::xcm_config::LocationToAccountId::convert_location( - &treasury_location, - ) - .unwrap(); + ahw_xcm_config::LocationToAccountId::convert_location(&treasury_location).unwrap(); let asset_hub_location = Location::new(1, [Parachain(AssetHubWestend::para_id().into())]); let root = ::RuntimeOrigin::root(); // asset kind to be spent from the treasury. diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/hybrid_transfers.rs b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/hybrid_transfers.rs index d39c72c7c5f0..49dfe8d58394 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/hybrid_transfers.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/hybrid_transfers.rs @@ -170,7 +170,7 @@ fn transfer_foreign_assets_from_asset_hub_to_para() { assert_ok!(::System::set_storage( ::RuntimeOrigin::root(), vec![( - penpal_runtime::xcm_config::CustomizableAssetFromSystemAssetHub::key().to_vec(), + PenpalCustomizableAssetFromSystemAssetHub::key().to_vec(), Location::new(2, [GlobalConsensus(Rococo)]).encode(), )], )); @@ -300,7 +300,7 @@ fn transfer_foreign_assets_from_para_to_asset_hub() { assert_ok!(::System::set_storage( ::RuntimeOrigin::root(), vec![( - penpal_runtime::xcm_config::CustomizableAssetFromSystemAssetHub::key().to_vec(), + PenpalCustomizableAssetFromSystemAssetHub::key().to_vec(), Location::new(2, [GlobalConsensus(Rococo)]).encode(), )], )); @@ -455,7 +455,7 @@ fn transfer_foreign_assets_from_para_to_para_through_asset_hub() { assert_ok!(::System::set_storage( ::RuntimeOrigin::root(), vec![( - penpal_runtime::xcm_config::CustomizableAssetFromSystemAssetHub::key().to_vec(), + PenpalCustomizableAssetFromSystemAssetHub::key().to_vec(), Location::new(2, [GlobalConsensus(Rococo)]).encode(), )], )); diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/swap.rs b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/swap.rs index f6b658098865..cf429378cf6d 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/swap.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/swap.rs @@ -17,10 +17,8 @@ use crate::imports::*; #[test] fn swap_locally_on_chain_using_local_assets() { - let asset_native = Box::new( - v3::Location::try_from(asset_hub_westend_runtime::xcm_config::WestendLocation::get()) - .expect("conversion works"), - ); + let asset_native = + Box::new(v3::Location::try_from(RelayLocation::get()).expect("conversion works")); let asset_one = Box::new(v3::Location { parents: 0, interior: [ @@ -229,12 +227,12 @@ fn swap_locally_on_chain_using_foreign_assets() { #[test] fn cannot_create_pool_from_pool_assets() { - let asset_native = asset_hub_westend_runtime::xcm_config::WestendLocation::get(); - let mut asset_one = asset_hub_westend_runtime::xcm_config::PoolAssetsPalletLocation::get(); + let asset_native = RelayLocation::get(); + let mut asset_one = ahw_xcm_config::PoolAssetsPalletLocation::get(); asset_one.append_with(GeneralIndex(ASSET_ID.into())).expect("pool assets"); AssetHubWestend::execute_with(|| { - let pool_owner_account_id = asset_hub_westend_runtime::AssetConversionOrigin::get(); + let pool_owner_account_id = AssetHubWestendAssetConversionOrigin::get(); assert_ok!(::PoolAssets::create( ::RuntimeOrigin::signed(pool_owner_account_id.clone()), @@ -264,9 +262,7 @@ fn cannot_create_pool_from_pool_assets() { #[test] fn pay_xcm_fee_with_some_asset_swapped_for_native() { - let asset_native = - v3::Location::try_from(asset_hub_westend_runtime::xcm_config::WestendLocation::get()) - .expect("conversion works"); + let asset_native = v3::Location::try_from(RelayLocation::get()).expect("conversion works"); let asset_one = xcm::v3::Location { parents: 0, interior: [ diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/treasury.rs b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/treasury.rs index 6d8c0f5e5de6..8cbce3e0d223 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/treasury.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/treasury.rs @@ -27,10 +27,7 @@ fn create_and_claim_treasury_spend() { let treasury_location: Location = Location::new(1, PalletInstance(37)); // treasury account on a sibling parachain. let treasury_account = - asset_hub_westend_runtime::xcm_config::LocationToAccountId::convert_location( - &treasury_location, - ) - .unwrap(); + ahw_xcm_config::LocationToAccountId::convert_location(&treasury_location).unwrap(); let asset_hub_location = Location::new(0, Parachain(AssetHubWestend::para_id().into())); let root = ::RuntimeOrigin::root(); // asset kind to be spend from the treasury. 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 12ae785f0eef..a5787885329d 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 @@ -33,15 +33,12 @@ xcm-executor = { workspace = true } pallet-bridge-messages = { workspace = true } # Cumulus -parachains-common = { workspace = true, default-features = true } -testnet-parachains-constants = { features = ["rococo"], workspace = true, default-features = true } cumulus-pallet-xcmp-queue = { workspace = true } emulated-integration-tests-common = { workspace = true } -asset-hub-rococo-runtime = { workspace = true } -bridge-hub-rococo-runtime = { workspace = true } -penpal-runtime = { workspace = true } -rococo-westend-system-emulated-network = { workspace = true } +parachains-common = { workspace = true, default-features = true } rococo-system-emulated-network = { workspace = true } +rococo-westend-system-emulated-network = { workspace = true } +testnet-parachains-constants = { features = ["rococo"], workspace = true, default-features = true } # Snowbridge snowbridge-core = { workspace = true } 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 43ea0524d55d..04466a611c71 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 @@ -38,9 +38,9 @@ mod imports { ASSETS_PALLET_ID, USDT_ID, }; pub use parachains_common::AccountId; - pub use penpal_runtime::xcm_config::UniversalLocation as PenpalUniversalLocation; pub use rococo_westend_system_emulated_network::{ asset_hub_rococo_emulated_chain::{ + asset_hub_rococo_runtime::xcm_config as ahr_xcm_config, genesis::{AssetHubRococoAssetOwner, ED as ASSET_HUB_ROCOCO_ED}, AssetHubRococoParaPallet as AssetHubRococoPallet, }, @@ -48,9 +48,17 @@ mod imports { genesis::ED as ASSET_HUB_WESTEND_ED, AssetHubWestendParaPallet as AssetHubWestendPallet, }, bridge_hub_rococo_emulated_chain::{ - genesis::ED as BRIDGE_HUB_ROCOCO_ED, BridgeHubRococoParaPallet as BridgeHubRococoPallet, + genesis::ED as BRIDGE_HUB_ROCOCO_ED, + BridgeHubRococoParaPallet as BridgeHubRococoPallet, BridgeHubRococoRuntimeOrigin, + BridgeHubRococoXcmConfig, EthereumBeaconClient, EthereumInboundQueue, + }, + penpal_emulated_chain::{ + penpal_runtime::xcm_config::{ + CustomizableAssetFromSystemAssetHub as PenpalCustomizableAssetFromSystemAssetHub, + UniversalLocation as PenpalUniversalLocation, + }, + PenpalAParaPallet as PenpalAPallet, PenpalAssetOwner, }, - penpal_emulated_chain::{PenpalAParaPallet as PenpalAPallet, PenpalAssetOwner}, rococo_emulated_chain::{genesis::ED as ROCOCO_ED, RococoRelayPallet as RococoPallet}, AssetHubRococoPara as AssetHubRococo, AssetHubRococoParaReceiver as AssetHubRococoReceiver, AssetHubRococoParaSender as AssetHubRococoSender, AssetHubWestendPara as AssetHubWestend, diff --git a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs index e2f62fdb94ed..40a1968ec557 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs @@ -13,12 +13,10 @@ // See the License for the specific language governing permissions and // limitations under the License. use crate::imports::*; -use bridge_hub_rococo_runtime::{EthereumBeaconClient, EthereumInboundQueue, RuntimeOrigin}; use codec::{Decode, Encode}; use emulated_integration_tests_common::xcm_emulator::ConvertLocation; use frame_support::pallet_prelude::TypeInfo; use hex_literal::hex; -use rococo_system_emulated_network::penpal_emulated_chain::CustomizableAssetFromSystemAssetHub; use rococo_westend_system_emulated_network::BridgeHubRococoParaSender as BridgeHubRococoSender; use snowbridge_core::{inbound::InboundQueueFixture, outbound::OperatingMode}; use snowbridge_pallet_inbound_queue_fixtures::{ @@ -64,7 +62,7 @@ pub fn send_inbound_message(fixture: InboundQueueFixture) -> DispatchResult { ) .unwrap(); EthereumInboundQueue::submit( - RuntimeOrigin::signed(BridgeHubRococoSender::get()), + BridgeHubRococoRuntimeOrigin::signed(BridgeHubRococoSender::get()), fixture.message, ) } @@ -298,7 +296,7 @@ fn send_token_from_ethereum_to_penpal() { assert_ok!(::System::set_storage( ::RuntimeOrigin::root(), vec![( - CustomizableAssetFromSystemAssetHub::key().to_vec(), + PenpalCustomizableAssetFromSystemAssetHub::key().to_vec(), Location::new(2, [GlobalConsensus(Ethereum { chain_id: CHAIN_ID })]).encode(), )], )); @@ -379,7 +377,7 @@ fn send_token_from_ethereum_to_penpal() { /// - returning the token to Ethereum #[test] fn send_weth_asset_from_asset_hub_to_ethereum() { - use asset_hub_rococo_runtime::xcm_config::bridging::to_ethereum::DefaultBridgeHubEthereumBaseFee; + use ahr_xcm_config::bridging::to_ethereum::DefaultBridgeHubEthereumBaseFee; let assethub_location = BridgeHubRococo::sibling_location_of(AssetHubRococo::para_id()); let assethub_sovereign = BridgeHubRococo::sovereign_account_id_of(assethub_location); diff --git a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/teleport.rs b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/teleport.rs index 8f51f5b18000..1fb03748d926 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/teleport.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/teleport.rs @@ -13,8 +13,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::tests::*; -use bridge_hub_rococo_runtime::xcm_config::XcmConfig; +use crate::imports::*; #[test] fn teleport_to_other_system_parachains_works() { @@ -22,9 +21,9 @@ fn teleport_to_other_system_parachains_works() { let native_asset: Assets = (Parent, amount).into(); test_parachain_is_trusted_teleporter!( - BridgeHubRococo, // Origin - XcmConfig, // XCM configuration - vec![AssetHubRococo], // Destinations + BridgeHubRococo, // Origin + BridgeHubRococoXcmConfig, // XCM configuration + vec![AssetHubRococo], // Destinations (native_asset, amount) ); } 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 4be226f0dc7b..6b83479eaf89 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 @@ -30,8 +30,7 @@ xcm-executor = { workspace = true } pallet-bridge-messages = { workspace = true } # Cumulus -parachains-common = { workspace = true, default-features = true } cumulus-pallet-xcmp-queue = { workspace = true } -bridge-hub-westend-runtime = { workspace = true } emulated-integration-tests-common = { workspace = true } +parachains-common = { workspace = true, default-features = true } rococo-westend-system-emulated-network = { workspace = true } 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 b92a22cef628..a0dfcaa74947 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 @@ -49,7 +49,7 @@ mod imports { }, bridge_hub_westend_emulated_chain::{ genesis::ED as BRIDGE_HUB_WESTEND_ED, - BridgeHubWestendParaPallet as BridgeHubWestendPallet, + BridgeHubWestendParaPallet as BridgeHubWestendPallet, BridgeHubWestendXcmConfig, }, penpal_emulated_chain::{PenpalAssetOwner, PenpalBParaPallet as PenpalBPallet}, westend_emulated_chain::WestendRelayPallet as WestendPallet, diff --git a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-westend/src/tests/teleport.rs b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-westend/src/tests/teleport.rs index c960233c08b7..64378a844f52 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-westend/src/tests/teleport.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-westend/src/tests/teleport.rs @@ -13,8 +13,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::tests::*; -use bridge_hub_westend_runtime::xcm_config::XcmConfig; +use crate::imports::*; #[test] fn teleport_to_other_system_parachains_works() { @@ -22,9 +21,9 @@ fn teleport_to_other_system_parachains_works() { let native_asset: Assets = (Parent, amount).into(); test_parachain_is_trusted_teleporter!( - BridgeHubWestend, // Origin - XcmConfig, // XCM configuration - vec![AssetHubWestend], // Destinations + BridgeHubWestend, // Origin + BridgeHubWestendXcmConfig, // XCM configuration + vec![AssetHubWestend], // Destinations (native_asset, amount) ); } diff --git a/cumulus/parachains/integration-tests/emulated/tests/collectives/collectives-westend/Cargo.toml b/cumulus/parachains/integration-tests/emulated/tests/collectives/collectives-westend/Cargo.toml index c546132fa63b..3012e2b19f53 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/collectives/collectives-westend/Cargo.toml +++ b/cumulus/parachains/integration-tests/emulated/tests/collectives/collectives-westend/Cargo.toml @@ -29,14 +29,11 @@ polkadot-runtime-common = { workspace = true, default-features = true } xcm = { workspace = true } xcm-executor = { workspace = true } pallet-xcm = { workspace = true } -westend-runtime = { workspace = true } westend-runtime-constants = { workspace = true, default-features = true } # Cumulus parachains-common = { workspace = true, default-features = true } testnet-parachains-constants = { features = ["westend"], workspace = true, default-features = true } -asset-hub-westend-runtime = { workspace = true } -collectives-westend-runtime = { workspace = true } cumulus-pallet-xcmp-queue = { workspace = true } cumulus-pallet-parachain-system = { workspace = true } emulated-integration-tests-common = { workspace = true } diff --git a/cumulus/parachains/integration-tests/emulated/tests/collectives/collectives-westend/src/lib.rs b/cumulus/parachains/integration-tests/emulated/tests/collectives/collectives-westend/src/lib.rs index 97239330216a..8af93a62f4a1 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/collectives/collectives-westend/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/collectives/collectives-westend/src/lib.rs @@ -19,9 +19,18 @@ pub use emulated_integration_tests_common::xcm_emulator::{ assert_expected_events, bx, Chain, RelayChain as Relay, TestExt, }; pub use westend_system_emulated_network::{ - asset_hub_westend_emulated_chain::AssetHubWestendParaPallet as AssetHubWestendPallet, - collectives_westend_emulated_chain::CollectivesWestendParaPallet as CollectivesWestendPallet, - westend_emulated_chain::WestendRelayPallet as WestendPallet, + asset_hub_westend_emulated_chain::{ + asset_hub_westend_runtime::xcm_config::LocationToAccountId as AssetHubLocationToAccountId, + AssetHubWestendParaPallet as AssetHubWestendPallet, + }, + collectives_westend_emulated_chain::{ + collectives_westend_runtime::fellowship as collectives_fellowship, + CollectivesWestendParaPallet as CollectivesWestendPallet, + }, + westend_emulated_chain::{ + westend_runtime::{governance as westend_governance, OriginCaller as WestendOriginCaller}, + WestendRelayPallet as WestendPallet, + }, AssetHubWestendPara as AssetHubWestend, CollectivesWestendPara as CollectivesWestend, WestendRelay as Westend, }; diff --git a/cumulus/parachains/integration-tests/emulated/tests/collectives/collectives-westend/src/tests/fellowship_treasury.rs b/cumulus/parachains/integration-tests/emulated/tests/collectives/collectives-westend/src/tests/fellowship_treasury.rs index bde1220e2495..abd9a982c8ed 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/collectives/collectives-westend/src/tests/fellowship_treasury.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/collectives/collectives-westend/src/tests/fellowship_treasury.rs @@ -14,14 +14,12 @@ // limitations under the License. use crate::*; -use asset_hub_westend_runtime::xcm_config::LocationToAccountId as AssetHubLocationToAccountId; use emulated_integration_tests_common::accounts::ALICE; use frame_support::{ assert_ok, dispatch::RawOrigin, instances::Instance1, sp_runtime::traits::Dispatchable, traits::fungible::Inspect, }; use polkadot_runtime_common::impls::VersionedLocatableAsset; -use westend_runtime::OriginCaller; use westend_runtime_constants::currency::UNITS; use xcm_executor::traits::ConvertLocation; @@ -65,7 +63,7 @@ fn fellowship_treasury_spend() { let treasury_location: Location = (Parent, PalletInstance(37)).into(); let teleport_call = RuntimeCall::Utility(pallet_utility::Call::::dispatch_as { - as_origin: bx!(OriginCaller::system(RawOrigin::Signed(treasury_account))), + as_origin: bx!(WestendOriginCaller::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)), @@ -97,7 +95,7 @@ fn fellowship_treasury_spend() { // Fund Fellowship Treasury from Westend Treasury. let treasury_origin: RuntimeOrigin = - westend_runtime::governance::pallet_custom_origins::Origin::Treasurer.into(); + westend_governance::pallet_custom_origins::Origin::Treasurer.into(); let fellowship_treasury_location: Location = Location::new(1, [Parachain(1001), PalletInstance(65)]); let asset_hub_location: Location = [Parachain(1000)].into(); @@ -170,8 +168,7 @@ fn fellowship_treasury_spend() { // Fund Alice account from Fellowship Treasury. let fellows_origin: RuntimeOrigin = - collectives_westend_runtime::fellowship::pallet_fellowship_origins::Origin::Fellows - .into(); + collectives_fellowship::pallet_fellowship_origins::Origin::Fellows.into(); let asset_hub_location: Location = (Parent, Parachain(1000)).into(); let native_asset = Location::parent(); diff --git a/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/Cargo.toml b/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/Cargo.toml index 5221b782ac64..011be93ecac7 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/Cargo.toml +++ b/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/Cargo.toml @@ -11,22 +11,20 @@ publish = false codec = { workspace = true } # Substrate -sp-runtime = { workspace = true } frame-support = { workspace = true } pallet-balances = { workspace = true } pallet-message-queue = { workspace = true } pallet-identity = { workspace = true } +sp-runtime = { workspace = true } # Polkadot +polkadot-runtime-common = { workspace = true, default-features = true } +rococo-runtime-constants = { workspace = true, default-features = true } xcm = { workspace = true } xcm-executor = { workspace = true } -rococo-runtime = { workspace = true } -rococo-runtime-constants = { workspace = true, default-features = true } -polkadot-runtime-common = { workspace = true, default-features = true } # Cumulus asset-test-utils = { workspace = true, default-features = true } -parachains-common = { workspace = true, default-features = true } -people-rococo-runtime = { workspace = true } emulated-integration-tests-common = { workspace = true } +parachains-common = { workspace = true, default-features = true } rococo-system-emulated-network = { workspace = true } diff --git a/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/lib.rs b/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/lib.rs index 38ff08b486d4..6c23c2f1f292 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/lib.rs @@ -37,9 +37,19 @@ mod imports { pub use parachains_common::Balance; pub use rococo_system_emulated_network::{ people_rococo_emulated_chain::{ - genesis::ED as PEOPLE_ROCOCO_ED, PeopleRococoParaPallet as PeopleRococoPallet, + genesis::ED as PEOPLE_ROCOCO_ED, + people_rococo_runtime::{people, xcm_config::XcmConfig as PeopleRococoXcmConfig}, + PeopleRococoParaPallet as PeopleRococoPallet, + }, + rococo_emulated_chain::{ + genesis::ED as ROCOCO_ED, + rococo_runtime::{ + xcm_config::XcmConfig as RococoXcmConfig, BasicDeposit, ByteDeposit, + MaxAdditionalFields, MaxSubAccounts, RuntimeOrigin as RococoOrigin, + SubAccountDeposit, + }, + RococoRelayPallet as RococoPallet, }, - rococo_emulated_chain::{genesis::ED as ROCOCO_ED, RococoRelayPallet as RococoPallet}, PeopleRococoPara as PeopleRococo, PeopleRococoParaReceiver as PeopleRococoReceiver, PeopleRococoParaSender as PeopleRococoSender, RococoRelay as Rococo, RococoRelayReceiver as RococoReceiver, RococoRelaySender as RococoSender, diff --git a/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/reap_identity.rs b/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/reap_identity.rs index 3f1f8638d6fa..342a8f053f60 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/reap_identity.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/reap_identity.rs @@ -42,14 +42,10 @@ use crate::imports::*; use frame_support::BoundedVec; use pallet_balances::Event as BalancesEvent; use pallet_identity::{legacy::IdentityInfo, Data, Event as IdentityEvent}; -use people_rococo_runtime::people::{ +use people::{ BasicDeposit as BasicDepositParachain, ByteDeposit as ByteDepositParachain, IdentityInfo as IdentityInfoParachain, SubAccountDeposit as SubAccountDepositParachain, }; -use rococo_runtime::{ - BasicDeposit, ByteDeposit, MaxAdditionalFields, MaxSubAccounts, RuntimeOrigin as RococoOrigin, - SubAccountDeposit, -}; use rococo_runtime_constants::currency::*; use rococo_system_emulated_network::{ rococo_emulated_chain::RococoRelayPallet, RococoRelay, RococoRelaySender, diff --git a/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/teleport.rs b/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/teleport.rs index 350d87d638ab..f1070ecfa0e8 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/teleport.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/teleport.rs @@ -14,8 +14,6 @@ // limitations under the License. use crate::imports::*; -use people_rococo_runtime::xcm_config::XcmConfig as PeopleRococoXcmConfig; -use rococo_runtime::xcm_config::XcmConfig as RococoXcmConfig; fn relay_origin_assertions(t: RelayToSystemParaTest) { type RuntimeEvent = ::RuntimeEvent; @@ -157,7 +155,9 @@ fn limited_teleport_native_assets_from_relay_to_system_para_works() { let delivery_fees = Rococo::execute_with(|| { xcm_helpers::teleport_assets_delivery_fees::< ::XcmSender, - >(test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest) + >( + test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest + ) }); let sender_balance_after = test.sender.balance; @@ -206,7 +206,9 @@ fn limited_teleport_native_assets_back_from_system_para_to_relay_works() { let delivery_fees = PeopleRococo::execute_with(|| { xcm_helpers::teleport_assets_delivery_fees::< ::XcmSender, - >(test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest) + >( + test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest + ) }); // Sender's balance is reduced @@ -250,7 +252,9 @@ fn limited_teleport_native_assets_from_system_para_to_relay_fails() { let delivery_fees = PeopleRococo::execute_with(|| { xcm_helpers::teleport_assets_delivery_fees::< ::XcmSender, - >(test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest) + >( + test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest + ) }); // Sender's balance is reduced diff --git a/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/Cargo.toml b/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/Cargo.toml index 58dbf82f222f..f7e1cce85a2c 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/Cargo.toml +++ b/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/Cargo.toml @@ -11,22 +11,20 @@ publish = false codec = { workspace = true } # Substrate -sp-runtime = { workspace = true } frame-support = { workspace = true } pallet-balances = { workspace = true } pallet-message-queue = { workspace = true } pallet-identity = { workspace = true } +sp-runtime = { workspace = true } # Polkadot +polkadot-runtime-common = { workspace = true, default-features = true } +westend-runtime-constants = { workspace = true, default-features = true } xcm = { workspace = true } xcm-executor = { workspace = true } -westend-runtime = { workspace = true } -westend-runtime-constants = { workspace = true, default-features = true } -polkadot-runtime-common = { workspace = true, default-features = true } # Cumulus asset-test-utils = { workspace = true, default-features = true } -parachains-common = { workspace = true, default-features = true } -people-westend-runtime = { workspace = true } emulated-integration-tests-common = { workspace = true } +parachains-common = { workspace = true, default-features = true } westend-system-emulated-network = { workspace = true } diff --git a/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/lib.rs b/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/lib.rs index 77ac7cfc78c7..ce1ed9751a2e 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/lib.rs @@ -35,10 +35,21 @@ mod imports { }; pub use parachains_common::Balance; pub use westend_system_emulated_network::{ + self, people_westend_emulated_chain::{ - genesis::ED as PEOPLE_WESTEND_ED, PeopleWestendParaPallet as PeopleWestendPallet, + genesis::ED as PEOPLE_WESTEND_ED, + people_westend_runtime::{people, xcm_config::XcmConfig as PeopleWestendXcmConfig}, + PeopleWestendParaPallet as PeopleWestendPallet, + }, + westend_emulated_chain::{ + genesis::ED as WESTEND_ED, + westend_runtime::{ + xcm_config::XcmConfig as WestendXcmConfig, BasicDeposit, ByteDeposit, + MaxAdditionalFields, MaxSubAccounts, RuntimeOrigin as WestendOrigin, + SubAccountDeposit, + }, + WestendRelayPallet as WestendPallet, }, - westend_emulated_chain::{genesis::ED as WESTEND_ED, WestendRelayPallet as WestendPallet}, PeopleWestendPara as PeopleWestend, PeopleWestendParaReceiver as PeopleWestendReceiver, PeopleWestendParaSender as PeopleWestendSender, WestendRelay as Westend, WestendRelayReceiver as WestendReceiver, WestendRelaySender as WestendSender, diff --git a/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/reap_identity.rs b/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/reap_identity.rs index 3ed8592918d6..28d1be853204 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/reap_identity.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/reap_identity.rs @@ -42,14 +42,10 @@ use crate::imports::*; use frame_support::BoundedVec; use pallet_balances::Event as BalancesEvent; use pallet_identity::{legacy::IdentityInfo, Data, Event as IdentityEvent}; -use people_westend_runtime::people::{ +use people::{ BasicDeposit as BasicDepositParachain, ByteDeposit as ByteDepositParachain, IdentityInfo as IdentityInfoParachain, SubAccountDeposit as SubAccountDepositParachain, }; -use westend_runtime::{ - BasicDeposit, ByteDeposit, MaxAdditionalFields, MaxSubAccounts, RuntimeOrigin as WestendOrigin, - SubAccountDeposit, -}; use westend_runtime_constants::currency::*; use westend_system_emulated_network::{ westend_emulated_chain::WestendRelayPallet, WestendRelay, WestendRelaySender, diff --git a/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/teleport.rs b/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/teleport.rs index 8697477ba769..f22261d9a9e9 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/teleport.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/teleport.rs @@ -14,8 +14,6 @@ // limitations under the License. use crate::imports::*; -use people_westend_runtime::xcm_config::XcmConfig as PeopleWestendXcmConfig; -use westend_runtime::xcm_config::XcmConfig as WestendXcmConfig; fn relay_origin_assertions(t: RelayToSystemParaTest) { type RuntimeEvent = ::RuntimeEvent; @@ -157,7 +155,9 @@ fn limited_teleport_native_assets_from_relay_to_system_para_works() { let delivery_fees = Westend::execute_with(|| { xcm_helpers::teleport_assets_delivery_fees::< ::XcmSender, - >(test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest) + >( + test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest + ) }); let sender_balance_after = test.sender.balance; @@ -206,7 +206,9 @@ fn limited_teleport_native_assets_back_from_system_para_to_relay_works() { let delivery_fees = PeopleWestend::execute_with(|| { xcm_helpers::teleport_assets_delivery_fees::< ::XcmSender, - >(test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest) + >( + test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest + ) }); // Sender's balance is reduced @@ -250,7 +252,9 @@ fn limited_teleport_native_assets_from_system_para_to_relay_fails() { let delivery_fees = PeopleWestend::execute_with(|| { xcm_helpers::teleport_assets_delivery_fees::< ::XcmSender, - >(test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest) + >( + test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest + ) }); // Sender's balance is reduced From 7a55c8ba08b35dc9bee4cfb1f5b68487e349408d Mon Sep 17 00:00:00 2001 From: Adrian Catangiu Date: Fri, 28 Jun 2024 18:41:53 +0300 Subject: [PATCH 3/5] refactor bridge-hub-westend as well --- .../src/tests/asset_transfers.rs | 4 +- .../src/tests/asset_transfers.rs | 212 ++++++++++-------- 2 files changed, 117 insertions(+), 99 deletions(-) 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 70c9e0889483..6053936487b2 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 @@ -277,7 +277,7 @@ fn send_back_wnds_from_asset_hub_rococo_to_asset_hub_westend() { assert_eq!(sender_wnds_before, prefund_amount); let receiver_wnds_before = ::account_data_of(receiver.clone()).free; - // send WNDs, use them for fees + // send back WNDs, use them for fees send_assets_over_bridge(|| { let destination = asset_hub_westend_location(); let assets: Assets = (wnd_at_asset_hub_rococo, amount_to_send).into(); @@ -351,7 +351,7 @@ fn send_rocs_from_penpal_rococo_through_asset_hub_rococo_to_asset_hub_westend() let fees_id: AssetId = roc_at_rococo_parachains.clone().into(); let fees_transfer_type = TransferType::RemoteReserve(local_asset_hub.into()); let beneficiary: Location = - AccountId32Junction { network: None, id: AssetHubWestendReceiver::get().into() }.into(); + AccountId32Junction { network: None, id: receiver.clone().into() }.into(); let custom_xcm_on_dest = Xcm::<()>(vec![DepositAsset { assets: Wild(AllCounted(assets.len() as u32)), beneficiary, 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 63ccb0ff4862..1b876882ca02 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 @@ -14,91 +14,99 @@ // limitations under the License. use crate::tests::*; -fn send_assets_from_asset_hub_westend_to_asset_hub_rococo(assets: Assets, fee_idx: u32) { - let destination = asset_hub_rococo_location(); - +fn send_assets_over_bridge(send_fn: F) { // fund the AHW's SA on BHW for paying bridge transport fees BridgeHubWestend::fund_para_sovereign(AssetHubWestend::para_id(), 10_000_000_000_000u128); // set XCM versions - AssetHubWestend::force_xcm_version(destination.clone(), XCM_VERSION); + let local_asset_hub = PenpalB::sibling_location_of(AssetHubWestend::para_id()); + PenpalB::force_xcm_version(local_asset_hub.clone(), XCM_VERSION); + AssetHubWestend::force_xcm_version(asset_hub_rococo_location(), XCM_VERSION); BridgeHubWestend::force_xcm_version(bridge_hub_rococo_location(), XCM_VERSION); // send message over bridge - assert_ok!(send_assets_from_asset_hub_westend(destination, assets, fee_idx)); + send_fn(); + + // process and verify intermediary hops assert_bridge_hub_westend_message_accepted(true); assert_bridge_hub_rococo_message_received(); } -fn send_asset_from_penpal_westend_through_local_asset_hub_to_rococo_asset_hub( - id: Location, - transfer_amount: u128, -) { - let destination = asset_hub_rococo_location(); - let local_asset_hub: Location = PenpalB::sibling_location_of(AssetHubWestend::para_id()); - let sov_penpal_on_ahw = AssetHubWestend::sovereign_account_id_of( - AssetHubWestend::sibling_location_of(PenpalB::para_id()), - ); - let sov_ahr_on_ahw = AssetHubWestend::sovereign_account_of_parachain_on_other_global_consensus( - Rococo, - AssetHubRococo::para_id(), - ); - - // fund the AHW's SA on BHW for paying bridge transport fees - BridgeHubWestend::fund_para_sovereign(AssetHubWestend::para_id(), 10_000_000_000_000u128); - - // set XCM versions - PenpalB::force_xcm_version(local_asset_hub.clone(), XCM_VERSION); - AssetHubWestend::force_xcm_version(destination.clone(), XCM_VERSION); - BridgeHubWestend::force_xcm_version(bridge_hub_rococo_location(), XCM_VERSION); +fn set_up_wnds_for_penpal_westend_through_ahw_to_ahr( + sender: &AccountId, + amount: u128, +) -> (Location, v3::Location) { + let wnd_at_westend_parachains = wnd_at_ah_westend(); + let wnd_at_asset_hub_rococo = bridged_wnd_at_ah_rococo().try_into().unwrap(); + create_foreign_on_ah_rococo(wnd_at_asset_hub_rococo, true); - // send message over bridge - assert_ok!(PenpalB::execute_with(|| { - let signed_origin = ::RuntimeOrigin::signed(PenpalBSender::get()); - let beneficiary: Location = - AccountId32Junction { network: None, id: AssetHubRococoReceiver::get().into() }.into(); - let assets: Assets = (id.clone(), transfer_amount).into(); - let fees_id: AssetId = id.into(); - let custom_xcm_on_dest = Xcm::<()>(vec![DepositAsset { - assets: Wild(AllCounted(assets.len() as u32)), - beneficiary, - }]); + let penpal_location = AssetHubWestend::sibling_location_of(PenpalB::para_id()); + let sov_penpal_on_ahw = AssetHubWestend::sovereign_account_id_of(penpal_location); + // fund Penpal's sovereign account on AssetHub + AssetHubWestend::fund_accounts(vec![(sov_penpal_on_ahw.into(), amount * 2)]); + // fund Penpal's sender account + PenpalB::mint_foreign_asset( + ::RuntimeOrigin::signed(PenpalAssetOwner::get()), + wnd_at_westend_parachains.clone(), + sender.clone(), + amount * 2, + ); + (wnd_at_westend_parachains, wnd_at_asset_hub_rococo) +} - ::PolkadotXcm::transfer_assets_using_type_and_then( - signed_origin, - bx!(destination.into()), - bx!(assets.into()), - bx!(TransferType::RemoteReserve(local_asset_hub.clone().into())), - bx!(fees_id.into()), - bx!(TransferType::RemoteReserve(local_asset_hub.into())), - bx!(VersionedXcm::from(custom_xcm_on_dest)), - WeightLimit::Unlimited, - ) - })); - AssetHubWestend::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - assert_expected_events!( - AssetHubWestend, - vec![ - // Amount to reserve transfer is withdrawn from Penpal's sovereign account - RuntimeEvent::Balances( - pallet_balances::Event::Burned { who, amount } - ) => { - who: *who == sov_penpal_on_ahw.clone().into(), - amount: *amount == transfer_amount, - }, - // Amount deposited in AHR's sovereign account - RuntimeEvent::Balances(pallet_balances::Event::Minted { who, .. }) => { - who: *who == sov_ahr_on_ahw.clone().into(), - }, - RuntimeEvent::XcmpQueue( - cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { .. } - ) => {}, - ] +fn send_assets_from_penpal_westend_through_westend_ah_to_rococo_ah( + destination: Location, + assets: (Assets, TransferType), + fees: (AssetId, TransferType), + custom_xcm_on_dest: Xcm<()>, +) { + send_assets_over_bridge(|| { + let sov_penpal_on_ahw = AssetHubWestend::sovereign_account_id_of( + AssetHubWestend::sibling_location_of(PenpalB::para_id()), ); + let sov_ahr_on_ahw = + AssetHubWestend::sovereign_account_of_parachain_on_other_global_consensus( + Rococo, + AssetHubRococo::para_id(), + ); + + // send message over bridge + assert_ok!(PenpalB::execute_with(|| { + let signed_origin = ::RuntimeOrigin::signed(PenpalBSender::get()); + ::PolkadotXcm::transfer_assets_using_type_and_then( + signed_origin, + bx!(destination.into()), + bx!(assets.0.into()), + bx!(assets.1), + bx!(fees.0.into()), + bx!(fees.1), + bx!(VersionedXcm::from(custom_xcm_on_dest)), + WeightLimit::Unlimited, + ) + })); + // verify intermediary AH Westend hop + AssetHubWestend::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + assert_expected_events!( + AssetHubWestend, + vec![ + // Amount to reserve transfer is withdrawn from Penpal's sovereign account + RuntimeEvent::Balances( + pallet_balances::Event::Burned { who, .. } + ) => { + who: *who == sov_penpal_on_ahw.clone().into(), + }, + // Amount deposited in AHR's sovereign account + RuntimeEvent::Balances(pallet_balances::Event::Minted { who, .. }) => { + who: *who == sov_ahr_on_ahw.clone().into(), + }, + RuntimeEvent::XcmpQueue( + cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { .. } + ) => {}, + ] + ); + }); }); - assert_bridge_hub_westend_message_accepted(true); - assert_bridge_hub_rococo_message_received(); } #[test] @@ -124,9 +132,12 @@ fn send_wnds_from_asset_hub_westend_to_asset_hub_rococo() { foreign_balance_on_ah_rococo(bridged_wnd_at_asset_hub_rococo, &receiver); // send WNDs, use them for fees - let assets: Assets = (wnd_at_asset_hub_westend, amount).into(); - let fee_index = 0; - send_assets_from_asset_hub_westend_to_asset_hub_rococo(assets, fee_index); + send_assets_over_bridge(|| { + let destination = asset_hub_rococo_location(); + let assets: Assets = (wnd_at_asset_hub_westend, amount).into(); + let fee_idx = 0; + assert_ok!(send_assets_from_asset_hub_westend(destination, assets, fee_idx)); + }); // verify expected events on final destination AssetHubRococo::execute_with(|| { @@ -172,6 +183,7 @@ fn send_wnds_from_asset_hub_westend_to_asset_hub_rococo() { /// Ethereum to Rococo over Snowbridge, then bridged over to Westend through this bridge). fn send_back_rocs_usdt_and_weth_from_asset_hub_westend_to_asset_hub_rococo() { let prefund_amount = 10_000_000_000_000u128; + let amount_to_send = ASSET_HUB_ROCOCO_ED * 1_000; let sender = AssetHubWestendSender::get(); let receiver = AssetHubRococoReceiver::get(); let bridged_roc_at_asset_hub_westend = bridged_roc_at_ah_westend(); @@ -200,11 +212,14 @@ fn send_back_rocs_usdt_and_weth_from_asset_hub_westend_to_asset_hub_rococo() { assert_eq!(sender_rocs_before, prefund_amount); let receiver_rocs_before = ::account_data_of(receiver.clone()).free; - let amount_to_send = ASSET_HUB_ROCOCO_ED * 1_000; - send_assets_from_asset_hub_westend_to_asset_hub_rococo( - (bridged_roc_at_asset_hub_westend, amount_to_send).into(), - 0, - ); + // send back ROCs, use them for fees + send_assets_over_bridge(|| { + let destination = asset_hub_rococo_location(); + let assets: Assets = (bridged_roc_at_asset_hub_westend, amount_to_send).into(); + let fee_idx = 0; + assert_ok!(send_assets_from_asset_hub_westend(destination, assets, fee_idx)); + }); + AssetHubRococo::execute_with(|| { type RuntimeEvent = ::RuntimeEvent; assert_expected_events!( @@ -335,24 +350,12 @@ fn send_back_rocs_usdt_and_weth_from_asset_hub_westend_to_asset_hub_rococo() { #[test] fn send_wnds_from_penpal_westend_through_asset_hub_westend_to_asset_hub_rococo() { - let wnd_at_westend_parachains = wnd_at_ah_westend(); - let wnd_at_asset_hub_rococo = bridged_wnd_at_ah_rococo().try_into().unwrap(); - create_foreign_on_ah_rococo(wnd_at_asset_hub_rococo, true); - let amount = ASSET_HUB_WESTEND_ED * 10_000_000; let sender = PenpalBSender::get(); let receiver = AssetHubRococoReceiver::get(); - let penpal_location = AssetHubWestend::sibling_location_of(PenpalB::para_id()); - let sov_penpal_on_ahw = AssetHubWestend::sovereign_account_id_of(penpal_location); - // fund Penpal's sovereign account on AssetHub - AssetHubWestend::fund_accounts(vec![(sov_penpal_on_ahw.into(), amount * 2)]); - // fund Penpal's sender account - PenpalB::mint_foreign_asset( - ::RuntimeOrigin::signed(PenpalAssetOwner::get()), - wnd_at_westend_parachains.clone(), - sender.clone(), - amount * 2, - ); + let local_asset_hub = PenpalB::sibling_location_of(AssetHubWestend::para_id()); + let (wnd_at_westend_parachains, wnd_at_asset_hub_rococo) = + set_up_wnds_for_penpal_westend_through_ahw_to_ahr(&sender, amount); let sov_ahr_on_ahw = AssetHubWestend::sovereign_account_of_parachain_on_other_global_consensus( Rococo, @@ -367,10 +370,25 @@ fn send_wnds_from_penpal_westend_through_asset_hub_westend_to_asset_hub_rococo() let receiver_wnds_before = foreign_balance_on_ah_rococo(wnd_at_asset_hub_rococo, &receiver); // Send WNDs over bridge - send_asset_from_penpal_westend_through_local_asset_hub_to_rococo_asset_hub( - wnd_at_westend_parachains.clone(), - amount, - ); + { + let destination = asset_hub_rococo_location(); + let assets: Assets = (wnd_at_westend_parachains.clone(), amount).into(); + let asset_transfer_type = TransferType::RemoteReserve(local_asset_hub.clone().into()); + let fees_id: AssetId = wnd_at_westend_parachains.clone().into(); + let fees_transfer_type = TransferType::RemoteReserve(local_asset_hub.into()); + let beneficiary: Location = + AccountId32Junction { network: None, id: receiver.clone().into() }.into(); + let custom_xcm_on_dest = Xcm::<()>(vec![DepositAsset { + assets: Wild(AllCounted(assets.len() as u32)), + beneficiary, + }]); + send_assets_from_penpal_westend_through_westend_ah_to_rococo_ah( + destination, + (assets, asset_transfer_type), + (fees_id, fees_transfer_type), + custom_xcm_on_dest, + ); + } AssetHubRococo::execute_with(|| { type RuntimeEvent = ::RuntimeEvent; From f77060b95ae45e48a683328fd9a0d393d2c16c87 Mon Sep 17 00:00:00 2001 From: Adrian Catangiu Date: Mon, 1 Jul 2024 16:08:10 +0300 Subject: [PATCH 4/5] add the other direction as well --- .../bridges/bridge-hub-westend/src/lib.rs | 5 +- .../src/tests/asset_transfers.rs | 119 ++++++++++++++++++ 2 files changed, 123 insertions(+), 1 deletion(-) 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 a0dfcaa74947..3b0fcea57a26 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 @@ -51,7 +51,10 @@ mod imports { genesis::ED as BRIDGE_HUB_WESTEND_ED, BridgeHubWestendParaPallet as BridgeHubWestendPallet, BridgeHubWestendXcmConfig, }, - penpal_emulated_chain::{PenpalAssetOwner, PenpalBParaPallet as PenpalBPallet}, + penpal_emulated_chain::{ + penpal_runtime::xcm_config::UniversalLocation as PenpalUniversalLocation, + PenpalAssetOwner, PenpalBParaPallet as PenpalBPallet, + }, westend_emulated_chain::WestendRelayPallet as WestendPallet, AssetHubRococoPara as AssetHubRococo, AssetHubRococoParaReceiver as AssetHubRococoReceiver, AssetHubRococoParaSender as AssetHubRococoSender, AssetHubWestendPara as AssetHubWestend, 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 1b876882ca02..0c0b04cd45a9 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 @@ -390,6 +390,7 @@ fn send_wnds_from_penpal_westend_through_asset_hub_westend_to_asset_hub_rococo() ); } + // process AHR incoming message and check events AssetHubRococo::execute_with(|| { type RuntimeEvent = ::RuntimeEvent; assert_expected_events!( @@ -424,3 +425,121 @@ fn send_wnds_from_penpal_westend_through_asset_hub_westend_to_asset_hub_rococo() assert!(wnds_in_reserve_on_ahw_after > wnds_in_reserve_on_ahw_before); assert!(wnds_in_reserve_on_ahw_after <= wnds_in_reserve_on_ahw_before + amount); } + +#[test] +fn send_back_rocs_from_penpal_westend_through_asset_hub_westend_to_asset_hub_rococo() { + let roc_at_westend_parachains = bridged_roc_at_ah_westend(); + let roc_at_westend_parachains_v3 = roc_at_westend_parachains.clone().try_into().unwrap(); + let amount = ASSET_HUB_WESTEND_ED * 10_000_000; + let sender = PenpalBSender::get(); + let receiver = AssetHubRococoReceiver::get(); + + // set up WNDs for transfer + let (wnd_at_westend_parachains, _) = + set_up_wnds_for_penpal_westend_through_ahw_to_ahr(&sender, amount); + + // set up ROCs for transfer + let penpal_location = AssetHubWestend::sibling_location_of(PenpalB::para_id()); + let sov_penpal_on_ahr = AssetHubWestend::sovereign_account_id_of(penpal_location); + let prefund_accounts = vec![(sov_penpal_on_ahr, amount * 2)]; + create_foreign_on_ah_westend(roc_at_westend_parachains_v3, true, prefund_accounts); + let asset_owner: AccountId = AssetHubWestend::account_id_of(ALICE); + PenpalB::force_create_foreign_asset( + roc_at_westend_parachains.clone(), + asset_owner.clone(), + true, + ASSET_MIN_BALANCE, + vec![(sender.clone(), amount * 2)], + ); + + // fund the AHW's SA on AHR with the ROC tokens held in reserve + let sov_ahw_on_ahr = AssetHubRococo::sovereign_account_of_parachain_on_other_global_consensus( + NetworkId::Westend, + AssetHubWestend::para_id(), + ); + AssetHubRococo::fund_accounts(vec![(sov_ahw_on_ahr.clone(), amount * 2)]); + + // balances before + let sender_rocs_before = PenpalB::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(roc_at_westend_parachains.clone().into(), &sender) + }); + let receiver_rocs_before = ::account_data_of(receiver.clone()).free; + + // send ROCs over the bridge, WNDs only used to pay fees on local AH, pay with ROC on remote AH + { + let final_destination = asset_hub_rococo_location(); + let intermediary_hop = PenpalB::sibling_location_of(AssetHubWestend::para_id()); + let context = PenpalB::execute_with(|| PenpalUniversalLocation::get()); + + // what happens at final destination + let beneficiary = AccountId32Junction { network: None, id: receiver.clone().into() }.into(); + // use ROC as fees on the final destination (AHW) + let remote_fees: Asset = (roc_at_westend_parachains.clone(), amount).into(); + let remote_fees = remote_fees.reanchored(&final_destination, &context).unwrap(); + // buy execution using ROCs, then deposit all remaining ROCs + let xcm_on_final_dest = Xcm::<()>(vec![ + BuyExecution { fees: remote_fees, weight_limit: WeightLimit::Unlimited }, + DepositAsset { assets: Wild(AllCounted(1)), beneficiary }, + ]); + + // what happens at intermediary hop + // reanchor final dest (Asset Hub Rococo) to the view of hop (Asset Hub Westend) + let mut final_destination = final_destination.clone(); + final_destination.reanchor(&intermediary_hop, &context).unwrap(); + // reanchor ROCs to the view of hop (Asset Hub Westend) + let asset: Asset = (roc_at_westend_parachains.clone(), amount).into(); + let asset = asset.reanchored(&intermediary_hop, &context).unwrap(); + // on Asset Hub Westend, forward a request to withdraw ROCs from reserve on Asset Hub Rococo + let xcm_on_hop = Xcm::<()>(vec![InitiateReserveWithdraw { + assets: Definite(asset.into()), // ROCs + reserve: final_destination, // AHR + xcm: xcm_on_final_dest, // XCM to execute on AHR + }]); + // assets to send from Penpal and how they reach the intermediary hop + let assets: Assets = vec![ + (roc_at_westend_parachains.clone(), amount).into(), + (wnd_at_westend_parachains.clone(), amount).into(), + ] + .into(); + let asset_transfer_type = TransferType::DestinationReserve; + let fees_id: AssetId = wnd_at_westend_parachains.into(); + let fees_transfer_type = TransferType::DestinationReserve; + + // initiate the transfer + send_assets_from_penpal_westend_through_westend_ah_to_rococo_ah( + intermediary_hop, + (assets, asset_transfer_type), + (fees_id, fees_transfer_type), + xcm_on_hop, + ); + } + + // process AHR incoming message and check events + AssetHubRococo::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + assert_expected_events!( + AssetHubRococo, + vec![ + // issue WNDs on AHR + RuntimeEvent::Balances(pallet_balances::Event::Issued { .. }) => {}, + // message processed successfully + RuntimeEvent::MessageQueue( + pallet_message_queue::Event::Processed { success: true, .. } + ) => {}, + ] + ); + }); + + let sender_rocs_after = PenpalB::execute_with(|| { + type ForeignAssets = ::ForeignAssets; + >::balance(roc_at_westend_parachains.into(), &sender) + }); + let receiver_rocs_after = ::account_data_of(receiver).free; + + // Sender's balance is reduced by sent "amount" + assert_eq!(sender_rocs_after, sender_rocs_before - amount); + // Receiver's balance is increased by no more than "amount" + assert!(receiver_rocs_after > receiver_rocs_before); + assert!(receiver_rocs_after <= receiver_rocs_before + amount); +} From 719e3008c57c45c4c5a162d33147d5b974b2a04e Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Mon, 1 Jul 2024 13:12:29 +0000 Subject: [PATCH 5/5] ".git/.scripts/commands/fmt/fmt.sh" --- .../tests/people/people-rococo/src/tests/teleport.rs | 12 +++--------- .../people/people-westend/src/tests/teleport.rs | 12 +++--------- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/teleport.rs b/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/teleport.rs index f1070ecfa0e8..4410d1bd40dc 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/teleport.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/teleport.rs @@ -155,9 +155,7 @@ fn limited_teleport_native_assets_from_relay_to_system_para_works() { let delivery_fees = Rococo::execute_with(|| { xcm_helpers::teleport_assets_delivery_fees::< ::XcmSender, - >( - test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest - ) + >(test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest) }); let sender_balance_after = test.sender.balance; @@ -206,9 +204,7 @@ fn limited_teleport_native_assets_back_from_system_para_to_relay_works() { let delivery_fees = PeopleRococo::execute_with(|| { xcm_helpers::teleport_assets_delivery_fees::< ::XcmSender, - >( - test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest - ) + >(test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest) }); // Sender's balance is reduced @@ -252,9 +248,7 @@ fn limited_teleport_native_assets_from_system_para_to_relay_fails() { let delivery_fees = PeopleRococo::execute_with(|| { xcm_helpers::teleport_assets_delivery_fees::< ::XcmSender, - >( - test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest - ) + >(test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest) }); // Sender's balance is reduced diff --git a/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/teleport.rs b/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/teleport.rs index f22261d9a9e9..6fd3cdeb61fb 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/teleport.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/teleport.rs @@ -155,9 +155,7 @@ fn limited_teleport_native_assets_from_relay_to_system_para_works() { let delivery_fees = Westend::execute_with(|| { xcm_helpers::teleport_assets_delivery_fees::< ::XcmSender, - >( - test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest - ) + >(test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest) }); let sender_balance_after = test.sender.balance; @@ -206,9 +204,7 @@ fn limited_teleport_native_assets_back_from_system_para_to_relay_works() { let delivery_fees = PeopleWestend::execute_with(|| { xcm_helpers::teleport_assets_delivery_fees::< ::XcmSender, - >( - test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest - ) + >(test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest) }); // Sender's balance is reduced @@ -252,9 +248,7 @@ fn limited_teleport_native_assets_from_system_para_to_relay_fails() { let delivery_fees = PeopleWestend::execute_with(|| { xcm_helpers::teleport_assets_delivery_fees::< ::XcmSender, - >( - test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest - ) + >(test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest) }); // Sender's balance is reduced