From 59929957f35889e202e6d723a5a99108055d092e Mon Sep 17 00:00:00 2001 From: NachoPal Date: Sat, 2 Sep 2023 20:08:32 +0200 Subject: [PATCH 01/27] migrate cumulus #2842 --- Cargo.lock | 23 ++++ Cargo.toml | 2 + cumulus/parachains/common/src/xcm_config.rs | 56 ++++++++++ .../assets/asset-hub-kusama/src/lib.rs | 2 + .../asset-hub-kusama/src/tests/teleport.rs | 13 +++ .../assets/asset-hub-polkadot/src/lib.rs | 3 + .../asset-hub-polkadot/src/tests/teleport.rs | 12 +++ .../assets/asset-hub-rococo/Cargo.toml | 24 +++++ .../assets/asset-hub-rococo/src/lib.rs | 28 +++++ .../assets/asset-hub-rococo/src/tests/mod.rs | 17 +++ .../asset-hub-rococo/src/tests/teleport.rs | 29 +++++ .../assets/asset-hub-westend/src/lib.rs | 3 +- .../asset-hub-westend/src/tests/teleport.rs | 12 +++ .../bridges/bridge-hub-rococo/src/lib.rs | 5 +- .../bridge-hub-rococo/src/tests/mod.rs | 1 + .../bridge-hub-rococo/src/tests/teleport.rs | 29 +++++ .../collectives-polkadot/src/lib.rs | 7 +- .../src/tests/fellowship.rs | 8 +- .../collectives-polkadot/src/tests/mod.rs | 1 + .../src/tests/teleport.rs | 29 +++++ .../collectives-westend/Cargo.toml | 26 +++++ .../collectives-westend/src/lib.rs | 28 +++++ .../collectives-westend/src/tests/mod.rs | 17 +++ .../collectives-westend/src/tests/teleport.rs | 29 +++++ .../emulated/common/Cargo.toml | 1 + .../emulated/common/src/lib.rs | 50 +++++++-- .../emulated/common/src/macros.rs | 101 ++++++++++++++++++ .../assets/asset-hub-kusama/src/xcm_config.rs | 21 ++-- .../asset-hub-polkadot/src/xcm_config.rs | 21 ++-- .../asset-hub-westend/src/xcm_config.rs | 21 ++-- .../bridge-hub-kusama/src/xcm_config.rs | 8 +- .../bridge-hub-polkadot/src/xcm_config.rs | 8 +- .../bridge-hub-rococo/src/xcm_config.rs | 8 +- .../collectives-polkadot/src/xcm_config.rs | 8 +- .../contracts-rococo/src/xcm_config.rs | 5 +- 35 files changed, 615 insertions(+), 41 deletions(-) create mode 100644 cumulus/parachains/integration-tests/emulated/assets/asset-hub-rococo/Cargo.toml create mode 100644 cumulus/parachains/integration-tests/emulated/assets/asset-hub-rococo/src/lib.rs create mode 100644 cumulus/parachains/integration-tests/emulated/assets/asset-hub-rococo/src/tests/mod.rs create mode 100644 cumulus/parachains/integration-tests/emulated/assets/asset-hub-rococo/src/tests/teleport.rs create mode 100644 cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/tests/teleport.rs create mode 100644 cumulus/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/tests/teleport.rs create mode 100644 cumulus/parachains/integration-tests/emulated/collectives/collectives-westend/Cargo.toml create mode 100644 cumulus/parachains/integration-tests/emulated/collectives/collectives-westend/src/lib.rs create mode 100644 cumulus/parachains/integration-tests/emulated/collectives/collectives-westend/src/tests/mod.rs create mode 100644 cumulus/parachains/integration-tests/emulated/collectives/collectives-westend/src/tests/teleport.rs create mode 100644 cumulus/parachains/integration-tests/emulated/common/src/macros.rs diff --git a/Cargo.lock b/Cargo.lock index 13bc2327daef8..e0cfa6bd4665e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -881,6 +881,17 @@ dependencies = [ "substrate-wasm-builder", ] +[[package]] +name = "asset-hub-rococo-integration-tests" +version = "1.0.0" +dependencies = [ + "frame-support", + "integration-tests-common", + "parity-scale-codec", + "staging-xcm", + "xcm-emulator", +] + [[package]] name = "asset-hub-westend-integration-tests" version = "1.0.0" @@ -2651,6 +2662,17 @@ dependencies = [ "substrate-wasm-builder", ] +[[package]] +name = "collectives-westend-integration-tests" +version = "0.1.0" +dependencies = [ + "frame-support", + "integration-tests-common", + "parity-scale-codec", + "staging-xcm", + "xcm-emulator", +] + [[package]] name = "color-eyre" version = "0.6.2" @@ -6421,6 +6443,7 @@ dependencies = [ "frame-support", "kusama-runtime-constants", "pallet-assets", + "pallet-balances", "pallet-bridge-messages", "pallet-im-online", "pallet-message-queue", diff --git a/Cargo.toml b/Cargo.toml index 4db27b98e9078..473cfc8621ff7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -61,9 +61,11 @@ members = [ "cumulus/parachains/common", "cumulus/parachains/integration-tests/emulated/assets/asset-hub-kusama", "cumulus/parachains/integration-tests/emulated/assets/asset-hub-polkadot", + "cumulus/parachains/integration-tests/emulated/assets/asset-hub-rococo", "cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend", "cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo", "cumulus/parachains/integration-tests/emulated/collectives/collectives-polkadot", + "cumulus/parachains/integration-tests/emulated/collectives/collectives-westend", "cumulus/parachains/integration-tests/emulated/common", "cumulus/parachains/pallets/parachain-info", "cumulus/parachains/pallets/ping", diff --git a/cumulus/parachains/common/src/xcm_config.rs b/cumulus/parachains/common/src/xcm_config.rs index 146671441453d..137c3446abe8b 100644 --- a/cumulus/parachains/common/src/xcm_config.rs +++ b/cumulus/parachains/common/src/xcm_config.rs @@ -78,3 +78,59 @@ impl> ContainsPair matches!(asset.id, Concrete(ref id) if id == origin && origin == &Location::get()) } } + +/// Accepts an asset if it is a native asset from the system (Relay Chain or system parachain). +pub struct ConcreteNativeAssetFromSystem; +impl ContainsPair for ConcreteNativeAssetFromSystem { + fn contains(asset: &MultiAsset, origin: &MultiLocation) -> bool { + log::trace!(target: "xcm::contains", "ConcreteNativeAssetFromSystem asset: {:?}, origin: {:?}", asset, origin); + let parent = MultiLocation::parent(); + let is_system = match origin { + // The Relay Chain + MultiLocation { parents: 1, interior: Here } => true, + // System parachain + MultiLocation { parents: 1, interior: X1(Parachain(id)) } if *id < 2000 => true, + // Others + _ => false, + }; + matches!(asset.id, Concrete(id) if id == parent && is_system) + } +} + +#[cfg(test)] +mod tests { + use super::{ + ConcreteNativeAssetFromSystem, ContainsPair, GeneralIndex, Here, MultiAsset, MultiLocation, + PalletInstance, Parachain, Parent, + }; + + #[test] + fn native_asset_from_sibling_system_para_works() { + let expected_asset: MultiAsset = (Parent, 1000000).into(); + let expected_origin: MultiLocation = (Parent, Parachain(1999)).into(); + + assert!(ConcreteNativeAssetFromSystem::contains(&expected_asset, &expected_origin)); + } + + #[test] + fn native_asset_from_sibling_system_para_fails_for_wrong_asset() { + let unexpected_assets: Vec = vec![ + (Here, 1000000).into(), + ((PalletInstance(50), GeneralIndex(1)), 1000000).into(), + ((Parent, Parachain(1000), PalletInstance(50), GeneralIndex(1)), 1000000).into(), + ]; + let expected_origin: MultiLocation = (Parent, Parachain(1000)).into(); + + unexpected_assets.iter().for_each(|asset| { + assert!(!ConcreteNativeAssetFromSystem::contains(asset, &expected_origin)); + }); + } + + #[test] + fn native_asset_from_sibling_system_para_fails_for_wrong_origin() { + let expected_asset: MultiAsset = (Parent, 1000000).into(); + let unexpected_origin: MultiLocation = (Parent, Parachain(2000)).into(); + + assert!(!ConcreteNativeAssetFromSystem::contains(&expected_asset, &unexpected_origin)); + } +} diff --git a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/lib.rs b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/lib.rs index 9325ca54b068f..cdedb33c39916 100644 --- a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/lib.rs @@ -26,10 +26,12 @@ pub use integration_tests_common::{ asset_hub_kusama::ED as ASSET_HUB_KUSAMA_ED, kusama::ED as KUSAMA_ED, PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V3, }, + test_parachain_is_trusted_teleporter, xcm_helpers::{xcm_transact_paid_execution, xcm_transact_unpaid_execution}, AssetHubKusama, AssetHubKusamaPallet, AssetHubKusamaReceiver, AssetHubKusamaSender, Kusama, KusamaPallet, KusamaReceiver, KusamaSender, PenpalKusamaA, PenpalKusamaAPallet, PenpalKusamaAReceiver, PenpalKusamaASender, PenpalKusamaB, PenpalKusamaBPallet, + BridgeHubKusama, BridgeHubKusamaReceiver, }; pub use parachains_common::{AccountId, Balance}; pub use xcm::{ diff --git a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/tests/teleport.rs b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/tests/teleport.rs index b671fd5b44480..b19fc56f76b4c 100644 --- a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/tests/teleport.rs +++ b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/tests/teleport.rs @@ -362,3 +362,16 @@ fn teleport_native_assets_from_relay_to_system_para_works() { // // Receiver's balance does not change // assert_eq!(receiver_balance_after, receiver_balance_before); // } + +#[test] +fn teleport_to_other_system_parachains_works() { + let amount = ASSET_HUB_KUSAMA_ED * 100; + let expected_asset: VersionedMultiAssets = (Parent, amount).into(); + + // Works for the right origin and asset + test_parachain_is_trusted_teleporter!( + AssetHubKusama, // Origin + vec![BridgeHubKusama], // Destinations + (expected_asset, amount) + ); +} diff --git a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/lib.rs b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/lib.rs index 6cbf6ab1ccb0e..559c9277f5914 100644 --- a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/lib.rs @@ -26,10 +26,13 @@ pub use integration_tests_common::{ asset_hub_polkadot::ED as ASSET_HUB_POLKADOT_ED, polkadot::ED as POLKADOT_ED, PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V3, }, + test_parachain_is_trusted_teleporter, xcm_helpers::{xcm_transact_paid_execution, xcm_transact_unpaid_execution}, AssetHubPolkadot, AssetHubPolkadotPallet, AssetHubPolkadotReceiver, AssetHubPolkadotSender, PenpalPolkadotA, PenpalPolkadotAPallet, PenpalPolkadotAReceiver, PenpalPolkadotB, PenpalPolkadotBPallet, Polkadot, PolkadotPallet, PolkadotReceiver, PolkadotSender, + CollectivesPolkadotReceiver, CollectivesPolkadot, BridgeHubPolkadotReceiver, + BridgeHubPolkadot }; pub use parachains_common::{AccountId, Balance}; pub use xcm::{ diff --git a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/teleport.rs b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/teleport.rs index 166f73137e750..614431a53528f 100644 --- a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/teleport.rs +++ b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/teleport.rs @@ -364,3 +364,15 @@ fn teleport_native_assets_from_relay_to_system_para_works() { // // Receiver's balance does not change // assert_eq!(receiver_balance_after, receiver_balance_before); // } + +#[test] +fn teleport_to_other_system_parachains_works() { + let amount = ASSET_HUB_POLKADOT_ED * 100; + let native_asset: VersionedMultiAssets = (Parent, amount).into(); + + test_parachain_is_trusted_teleporter!( + AssetHubPolkadot, // Origin + vec![CollectivesPolkadot, BridgeHubPolkadot], // Destinations + (native_asset, amount) + ); +} diff --git a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-rococo/Cargo.toml b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-rococo/Cargo.toml new file mode 100644 index 0000000000000..f280afdda4a44 --- /dev/null +++ b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-rococo/Cargo.toml @@ -0,0 +1,24 @@ +[package] +name = "asset-hub-rococo-integration-tests" +version = "1.0.0" +authors.workspace = true +edition.workspace = true +description = "Asset Hub Rococo runtime integration tests with xcm-emulator" +publish = false + +[dependencies] +codec = { package = "parity-scale-codec", version = "3.4.0", default-features = false } + +# Substrate +frame-support = { path = "../../../../../../substrate/frame/support", default-features = false} +xcm = { package = "staging-xcm", path = "../../../../../../polkadot/xcm", default-features = false} + +# Local +xcm-emulator = { path = "../../../../../xcm/xcm-emulator", default-features = false} +integration-tests-common = { path = "../../common", default-features = false} + +[features] +runtime-benchmarks = [ + "frame-support/runtime-benchmarks", + "integration-tests-common/runtime-benchmarks", +] diff --git a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-rococo/src/lib.rs b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-rococo/src/lib.rs new file mode 100644 index 0000000000000..e0f061b566086 --- /dev/null +++ b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-rococo/src/lib.rs @@ -0,0 +1,28 @@ +// Copyright (C) Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Cumulus is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Cumulus. If not, see . + +pub use frame_support::assert_ok; +pub use integration_tests_common::{ + constants::asset_hub_polkadot::ED as ASSET_HUB_ROCOCO_ED, test_parachain_is_trusted_teleporter, + AssetHubRococo, AssetHubRococoPallet, AssetHubRococoSender, BridgeHubRococo, + BridgeHubRococoReceiver, +}; +pub use xcm::prelude::*; +pub use xcm_emulator::{assert_expected_events, bx, Chain, Parachain, TestExt}; + +#[cfg(test)] +#[cfg(not(feature = "runtime-benchmarks"))] +mod tests; diff --git a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-rococo/src/tests/mod.rs b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-rococo/src/tests/mod.rs new file mode 100644 index 0000000000000..bd1fa199548e7 --- /dev/null +++ b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-rococo/src/tests/mod.rs @@ -0,0 +1,17 @@ +// Copyright (C) Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Cumulus is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Cumulus. If not, see . + +mod teleport; diff --git a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-rococo/src/tests/teleport.rs b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-rococo/src/tests/teleport.rs new file mode 100644 index 0000000000000..246490bc9dc28 --- /dev/null +++ b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-rococo/src/tests/teleport.rs @@ -0,0 +1,29 @@ +// Copyright (C) Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Cumulus is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Cumulus. If not, see . + +use crate::*; + +#[test] +fn teleport_to_other_system_parachains_works() { + let amount = ASSET_HUB_ROCOCO_ED * 100; + let native_asset: VersionedMultiAssets = (Parent, amount).into(); + + test_parachain_is_trusted_teleporter!( + AssetHubRococo, // Origin + vec![BridgeHubRococo], // Destinations + (native_asset, amount) + ); +} diff --git a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs index 2c89c0f9dd469..f9c9420cefd1d 100644 --- a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs @@ -28,10 +28,11 @@ pub use integration_tests_common::{ asset_hub_westend::ED as ASSET_HUB_WESTEND_ED, westend::ED as WESTEND_ED, PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V3, }, + test_parachain_is_trusted_teleporter, xcm_helpers::{xcm_transact_paid_execution, xcm_transact_unpaid_execution}, AssetHubWestend, AssetHubWestendPallet, AssetHubWestendReceiver, AssetHubWestendSender, PenpalWestendA, PenpalWestendAPallet, PenpalWestendAReceiver, PenpalWestendASender, Westend, - WestendPallet, WestendReceiver, WestendSender, + WestendPallet, WestendReceiver, WestendSender, CollectivesWestend, CollectivesWestendReceiver }; pub use parachains_common::{AccountId, Balance}; pub use xcm::{ diff --git a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/tests/teleport.rs b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/tests/teleport.rs index 233dc32b13b5c..98ecc1a7d4137 100644 --- a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/tests/teleport.rs +++ b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/tests/teleport.rs @@ -362,3 +362,15 @@ fn teleport_native_assets_from_relay_to_system_para_works() { // // Receiver's balance does not change // assert_eq!(receiver_balance_after, receiver_balance_before); // } + +#[test] +fn teleport_to_other_system_parachains_works() { + let amount = ASSET_HUB_WESTEND_ED * 100; + let native_asset: VersionedMultiAssets = (Parent, amount).into(); + + test_parachain_is_trusted_teleporter!( + AssetHubWestend, // Origin + vec![CollectivesWestend], // Destinations + (native_asset, amount) + ); +} diff --git a/cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/lib.rs b/cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/lib.rs index 0a923ec04de76..4de97b529cb96 100644 --- a/cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/lib.rs @@ -19,11 +19,14 @@ pub use frame_support::assert_ok; pub use integration_tests_common::{ constants::{ asset_hub_kusama::ED as ASSET_HUB_ROCOCO_ED, kusama::ED as ROCOCO_ED, PROOF_SIZE_THRESHOLD, + bridge_hub_rococo::ED as BRIDGE_HUB_ROCOCO_ED, REF_TIME_THRESHOLD, XCM_V3, }, + test_parachain_is_trusted_teleporter, xcm_helpers::{xcm_transact_paid_execution, xcm_transact_unpaid_execution}, AssetHubRococo, AssetHubRococoReceiver, AssetHubWococo, BridgeHubRococo, BridgeHubWococo, - PenpalRococoA, Rococo, RococoPallet, + PenpalRococoA, Rococo, RococoPallet, BridgeHubRococoSender, BridgeHubRococoPallet, + CollectivesPolkadotReceiver, CollectivesPolkadot, BridgeHubPolkadotReceiver, BridgeHubPolkadot }; pub use parachains_common::{AccountId, Balance}; pub use xcm::{ diff --git a/cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/tests/mod.rs b/cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/tests/mod.rs index 6e11743aecbf3..f357209f1ebcd 100644 --- a/cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/tests/mod.rs +++ b/cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/tests/mod.rs @@ -15,3 +15,4 @@ // along with Cumulus. If not, see . mod example; +mod teleport; diff --git a/cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/tests/teleport.rs b/cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/tests/teleport.rs new file mode 100644 index 0000000000000..d1a2044925cc1 --- /dev/null +++ b/cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/tests/teleport.rs @@ -0,0 +1,29 @@ +// Copyright (C) Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Cumulus is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Cumulus. If not, see . + +use crate::*; + +#[test] +fn teleport_to_other_system_parachains_works() { + let amount = BRIDGE_HUB_ROCOCO_ED * 100; + let native_asset: VersionedMultiAssets = (Parent, amount).into(); + + test_parachain_is_trusted_teleporter!( + BridgeHubRococo, // Origin + vec![AssetHubRococo], // Destinations + (native_asset, amount) + ); +} diff --git a/cumulus/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/lib.rs b/cumulus/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/lib.rs index ad2b5a5011175..33ee968eb9c20 100644 --- a/cumulus/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/lib.rs @@ -19,11 +19,14 @@ pub use frame_support::{assert_ok, sp_runtime::AccountId32}; pub use integration_tests_common::{ constants::{ accounts::ALICE, asset_hub_polkadot::ED as ASSET_HUB_POLKADOT_ED, + collectives::ED as COLLECTIVES_POLKADOT_ED, polkadot::ED as POLKADOT_ED, PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V3, }, + test_parachain_is_trusted_teleporter, xcm_helpers::{xcm_transact_paid_execution, xcm_transact_unpaid_execution}, - AssetHubPolkadot, AssetHubPolkadotPallet, AssetHubPolkadotReceiver, Collectives, - PenpalPolkadotA, Polkadot, + AssetHubPolkadot, AssetHubPolkadotPallet, AssetHubPolkadotReceiver, CollectivesPolkadot, + PenpalPolkadotA, Polkadot, CollectivesPolkadotSender, CollectivesPolkadotPallet, + BridgeHubPolkadotReceiver, BridgeHubPolkadot, }; pub use parachains_common::{AccountId, Balance}; pub use xcm::{ diff --git a/cumulus/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/tests/fellowship.rs b/cumulus/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/tests/fellowship.rs index 26fa55acb0d66..cd08c1db8a262 100644 --- a/cumulus/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/tests/fellowship.rs +++ b/cumulus/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/tests/fellowship.rs @@ -46,19 +46,19 @@ fn pay_salary() { assert_ok!(>::mint_into(asset_id, &pay_from, pay_amount * 2)); }); - Collectives::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; + CollectivesPolkadot::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; assert_ok!(FellowshipSalaryPaymaster::pay(&pay_to, (), pay_amount)); assert_expected_events!( - Collectives, + CollectivesPolkadot, vec![ RuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { .. }) => {}, ] ); }); - Collectives::execute_with(|| {}); + CollectivesPolkadot::execute_with(|| {}); AssetHubPolkadot::execute_with(|| { type RuntimeEvent = ::RuntimeEvent; diff --git a/cumulus/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/tests/mod.rs b/cumulus/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/tests/mod.rs index a9445ac8ec7eb..2bb72f01b26cd 100644 --- a/cumulus/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/tests/mod.rs +++ b/cumulus/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/tests/mod.rs @@ -15,3 +15,4 @@ // along with Cumulus. If not, see . mod fellowship; +mod teleport; diff --git a/cumulus/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/tests/teleport.rs b/cumulus/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/tests/teleport.rs new file mode 100644 index 0000000000000..8df531dd837b3 --- /dev/null +++ b/cumulus/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/tests/teleport.rs @@ -0,0 +1,29 @@ +// Copyright Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Cumulus is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Cumulus. If not, see . + +use crate::*; + +#[test] +fn teleport_to_other_system_parachains_works() { + let amount = COLLECTIVES_POLKADOT_ED * 100; + let native_asset: VersionedMultiAssets = (Parent, amount).into(); + + test_parachain_is_trusted_teleporter!( + CollectivesPolkadot, // Origin + vec![AssetHubPolkadot, BridgeHubPolkadot], // Destinations + (native_asset, amount) + ); +} diff --git a/cumulus/parachains/integration-tests/emulated/collectives/collectives-westend/Cargo.toml b/cumulus/parachains/integration-tests/emulated/collectives/collectives-westend/Cargo.toml new file mode 100644 index 0000000000000..ba34ddc7f6472 --- /dev/null +++ b/cumulus/parachains/integration-tests/emulated/collectives/collectives-westend/Cargo.toml @@ -0,0 +1,26 @@ +[package] +name = "collectives-westend-integration-tests" +version = "0.1.0" +authors.workspace = true +edition.workspace = true +description = "Polkadot Westend parachain runtime integration tests based on xcm-emulator" +publish = false + +[dependencies] +codec = { package = "parity-scale-codec", version = "3.4.0", default-features = false } + +# Substrate +frame-support = { path = "../../../../../../substrate/frame/support", default-features = false} + +# Polkadot +xcm = { package = "staging-xcm", path = "../../../../../../polkadot/xcm", default-features = false} + +# Local +xcm-emulator = { path = "../../../../../xcm/xcm-emulator", default-features = false} +integration-tests-common = { path = "../../common", default-features = false} + +[features] +runtime-benchmarks = [ + "frame-support/runtime-benchmarks", + "integration-tests-common/runtime-benchmarks", +] diff --git a/cumulus/parachains/integration-tests/emulated/collectives/collectives-westend/src/lib.rs b/cumulus/parachains/integration-tests/emulated/collectives/collectives-westend/src/lib.rs new file mode 100644 index 0000000000000..6a230cf69c32f --- /dev/null +++ b/cumulus/parachains/integration-tests/emulated/collectives/collectives-westend/src/lib.rs @@ -0,0 +1,28 @@ +// Copyright (C) Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Cumulus is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Cumulus. If not, see . + +pub use frame_support::assert_ok; +pub use integration_tests_common::{ + constants::collectives::ED as COLLECTIVES_WESTEND_ED, test_parachain_is_trusted_teleporter, + AssetHubWestend, AssetHubWestendPallet, AssetHubWestendReceiver, CollectivesWestend, + CollectivesWestendPallet, CollectivesWestendSender, +}; +pub use xcm::prelude::*; +pub use xcm_emulator::{assert_expected_events, bx, Chain, Parachain, TestExt}; + +#[cfg(test)] +#[cfg(not(feature = "runtime-benchmarks"))] +mod tests; diff --git a/cumulus/parachains/integration-tests/emulated/collectives/collectives-westend/src/tests/mod.rs b/cumulus/parachains/integration-tests/emulated/collectives/collectives-westend/src/tests/mod.rs new file mode 100644 index 0000000000000..bd1fa199548e7 --- /dev/null +++ b/cumulus/parachains/integration-tests/emulated/collectives/collectives-westend/src/tests/mod.rs @@ -0,0 +1,17 @@ +// Copyright (C) Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Cumulus is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Cumulus. If not, see . + +mod teleport; diff --git a/cumulus/parachains/integration-tests/emulated/collectives/collectives-westend/src/tests/teleport.rs b/cumulus/parachains/integration-tests/emulated/collectives/collectives-westend/src/tests/teleport.rs new file mode 100644 index 0000000000000..878badcaa3349 --- /dev/null +++ b/cumulus/parachains/integration-tests/emulated/collectives/collectives-westend/src/tests/teleport.rs @@ -0,0 +1,29 @@ +// Copyright (C) Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Cumulus is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Cumulus. If not, see . + +use crate::*; + +#[test] +fn teleport_to_other_system_parachains_works() { + let amount = COLLECTIVES_WESTEND_ED * 100; + let native_asset: VersionedMultiAssets = (Parent, amount).into(); + + test_parachain_is_trusted_teleporter!( + CollectivesWestend, // Origin + vec![AssetHubWestend], // Destinations + (native_asset, amount) + ); +} diff --git a/cumulus/parachains/integration-tests/emulated/common/Cargo.toml b/cumulus/parachains/integration-tests/emulated/common/Cargo.toml index a8002158dbc13..e4baad9bdb34c 100644 --- a/cumulus/parachains/integration-tests/emulated/common/Cargo.toml +++ b/cumulus/parachains/integration-tests/emulated/common/Cargo.toml @@ -18,6 +18,7 @@ frame-support = { path = "../../../../../substrate/frame/support", default-featu sp-core = { path = "../../../../../substrate/primitives/core", default-features = false} sp-consensus-babe = { path = "../../../../../substrate/primitives/consensus/babe", default-features = false} pallet-assets = { path = "../../../../../substrate/frame/assets", default-features = false} +pallet-balances = { path = "../../../../../substrate/frame/balances", default-features = false} pallet-staking = { path = "../../../../../substrate/frame/staking", default-features = false} pallet-message-queue = { path = "../../../../../substrate/frame/message-queue", default-features = false} pallet-im-online = { path = "../../../../../substrate/frame/im-online", default-features = false} diff --git a/cumulus/parachains/integration-tests/emulated/common/src/lib.rs b/cumulus/parachains/integration-tests/emulated/common/src/lib.rs index 49751136f7ba0..bdefb2c55eb68 100644 --- a/cumulus/parachains/integration-tests/emulated/common/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/common/src/lib.rs @@ -16,8 +16,10 @@ pub mod constants; pub mod impls; +pub mod macros; pub mod xcm_helpers; +pub use paste; use constants::{ accounts::{ALICE, BOB}, asset_hub_kusama, asset_hub_polkadot, asset_hub_westend, bridge_hub_kusama, @@ -27,12 +29,19 @@ use impls::{RococoWococoMessageHandler, WococoRococoMessageHandler}; // Substrate use frame_support::traits::OnInitialize; +pub use pallet_balances; // Cumulus use xcm_emulator::{ decl_test_bridges, decl_test_networks, decl_test_parachains, decl_test_relay_chains, decl_test_sender_receiver_accounts_parameter_types, DefaultMessageProcessor, }; +pub use xcm_emulator::Chain; +pub use cumulus_pallet_xcmp_queue; + +// Polkadot +pub use xcm::prelude::{AccountId32, WeightLimit}; +pub use pallet_xcm; decl_test_relay_chains! { #[api_version(5)] @@ -132,7 +141,7 @@ decl_test_parachains! { Balances: asset_hub_polkadot_runtime::Balances, } }, - pub struct Collectives { + pub struct CollectivesPolkadot { genesis = collectives::genesis(), on_init = { collectives_polkadot_runtime::AuraExt::on_initialize(1); @@ -293,6 +302,21 @@ decl_test_parachains! { AssetConversion: asset_hub_westend_runtime::AssetConversion, } }, + pub struct CollectivesWestend { + genesis = collectives::genesis(), + on_init = (), + runtime = collectives_polkadot_runtime, + core = { + XcmpMessageHandler: collectives_polkadot_runtime::XcmpQueue, + DmpMessageHandler: collectives_polkadot_runtime::DmpQueue, + LocationToAccountId: collectives_polkadot_runtime::xcm_config::LocationToAccountId, + ParachainInfo: collectives_polkadot_runtime::ParachainInfo, + }, + pallets = { + PolkadotXcm: collectives_polkadot_runtime::PolkadotXcm, + Balances: collectives_polkadot_runtime::Balances, + } + }, pub struct PenpalWestendA { genesis = penpal::genesis(penpal::PARA_ID_A), on_init = { @@ -308,6 +332,7 @@ decl_test_parachains! { pallets = { PolkadotXcm: penpal_runtime::PolkadotXcm, Assets: penpal_runtime::Assets, + Balances: penpal_runtime::Balances, } }, // Rococo Parachains @@ -344,6 +369,7 @@ decl_test_parachains! { pallets = { PolkadotXcm: asset_hub_kusama_runtime::PolkadotXcm, Assets: asset_hub_kusama_runtime::Assets, + Balances: asset_hub_kusama_runtime::Balances, } }, // Wococo Parachains @@ -378,6 +404,7 @@ decl_test_parachains! { pallets = { PolkadotXcm: asset_hub_polkadot_runtime::PolkadotXcm, Assets: asset_hub_polkadot_runtime::Assets, + Balances: asset_hub_polkadot_runtime::Balances, } }, pub struct PenpalRococoA { @@ -404,7 +431,7 @@ decl_test_networks! { relay_chain = Polkadot, parachains = vec![ AssetHubPolkadot, - Collectives, + CollectivesPolkadot, BridgeHubPolkadot, PenpalPolkadotA, PenpalPolkadotB, @@ -429,6 +456,7 @@ decl_test_networks! { relay_chain = Westend, parachains = vec![ AssetHubWestend, + CollectivesWestend, PenpalWestendA, ], bridge = () @@ -513,6 +541,11 @@ impl_accounts_helpers_for_parachain!(AssetHubWestend); impl_assets_helpers_for_parachain!(AssetHubWestend, Westend); impl_assert_events_helpers_for_parachain!(AssetHubWestend); +// AssetHubRococo implementation +impl_accounts_helpers_for_parachain!(AssetHubRococo); +impl_assets_helpers_for_parachain!(AssetHubRococo, Rococo); +impl_assert_events_helpers_for_parachain!(AssetHubRococo); + // PenpalPolkadot implementations impl_assert_events_helpers_for_parachain!(PenpalPolkadotA); impl_assert_events_helpers_for_parachain!(PenpalPolkadotB); @@ -524,9 +557,13 @@ impl_assert_events_helpers_for_parachain!(PenpalKusamaB); // PenpalWestendA implementation impl_assert_events_helpers_for_parachain!(PenpalWestendA); -// Collectives implementation -impl_accounts_helpers_for_parachain!(Collectives); -impl_assert_events_helpers_for_parachain!(Collectives); +// CollectivesPolkadot implementation +impl_accounts_helpers_for_parachain!(CollectivesPolkadot); +impl_assert_events_helpers_for_parachain!(CollectivesPolkadot); + +// CollectivesWestend implementation +impl_accounts_helpers_for_parachain!(CollectivesWestend); +impl_assert_events_helpers_for_parachain!(CollectivesWestend); // BridgeHubRococo implementation impl_accounts_helpers_for_parachain!(BridgeHubRococo); @@ -546,7 +583,8 @@ decl_test_sender_receiver_accounts_parameter_types! { AssetHubRococo { sender: ALICE, receiver: BOB }, AssetHubWococo { sender: ALICE, receiver: BOB }, // Collectives - Collectives { sender: ALICE, receiver: BOB }, + CollectivesPolkadot { sender: ALICE, receiver: BOB }, + CollectivesWestend { sender: ALICE, receiver: BOB }, // Bridged Hubs BridgeHubPolkadot { sender: ALICE, receiver: BOB }, BridgeHubKusama { sender: ALICE, receiver: BOB }, diff --git a/cumulus/parachains/integration-tests/emulated/common/src/macros.rs b/cumulus/parachains/integration-tests/emulated/common/src/macros.rs new file mode 100644 index 0000000000000..fa3816ccd2df6 --- /dev/null +++ b/cumulus/parachains/integration-tests/emulated/common/src/macros.rs @@ -0,0 +1,101 @@ +// Copyright (C) Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Cumulus is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Cumulus. If not, see . + +#[macro_export] +macro_rules! test_parachain_is_trusted_teleporter { + ( $sender_para:ty, vec![$( $receiver_para:ty ),+], ($assets:expr, $amount:expr) ) => { + $crate::paste::paste! { + // init Origin variables + let sender = [<$sender_para Sender>]::get(); + let mut para_sender_balance_before = + <$sender_para as $crate::Chain>::account_data_of(sender.clone()).free; + let origin = <$sender_para as $crate::Chain>::RuntimeOrigin::signed(sender.clone()); + let fee_asset_item = 0; + let weight_limit = $crate::WeightLimit::Unlimited; + + $( + { + // init Destination variables + let receiver = [<$receiver_para Receiver>]::get(); + let para_receiver_balance_before = + <$receiver_para as $crate::Chain>::account_data_of(receiver.clone()).free; + let para_destination = + <$sender_para>::sibling_location_of(<$receiver_para>::para_id()).into(); + let beneficiary = + $crate::AccountId32 { network: None, id: receiver.clone().into() }.into(); + + // Send XCM message from Origin Parachain + <$sender_para>::execute_with(|| { + assert_ok!(<$sender_para as [<$sender_para Pallet>]>::PolkadotXcm::limited_teleport_assets( + origin.clone(), + bx!(para_destination), + bx!(beneficiary), + bx!($assets.clone()), + fee_asset_item, + weight_limit.clone(), + )); + + type RuntimeEvent = <$sender_para as $crate::Chain>::RuntimeEvent; + + assert_expected_events!( + $sender_para, + vec![ + RuntimeEvent::PolkadotXcm( + $crate::pallet_xcm::Event::Attempted { outcome: Outcome::Complete { .. } } + ) => {}, + RuntimeEvent::XcmpQueue( + $crate::cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { .. } + ) => {}, + RuntimeEvent::Balances( + $crate::pallet_balances::Event::Withdraw { who: sender, amount } + ) => {}, + ] + ); + }); + + // Receive XCM message in Destination Parachain + <$receiver_para>::execute_with(|| { + type RuntimeEvent = <$receiver_para as $crate::Chain>::RuntimeEvent; + + assert_expected_events!( + $receiver_para, + vec![ + RuntimeEvent::Balances( + $crate::pallet_balances::Event::Deposit { who: receiver, .. } + ) => {}, + RuntimeEvent::XcmpQueue( + $crate::cumulus_pallet_xcmp_queue::Event::Success { .. } + ) => {}, + ] + ); + }); + + // Check if balances are updated accordingly in Origin and Destination Parachains + let para_sender_balance_after = + <$sender_para as $crate::Chain>::account_data_of(sender.clone()).free; + let para_receiver_balance_after = + <$receiver_para as $crate::Chain>::account_data_of(receiver.clone()).free; + + assert_eq!(para_sender_balance_before - $amount, para_sender_balance_after); + assert!(para_receiver_balance_after > para_receiver_balance_before); + + // Update sender balance + para_sender_balance_before = <$sender_para as $crate::Chain>::account_data_of(sender.clone()).free; + } + )+ + } + }; +} diff --git a/cumulus/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs b/cumulus/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs index 0c197598f8895..8596d9f30ce17 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs @@ -31,7 +31,10 @@ use frame_support::{ }; use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; -use parachains_common::{impls::ToStakingPot, xcm_config::AssetFeeAsExistentialDepositMultiplier}; +use parachains_common::{ + impls::ToStakingPot, + xcm_config::{AssetFeeAsExistentialDepositMultiplier, ConcreteNativeAssetFromSystem}, +}; use polkadot_parachain_primitives::primitives::Sibling; use sp_runtime::traits::ConvertInto; use xcm::latest::prelude::*; @@ -39,7 +42,7 @@ use xcm_builder::{ AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, CurrencyAdapter, DenyReserveTransferToRelayChain, DenyThenTry, DescribeAllTerminal, DescribeFamily, - EnsureXcmOrigin, FungiblesAdapter, HashedDescription, IsConcrete, LocalMint, NativeAsset, + EnsureXcmOrigin, FungiblesAdapter, HashedDescription, IsConcrete, LocalMint, NoChecking, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId, UsingComponents, @@ -470,6 +473,15 @@ pub type AssetFeeAsExistentialDepositMultiplierFeeCharger = AssetFeeAsExistentia TrustBackedAssetsInstance, >; +/// Cases where a remote origin is accepted as a Trusted Teleporter: +/// +/// - teleportation of KSM from the parent Relay Chain and sibling system parachains; and +/// - teleportation of sibling parachains' assets (as `ForeignCreators`). +pub type TrustedTeleporters = ( + ConcreteNativeAssetFromSystem, + IsForeignConcreteAsset>>, +); + pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { type RuntimeCall = RuntimeCall; @@ -483,10 +495,7 @@ impl xcm_executor::Config for XcmConfig { // We allow: // - teleportation of KSM // - teleportation of sibling parachain's assets (as ForeignCreators) - type IsTeleporter = ( - NativeAsset, - IsForeignConcreteAsset>>, - ); + type IsTeleporter = TrustedTeleporters; type UniversalLocation = UniversalLocation; type Barrier = Barrier; type Weigher = WeightInfoBounds< diff --git a/cumulus/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs b/cumulus/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs index d59507e4bd07d..2e5a8511d8749 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs @@ -27,7 +27,10 @@ use frame_support::{ }; use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; -use parachains_common::{impls::ToStakingPot, xcm_config::AssetFeeAsExistentialDepositMultiplier}; +use parachains_common::{ + impls::ToStakingPot, + xcm_config::{AssetFeeAsExistentialDepositMultiplier, ConcreteNativeAssetFromSystem}, +}; use polkadot_parachain_primitives::primitives::Sibling; use sp_runtime::traits::ConvertInto; use xcm::latest::prelude::*; @@ -35,7 +38,7 @@ use xcm_builder::{ AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, CurrencyAdapter, DenyReserveTransferToRelayChain, DenyThenTry, DescribeFamily, DescribePalletTerminal, - EnsureXcmOrigin, FungiblesAdapter, HashedDescription, IsConcrete, LocalMint, NativeAsset, + EnsureXcmOrigin, FungiblesAdapter, HashedDescription, IsConcrete, LocalMint, NoChecking, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId, UsingComponents, @@ -390,6 +393,15 @@ pub type AssetFeeAsExistentialDepositMultiplierFeeCharger = AssetFeeAsExistentia TrustBackedAssetsInstance, >; +/// Cases where a remote origin is accepted as a Trusted Teleporter: +/// +/// - teleportation of DOT from the parent Relay Chain and sibling system parachains; and +/// - teleportation of sibling parachains' assets (as `ForeignCreators`). +pub type TrustedTeleporters = ( + ConcreteNativeAssetFromSystem, + IsForeignConcreteAsset>>, +); + pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { type RuntimeCall = RuntimeCall; @@ -403,10 +415,7 @@ impl xcm_executor::Config for XcmConfig { // We allow: // - teleportation of DOT // - teleportation of sibling parachain's assets (as ForeignCreators) - type IsTeleporter = ( - NativeAsset, - IsForeignConcreteAsset>>, - ); + type IsTeleporter = TrustedTeleporters; type UniversalLocation = UniversalLocation; type Barrier = Barrier; type Weigher = WeightInfoBounds< diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs index 6981c290c98ce..eee9e2dd3ffe1 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs @@ -31,7 +31,10 @@ use frame_support::{ }; use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; -use parachains_common::{impls::ToStakingPot, xcm_config::AssetFeeAsExistentialDepositMultiplier}; +use parachains_common::{ + impls::ToStakingPot, + xcm_config::{AssetFeeAsExistentialDepositMultiplier, ConcreteNativeAssetFromSystem}, +}; use polkadot_parachain_primitives::primitives::Sibling; use sp_runtime::traits::ConvertInto; use xcm::latest::prelude::*; @@ -39,7 +42,7 @@ use xcm_builder::{ AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, CurrencyAdapter, DenyReserveTransferToRelayChain, DenyThenTry, EnsureXcmOrigin, FungiblesAdapter, IsConcrete, - LocalMint, NativeAsset, NoChecking, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, + LocalMint, NoChecking, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId, UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic, @@ -473,6 +476,15 @@ pub type AssetFeeAsExistentialDepositMultiplierFeeCharger = AssetFeeAsExistentia TrustBackedAssetsInstance, >; +/// Cases where a remote origin is accepted as a Trusted Teleporter: +/// +/// - teleportation of WND from the parent Relay Chain and sibling system parachains; and +/// - teleportation of sibling parachains' assets (as `ForeignCreators`). +pub type TrustedTeleporters = ( + ConcreteNativeAssetFromSystem, + IsForeignConcreteAsset>>, +); + pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { type RuntimeCall = RuntimeCall; @@ -486,10 +498,7 @@ impl xcm_executor::Config for XcmConfig { // We allow: // - teleportation of WND // - teleportation of sibling parachain's assets (as ForeignCreators) - type IsTeleporter = ( - NativeAsset, - IsForeignConcreteAsset>>, - ); + type IsTeleporter = TrustedTeleporters; type UniversalLocation = UniversalLocation; type Barrier = Barrier; type Weigher = WeightInfoBounds< diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs index 696462be9c45c..4c098f199aea2 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs @@ -24,7 +24,7 @@ use frame_support::{ }; use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; -use parachains_common::{impls::ToStakingPot, xcm_config::ConcreteNativeAssetFrom}; +use parachains_common::{impls::ToStakingPot, xcm_config::ConcreteNativeAssetFromSystem}; use polkadot_parachain_primitives::primitives::Sibling; use xcm::latest::prelude::*; use xcm_builder::{ @@ -177,6 +177,10 @@ pub type Barrier = TrailingSetTopicAsId< >, >; +/// Cases where a remote origin is accepted as trusted Teleporter: +/// - teleportation of KSM from the parent Relay Chain and sibling parachains. +pub type TrustedTeleporters = ConcreteNativeAssetFromSystem; + pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { type RuntimeCall = RuntimeCall; @@ -187,7 +191,7 @@ impl xcm_executor::Config for XcmConfig { // where allowed (e.g. with the Relay Chain). type IsReserve = (); /// Only allow teleportation of KSM. - type IsTeleporter = ConcreteNativeAssetFrom; + type IsTeleporter = TrustedTeleporters; type UniversalLocation = UniversalLocation; type Barrier = Barrier; type Weigher = WeightInfoBounds< diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs index 0965600c24681..3faea943f22a6 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs @@ -24,7 +24,7 @@ use frame_support::{ }; use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; -use parachains_common::{impls::ToStakingPot, xcm_config::ConcreteNativeAssetFrom}; +use parachains_common::{impls::ToStakingPot, xcm_config::ConcreteNativeAssetFromSystem}; use polkadot_parachain_primitives::primitives::Sibling; use xcm::latest::prelude::*; use xcm_builder::{ @@ -181,6 +181,10 @@ pub type Barrier = TrailingSetTopicAsId< >, >; +/// Cases where a remote origin is accepted as trusted Teleporter: +/// - teleportation of DOT from the parent Relay Chain and sibling parachains. +pub type TrustedTeleporters = ConcreteNativeAssetFromSystem; + pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { type RuntimeCall = RuntimeCall; @@ -191,7 +195,7 @@ impl xcm_executor::Config for XcmConfig { // where allowed (e.g. with the Relay Chain). type IsReserve = (); /// Only allow teleportation of DOT. - type IsTeleporter = ConcreteNativeAssetFrom; + type IsTeleporter = TrustedTeleporters; type UniversalLocation = UniversalLocation; type Barrier = Barrier; type Weigher = WeightInfoBounds< diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs index e3d8645d49e7e..768550e12fb09 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs @@ -30,7 +30,7 @@ use frame_support::{ }; use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; -use parachains_common::{impls::ToStakingPot, xcm_config::ConcreteNativeAssetFrom}; +use parachains_common::{impls::ToStakingPot, xcm_config::ConcreteNativeAssetFromSystem}; use polkadot_parachain_primitives::primitives::Sibling; use sp_core::Get; use xcm::latest::prelude::*; @@ -224,6 +224,10 @@ pub type Barrier = TrailingSetTopicAsId< >, >; +/// Cases where a remote origin is accepted as trusted Teleporter: +/// - teleportation of NativeToken from the parent Relay Chain and sibling parachains. +pub type TrustedTeleporters = ConcreteNativeAssetFromSystem; + pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { type RuntimeCall = RuntimeCall; @@ -234,7 +238,7 @@ impl xcm_executor::Config for XcmConfig { // token where allowed (e.g. with the Relay Chain). type IsReserve = (); /// Only allow teleportation of NativeToken of relay chain. - type IsTeleporter = ConcreteNativeAssetFrom; + type IsTeleporter = TrustedTeleporters; type UniversalLocation = UniversalLocation; type Barrier = Barrier; type Weigher = WeightInfoBounds< diff --git a/cumulus/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs b/cumulus/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs index b4db73e3ab440..b789daad2610f 100644 --- a/cumulus/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs @@ -24,7 +24,7 @@ use frame_support::{ }; use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; -use parachains_common::{impls::ToStakingPot, xcm_config::ConcreteNativeAssetFrom}; +use parachains_common::{impls::ToStakingPot, xcm_config::ConcreteNativeAssetFromSystem}; use polkadot_parachain_primitives::primitives::Sibling; use xcm::latest::prelude::*; use xcm_builder::{ @@ -227,6 +227,10 @@ pub type Barrier = TrailingSetTopicAsId< >, >; +/// Cases where a remote origin is accepted as trusted Teleporter: +/// - teleportation of DOT from the parent Relay Chain and sibling parachains. +pub type TrustedTeleporters = ConcreteNativeAssetFromSystem; + pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { type RuntimeCall = RuntimeCall; @@ -237,7 +241,7 @@ impl xcm_executor::Config for XcmConfig { // where allowed (e.g. with the Relay Chain). type IsReserve = (); /// Only allow teleportation of DOT. - type IsTeleporter = ConcreteNativeAssetFrom; + type IsTeleporter = TrustedTeleporters; type UniversalLocation = UniversalLocation; type Barrier = Barrier; type Weigher = FixedWeightBounds; diff --git a/cumulus/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs b/cumulus/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs index 7433b8e94d6c1..dfd1fb3ae70f3 100644 --- a/cumulus/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs @@ -24,6 +24,7 @@ use frame_support::{ }; use frame_system::EnsureRoot; use pallet_xcm::{EnsureXcm, IsMajorityOfBody, XcmPassthrough}; +use parachains_common::xcm_config::ConcreteNativeAssetFromSystem; use polkadot_parachain_primitives::primitives::Sibling; use xcm::latest::prelude::*; use xcm_builder::{ @@ -144,6 +145,8 @@ pub type Barrier = TrailingSetTopicAsId< >, >; +pub type TrustedTeleporter = ConcreteNativeAssetFromSystem; + pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { type RuntimeCall = RuntimeCall; @@ -151,7 +154,7 @@ impl xcm_executor::Config for XcmConfig { type AssetTransactor = CurrencyTransactor; type OriginConverter = XcmOriginToTransactDispatchOrigin; type IsReserve = NativeAsset; - type IsTeleporter = NativeAsset; + type IsTeleporter = TrustedTeleporter; type UniversalLocation = UniversalLocation; type Barrier = Barrier; type Weigher = FixedWeightBounds; From 935a95d517897674fd325401487e9348ea390dd4 Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Sat, 2 Sep 2023 18:14:20 +0000 Subject: [PATCH 02/27] ".git/.scripts/commands/fmt/fmt.sh" --- .../emulated/assets/asset-hub-kusama/src/lib.rs | 8 ++++---- .../emulated/assets/asset-hub-polkadot/src/lib.rs | 3 +-- .../emulated/assets/asset-hub-westend/src/lib.rs | 5 +++-- .../collectives/collectives-polkadot/src/lib.rs | 10 +++++----- .../integration-tests/emulated/common/src/lib.rs | 8 ++++---- .../runtimes/assets/asset-hub-kusama/src/xcm_config.rs | 4 ++-- .../assets/asset-hub-polkadot/src/xcm_config.rs | 4 ++-- 7 files changed, 21 insertions(+), 21 deletions(-) diff --git a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/lib.rs b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/lib.rs index cdedb33c39916..34cfa3bc399af 100644 --- a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/lib.rs @@ -28,10 +28,10 @@ pub use integration_tests_common::{ }, test_parachain_is_trusted_teleporter, xcm_helpers::{xcm_transact_paid_execution, xcm_transact_unpaid_execution}, - AssetHubKusama, AssetHubKusamaPallet, AssetHubKusamaReceiver, AssetHubKusamaSender, Kusama, - KusamaPallet, KusamaReceiver, KusamaSender, PenpalKusamaA, PenpalKusamaAPallet, - PenpalKusamaAReceiver, PenpalKusamaASender, PenpalKusamaB, PenpalKusamaBPallet, - BridgeHubKusama, BridgeHubKusamaReceiver, + AssetHubKusama, AssetHubKusamaPallet, AssetHubKusamaReceiver, AssetHubKusamaSender, + BridgeHubKusama, BridgeHubKusamaReceiver, Kusama, KusamaPallet, KusamaReceiver, KusamaSender, + PenpalKusamaA, PenpalKusamaAPallet, PenpalKusamaAReceiver, PenpalKusamaASender, PenpalKusamaB, + PenpalKusamaBPallet, }; pub use parachains_common::{AccountId, Balance}; pub use xcm::{ diff --git a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/lib.rs b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/lib.rs index 559c9277f5914..cc61687a87a2f 100644 --- a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/lib.rs @@ -29,10 +29,9 @@ pub use integration_tests_common::{ test_parachain_is_trusted_teleporter, xcm_helpers::{xcm_transact_paid_execution, xcm_transact_unpaid_execution}, AssetHubPolkadot, AssetHubPolkadotPallet, AssetHubPolkadotReceiver, AssetHubPolkadotSender, + BridgeHubPolkadot, BridgeHubPolkadotReceiver, CollectivesPolkadot, CollectivesPolkadotReceiver, PenpalPolkadotA, PenpalPolkadotAPallet, PenpalPolkadotAReceiver, PenpalPolkadotB, PenpalPolkadotBPallet, Polkadot, PolkadotPallet, PolkadotReceiver, PolkadotSender, - CollectivesPolkadotReceiver, CollectivesPolkadot, BridgeHubPolkadotReceiver, - BridgeHubPolkadot }; pub use parachains_common::{AccountId, Balance}; pub use xcm::{ diff --git a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs index f9c9420cefd1d..68818dc94f5e9 100644 --- a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs @@ -31,8 +31,9 @@ pub use integration_tests_common::{ test_parachain_is_trusted_teleporter, xcm_helpers::{xcm_transact_paid_execution, xcm_transact_unpaid_execution}, AssetHubWestend, AssetHubWestendPallet, AssetHubWestendReceiver, AssetHubWestendSender, - PenpalWestendA, PenpalWestendAPallet, PenpalWestendAReceiver, PenpalWestendASender, Westend, - WestendPallet, WestendReceiver, WestendSender, CollectivesWestend, CollectivesWestendReceiver + CollectivesWestend, CollectivesWestendReceiver, PenpalWestendA, PenpalWestendAPallet, + PenpalWestendAReceiver, PenpalWestendASender, Westend, WestendPallet, WestendReceiver, + WestendSender, }; pub use parachains_common::{AccountId, Balance}; pub use xcm::{ diff --git a/cumulus/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/lib.rs b/cumulus/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/lib.rs index 33ee968eb9c20..86153cb2884d2 100644 --- a/cumulus/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/lib.rs @@ -19,14 +19,14 @@ pub use frame_support::{assert_ok, sp_runtime::AccountId32}; pub use integration_tests_common::{ constants::{ accounts::ALICE, asset_hub_polkadot::ED as ASSET_HUB_POLKADOT_ED, - collectives::ED as COLLECTIVES_POLKADOT_ED, - polkadot::ED as POLKADOT_ED, PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V3, + collectives::ED as COLLECTIVES_POLKADOT_ED, polkadot::ED as POLKADOT_ED, + PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V3, }, test_parachain_is_trusted_teleporter, xcm_helpers::{xcm_transact_paid_execution, xcm_transact_unpaid_execution}, - AssetHubPolkadot, AssetHubPolkadotPallet, AssetHubPolkadotReceiver, CollectivesPolkadot, - PenpalPolkadotA, Polkadot, CollectivesPolkadotSender, CollectivesPolkadotPallet, - BridgeHubPolkadotReceiver, BridgeHubPolkadot, + AssetHubPolkadot, AssetHubPolkadotPallet, AssetHubPolkadotReceiver, BridgeHubPolkadot, + BridgeHubPolkadotReceiver, CollectivesPolkadot, CollectivesPolkadotPallet, + CollectivesPolkadotSender, PenpalPolkadotA, Polkadot, }; pub use parachains_common::{AccountId, Balance}; pub use xcm::{ diff --git a/cumulus/parachains/integration-tests/emulated/common/src/lib.rs b/cumulus/parachains/integration-tests/emulated/common/src/lib.rs index bdefb2c55eb68..3c3189035686c 100644 --- a/cumulus/parachains/integration-tests/emulated/common/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/common/src/lib.rs @@ -19,29 +19,29 @@ pub mod impls; pub mod macros; pub mod xcm_helpers; -pub use paste; use constants::{ accounts::{ALICE, BOB}, asset_hub_kusama, asset_hub_polkadot, asset_hub_westend, bridge_hub_kusama, bridge_hub_polkadot, bridge_hub_rococo, collectives, kusama, penpal, polkadot, rococo, westend, }; use impls::{RococoWococoMessageHandler, WococoRococoMessageHandler}; +pub use paste; // Substrate use frame_support::traits::OnInitialize; pub use pallet_balances; // Cumulus +pub use cumulus_pallet_xcmp_queue; +pub use xcm_emulator::Chain; use xcm_emulator::{ decl_test_bridges, decl_test_networks, decl_test_parachains, decl_test_relay_chains, decl_test_sender_receiver_accounts_parameter_types, DefaultMessageProcessor, }; -pub use xcm_emulator::Chain; -pub use cumulus_pallet_xcmp_queue; // Polkadot -pub use xcm::prelude::{AccountId32, WeightLimit}; pub use pallet_xcm; +pub use xcm::prelude::{AccountId32, WeightLimit}; decl_test_relay_chains! { #[api_version(5)] diff --git a/cumulus/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs b/cumulus/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs index 8596d9f30ce17..c8764fb54cbb8 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs @@ -42,8 +42,8 @@ use xcm_builder::{ AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, CurrencyAdapter, DenyReserveTransferToRelayChain, DenyThenTry, DescribeAllTerminal, DescribeFamily, - EnsureXcmOrigin, FungiblesAdapter, HashedDescription, IsConcrete, LocalMint, - NoChecking, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, + EnsureXcmOrigin, FungiblesAdapter, HashedDescription, IsConcrete, LocalMint, NoChecking, + ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId, UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic, diff --git a/cumulus/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs b/cumulus/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs index 2e5a8511d8749..f2078a1a73626 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs @@ -38,8 +38,8 @@ use xcm_builder::{ AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, CurrencyAdapter, DenyReserveTransferToRelayChain, DenyThenTry, DescribeFamily, DescribePalletTerminal, - EnsureXcmOrigin, FungiblesAdapter, HashedDescription, IsConcrete, LocalMint, - NoChecking, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, + EnsureXcmOrigin, FungiblesAdapter, HashedDescription, IsConcrete, LocalMint, NoChecking, + ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId, UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic, From a6191b76afc9e98c8b227b26d007926b7f48e7d0 Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Mon, 4 Sep 2023 11:21:55 +0000 Subject: [PATCH 03/27] ".git/.scripts/commands/fmt/fmt.sh" --- .../emulated/bridges/bridge-hub-rococo/src/lib.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/lib.rs b/cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/lib.rs index 4de97b529cb96..7a91d428ac074 100644 --- a/cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/lib.rs @@ -18,15 +18,15 @@ pub use bp_messages::LaneId; pub use frame_support::assert_ok; pub use integration_tests_common::{ constants::{ - asset_hub_kusama::ED as ASSET_HUB_ROCOCO_ED, kusama::ED as ROCOCO_ED, PROOF_SIZE_THRESHOLD, - bridge_hub_rococo::ED as BRIDGE_HUB_ROCOCO_ED, - REF_TIME_THRESHOLD, XCM_V3, + asset_hub_kusama::ED as ASSET_HUB_ROCOCO_ED, bridge_hub_rococo::ED as BRIDGE_HUB_ROCOCO_ED, + kusama::ED as ROCOCO_ED, PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V3, }, test_parachain_is_trusted_teleporter, xcm_helpers::{xcm_transact_paid_execution, xcm_transact_unpaid_execution}, - AssetHubRococo, AssetHubRococoReceiver, AssetHubWococo, BridgeHubRococo, BridgeHubWococo, - PenpalRococoA, Rococo, RococoPallet, BridgeHubRococoSender, BridgeHubRococoPallet, - CollectivesPolkadotReceiver, CollectivesPolkadot, BridgeHubPolkadotReceiver, BridgeHubPolkadot + AssetHubRococo, AssetHubRococoReceiver, AssetHubWococo, BridgeHubPolkadot, + BridgeHubPolkadotReceiver, BridgeHubRococo, BridgeHubRococoPallet, BridgeHubRococoSender, + BridgeHubWococo, CollectivesPolkadot, CollectivesPolkadotReceiver, PenpalRococoA, Rococo, + RococoPallet, }; pub use parachains_common::{AccountId, Balance}; pub use xcm::{ From 0268b197c63bae880016fe008b84f9ef08a3f4fe Mon Sep 17 00:00:00 2001 From: NachoPal Date: Wed, 6 Sep 2023 11:30:18 +0200 Subject: [PATCH 04/27] comments --- cumulus/parachains/common/src/xcm_config.rs | 3 ++- .../assets/asset-hub-rococo/src/lib.rs | 25 +++++++++---------- .../assets/asset-hub-rococo/src/tests/mod.rs | 25 +++++++++---------- .../asset-hub-rococo/src/tests/teleport.rs | 25 +++++++++---------- .../collectives-westend/src/lib.rs | 25 +++++++++---------- .../collectives-westend/src/tests/mod.rs | 25 +++++++++---------- .../collectives-westend/src/tests/teleport.rs | 25 +++++++++---------- 7 files changed, 74 insertions(+), 79 deletions(-) diff --git a/cumulus/parachains/common/src/xcm_config.rs b/cumulus/parachains/common/src/xcm_config.rs index 137c3446abe8b..0ad7c51c11572 100644 --- a/cumulus/parachains/common/src/xcm_config.rs +++ b/cumulus/parachains/common/src/xcm_config.rs @@ -89,7 +89,8 @@ impl ContainsPair for ConcreteNativeAssetFromSystem { // The Relay Chain MultiLocation { parents: 1, interior: Here } => true, // System parachain - MultiLocation { parents: 1, interior: X1(Parachain(id)) } if *id < 2000 => true, + // TODO: reuse SystemParachains matcher when https://github.com/paritytech/polkadot-sdk/pull/1234 is merged + MultiLocation { parents: 1, interior: X1(Parachain(id)) } => *id < 2000, // Others _ => false, }; diff --git a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-rococo/src/lib.rs b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-rococo/src/lib.rs index e0f061b566086..155f6320e3809 100644 --- a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-rococo/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-rococo/src/lib.rs @@ -1,18 +1,17 @@ // Copyright (C) Parity Technologies (UK) Ltd. -// This file is part of Cumulus. +// SPDX-License-Identifier: Apache-2.0 -// Cumulus is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Cumulus is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Cumulus. If not, see . +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// 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 frame_support::assert_ok; pub use integration_tests_common::{ diff --git a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-rococo/src/tests/mod.rs b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-rococo/src/tests/mod.rs index bd1fa199548e7..516ec37cc10a0 100644 --- a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-rococo/src/tests/mod.rs +++ b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-rococo/src/tests/mod.rs @@ -1,17 +1,16 @@ // Copyright (C) Parity Technologies (UK) Ltd. -// This file is part of Cumulus. +// SPDX-License-Identifier: Apache-2.0 -// Cumulus is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Cumulus is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Cumulus. If not, see . +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// 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. mod teleport; diff --git a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-rococo/src/tests/teleport.rs b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-rococo/src/tests/teleport.rs index 246490bc9dc28..36b65c6d010ff 100644 --- a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-rococo/src/tests/teleport.rs +++ b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-rococo/src/tests/teleport.rs @@ -1,18 +1,17 @@ // Copyright (C) Parity Technologies (UK) Ltd. -// This file is part of Cumulus. +// SPDX-License-Identifier: Apache-2.0 -// Cumulus is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Cumulus is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Cumulus. If not, see . +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. use crate::*; diff --git a/cumulus/parachains/integration-tests/emulated/collectives/collectives-westend/src/lib.rs b/cumulus/parachains/integration-tests/emulated/collectives/collectives-westend/src/lib.rs index 6a230cf69c32f..7e293b7268dcf 100644 --- a/cumulus/parachains/integration-tests/emulated/collectives/collectives-westend/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/collectives/collectives-westend/src/lib.rs @@ -1,18 +1,17 @@ // Copyright (C) Parity Technologies (UK) Ltd. -// This file is part of Cumulus. +// SPDX-License-Identifier: Apache-2.0 -// Cumulus is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Cumulus is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Cumulus. If not, see . +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// 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 frame_support::assert_ok; pub use integration_tests_common::{ diff --git a/cumulus/parachains/integration-tests/emulated/collectives/collectives-westend/src/tests/mod.rs b/cumulus/parachains/integration-tests/emulated/collectives/collectives-westend/src/tests/mod.rs index bd1fa199548e7..516ec37cc10a0 100644 --- a/cumulus/parachains/integration-tests/emulated/collectives/collectives-westend/src/tests/mod.rs +++ b/cumulus/parachains/integration-tests/emulated/collectives/collectives-westend/src/tests/mod.rs @@ -1,17 +1,16 @@ // Copyright (C) Parity Technologies (UK) Ltd. -// This file is part of Cumulus. +// SPDX-License-Identifier: Apache-2.0 -// Cumulus is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Cumulus is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Cumulus. If not, see . +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// 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. mod teleport; diff --git a/cumulus/parachains/integration-tests/emulated/collectives/collectives-westend/src/tests/teleport.rs b/cumulus/parachains/integration-tests/emulated/collectives/collectives-westend/src/tests/teleport.rs index 878badcaa3349..e04e07c6fac3b 100644 --- a/cumulus/parachains/integration-tests/emulated/collectives/collectives-westend/src/tests/teleport.rs +++ b/cumulus/parachains/integration-tests/emulated/collectives/collectives-westend/src/tests/teleport.rs @@ -1,18 +1,17 @@ // Copyright (C) Parity Technologies (UK) Ltd. -// This file is part of Cumulus. +// SPDX-License-Identifier: Apache-2.0 -// Cumulus is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Cumulus is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Cumulus. If not, see . +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. use crate::*; From a888eaa588e2b893354db07c211f496bf2ca8395 Mon Sep 17 00:00:00 2001 From: NachoPal Date: Thu, 7 Sep 2023 17:13:50 +0200 Subject: [PATCH 05/27] more comments --- .../bridge-hub-rococo/src/tests/teleport.rs | 25 +++++++++-------- .../src/tests/teleport.rs | 27 +++++++++---------- .../emulated/common/src/macros.rs | 25 +++++++++-------- .../assets/asset-hub-kusama/src/xcm_config.rs | 6 ++--- .../asset-hub-polkadot/src/xcm_config.rs | 6 ++--- .../asset-hub-westend/src/xcm_config.rs | 6 ++--- .../bridge-hub-kusama/src/xcm_config.rs | 4 +-- .../bridge-hub-polkadot/src/xcm_config.rs | 4 +-- .../bridge-hub-rococo/src/xcm_config.rs | 4 +-- .../collectives-polkadot/src/xcm_config.rs | 4 +-- 10 files changed, 54 insertions(+), 57 deletions(-) diff --git a/cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/tests/teleport.rs b/cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/tests/teleport.rs index d1a2044925cc1..4c7e37fab6230 100644 --- a/cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/tests/teleport.rs +++ b/cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/tests/teleport.rs @@ -1,18 +1,17 @@ // Copyright (C) Parity Technologies (UK) Ltd. -// This file is part of Cumulus. +// SPDX-License-Identifier: Apache-2.0 -// Cumulus is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Cumulus is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Cumulus. If not, see . +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. use crate::*; diff --git a/cumulus/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/tests/teleport.rs b/cumulus/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/tests/teleport.rs index 8df531dd837b3..cf946a59e52fb 100644 --- a/cumulus/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/tests/teleport.rs +++ b/cumulus/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/tests/teleport.rs @@ -1,18 +1,17 @@ -// Copyright Parity Technologies (UK) Ltd. -// This file is part of Cumulus. +// Copyright (C) Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 -// Cumulus is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Cumulus is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Cumulus. If not, see . +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. use crate::*; diff --git a/cumulus/parachains/integration-tests/emulated/common/src/macros.rs b/cumulus/parachains/integration-tests/emulated/common/src/macros.rs index fa3816ccd2df6..4ed8f957bc208 100644 --- a/cumulus/parachains/integration-tests/emulated/common/src/macros.rs +++ b/cumulus/parachains/integration-tests/emulated/common/src/macros.rs @@ -1,18 +1,17 @@ // Copyright (C) Parity Technologies (UK) Ltd. -// This file is part of Cumulus. +// SPDX-License-Identifier: Apache-2.0 -// Cumulus is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Cumulus is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Cumulus. If not, see . +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// 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. #[macro_export] macro_rules! test_parachain_is_trusted_teleporter { diff --git a/cumulus/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs b/cumulus/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs index c8764fb54cbb8..f238ab1454d83 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs @@ -473,10 +473,10 @@ pub type AssetFeeAsExistentialDepositMultiplierFeeCharger = AssetFeeAsExistentia TrustBackedAssetsInstance, >; -/// Cases where a remote origin is accepted as a Trusted Teleporter: +/// Cases where a remote origin is accepted as trusted Teleporter for a given asset: /// -/// - teleportation of KSM from the parent Relay Chain and sibling system parachains; and -/// - teleportation of sibling parachains' assets (as `ForeignCreators`). +/// - KSM with the parent Relay Chain and sibling system parachains; and +/// - Sibling parachains' assets from where they originate (as `ForeignCreators`). pub type TrustedTeleporters = ( ConcreteNativeAssetFromSystem, IsForeignConcreteAsset>>, diff --git a/cumulus/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs b/cumulus/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs index f2078a1a73626..694563f7b13f4 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs @@ -393,10 +393,10 @@ pub type AssetFeeAsExistentialDepositMultiplierFeeCharger = AssetFeeAsExistentia TrustBackedAssetsInstance, >; -/// Cases where a remote origin is accepted as a Trusted Teleporter: +/// Cases where a remote origin is accepted as trusted Teleporter for a given asset: /// -/// - teleportation of DOT from the parent Relay Chain and sibling system parachains; and -/// - teleportation of sibling parachains' assets (as `ForeignCreators`). +/// - DOT with the parent Relay Chain and sibling system parachains; and +/// - Sibling parachains' assets from where they originate (as `ForeignCreators`). pub type TrustedTeleporters = ( ConcreteNativeAssetFromSystem, IsForeignConcreteAsset>>, diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs index eee9e2dd3ffe1..d4516af2268ec 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs @@ -476,10 +476,10 @@ pub type AssetFeeAsExistentialDepositMultiplierFeeCharger = AssetFeeAsExistentia TrustBackedAssetsInstance, >; -/// Cases where a remote origin is accepted as a Trusted Teleporter: +/// Cases where a remote origin is accepted as trusted Teleporter for a given asset: /// -/// - teleportation of WND from the parent Relay Chain and sibling system parachains; and -/// - teleportation of sibling parachains' assets (as `ForeignCreators`). +/// - WND with the parent Relay Chain and sibling system parachains; and +/// - Sibling parachains' assets from where they originate (as `ForeignCreators`). pub type TrustedTeleporters = ( ConcreteNativeAssetFromSystem, IsForeignConcreteAsset>>, diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs index 4c098f199aea2..a7295071cf96a 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs @@ -177,8 +177,8 @@ pub type Barrier = TrailingSetTopicAsId< >, >; -/// Cases where a remote origin is accepted as trusted Teleporter: -/// - teleportation of KSM from the parent Relay Chain and sibling parachains. +/// Cases where a remote origin is accepted as trusted Teleporter for a given asset: +/// - KSM with the parent Relay Chain and sibling parachains. pub type TrustedTeleporters = ConcreteNativeAssetFromSystem; pub struct XcmConfig; diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs index 3faea943f22a6..af9625c491971 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs @@ -181,8 +181,8 @@ pub type Barrier = TrailingSetTopicAsId< >, >; -/// Cases where a remote origin is accepted as trusted Teleporter: -/// - teleportation of DOT from the parent Relay Chain and sibling parachains. +/// Cases where a remote origin is accepted as trusted Teleporter for a given asset: +/// - DOT with the parent Relay Chain and sibling parachains. pub type TrustedTeleporters = ConcreteNativeAssetFromSystem; pub struct XcmConfig; diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs index 768550e12fb09..d2e5307f83ef2 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs @@ -224,8 +224,8 @@ pub type Barrier = TrailingSetTopicAsId< >, >; -/// Cases where a remote origin is accepted as trusted Teleporter: -/// - teleportation of NativeToken from the parent Relay Chain and sibling parachains. +/// Cases where a remote origin is accepted as trusted Teleporter for a given asset: +/// - NativeToken with the parent Relay Chain and sibling parachains. pub type TrustedTeleporters = ConcreteNativeAssetFromSystem; pub struct XcmConfig; diff --git a/cumulus/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs b/cumulus/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs index b789daad2610f..dd1eb562c7f51 100644 --- a/cumulus/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs @@ -227,8 +227,8 @@ pub type Barrier = TrailingSetTopicAsId< >, >; -/// Cases where a remote origin is accepted as trusted Teleporter: -/// - teleportation of DOT from the parent Relay Chain and sibling parachains. +/// Cases where a remote origin is accepted as trusted Teleporter for a given asset: +/// - DOT with the parent Relay Chain and sibling parachains. pub type TrustedTeleporters = ConcreteNativeAssetFromSystem; pub struct XcmConfig; From 478f6494378b12abbe71315f61058c6c4fd4204a Mon Sep 17 00:00:00 2001 From: NachoPal Date: Thu, 7 Sep 2023 17:21:12 +0200 Subject: [PATCH 06/27] remove dup comments --- .../runtimes/assets/asset-hub-kusama/src/xcm_config.rs | 3 --- .../runtimes/assets/asset-hub-polkadot/src/xcm_config.rs | 3 --- .../runtimes/assets/asset-hub-westend/src/xcm_config.rs | 3 --- .../runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs | 1 - .../runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs | 1 - .../runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs | 1 - .../collectives/collectives-polkadot/src/xcm_config.rs | 1 - 7 files changed, 13 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs b/cumulus/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs index f238ab1454d83..9d4bae4b15bee 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs @@ -492,9 +492,6 @@ impl xcm_executor::Config for XcmConfig { // Asset Hub acting _as_ a reserve location for KSM and assets created under `pallet-assets`. // For KSM, users must use teleport where allowed (e.g. with the Relay Chain). type IsReserve = (); - // We allow: - // - teleportation of KSM - // - teleportation of sibling parachain's assets (as ForeignCreators) type IsTeleporter = TrustedTeleporters; type UniversalLocation = UniversalLocation; type Barrier = Barrier; diff --git a/cumulus/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs b/cumulus/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs index 694563f7b13f4..b5a566046c9f3 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs @@ -412,9 +412,6 @@ impl xcm_executor::Config for XcmConfig { // Asset Hub acting _as_ a reserve location for DOT and assets created under `pallet-assets`. // For DOT, users must use teleport where allowed (e.g. with the Relay Chain). type IsReserve = (); - // We allow: - // - teleportation of DOT - // - teleportation of sibling parachain's assets (as ForeignCreators) type IsTeleporter = TrustedTeleporters; type UniversalLocation = UniversalLocation; type Barrier = Barrier; diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs index d4516af2268ec..bed18a9e1e04c 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs @@ -495,9 +495,6 @@ impl xcm_executor::Config for XcmConfig { // Asset Hub acting _as_ a reserve location for WND and assets created under `pallet-assets`. // For WND, users must use teleport where allowed (e.g. with the Relay Chain). type IsReserve = (); - // We allow: - // - teleportation of WND - // - teleportation of sibling parachain's assets (as ForeignCreators) type IsTeleporter = TrustedTeleporters; type UniversalLocation = UniversalLocation; type Barrier = Barrier; diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs index a7295071cf96a..ac82795b79821 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs @@ -190,7 +190,6 @@ impl xcm_executor::Config for XcmConfig { // BridgeHub does not recognize a reserve location for any asset. Users must teleport KSM // where allowed (e.g. with the Relay Chain). type IsReserve = (); - /// Only allow teleportation of KSM. type IsTeleporter = TrustedTeleporters; type UniversalLocation = UniversalLocation; type Barrier = Barrier; diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs index af9625c491971..a9f194e340045 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs @@ -194,7 +194,6 @@ impl xcm_executor::Config for XcmConfig { // BridgeHub does not recognize a reserve location for any asset. Users must teleport DOT // where allowed (e.g. with the Relay Chain). type IsReserve = (); - /// Only allow teleportation of DOT. type IsTeleporter = TrustedTeleporters; type UniversalLocation = UniversalLocation; type Barrier = Barrier; diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs index d2e5307f83ef2..45b52136df576 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs @@ -237,7 +237,6 @@ impl xcm_executor::Config for XcmConfig { // BridgeHub does not recognize a reserve location for any asset. Users must teleport Native // token where allowed (e.g. with the Relay Chain). type IsReserve = (); - /// Only allow teleportation of NativeToken of relay chain. type IsTeleporter = TrustedTeleporters; type UniversalLocation = UniversalLocation; type Barrier = Barrier; diff --git a/cumulus/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs b/cumulus/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs index dd1eb562c7f51..6b3339aba00fb 100644 --- a/cumulus/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs @@ -240,7 +240,6 @@ impl xcm_executor::Config for XcmConfig { // Collectives does not recognize a reserve location for any asset. Users must teleport DOT // where allowed (e.g. with the Relay Chain). type IsReserve = (); - /// Only allow teleportation of DOT. type IsTeleporter = TrustedTeleporters; type UniversalLocation = UniversalLocation; type Barrier = Barrier; From 00fcbae6ad9759336dc5516d181b0ac4da478c48 Mon Sep 17 00:00:00 2001 From: NachoPal Date: Thu, 7 Sep 2023 18:30:33 +0200 Subject: [PATCH 07/27] rework tests --- cumulus/parachains/common/src/xcm_config.rs | 22 ++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/cumulus/parachains/common/src/xcm_config.rs b/cumulus/parachains/common/src/xcm_config.rs index 0ad7c51c11572..37596b71a3b10 100644 --- a/cumulus/parachains/common/src/xcm_config.rs +++ b/cumulus/parachains/common/src/xcm_config.rs @@ -106,9 +106,9 @@ mod tests { }; #[test] - fn native_asset_from_sibling_system_para_works() { + fn native_asset_from_relay_works() { let expected_asset: MultiAsset = (Parent, 1000000).into(); - let expected_origin: MultiLocation = (Parent, Parachain(1999)).into(); + let expected_origin: MultiLocation = (Parent, Here).into(); assert!(ConcreteNativeAssetFromSystem::contains(&expected_asset, &expected_origin)); } @@ -128,10 +128,22 @@ mod tests { } #[test] - fn native_asset_from_sibling_system_para_fails_for_wrong_origin() { + fn native_asset_from_sibling_system_para_works_for_correct_asset() { + // (para_id, expected_result) + let test_data = vec![ + (0, true), + (1, true), + (1000, true), + (1999, true), + (2000, false), // Not a System Parachain + (2001, false), // Not a System Parachain + ]; + let expected_asset: MultiAsset = (Parent, 1000000).into(); - let unexpected_origin: MultiLocation = (Parent, Parachain(2000)).into(); - assert!(!ConcreteNativeAssetFromSystem::contains(&expected_asset, &unexpected_origin)); + for (para_id, expected_result) in test_data { + let origin: MultiLocation = (Parent, Parachain(para_id)).into(); + assert_eq!(expected_result, ConcreteNativeAssetFromSystem::contains(&expected_asset, &origin)); + } } } From be88eb6b83e7a218ffe0c7ab91b9e5d2ada92ab6 Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Thu, 7 Sep 2023 16:41:49 +0000 Subject: [PATCH 08/27] ".git/.scripts/commands/fmt/fmt.sh" --- cumulus/parachains/common/src/xcm_config.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cumulus/parachains/common/src/xcm_config.rs b/cumulus/parachains/common/src/xcm_config.rs index 37596b71a3b10..4f2941606a74d 100644 --- a/cumulus/parachains/common/src/xcm_config.rs +++ b/cumulus/parachains/common/src/xcm_config.rs @@ -143,7 +143,10 @@ mod tests { for (para_id, expected_result) in test_data { let origin: MultiLocation = (Parent, Parachain(para_id)).into(); - assert_eq!(expected_result, ConcreteNativeAssetFromSystem::contains(&expected_asset, &origin)); + assert_eq!( + expected_result, + ConcreteNativeAssetFromSystem::contains(&expected_asset, &origin) + ); } } } From 1f1f93033c9e6e89ee9f9f8f2f9c7cb37230b0a6 Mon Sep 17 00:00:00 2001 From: NachoPal Date: Fri, 8 Sep 2023 15:12:29 +0200 Subject: [PATCH 09/27] make asset location generic --- cumulus/parachains/common/src/xcm_config.rs | 28 ++++++++++++------- .../assets/asset-hub-kusama/src/xcm_config.rs | 4 +-- .../asset-hub-polkadot/src/xcm_config.rs | 4 +-- .../asset-hub-westend/src/xcm_config.rs | 4 +-- .../bridge-hub-kusama/src/xcm_config.rs | 4 +-- .../bridge-hub-polkadot/src/xcm_config.rs | 4 +-- .../bridge-hub-rococo/src/xcm_config.rs | 4 +-- .../collectives-polkadot/src/xcm_config.rs | 4 +-- .../contracts-rococo/src/xcm_config.rs | 4 +-- 9 files changed, 34 insertions(+), 26 deletions(-) diff --git a/cumulus/parachains/common/src/xcm_config.rs b/cumulus/parachains/common/src/xcm_config.rs index 4f2941606a74d..595d11427fd6b 100644 --- a/cumulus/parachains/common/src/xcm_config.rs +++ b/cumulus/parachains/common/src/xcm_config.rs @@ -80,11 +80,12 @@ impl> ContainsPair } /// Accepts an asset if it is a native asset from the system (Relay Chain or system parachain). -pub struct ConcreteNativeAssetFromSystem; -impl ContainsPair for ConcreteNativeAssetFromSystem { +pub struct ConcreteAssetFromSystem(PhantomData); +impl> ContainsPair + for ConcreteAssetFromSystem +{ fn contains(asset: &MultiAsset, origin: &MultiLocation) -> bool { - log::trace!(target: "xcm::contains", "ConcreteNativeAssetFromSystem asset: {:?}, origin: {:?}", asset, origin); - let parent = MultiLocation::parent(); + log::trace!(target: "xcm::contains", "ConcreteAssetFromSystem asset: {:?}, origin: {:?}", asset, origin); let is_system = match origin { // The Relay Chain MultiLocation { parents: 1, interior: Here } => true, @@ -94,23 +95,30 @@ impl ContainsPair for ConcreteNativeAssetFromSystem { // Others _ => false, }; - matches!(asset.id, Concrete(id) if id == parent && is_system) + matches!(asset.id, Concrete(id) if id == AssetLocation::get() && is_system) } } #[cfg(test)] mod tests { - use super::{ - ConcreteNativeAssetFromSystem, ContainsPair, GeneralIndex, Here, MultiAsset, MultiLocation, + use frame_support::parameter_types; + +use super::{ + ConcreteAssetFromSystem, ContainsPair, GeneralIndex, Here, MultiAsset, MultiLocation, PalletInstance, Parachain, Parent, }; + parameter_types! { + pub const RelayLocation: MultiLocation = MultiLocation::parent(); + } + + #[test] fn native_asset_from_relay_works() { let expected_asset: MultiAsset = (Parent, 1000000).into(); let expected_origin: MultiLocation = (Parent, Here).into(); - assert!(ConcreteNativeAssetFromSystem::contains(&expected_asset, &expected_origin)); + assert!(>::contains(&expected_asset, &expected_origin)); } #[test] @@ -123,7 +131,7 @@ mod tests { let expected_origin: MultiLocation = (Parent, Parachain(1000)).into(); unexpected_assets.iter().for_each(|asset| { - assert!(!ConcreteNativeAssetFromSystem::contains(asset, &expected_origin)); + assert!(!>::contains(asset, &expected_origin)); }); } @@ -145,7 +153,7 @@ mod tests { let origin: MultiLocation = (Parent, Parachain(para_id)).into(); assert_eq!( expected_result, - ConcreteNativeAssetFromSystem::contains(&expected_asset, &origin) + >::contains(&expected_asset, &origin) ); } } diff --git a/cumulus/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs b/cumulus/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs index 9d4bae4b15bee..cf91c1513ece2 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs @@ -33,7 +33,7 @@ use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; use parachains_common::{ impls::ToStakingPot, - xcm_config::{AssetFeeAsExistentialDepositMultiplier, ConcreteNativeAssetFromSystem}, + xcm_config::{AssetFeeAsExistentialDepositMultiplier, ConcreteAssetFromSystem}, }; use polkadot_parachain_primitives::primitives::Sibling; use sp_runtime::traits::ConvertInto; @@ -478,7 +478,7 @@ pub type AssetFeeAsExistentialDepositMultiplierFeeCharger = AssetFeeAsExistentia /// - KSM with the parent Relay Chain and sibling system parachains; and /// - Sibling parachains' assets from where they originate (as `ForeignCreators`). pub type TrustedTeleporters = ( - ConcreteNativeAssetFromSystem, + ConcreteAssetFromSystem, IsForeignConcreteAsset>>, ); diff --git a/cumulus/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs b/cumulus/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs index b5a566046c9f3..b6a7ab57affa7 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs @@ -29,7 +29,7 @@ use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; use parachains_common::{ impls::ToStakingPot, - xcm_config::{AssetFeeAsExistentialDepositMultiplier, ConcreteNativeAssetFromSystem}, + xcm_config::{AssetFeeAsExistentialDepositMultiplier, ConcreteAssetFromSystem}, }; use polkadot_parachain_primitives::primitives::Sibling; use sp_runtime::traits::ConvertInto; @@ -398,7 +398,7 @@ pub type AssetFeeAsExistentialDepositMultiplierFeeCharger = AssetFeeAsExistentia /// - DOT with the parent Relay Chain and sibling system parachains; and /// - Sibling parachains' assets from where they originate (as `ForeignCreators`). pub type TrustedTeleporters = ( - ConcreteNativeAssetFromSystem, + ConcreteAssetFromSystem, IsForeignConcreteAsset>>, ); diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs index bed18a9e1e04c..2b0aae0ae496f 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs @@ -33,7 +33,7 @@ use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; use parachains_common::{ impls::ToStakingPot, - xcm_config::{AssetFeeAsExistentialDepositMultiplier, ConcreteNativeAssetFromSystem}, + xcm_config::{AssetFeeAsExistentialDepositMultiplier, ConcreteAssetFromSystem}, }; use polkadot_parachain_primitives::primitives::Sibling; use sp_runtime::traits::ConvertInto; @@ -481,7 +481,7 @@ pub type AssetFeeAsExistentialDepositMultiplierFeeCharger = AssetFeeAsExistentia /// - WND with the parent Relay Chain and sibling system parachains; and /// - Sibling parachains' assets from where they originate (as `ForeignCreators`). pub type TrustedTeleporters = ( - ConcreteNativeAssetFromSystem, + ConcreteAssetFromSystem, IsForeignConcreteAsset>>, ); diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs index ac82795b79821..ddc5fc0c4a473 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs @@ -24,7 +24,7 @@ use frame_support::{ }; use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; -use parachains_common::{impls::ToStakingPot, xcm_config::ConcreteNativeAssetFromSystem}; +use parachains_common::{impls::ToStakingPot, xcm_config::ConcreteAssetFromSystem}; use polkadot_parachain_primitives::primitives::Sibling; use xcm::latest::prelude::*; use xcm_builder::{ @@ -179,7 +179,7 @@ pub type Barrier = TrailingSetTopicAsId< /// Cases where a remote origin is accepted as trusted Teleporter for a given asset: /// - KSM with the parent Relay Chain and sibling parachains. -pub type TrustedTeleporters = ConcreteNativeAssetFromSystem; +pub type TrustedTeleporters = ConcreteAssetFromSystem; pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs index a9f194e340045..84672a6c39441 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs @@ -24,7 +24,7 @@ use frame_support::{ }; use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; -use parachains_common::{impls::ToStakingPot, xcm_config::ConcreteNativeAssetFromSystem}; +use parachains_common::{impls::ToStakingPot, xcm_config::ConcreteAssetFromSystem}; use polkadot_parachain_primitives::primitives::Sibling; use xcm::latest::prelude::*; use xcm_builder::{ @@ -183,7 +183,7 @@ pub type Barrier = TrailingSetTopicAsId< /// Cases where a remote origin is accepted as trusted Teleporter for a given asset: /// - DOT with the parent Relay Chain and sibling parachains. -pub type TrustedTeleporters = ConcreteNativeAssetFromSystem; +pub type TrustedTeleporters = ConcreteAssetFromSystem; pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs index 45b52136df576..1639a507091d1 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs @@ -30,7 +30,7 @@ use frame_support::{ }; use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; -use parachains_common::{impls::ToStakingPot, xcm_config::ConcreteNativeAssetFromSystem}; +use parachains_common::{impls::ToStakingPot, xcm_config::ConcreteAssetFromSystem}; use polkadot_parachain_primitives::primitives::Sibling; use sp_core::Get; use xcm::latest::prelude::*; @@ -226,7 +226,7 @@ pub type Barrier = TrailingSetTopicAsId< /// Cases where a remote origin is accepted as trusted Teleporter for a given asset: /// - NativeToken with the parent Relay Chain and sibling parachains. -pub type TrustedTeleporters = ConcreteNativeAssetFromSystem; +pub type TrustedTeleporters = ConcreteAssetFromSystem; pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { diff --git a/cumulus/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs b/cumulus/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs index 6b3339aba00fb..458f4c443a16d 100644 --- a/cumulus/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs @@ -24,7 +24,7 @@ use frame_support::{ }; use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; -use parachains_common::{impls::ToStakingPot, xcm_config::ConcreteNativeAssetFromSystem}; +use parachains_common::{impls::ToStakingPot, xcm_config::ConcreteAssetFromSystem}; use polkadot_parachain_primitives::primitives::Sibling; use xcm::latest::prelude::*; use xcm_builder::{ @@ -229,7 +229,7 @@ pub type Barrier = TrailingSetTopicAsId< /// Cases where a remote origin is accepted as trusted Teleporter for a given asset: /// - DOT with the parent Relay Chain and sibling parachains. -pub type TrustedTeleporters = ConcreteNativeAssetFromSystem; +pub type TrustedTeleporters = ConcreteAssetFromSystem; pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { diff --git a/cumulus/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs b/cumulus/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs index dfd1fb3ae70f3..aafb61132b957 100644 --- a/cumulus/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs @@ -24,7 +24,7 @@ use frame_support::{ }; use frame_system::EnsureRoot; use pallet_xcm::{EnsureXcm, IsMajorityOfBody, XcmPassthrough}; -use parachains_common::xcm_config::ConcreteNativeAssetFromSystem; +use parachains_common::xcm_config::ConcreteAssetFromSystem; use polkadot_parachain_primitives::primitives::Sibling; use xcm::latest::prelude::*; use xcm_builder::{ @@ -145,7 +145,7 @@ pub type Barrier = TrailingSetTopicAsId< >, >; -pub type TrustedTeleporter = ConcreteNativeAssetFromSystem; +pub type TrustedTeleporter = ConcreteAssetFromSystem; pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { From 395d49534a48f09e124ac32b248da661c215d55f Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Fri, 8 Sep 2023 14:06:23 +0000 Subject: [PATCH 10/27] ".git/.scripts/commands/fmt/fmt.sh" --- cumulus/parachains/common/src/xcm_config.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cumulus/parachains/common/src/xcm_config.rs b/cumulus/parachains/common/src/xcm_config.rs index 595d11427fd6b..fd8bdf3290828 100644 --- a/cumulus/parachains/common/src/xcm_config.rs +++ b/cumulus/parachains/common/src/xcm_config.rs @@ -103,7 +103,7 @@ impl> ContainsPair mod tests { use frame_support::parameter_types; -use super::{ + use super::{ ConcreteAssetFromSystem, ContainsPair, GeneralIndex, Here, MultiAsset, MultiLocation, PalletInstance, Parachain, Parent, }; @@ -112,13 +112,15 @@ use super::{ pub const RelayLocation: MultiLocation = MultiLocation::parent(); } - #[test] fn native_asset_from_relay_works() { let expected_asset: MultiAsset = (Parent, 1000000).into(); let expected_origin: MultiLocation = (Parent, Here).into(); - assert!(>::contains(&expected_asset, &expected_origin)); + assert!(>::contains( + &expected_asset, + &expected_origin + )); } #[test] From 3305a5526e48924b6c791fade8b1208bf334121b Mon Sep 17 00:00:00 2001 From: NachoPal Date: Mon, 18 Sep 2023 12:11:28 +0200 Subject: [PATCH 11/27] fixes --- cumulus/parachains/common/src/xcm_config.rs | 14 +++++++------- .../integration-tests/emulated/common/Cargo.toml | 1 + 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/cumulus/parachains/common/src/xcm_config.rs b/cumulus/parachains/common/src/xcm_config.rs index fd8bdf3290828..802ea8e316571 100644 --- a/cumulus/parachains/common/src/xcm_config.rs +++ b/cumulus/parachains/common/src/xcm_config.rs @@ -79,7 +79,7 @@ impl> ContainsPair } } -/// Accepts an asset if it is a native asset from the system (Relay Chain or system parachain). +/// Accepts an asset if it is a concrete asset from the system (Relay Chain or system parachain). pub struct ConcreteAssetFromSystem(PhantomData); impl> ContainsPair for ConcreteAssetFromSystem @@ -113,18 +113,18 @@ mod tests { } #[test] - fn native_asset_from_relay_works() { + fn concrete_asset_from_relay_works() { let expected_asset: MultiAsset = (Parent, 1000000).into(); let expected_origin: MultiLocation = (Parent, Here).into(); - assert!(>::contains( + assert!(>::contains( &expected_asset, &expected_origin )); } #[test] - fn native_asset_from_sibling_system_para_fails_for_wrong_asset() { + fn concrete_asset_from_sibling_system_para_fails_for_wrong_asset() { let unexpected_assets: Vec = vec![ (Here, 1000000).into(), ((PalletInstance(50), GeneralIndex(1)), 1000000).into(), @@ -133,12 +133,12 @@ mod tests { let expected_origin: MultiLocation = (Parent, Parachain(1000)).into(); unexpected_assets.iter().for_each(|asset| { - assert!(!>::contains(asset, &expected_origin)); + assert!(!>::contains(asset, &expected_origin)); }); } #[test] - fn native_asset_from_sibling_system_para_works_for_correct_asset() { + fn concrete_asset_from_sibling_system_para_works_for_correct_asset() { // (para_id, expected_result) let test_data = vec![ (0, true), @@ -155,7 +155,7 @@ mod tests { let origin: MultiLocation = (Parent, Parachain(para_id)).into(); assert_eq!( expected_result, - >::contains(&expected_asset, &origin) + >::contains(&expected_asset, &origin) ); } } diff --git a/cumulus/parachains/integration-tests/emulated/common/Cargo.toml b/cumulus/parachains/integration-tests/emulated/common/Cargo.toml index 864c43892f865..1df78c00a1947 100644 --- a/cumulus/parachains/integration-tests/emulated/common/Cargo.toml +++ b/cumulus/parachains/integration-tests/emulated/common/Cargo.toml @@ -76,6 +76,7 @@ runtime-benchmarks = [ "frame-support/runtime-benchmarks", "kusama-runtime/runtime-benchmarks", "pallet-assets/runtime-benchmarks", + "pallet-balances/runtime-benchmarks", "pallet-bridge-messages/runtime-benchmarks", "pallet-im-online/runtime-benchmarks", "pallet-message-queue/runtime-benchmarks", From 49d31acfaf65268968ae0a977c9def83ad77cb9d Mon Sep 17 00:00:00 2001 From: NachoPal Date: Mon, 18 Sep 2023 15:44:18 +0200 Subject: [PATCH 12/27] init AuraExt for CollectivesWestend --- .../parachains/integration-tests/emulated/common/src/lib.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cumulus/parachains/integration-tests/emulated/common/src/lib.rs b/cumulus/parachains/integration-tests/emulated/common/src/lib.rs index 4dd00fde1727c..2bacd66560b90 100644 --- a/cumulus/parachains/integration-tests/emulated/common/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/common/src/lib.rs @@ -303,7 +303,9 @@ decl_test_parachains! { }, pub struct CollectivesWestend { genesis = collectives::genesis(), - on_init = (), + on_init = { + collectives_polkadot_runtime::AuraExt::on_initialize(1); + }, runtime = collectives_polkadot_runtime, core = { XcmpMessageHandler: collectives_polkadot_runtime::XcmpQueue, From d8b4b9fa19fce3c0fdd2a3fb99835c44565a37ec Mon Sep 17 00:00:00 2001 From: NachoPal Date: Mon, 18 Sep 2023 17:00:55 +0200 Subject: [PATCH 13/27] missing header --- .../emulated/common/src/xcm_helpers.rs | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/cumulus/parachains/integration-tests/emulated/common/src/xcm_helpers.rs b/cumulus/parachains/integration-tests/emulated/common/src/xcm_helpers.rs index 4096cdbba0b91..7c218bfbc092f 100644 --- a/cumulus/parachains/integration-tests/emulated/common/src/xcm_helpers.rs +++ b/cumulus/parachains/integration-tests/emulated/common/src/xcm_helpers.rs @@ -1,18 +1,17 @@ -// Copyright Parity Technologies (UK) Ltd. -// This file is part of Cumulus. +// Copyright (C) Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 -// Cumulus is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Cumulus is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Cumulus. If not, see . +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. use parachains_common::AccountId; use xcm::{ From 69454232cba6bc6e379339f3fd8ce23477e08b41 Mon Sep 17 00:00:00 2001 From: NachoPal Date: Wed, 20 Sep 2023 11:22:24 +0200 Subject: [PATCH 14/27] update is_system check --- cumulus/parachains/common/src/xcm_config.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cumulus/parachains/common/src/xcm_config.rs b/cumulus/parachains/common/src/xcm_config.rs index 802ea8e316571..f169d39257d44 100644 --- a/cumulus/parachains/common/src/xcm_config.rs +++ b/cumulus/parachains/common/src/xcm_config.rs @@ -22,6 +22,7 @@ use frame_support::{ use log; use sp_runtime::traits::Get; use xcm::latest::prelude::*; +use cumulus_primitives_core::{IsSystem, ParaId}; /// A `ChargeFeeInFungibles` implementation that converts the output of /// a given WeightToFee implementation an amount charged in @@ -90,8 +91,7 @@ impl> ContainsPair // The Relay Chain MultiLocation { parents: 1, interior: Here } => true, // System parachain - // TODO: reuse SystemParachains matcher when https://github.com/paritytech/polkadot-sdk/pull/1234 is merged - MultiLocation { parents: 1, interior: X1(Parachain(id)) } => *id < 2000, + MultiLocation { parents: 1, interior: X1(Parachain(id)) } => ParaId::from(*id).is_system(), // Others _ => false, }; From 44566611247bbc97388d5ee8c7f5c61d9a74cfeb Mon Sep 17 00:00:00 2001 From: NachoPal Date: Wed, 20 Sep 2023 11:29:38 +0200 Subject: [PATCH 15/27] test teleport macro comment --- .../parachains/integration-tests/emulated/common/src/macros.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cumulus/parachains/integration-tests/emulated/common/src/macros.rs b/cumulus/parachains/integration-tests/emulated/common/src/macros.rs index 4ed8f957bc208..e87c361ebeacc 100644 --- a/cumulus/parachains/integration-tests/emulated/common/src/macros.rs +++ b/cumulus/parachains/integration-tests/emulated/common/src/macros.rs @@ -37,6 +37,8 @@ macro_rules! test_parachain_is_trusted_teleporter { $crate::AccountId32 { network: None, id: receiver.clone().into() }.into(); // Send XCM message from Origin Parachain + // We are only testing the limited teleport version, which should be ok since success will + // depend only on a proper `XcmConfig` at destination. <$sender_para>::execute_with(|| { assert_ok!(<$sender_para as [<$sender_para Pallet>]>::PolkadotXcm::limited_teleport_assets( origin.clone(), From 17efd11c63717dd90aff3f127a6a257ad53b6e7c Mon Sep 17 00:00:00 2001 From: NachoPal Date: Wed, 20 Sep 2023 11:54:47 +0200 Subject: [PATCH 16/27] add BridgeHubWestend --- .../assets/asset-hub-westend/src/lib.rs | 2 +- .../asset-hub-westend/src/tests/teleport.rs | 2 +- .../collectives/collectives-westend/src/lib.rs | 2 +- .../collectives-westend/src/tests/teleport.rs | 2 +- .../emulated/common/src/lib.rs | 18 ++++++++++++++++++ 5 files changed, 22 insertions(+), 4 deletions(-) diff --git a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs index d90c29a86a3b5..3836ccb50df6f 100644 --- a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs @@ -32,7 +32,7 @@ pub use integration_tests_common::{ AssetHubWestend, AssetHubWestendPallet, AssetHubWestendReceiver, AssetHubWestendSender, CollectivesWestend, CollectivesWestendReceiver, PenpalWestendA, PenpalWestendAPallet, PenpalWestendAReceiver, PenpalWestendASender, Westend, WestendPallet, WestendReceiver, - WestendSender, + WestendSender, BridgeHubWestend, BridgeHubWestendReceiver, }; pub use parachains_common::{AccountId, Balance}; pub use xcm::{ diff --git a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/tests/teleport.rs b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/tests/teleport.rs index 34516d1e45d2d..fb0cec4dc5e44 100644 --- a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/tests/teleport.rs +++ b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/tests/teleport.rs @@ -369,7 +369,7 @@ fn teleport_to_other_system_parachains_works() { test_parachain_is_trusted_teleporter!( AssetHubWestend, // Origin - vec![CollectivesWestend], // Destinations + vec![CollectivesWestend, BridgeHubWestend], // Destinations (native_asset, amount) ); } diff --git a/cumulus/parachains/integration-tests/emulated/collectives/collectives-westend/src/lib.rs b/cumulus/parachains/integration-tests/emulated/collectives/collectives-westend/src/lib.rs index 7e293b7268dcf..2a63eb14a091d 100644 --- a/cumulus/parachains/integration-tests/emulated/collectives/collectives-westend/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/collectives/collectives-westend/src/lib.rs @@ -17,7 +17,7 @@ pub use frame_support::assert_ok; pub use integration_tests_common::{ constants::collectives::ED as COLLECTIVES_WESTEND_ED, test_parachain_is_trusted_teleporter, AssetHubWestend, AssetHubWestendPallet, AssetHubWestendReceiver, CollectivesWestend, - CollectivesWestendPallet, CollectivesWestendSender, + CollectivesWestendPallet, CollectivesWestendSender, BridgeHubWestend, BridgeHubWestendReceiver, }; pub use xcm::prelude::*; pub use xcm_emulator::{assert_expected_events, bx, Chain, Parachain, TestExt}; diff --git a/cumulus/parachains/integration-tests/emulated/collectives/collectives-westend/src/tests/teleport.rs b/cumulus/parachains/integration-tests/emulated/collectives/collectives-westend/src/tests/teleport.rs index e04e07c6fac3b..1fd7e2d484ff1 100644 --- a/cumulus/parachains/integration-tests/emulated/collectives/collectives-westend/src/tests/teleport.rs +++ b/cumulus/parachains/integration-tests/emulated/collectives/collectives-westend/src/tests/teleport.rs @@ -22,7 +22,7 @@ fn teleport_to_other_system_parachains_works() { test_parachain_is_trusted_teleporter!( CollectivesWestend, // Origin - vec![AssetHubWestend], // Destinations + vec![AssetHubWestend, BridgeHubWestend], // Destinations (native_asset, amount) ); } diff --git a/cumulus/parachains/integration-tests/emulated/common/src/lib.rs b/cumulus/parachains/integration-tests/emulated/common/src/lib.rs index 2bacd66560b90..b28989798d41a 100644 --- a/cumulus/parachains/integration-tests/emulated/common/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/common/src/lib.rs @@ -318,6 +318,22 @@ decl_test_parachains! { Balances: collectives_polkadot_runtime::Balances, } }, + pub struct BridgeHubWestend { + genesis = bridge_hub_kusama::genesis(), + on_init = { + bridge_hub_kusama_runtime::AuraExt::on_initialize(1); + }, + runtime = bridge_hub_kusama_runtime, + core = { + XcmpMessageHandler: bridge_hub_kusama_runtime::XcmpQueue, + DmpMessageHandler: bridge_hub_kusama_runtime::DmpQueue, + LocationToAccountId: bridge_hub_kusama_runtime::xcm_config::LocationToAccountId, + ParachainInfo: bridge_hub_kusama_runtime::ParachainInfo, + }, + pallets = { + PolkadotXcm: bridge_hub_kusama_runtime::PolkadotXcm, + } + }, pub struct PenpalWestendA { genesis = penpal::genesis(penpal::PARA_ID_A), on_init = { @@ -458,6 +474,7 @@ decl_test_networks! { parachains = vec![ AssetHubWestend, CollectivesWestend, + BridgeHubWestend, PenpalWestendA, ], bridge = () @@ -589,6 +606,7 @@ decl_test_sender_receiver_accounts_parameter_types! { // Bridged Hubs BridgeHubPolkadot { sender: ALICE, receiver: BOB }, BridgeHubKusama { sender: ALICE, receiver: BOB }, + BridgeHubWestend { sender: ALICE, receiver: BOB }, BridgeHubRococo { sender: ALICE, receiver: BOB }, BridgeHubWococo { sender: ALICE, receiver: BOB }, // Penpals From dfe4f7459075d9d3e78f53f550001b681ba2990a Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Wed, 20 Sep 2023 10:16:42 +0000 Subject: [PATCH 17/27] ".git/.scripts/commands/fmt/fmt.sh" --- cumulus/parachains/common/src/xcm_config.rs | 5 +++-- .../emulated/assets/asset-hub-westend/src/lib.rs | 6 +++--- .../emulated/assets/asset-hub-westend/src/tests/teleport.rs | 2 +- .../emulated/collectives/collectives-westend/src/lib.rs | 5 +++-- .../collectives/collectives-westend/src/tests/teleport.rs | 2 +- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/cumulus/parachains/common/src/xcm_config.rs b/cumulus/parachains/common/src/xcm_config.rs index f169d39257d44..cfe2f2f5fffb8 100644 --- a/cumulus/parachains/common/src/xcm_config.rs +++ b/cumulus/parachains/common/src/xcm_config.rs @@ -15,6 +15,7 @@ use crate::impls::AccountIdOf; use core::marker::PhantomData; +use cumulus_primitives_core::{IsSystem, ParaId}; use frame_support::{ traits::{fungibles::Inspect, tokens::ConversionToAssetBalance, ContainsPair}, weights::Weight, @@ -22,7 +23,6 @@ use frame_support::{ use log; use sp_runtime::traits::Get; use xcm::latest::prelude::*; -use cumulus_primitives_core::{IsSystem, ParaId}; /// A `ChargeFeeInFungibles` implementation that converts the output of /// a given WeightToFee implementation an amount charged in @@ -91,7 +91,8 @@ impl> ContainsPair // The Relay Chain MultiLocation { parents: 1, interior: Here } => true, // System parachain - MultiLocation { parents: 1, interior: X1(Parachain(id)) } => ParaId::from(*id).is_system(), + MultiLocation { parents: 1, interior: X1(Parachain(id)) } => + ParaId::from(*id).is_system(), // Others _ => false, }; diff --git a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs index 3836ccb50df6f..f4735f00b9fe2 100644 --- a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs @@ -30,9 +30,9 @@ pub use integration_tests_common::{ test_parachain_is_trusted_teleporter, xcm_helpers::{xcm_transact_paid_execution, xcm_transact_unpaid_execution}, AssetHubWestend, AssetHubWestendPallet, AssetHubWestendReceiver, AssetHubWestendSender, - CollectivesWestend, CollectivesWestendReceiver, PenpalWestendA, PenpalWestendAPallet, - PenpalWestendAReceiver, PenpalWestendASender, Westend, WestendPallet, WestendReceiver, - WestendSender, BridgeHubWestend, BridgeHubWestendReceiver, + BridgeHubWestend, BridgeHubWestendReceiver, CollectivesWestend, CollectivesWestendReceiver, + PenpalWestendA, PenpalWestendAPallet, PenpalWestendAReceiver, PenpalWestendASender, Westend, + WestendPallet, WestendReceiver, WestendSender, }; pub use parachains_common::{AccountId, Balance}; pub use xcm::{ diff --git a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/tests/teleport.rs b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/tests/teleport.rs index fb0cec4dc5e44..cc33698469741 100644 --- a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/tests/teleport.rs +++ b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/tests/teleport.rs @@ -368,7 +368,7 @@ fn teleport_to_other_system_parachains_works() { let native_asset: VersionedMultiAssets = (Parent, amount).into(); test_parachain_is_trusted_teleporter!( - AssetHubWestend, // Origin + AssetHubWestend, // Origin vec![CollectivesWestend, BridgeHubWestend], // Destinations (native_asset, amount) ); diff --git a/cumulus/parachains/integration-tests/emulated/collectives/collectives-westend/src/lib.rs b/cumulus/parachains/integration-tests/emulated/collectives/collectives-westend/src/lib.rs index 2a63eb14a091d..8907963a38e6a 100644 --- a/cumulus/parachains/integration-tests/emulated/collectives/collectives-westend/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/collectives/collectives-westend/src/lib.rs @@ -16,8 +16,9 @@ pub use frame_support::assert_ok; pub use integration_tests_common::{ constants::collectives::ED as COLLECTIVES_WESTEND_ED, test_parachain_is_trusted_teleporter, - AssetHubWestend, AssetHubWestendPallet, AssetHubWestendReceiver, CollectivesWestend, - CollectivesWestendPallet, CollectivesWestendSender, BridgeHubWestend, BridgeHubWestendReceiver, + AssetHubWestend, AssetHubWestendPallet, AssetHubWestendReceiver, BridgeHubWestend, + BridgeHubWestendReceiver, CollectivesWestend, CollectivesWestendPallet, + CollectivesWestendSender, }; pub use xcm::prelude::*; pub use xcm_emulator::{assert_expected_events, bx, Chain, Parachain, TestExt}; diff --git a/cumulus/parachains/integration-tests/emulated/collectives/collectives-westend/src/tests/teleport.rs b/cumulus/parachains/integration-tests/emulated/collectives/collectives-westend/src/tests/teleport.rs index 1fd7e2d484ff1..2180733eedcab 100644 --- a/cumulus/parachains/integration-tests/emulated/collectives/collectives-westend/src/tests/teleport.rs +++ b/cumulus/parachains/integration-tests/emulated/collectives/collectives-westend/src/tests/teleport.rs @@ -21,7 +21,7 @@ fn teleport_to_other_system_parachains_works() { let native_asset: VersionedMultiAssets = (Parent, amount).into(); test_parachain_is_trusted_teleporter!( - CollectivesWestend, // Origin + CollectivesWestend, // Origin vec![AssetHubWestend, BridgeHubWestend], // Destinations (native_asset, amount) ); From a111b4b098c2d4b20e3903cc0c1d67c75b390460 Mon Sep 17 00:00:00 2001 From: NachoPal Date: Mon, 16 Oct 2023 11:53:14 +0200 Subject: [PATCH 18/27] remove prod runtimes and clean up --- .../assets/asset-hub-kusama/src/lib.rs | 92 ----- .../asset-hub-kusama/src/tests/teleport.rs | 376 ------------------ .../assets/asset-hub-polkadot/src/lib.rs | 92 ----- .../asset-hub-polkadot/src/tests/teleport.rs | 375 ----------------- .../assets/asset-hub-westend/src/lib.rs | 1 - .../asset-hub-westend/src/tests/teleport.rs | 23 +- .../collectives-polkadot/src/lib.rs | 86 ---- .../src/tests/fellowship.rs | 75 ---- .../collectives-polkadot/src/tests/mod.rs | 17 - .../src/tests/teleport.rs | 28 -- .../collectives-westend/Cargo.toml | 26 -- .../collectives-westend/src/lib.rs | 28 -- .../collectives-westend/src/tests/mod.rs | 16 - .../collectives-westend/src/tests/teleport.rs | 28 -- .../emulated/common/src/lib.rs | 33 -- 15 files changed, 12 insertions(+), 1284 deletions(-) delete mode 100644 cumulus/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/lib.rs delete mode 100644 cumulus/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/tests/teleport.rs delete mode 100644 cumulus/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/lib.rs delete mode 100644 cumulus/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/teleport.rs delete mode 100644 cumulus/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/lib.rs delete mode 100644 cumulus/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/tests/fellowship.rs delete mode 100644 cumulus/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/tests/mod.rs delete mode 100644 cumulus/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/tests/teleport.rs delete mode 100644 cumulus/parachains/integration-tests/emulated/collectives/collectives-westend/Cargo.toml delete mode 100644 cumulus/parachains/integration-tests/emulated/collectives/collectives-westend/src/lib.rs delete mode 100644 cumulus/parachains/integration-tests/emulated/collectives/collectives-westend/src/tests/mod.rs delete mode 100644 cumulus/parachains/integration-tests/emulated/collectives/collectives-westend/src/tests/teleport.rs diff --git a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/lib.rs b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/lib.rs deleted file mode 100644 index 054e760044ef2..0000000000000 --- a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/lib.rs +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright (C) Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// 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 codec::Encode; -pub use frame_support::{ - assert_err, assert_ok, - pallet_prelude::Weight, - sp_runtime::{AccountId32, DispatchError, DispatchResult}, - traits::fungibles::Inspect, -}; -pub use integration_tests_common::{ - constants::{ - asset_hub_kusama::ED as ASSET_HUB_KUSAMA_ED, kusama::ED as KUSAMA_ED, PROOF_SIZE_THRESHOLD, - REF_TIME_THRESHOLD, XCM_V3, - }, - test_parachain_is_trusted_teleporter, - xcm_helpers::{xcm_transact_paid_execution, xcm_transact_unpaid_execution}, - AssetHubKusama, AssetHubKusamaPallet, AssetHubKusamaReceiver, AssetHubKusamaSender, - BridgeHubKusama, BridgeHubKusamaReceiver, Kusama, KusamaPallet, KusamaReceiver, KusamaSender, - PenpalKusamaA, PenpalKusamaAPallet, PenpalKusamaAReceiver, PenpalKusamaASender, PenpalKusamaB, - PenpalKusamaBPallet, -}; -pub use parachains_common::{AccountId, Balance}; -pub use xcm::{ - prelude::{AccountId32 as AccountId32Junction, *}, - v3::{Error, NetworkId::Kusama as KusamaId}, -}; -pub use xcm_emulator::{ - assert_expected_events, bx, helpers::weight_within_threshold, Chain, Parachain as Para, - RelayChain as Relay, Test, TestArgs, TestContext, TestExt, -}; - -pub const ASSET_ID: u32 = 1; -pub const ASSET_MIN_BALANCE: u128 = 1000; -// `Assets` pallet index -pub const ASSETS_PALLET_ID: u8 = 50; - -pub type RelayToSystemParaTest = Test; -pub type SystemParaToRelayTest = Test; -pub type SystemParaToParaTest = Test; - -/// Returns a `TestArgs` instance to de used for the Relay Chain accross integraton tests -pub fn relay_test_args(amount: Balance) -> TestArgs { - TestArgs { - dest: Kusama::child_location_of(AssetHubKusama::para_id()), - beneficiary: AccountId32Junction { - network: None, - id: AssetHubKusamaReceiver::get().into(), - } - .into(), - amount, - assets: (Here, amount).into(), - asset_id: None, - fee_asset_item: 0, - weight_limit: WeightLimit::Unlimited, - } -} - -/// Returns a `TestArgs` instance to de used for the System Parachain accross integraton tests -pub fn system_para_test_args( - dest: MultiLocation, - beneficiary_id: AccountId32, - amount: Balance, - assets: MultiAssets, - asset_id: Option, -) -> TestArgs { - TestArgs { - dest, - beneficiary: AccountId32Junction { network: None, id: beneficiary_id.into() }.into(), - amount, - assets, - asset_id, - fee_asset_item: 0, - weight_limit: WeightLimit::Unlimited, - } -} - -#[cfg(test)] -#[cfg(not(feature = "runtime-benchmarks"))] -mod tests; diff --git a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/tests/teleport.rs b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/tests/teleport.rs deleted file mode 100644 index 4e0b36dee5ba7..0000000000000 --- a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/tests/teleport.rs +++ /dev/null @@ -1,376 +0,0 @@ -// Copyright (C) Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// 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. - -#![allow(dead_code)] // - -use crate::*; - -fn relay_origin_assertions(t: RelayToSystemParaTest) { - type RuntimeEvent = ::RuntimeEvent; - - Kusama::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts(631_531_000, 7_186))); - - assert_expected_events!( - Kusama, - vec![ - // Amount to teleport is withdrawn from Sender - RuntimeEvent::Balances(pallet_balances::Event::Withdraw { who, amount }) => { - who: *who == t.sender.account_id, - amount: *amount == t.args.amount, - }, - // Amount to teleport is deposited in Relay's `CheckAccount` - RuntimeEvent::Balances(pallet_balances::Event::Deposit { who, amount }) => { - who: *who == ::XcmPallet::check_account(), - amount: *amount == t.args.amount, - }, - ] - ); -} - -fn relay_dest_assertions(t: SystemParaToRelayTest) { - type RuntimeEvent = ::RuntimeEvent; - - Kusama::assert_ump_queue_processed( - true, - Some(AssetHubKusama::para_id()), - Some(Weight::from_parts(307_225_000, 7_186)), - ); - - assert_expected_events!( - Kusama, - vec![ - // Amount is witdrawn from Relay Chain's `CheckAccount` - RuntimeEvent::Balances(pallet_balances::Event::Withdraw { who, amount }) => { - who: *who == ::XcmPallet::check_account(), - amount: *amount == t.args.amount, - }, - // Amount minus fees are deposited in Receiver's account - RuntimeEvent::Balances(pallet_balances::Event::Deposit { who, .. }) => { - who: *who == t.receiver.account_id, - }, - ] - ); -} - -fn relay_dest_assertions_fail(_t: SystemParaToRelayTest) { - Kusama::assert_ump_queue_processed( - false, - Some(AssetHubKusama::para_id()), - Some(Weight::from_parts(148_433_000, 3_593)), - ); -} - -fn para_origin_assertions(t: SystemParaToRelayTest) { - type RuntimeEvent = ::RuntimeEvent; - - AssetHubKusama::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts( - 534_872_000, - 7_133, - ))); - - AssetHubKusama::assert_parachain_system_ump_sent(); - - assert_expected_events!( - AssetHubKusama, - vec![ - // Amount is withdrawn from Sender's account - RuntimeEvent::Balances(pallet_balances::Event::Withdraw { who, amount }) => { - who: *who == t.sender.account_id, - amount: *amount == t.args.amount, - }, - ] - ); -} - -fn para_dest_assertions(t: RelayToSystemParaTest) { - type RuntimeEvent = ::RuntimeEvent; - - AssetHubKusama::assert_dmp_queue_complete(Some(Weight::from_parts(165_592_000, 0))); - - assert_expected_events!( - AssetHubKusama, - vec![ - // Amount minus fees are deposited in Receiver's account - RuntimeEvent::Balances(pallet_balances::Event::Deposit { who, .. }) => { - who: *who == t.receiver.account_id, - }, - ] - ); -} - -fn relay_limited_teleport_assets(t: RelayToSystemParaTest) -> DispatchResult { - ::XcmPallet::limited_teleport_assets( - t.signed_origin, - bx!(t.args.dest.into()), - bx!(t.args.beneficiary.into()), - bx!(t.args.assets.into()), - t.args.fee_asset_item, - t.args.weight_limit, - ) -} - -fn relay_teleport_assets(t: RelayToSystemParaTest) -> DispatchResult { - ::XcmPallet::teleport_assets( - t.signed_origin, - bx!(t.args.dest.into()), - bx!(t.args.beneficiary.into()), - bx!(t.args.assets.into()), - t.args.fee_asset_item, - ) -} - -fn system_para_limited_teleport_assets(t: SystemParaToRelayTest) -> DispatchResult { - ::PolkadotXcm::limited_teleport_assets( - t.signed_origin, - bx!(t.args.dest.into()), - bx!(t.args.beneficiary.into()), - bx!(t.args.assets.into()), - t.args.fee_asset_item, - t.args.weight_limit, - ) -} - -// TODO: Uncomment when https://github.com/paritytech/polkadot/pull/7424 is merged -// fn system_para_teleport_assets(t: SystemParaToRelayTest) -> DispatchResult { -// ::PolkadotXcm::teleport_assets( -// t.signed_origin, -// bx!(t.args.dest), -// bx!(t.args.beneficiary), -// bx!(t.args.assets), -// t.args.fee_asset_item, -// ) -// } - -/// Limited Teleport of native asset from Relay Chain to the System Parachain should work -#[test] -fn limited_teleport_native_assets_from_relay_to_system_para_works() { - // Init values for Relay Chain - let amount_to_send: Balance = KUSAMA_ED * 1000; - let test_args = TestContext { - sender: KusamaSender::get(), - receiver: AssetHubKusamaReceiver::get(), - args: relay_test_args(amount_to_send), - }; - - let mut test = RelayToSystemParaTest::new(test_args); - - let sender_balance_before = test.sender.balance; - let receiver_balance_before = test.receiver.balance; - - test.set_assertion::(relay_origin_assertions); - test.set_assertion::(para_dest_assertions); - test.set_dispatchable::(relay_limited_teleport_assets); - test.assert(); - - let sender_balance_after = test.sender.balance; - let receiver_balance_after = test.receiver.balance; - - // Sender's balance is reduced - assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); - // Receiver's balance is increased - assert!(receiver_balance_after > receiver_balance_before); -} - -/// Limited Teleport of native asset from System Parachain to Relay Chain -/// should work when there is enough balance in Relay Chain's `CheckAccount` -#[test] -fn limited_teleport_native_assets_back_from_system_para_to_relay_works() { - // Dependency - Relay Chain's `CheckAccount` should have enough balance - limited_teleport_native_assets_from_relay_to_system_para_works(); - - // Init values for Relay Chain - let amount_to_send: Balance = ASSET_HUB_KUSAMA_ED * 1000; - let destination = AssetHubKusama::parent_location(); - let beneficiary_id = KusamaReceiver::get(); - let assets = (Parent, amount_to_send).into(); - - let test_args = TestContext { - sender: AssetHubKusamaSender::get(), - receiver: KusamaReceiver::get(), - args: system_para_test_args(destination, beneficiary_id, amount_to_send, assets, None), - }; - - let mut test = SystemParaToRelayTest::new(test_args); - - let sender_balance_before = test.sender.balance; - let receiver_balance_before = test.receiver.balance; - - test.set_assertion::(para_origin_assertions); - test.set_assertion::(relay_dest_assertions); - test.set_dispatchable::(system_para_limited_teleport_assets); - test.assert(); - - let sender_balance_after = test.sender.balance; - let receiver_balance_after = test.receiver.balance; - - // Sender's balance is reduced - assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); - // Receiver's balance is increased - assert!(receiver_balance_after > receiver_balance_before); -} - -/// Limited Teleport of native asset from System Parachain to Relay Chain -/// should't work when there is not enough balance in Relay Chain's `CheckAccount` -#[test] -fn limited_teleport_native_assets_from_system_para_to_relay_fails() { - // Init values for Relay Chain - let amount_to_send: Balance = ASSET_HUB_KUSAMA_ED * 1000; - let destination = AssetHubKusama::parent_location().into(); - let beneficiary_id = KusamaReceiver::get().into(); - let assets = (Parent, amount_to_send).into(); - - let test_args = TestContext { - sender: AssetHubKusamaSender::get(), - receiver: KusamaReceiver::get(), - args: system_para_test_args(destination, beneficiary_id, amount_to_send, assets, None), - }; - - let mut test = SystemParaToRelayTest::new(test_args); - - let sender_balance_before = test.sender.balance; - let receiver_balance_before = test.receiver.balance; - - test.set_assertion::(para_origin_assertions); - test.set_assertion::(relay_dest_assertions_fail); - test.set_dispatchable::(system_para_limited_teleport_assets); - test.assert(); - - let sender_balance_after = test.sender.balance; - let receiver_balance_after = test.receiver.balance; - - // Sender's balance is reduced - assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); - // Receiver's balance does not change - assert_eq!(receiver_balance_after, receiver_balance_before); -} - -/// Teleport of native asset from Relay Chain to the System Parachain should work -#[test] -fn teleport_native_assets_from_relay_to_system_para_works() { - // Init values for Relay Chain - let amount_to_send: Balance = KUSAMA_ED * 1000; - let test_args = TestContext { - sender: KusamaSender::get(), - receiver: AssetHubKusamaReceiver::get(), - args: relay_test_args(amount_to_send), - }; - - let mut test = RelayToSystemParaTest::new(test_args); - - let sender_balance_before = test.sender.balance; - let receiver_balance_before = test.receiver.balance; - - test.set_assertion::(relay_origin_assertions); - test.set_assertion::(para_dest_assertions); - test.set_dispatchable::(relay_teleport_assets); - test.assert(); - - let sender_balance_after = test.sender.balance; - let receiver_balance_after = test.receiver.balance; - - // Sender's balance is reduced - assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); - // Receiver's balance is increased - assert!(receiver_balance_after > receiver_balance_before); -} - -// TODO: Uncomment when https://github.com/paritytech/polkadot/pull/7424 is merged - -// Right now it is failing in the Relay Chain with a -// `messageQueue.ProcessingFailed` event `error: Unsupported`. -// The reason is the `Weigher` in `pallet_xcm` is not properly calculating the `remote_weight` -// and it cause an `Overweight` error in `AllowTopLevelPaidExecutionFrom` barrier - -// /// Teleport of native asset from System Parachains to the Relay Chain -// /// should work when there is enough balance in Relay Chain's `CheckAccount` -// #[test] -// fn teleport_native_assets_back_from_system_para_to_relay_works() { -// // Dependency - Relay Chain's `CheckAccount` should have enough balance -// teleport_native_assets_from_relay_to_system_para_works(); - -// // Init values for Relay Chain -// let amount_to_send: Balance = ASSET_HUB_KUSAMA_ED * 1000; -// let test_args = TestContext { -// sender: AssetHubKusamaSender::get(), -// receiver: KusamaReceiver::get(), -// args: get_para_dispatch_args(amount_to_send), -// }; - -// let mut test = SystemParaToRelayTest::new(test_args); - -// let sender_balance_before = test.sender.balance; -// let receiver_balance_before = test.receiver.balance; - -// test.set_assertion::(para_origin_assertions); -// test.set_assertion::(relay_dest_assertions); -// test.set_dispatchable::(system_para_teleport_assets); -// test.assert(); - -// let sender_balance_after = test.sender.balance; -// let receiver_balance_after = test.receiver.balance; - -// // Sender's balance is reduced -// assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); -// // Receiver's balance is increased -// assert!(receiver_balance_after > receiver_balance_before); -// } - -// /// Teleport of native asset from System Parachain to Relay Chain -// /// shouldn't work when there is not enough balance in Relay Chain's `CheckAccount` -// #[test] -// fn teleport_native_assets_from_system_para_to_relay_fails() { -// // Init values for Relay Chain -// let amount_to_send: Balance = ASSET_HUB_KUSAMA_ED * 1000; -// let assets = (Parent, amount_to_send).into(); -// -// let test_args = TestContext { -// sender: AssetHubKusamaSender::get(), -// receiver: KusamaReceiver::get(), -// args: system_para_test_args(amount_to_send), -// assets, -// None -// }; - -// let mut test = SystemParaToRelayTest::new(test_args); - -// let sender_balance_before = test.sender.balance; -// let receiver_balance_before = test.receiver.balance; - -// test.set_assertion::(para_origin_assertions); -// test.set_assertion::(relay_dest_assertions); -// test.set_dispatchable::(system_para_teleport_assets); -// test.assert(); - -// let sender_balance_after = test.sender.balance; -// let receiver_balance_after = test.receiver.balance; - -// // Sender's balance is reduced -// assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); -// // Receiver's balance does not change -// assert_eq!(receiver_balance_after, receiver_balance_before); -// } - -#[test] -fn teleport_to_other_system_parachains_works() { - let amount = ASSET_HUB_KUSAMA_ED * 100; - let expected_asset: VersionedMultiAssets = (Parent, amount).into(); - - // Works for the right origin and asset - test_parachain_is_trusted_teleporter!( - AssetHubKusama, // Origin - vec![BridgeHubKusama], // Destinations - (expected_asset, amount) - ); -} diff --git a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/lib.rs b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/lib.rs deleted file mode 100644 index 0484dfc78d7e2..0000000000000 --- a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/lib.rs +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright (C) Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// 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 codec::Encode; -pub use frame_support::{ - assert_err, assert_ok, - pallet_prelude::Weight, - sp_runtime::{AccountId32, DispatchError, DispatchResult}, - traits::fungibles::Inspect, -}; -pub use integration_tests_common::{ - constants::{ - asset_hub_polkadot::ED as ASSET_HUB_POLKADOT_ED, polkadot::ED as POLKADOT_ED, - PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V3, - }, - test_parachain_is_trusted_teleporter, - xcm_helpers::{xcm_transact_paid_execution, xcm_transact_unpaid_execution}, - AssetHubPolkadot, AssetHubPolkadotPallet, AssetHubPolkadotReceiver, AssetHubPolkadotSender, - BridgeHubPolkadot, BridgeHubPolkadotReceiver, CollectivesPolkadot, CollectivesPolkadotReceiver, - PenpalPolkadotA, PenpalPolkadotAPallet, PenpalPolkadotAReceiver, PenpalPolkadotB, - PenpalPolkadotBPallet, Polkadot, PolkadotPallet, PolkadotReceiver, PolkadotSender, -}; -pub use parachains_common::{AccountId, Balance}; -pub use xcm::{ - prelude::{AccountId32 as AccountId32Junction, *}, - v3::{Error, NetworkId::Polkadot as PolkadotId}, -}; -pub use xcm_emulator::{ - assert_expected_events, bx, helpers::weight_within_threshold, Chain, Parachain as Para, - RelayChain as Relay, Test, TestArgs, TestContext, TestExt, -}; - -pub const ASSET_ID: u32 = 1; -pub const ASSET_MIN_BALANCE: u128 = 1000; -// `Assets` pallet index -pub const ASSETS_PALLET_ID: u8 = 50; - -pub type RelayToSystemParaTest = Test; -pub type SystemParaToRelayTest = Test; -pub type SystemParaToParaTest = Test; - -/// Returns a `TestArgs` instance to de used for the Relay Chain accross integraton tests -pub fn relay_test_args(amount: Balance) -> TestArgs { - TestArgs { - dest: Polkadot::child_location_of(AssetHubPolkadot::para_id()), - beneficiary: AccountId32Junction { - network: None, - id: AssetHubPolkadotReceiver::get().into(), - } - .into(), - amount, - assets: (Here, amount).into(), - asset_id: None, - fee_asset_item: 0, - weight_limit: WeightLimit::Unlimited, - } -} - -/// Returns a `TestArgs` instance to de used for the System Parachain accross integraton tests -pub fn system_para_test_args( - dest: MultiLocation, - beneficiary_id: AccountId32, - amount: Balance, - assets: MultiAssets, - asset_id: Option, -) -> TestArgs { - TestArgs { - dest, - beneficiary: AccountId32Junction { network: None, id: beneficiary_id.into() }.into(), - amount, - assets, - asset_id, - fee_asset_item: 0, - weight_limit: WeightLimit::Unlimited, - } -} - -#[cfg(test)] -#[cfg(not(feature = "runtime-benchmarks"))] -mod tests; diff --git a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/teleport.rs b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/teleport.rs deleted file mode 100644 index 275d3aabec079..0000000000000 --- a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/teleport.rs +++ /dev/null @@ -1,375 +0,0 @@ -// Copyright (C) Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// 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. - -#![allow(dead_code)] // - -use crate::*; - -fn relay_origin_assertions(t: RelayToSystemParaTest) { - type RuntimeEvent = ::RuntimeEvent; - - Polkadot::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts(632_207_000, 7_186))); - - assert_expected_events!( - Polkadot, - vec![ - // Amount to teleport is withdrawn from Sender - RuntimeEvent::Balances(pallet_balances::Event::Withdraw { who, amount }) => { - who: *who == t.sender.account_id, - amount: *amount == t.args.amount, - }, - // Amount to teleport is deposited in Relay's `CheckAccount` - RuntimeEvent::Balances(pallet_balances::Event::Deposit { who, amount }) => { - who: *who == ::XcmPallet::check_account(), - amount: *amount == t.args.amount, - }, - ] - ); -} - -fn relay_dest_assertions(t: SystemParaToRelayTest) { - type RuntimeEvent = ::RuntimeEvent; - - Polkadot::assert_ump_queue_processed( - true, - Some(AssetHubPolkadot::para_id()), - Some(Weight::from_parts(368_931_000, 7_186)), - ); - - assert_expected_events!( - Polkadot, - vec![ - // Amount is witdrawn from Relay Chain's `CheckAccount` - RuntimeEvent::Balances(pallet_balances::Event::Withdraw { who, amount }) => { - who: *who == ::XcmPallet::check_account(), - amount: *amount == t.args.amount, - }, - // Amount minus fees are deposited in Receiver's account - RuntimeEvent::Balances(pallet_balances::Event::Deposit { who, .. }) => { - who: *who == t.receiver.account_id, - }, - ] - ); -} - -fn relay_dest_assertions_fail(_t: SystemParaToRelayTest) { - Polkadot::assert_ump_queue_processed( - false, - Some(AssetHubPolkadot::para_id()), - Some(Weight::from_parts(232_982_000, 3_593)), - ); -} - -fn para_origin_assertions(t: SystemParaToRelayTest) { - type RuntimeEvent = ::RuntimeEvent; - - AssetHubPolkadot::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts( - 632_207_000, - 7_186, - ))); - - AssetHubPolkadot::assert_parachain_system_ump_sent(); - - assert_expected_events!( - AssetHubPolkadot, - vec![ - // Amount is withdrawn from Sender's account - RuntimeEvent::Balances(pallet_balances::Event::Withdraw { who, amount }) => { - who: *who == t.sender.account_id, - amount: *amount == t.args.amount, - }, - ] - ); -} - -fn para_dest_assertions(t: RelayToSystemParaTest) { - type RuntimeEvent = ::RuntimeEvent; - - AssetHubPolkadot::assert_dmp_queue_complete(Some(Weight::from_parts(161_196_000, 0))); - - assert_expected_events!( - AssetHubPolkadot, - vec![ - // Amount minus fees are deposited in Receiver's account - RuntimeEvent::Balances(pallet_balances::Event::Deposit { who, .. }) => { - who: *who == t.receiver.account_id, - }, - ] - ); -} - -fn relay_limited_teleport_assets(t: RelayToSystemParaTest) -> DispatchResult { - ::XcmPallet::limited_teleport_assets( - t.signed_origin, - bx!(t.args.dest.into()), - bx!(t.args.beneficiary.into()), - bx!(t.args.assets.into()), - t.args.fee_asset_item, - t.args.weight_limit, - ) -} - -fn relay_teleport_assets(t: RelayToSystemParaTest) -> DispatchResult { - ::XcmPallet::teleport_assets( - t.signed_origin, - bx!(t.args.dest.into()), - bx!(t.args.beneficiary.into()), - bx!(t.args.assets.into()), - t.args.fee_asset_item, - ) -} - -fn system_para_limited_teleport_assets(t: SystemParaToRelayTest) -> DispatchResult { - ::PolkadotXcm::limited_teleport_assets( - t.signed_origin, - bx!(t.args.dest.into()), - bx!(t.args.beneficiary.into()), - bx!(t.args.assets.into()), - t.args.fee_asset_item, - t.args.weight_limit, - ) -} - -// TODO: Uncomment when https://github.com/paritytech/polkadot/pull/7424 is merged -// fn system_para_teleport_assets(t: SystemParaToRelayTest) -> DispatchResult { -// ::PolkadotXcm::teleport_assets( -// t.signed_origin, -// bx!(t.args.dest), -// bx!(t.args.beneficiary), -// bx!(t.args.assets), -// t.args.fee_asset_item, -// ) -// } - -/// Limited Teleport of native asset from Relay Chain to the System Parachain should work -#[test] -fn limited_teleport_native_assets_from_relay_to_system_para_works() { - // Init values for Relay Chain - let amount_to_send: Balance = POLKADOT_ED * 1000; - let test_args = TestContext { - sender: PolkadotSender::get(), - receiver: AssetHubPolkadotReceiver::get(), - args: relay_test_args(amount_to_send), - }; - - let mut test = RelayToSystemParaTest::new(test_args); - - let sender_balance_before = test.sender.balance; - let receiver_balance_before = test.receiver.balance; - - test.set_assertion::(relay_origin_assertions); - test.set_assertion::(para_dest_assertions); - test.set_dispatchable::(relay_limited_teleport_assets); - test.assert(); - - let sender_balance_after = test.sender.balance; - let receiver_balance_after = test.receiver.balance; - - // Sender's balance is reduced - assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); - // Receiver's balance is increased - assert!(receiver_balance_after > receiver_balance_before); -} - -/// Limited Teleport of native asset from System Parachain to Relay Chain -/// should work when there is enough balance in Relay Chain's `CheckAccount` -#[test] -fn limited_teleport_native_assets_back_from_system_para_to_relay_works() { - // Dependency - Relay Chain's `CheckAccount` should have enough balance - limited_teleport_native_assets_from_relay_to_system_para_works(); - - // Init values for Relay Chain - let amount_to_send: Balance = ASSET_HUB_POLKADOT_ED * 1000; - let destination = AssetHubPolkadot::parent_location(); - let beneficiary_id = PolkadotReceiver::get(); - let assets = (Parent, amount_to_send).into(); - - let test_args = TestContext { - sender: AssetHubPolkadotSender::get(), - receiver: PolkadotReceiver::get(), - args: system_para_test_args(destination, beneficiary_id, amount_to_send, assets, None), - }; - - let mut test = SystemParaToRelayTest::new(test_args); - - let sender_balance_before = test.sender.balance; - let receiver_balance_before = test.receiver.balance; - - test.set_assertion::(para_origin_assertions); - test.set_assertion::(relay_dest_assertions); - test.set_dispatchable::(system_para_limited_teleport_assets); - test.assert(); - - let sender_balance_after = test.sender.balance; - let receiver_balance_after = test.receiver.balance; - - // Sender's balance is reduced - assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); - // Receiver's balance is increased - assert!(receiver_balance_after > receiver_balance_before); -} - -/// Limited Teleport of native asset from System Parachain to Relay Chain -/// should't work when there is not enough balance in Relay Chain's `CheckAccount` -#[test] -fn limited_teleport_native_assets_from_system_para_to_relay_fails() { - // Init values for Relay Chain - let amount_to_send: Balance = ASSET_HUB_POLKADOT_ED * 1000; - let destination = AssetHubPolkadot::parent_location().into(); - let beneficiary_id = PolkadotReceiver::get().into(); - let assets = (Parent, amount_to_send).into(); - - let test_args = TestContext { - sender: AssetHubPolkadotSender::get(), - receiver: PolkadotReceiver::get(), - args: system_para_test_args(destination, beneficiary_id, amount_to_send, assets, None), - }; - - let mut test = SystemParaToRelayTest::new(test_args); - - let sender_balance_before = test.sender.balance; - let receiver_balance_before = test.receiver.balance; - - test.set_assertion::(para_origin_assertions); - test.set_assertion::(relay_dest_assertions_fail); - test.set_dispatchable::(system_para_limited_teleport_assets); - test.assert(); - - let sender_balance_after = test.sender.balance; - let receiver_balance_after = test.receiver.balance; - - // Sender's balance is reduced - assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); - // Receiver's balance does not change - assert_eq!(receiver_balance_after, receiver_balance_before); -} - -/// Teleport of native asset from Relay Chain to the System Parachain should work -#[test] -fn teleport_native_assets_from_relay_to_system_para_works() { - // Init values for Relay Chain - let amount_to_send: Balance = POLKADOT_ED * 1000; - let test_args = TestContext { - sender: PolkadotSender::get(), - receiver: AssetHubPolkadotReceiver::get(), - args: relay_test_args(amount_to_send), - }; - - let mut test = RelayToSystemParaTest::new(test_args); - - let sender_balance_before = test.sender.balance; - let receiver_balance_before = test.receiver.balance; - - test.set_assertion::(relay_origin_assertions); - test.set_assertion::(para_dest_assertions); - test.set_dispatchable::(relay_teleport_assets); - test.assert(); - - let sender_balance_after = test.sender.balance; - let receiver_balance_after = test.receiver.balance; - - // Sender's balance is reduced - assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); - // Receiver's balance is increased - assert!(receiver_balance_after > receiver_balance_before); -} - -// TODO: Uncomment when https://github.com/paritytech/polkadot/pull/7424 is merged - -// Right now it is failing in the Relay Chain with a -// `messageQueue.ProcessingFailed` event `error: Unsupported`. -// The reason is the `Weigher` in `pallet_xcm` is not properly calculating the `remote_weight` -// and it cause an `Overweight` error in `AllowTopLevelPaidExecutionFrom` barrier - -// /// Teleport of native asset from System Parachains to the Relay Chain -// /// should work when there is enough balance in Relay Chain's `CheckAccount` -// #[test] -// fn teleport_native_assets_back_from_system_para_to_relay_works() { -// // Dependency - Relay Chain's `CheckAccount` should have enough balance -// teleport_native_assets_from_relay_to_system_para_works(); - -// // Init values for Relay Chain -// let amount_to_send: Balance = ASSET_HUB_POLKADOT_ED * 1000; -// let test_args = TestContext { -// sender: AssetHubPolkadotSender::get(), -// receiver: PolkadotReceiver::get(), -// args: get_para_dispatch_args(amount_to_send), -// }; - -// let mut test = SystemParaToRelayTest::new(test_args); - -// let sender_balance_before = test.sender.balance; -// let receiver_balance_before = test.receiver.balance; - -// test.set_assertion::(para_origin_assertions); -// test.set_assertion::(relay_dest_assertions); -// test.set_dispatchable::(system_para_teleport_assets); -// test.assert(); - -// let sender_balance_after = test.sender.balance; -// let receiver_balance_after = test.receiver.balance; - -// // Sender's balance is reduced -// assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); -// // Receiver's balance is increased -// assert!(receiver_balance_after > receiver_balance_before); -// } - -// /// Teleport of native asset from System Parachain to Relay Chain -// /// shouldn't work when there is not enough balance in Relay Chain's `CheckAccount` -// #[test] -// fn teleport_native_assets_from_system_para_to_relay_fails() { -// // Init values for Relay Chain -// let amount_to_send: Balance = ASSET_HUB_POLKADOT_ED * 1000; -// let assets = (Parent, amount_to_send).into(); -// -// let test_args = TestContext { -// sender: AssetHubPolkadotSender::get(), -// receiver: PolkadotReceiver::get(), -// args: system_para_test_args(amount_to_send), -// assets, -// None -// }; - -// let mut test = SystemParaToRelayTest::new(test_args); - -// let sender_balance_before = test.sender.balance; -// let receiver_balance_before = test.receiver.balance; - -// test.set_assertion::(para_origin_assertions); -// test.set_assertion::(relay_dest_assertions); -// test.set_dispatchable::(system_para_teleport_assets); -// test.assert(); - -// let sender_balance_after = test.sender.balance; -// let receiver_balance_after = test.receiver.balance; - -// // Sender's balance is reduced -// assert_eq!(sender_balance_before - amount_to_send, sender_balance_after); -// // Receiver's balance does not change -// assert_eq!(receiver_balance_after, receiver_balance_before); -// } - -#[test] -fn teleport_to_other_system_parachains_works() { - let amount = ASSET_HUB_POLKADOT_ED * 100; - let native_asset: VersionedMultiAssets = (Parent, amount).into(); - - test_parachain_is_trusted_teleporter!( - AssetHubPolkadot, // Origin - vec![CollectivesPolkadot, BridgeHubPolkadot], // Destinations - (native_asset, amount) - ); -} diff --git a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs index f4735f00b9fe2..8355aed444f22 100644 --- a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs @@ -30,7 +30,6 @@ pub use integration_tests_common::{ test_parachain_is_trusted_teleporter, xcm_helpers::{xcm_transact_paid_execution, xcm_transact_unpaid_execution}, AssetHubWestend, AssetHubWestendPallet, AssetHubWestendReceiver, AssetHubWestendSender, - BridgeHubWestend, BridgeHubWestendReceiver, CollectivesWestend, CollectivesWestendReceiver, PenpalWestendA, PenpalWestendAPallet, PenpalWestendAReceiver, PenpalWestendASender, Westend, WestendPallet, WestendReceiver, WestendSender, }; diff --git a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/tests/teleport.rs b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/tests/teleport.rs index 5a51ce6ad8d58..1014116cf8730 100644 --- a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/tests/teleport.rs +++ b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/tests/teleport.rs @@ -358,14 +358,15 @@ fn teleport_native_assets_from_system_para_to_relay_fails() { assert_eq!(receiver_balance_after, receiver_balance_before); } -#[test] -fn teleport_to_other_system_parachains_works() { - let amount = ASSET_HUB_WESTEND_ED * 100; - let native_asset: VersionedMultiAssets = (Parent, amount).into(); - - test_parachain_is_trusted_teleporter!( - AssetHubWestend, // Origin - vec![CollectivesWestend, BridgeHubWestend], // Destinations - (native_asset, amount) - ); -} +// TODO: uncomment when Collectives and BridgeHubWestend are implemented +// #[test] +// fn teleport_to_other_system_parachains_works() { +// let amount = ASSET_HUB_WESTEND_ED * 100; +// let native_asset: VersionedMultiAssets = (Parent, amount).into(); + +// test_parachain_is_trusted_teleporter!( +// AssetHubWestend, // Origin +// vec![CollectivesWestend, BridgeHubWestend], // Destinations +// (native_asset, amount) +// ); +// } diff --git a/cumulus/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/lib.rs b/cumulus/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/lib.rs deleted file mode 100644 index 22677968061c3..0000000000000 --- a/cumulus/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/lib.rs +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright (C) Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// 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 codec::Encode; -pub use frame_support::{assert_ok, sp_runtime::AccountId32}; -pub use integration_tests_common::{ - constants::{ - accounts::ALICE, asset_hub_polkadot::ED as ASSET_HUB_POLKADOT_ED, - collectives::ED as COLLECTIVES_POLKADOT_ED, polkadot::ED as POLKADOT_ED, - PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V3, - }, - test_parachain_is_trusted_teleporter, - xcm_helpers::{xcm_transact_paid_execution, xcm_transact_unpaid_execution}, - AssetHubPolkadot, AssetHubPolkadotPallet, AssetHubPolkadotReceiver, BridgeHubPolkadot, - BridgeHubPolkadotReceiver, CollectivesPolkadot, CollectivesPolkadotPallet, - CollectivesPolkadotSender, PenpalPolkadotA, Polkadot, -}; -pub use parachains_common::{AccountId, Balance}; -pub use xcm::{ - prelude::{AccountId32 as AccountId32Junction, *}, - v3::{Error, NetworkId::Polkadot as PolkadotId}, -}; -pub use xcm_emulator::{ - assert_expected_events, bx, helpers::weight_within_threshold, Chain, ParaId, Parachain as Para, - RelayChain as Relay, Test, TestArgs, TestContext, TestExt, TestExternalities, -}; - -pub const ASSET_ID: u32 = 1; -pub const ASSET_MIN_BALANCE: u128 = 1000; -pub const ASSETS_PALLET_ID: u8 = 50; - -pub type RelayToSystemParaTest = Test; -pub type SystemParaToRelayTest = Test; -pub type SystemParaToParaTest = Test; - -/// Returns a `TestArgs` instance to de used for the Relay Chain accross integraton tests -pub fn relay_test_args(amount: Balance) -> TestArgs { - TestArgs { - dest: Polkadot::child_location_of(AssetHubPolkadot::para_id()), - beneficiary: AccountId32Junction { - network: None, - id: AssetHubPolkadotReceiver::get().into(), - } - .into(), - amount, - assets: (Here, amount).into(), - asset_id: None, - fee_asset_item: 0, - weight_limit: WeightLimit::Unlimited, - } -} - -/// Returns a `TestArgs` instance to de used for the System Parachain accross integraton tests -pub fn system_para_test_args( - dest: MultiLocation, - beneficiary_id: AccountId32, - amount: Balance, - assets: MultiAssets, - asset_id: Option, -) -> TestArgs { - TestArgs { - dest, - beneficiary: AccountId32Junction { network: None, id: beneficiary_id.into() }.into(), - amount, - assets, - asset_id, - fee_asset_item: 0, - weight_limit: WeightLimit::Unlimited, - } -} - -#[cfg(test)] -#[cfg(not(feature = "runtime-benchmarks"))] -mod tests; diff --git a/cumulus/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/tests/fellowship.rs b/cumulus/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/tests/fellowship.rs deleted file mode 100644 index 36ffb05a7c639..0000000000000 --- a/cumulus/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/tests/fellowship.rs +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (C) Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// 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. - -//! Integration tests concerning the Fellowship. - -use crate::*; -use collectives_polkadot_runtime::fellowship::FellowshipSalaryPaymaster; -use frame_support::traits::{ - fungibles::{Create, Mutate}, - tokens::Pay, -}; -use sp_core::crypto::Ss58Codec; -use xcm_emulator::TestExt; - -#[test] -fn pay_salary() { - let asset_id: u32 = 1984; - let pay_from: AccountId = - ::from_string("13w7NdvSR1Af8xsQTArDtZmVvjE8XhWNdL4yed3iFHrUNCnS") - .unwrap(); - let pay_to = Polkadot::account_id_of(ALICE); - let pay_amount = 9000; - - AssetHubPolkadot::execute_with(|| { - type AssetHubAssets = ::Assets; - - assert_ok!(>::create( - asset_id, - pay_to.clone(), - true, - pay_amount / 2 - )); - assert_ok!(>::mint_into(asset_id, &pay_from, pay_amount * 2)); - }); - - CollectivesPolkadot::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - - assert_ok!(FellowshipSalaryPaymaster::pay(&pay_to, (), pay_amount)); - assert_expected_events!( - CollectivesPolkadot, - vec![ - RuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { .. }) => {}, - ] - ); - }); - - AssetHubPolkadot::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - assert_expected_events!( - AssetHubPolkadot, - vec![ - RuntimeEvent::Assets(pallet_assets::Event::Transferred { asset_id: id, from, to, amount }) => - { asset_id: id == &asset_id, - from: from == &pay_from, - to: to == &pay_to, - amount: amount == &pay_amount, - }, - RuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::Success { .. }) => {}, - ] - ); - }); -} diff --git a/cumulus/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/tests/mod.rs b/cumulus/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/tests/mod.rs deleted file mode 100644 index eb53fc6c1b6a4..0000000000000 --- a/cumulus/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/tests/mod.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (C) Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// 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. - -mod fellowship; -mod teleport; diff --git a/cumulus/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/tests/teleport.rs b/cumulus/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/tests/teleport.rs deleted file mode 100644 index cf946a59e52fb..0000000000000 --- a/cumulus/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/tests/teleport.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -use crate::*; - -#[test] -fn teleport_to_other_system_parachains_works() { - let amount = COLLECTIVES_POLKADOT_ED * 100; - let native_asset: VersionedMultiAssets = (Parent, amount).into(); - - test_parachain_is_trusted_teleporter!( - CollectivesPolkadot, // Origin - vec![AssetHubPolkadot, BridgeHubPolkadot], // Destinations - (native_asset, amount) - ); -} diff --git a/cumulus/parachains/integration-tests/emulated/collectives/collectives-westend/Cargo.toml b/cumulus/parachains/integration-tests/emulated/collectives/collectives-westend/Cargo.toml deleted file mode 100644 index ba34ddc7f6472..0000000000000 --- a/cumulus/parachains/integration-tests/emulated/collectives/collectives-westend/Cargo.toml +++ /dev/null @@ -1,26 +0,0 @@ -[package] -name = "collectives-westend-integration-tests" -version = "0.1.0" -authors.workspace = true -edition.workspace = true -description = "Polkadot Westend parachain runtime integration tests based on xcm-emulator" -publish = false - -[dependencies] -codec = { package = "parity-scale-codec", version = "3.4.0", default-features = false } - -# Substrate -frame-support = { path = "../../../../../../substrate/frame/support", default-features = false} - -# Polkadot -xcm = { package = "staging-xcm", path = "../../../../../../polkadot/xcm", default-features = false} - -# Local -xcm-emulator = { path = "../../../../../xcm/xcm-emulator", default-features = false} -integration-tests-common = { path = "../../common", default-features = false} - -[features] -runtime-benchmarks = [ - "frame-support/runtime-benchmarks", - "integration-tests-common/runtime-benchmarks", -] diff --git a/cumulus/parachains/integration-tests/emulated/collectives/collectives-westend/src/lib.rs b/cumulus/parachains/integration-tests/emulated/collectives/collectives-westend/src/lib.rs deleted file mode 100644 index 8907963a38e6a..0000000000000 --- a/cumulus/parachains/integration-tests/emulated/collectives/collectives-westend/src/lib.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// 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 frame_support::assert_ok; -pub use integration_tests_common::{ - constants::collectives::ED as COLLECTIVES_WESTEND_ED, test_parachain_is_trusted_teleporter, - AssetHubWestend, AssetHubWestendPallet, AssetHubWestendReceiver, BridgeHubWestend, - BridgeHubWestendReceiver, CollectivesWestend, CollectivesWestendPallet, - CollectivesWestendSender, -}; -pub use xcm::prelude::*; -pub use xcm_emulator::{assert_expected_events, bx, Chain, Parachain, TestExt}; - -#[cfg(test)] -#[cfg(not(feature = "runtime-benchmarks"))] -mod tests; diff --git a/cumulus/parachains/integration-tests/emulated/collectives/collectives-westend/src/tests/mod.rs b/cumulus/parachains/integration-tests/emulated/collectives/collectives-westend/src/tests/mod.rs deleted file mode 100644 index 516ec37cc10a0..0000000000000 --- a/cumulus/parachains/integration-tests/emulated/collectives/collectives-westend/src/tests/mod.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// 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. - -mod teleport; diff --git a/cumulus/parachains/integration-tests/emulated/collectives/collectives-westend/src/tests/teleport.rs b/cumulus/parachains/integration-tests/emulated/collectives/collectives-westend/src/tests/teleport.rs deleted file mode 100644 index 2180733eedcab..0000000000000 --- a/cumulus/parachains/integration-tests/emulated/collectives/collectives-westend/src/tests/teleport.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -use crate::*; - -#[test] -fn teleport_to_other_system_parachains_works() { - let amount = COLLECTIVES_WESTEND_ED * 100; - let native_asset: VersionedMultiAssets = (Parent, amount).into(); - - test_parachain_is_trusted_teleporter!( - CollectivesWestend, // Origin - vec![AssetHubWestend, BridgeHubWestend], // Destinations - (native_asset, amount) - ); -} diff --git a/cumulus/parachains/integration-tests/emulated/common/src/lib.rs b/cumulus/parachains/integration-tests/emulated/common/src/lib.rs index bdf3be9154da8..e974fbf2aaa43 100644 --- a/cumulus/parachains/integration-tests/emulated/common/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/common/src/lib.rs @@ -114,39 +114,6 @@ decl_test_parachains! { AssetConversion: asset_hub_westend_runtime::AssetConversion, } }, - pub struct CollectivesWestend { - genesis = collectives::genesis(), - on_init = { - collectives_polkadot_runtime::AuraExt::on_initialize(1); - }, - runtime = collectives_polkadot_runtime, - core = { - XcmpMessageHandler: collectives_polkadot_runtime::XcmpQueue, - DmpMessageHandler: collectives_polkadot_runtime::DmpQueue, - LocationToAccountId: collectives_polkadot_runtime::xcm_config::LocationToAccountId, - ParachainInfo: collectives_polkadot_runtime::ParachainInfo, - }, - pallets = { - PolkadotXcm: collectives_polkadot_runtime::PolkadotXcm, - Balances: collectives_polkadot_runtime::Balances, - } - }, - pub struct BridgeHubWestend { - genesis = bridge_hub_kusama::genesis(), - on_init = { - bridge_hub_kusama_runtime::AuraExt::on_initialize(1); - }, - runtime = bridge_hub_kusama_runtime, - core = { - XcmpMessageHandler: bridge_hub_kusama_runtime::XcmpQueue, - DmpMessageHandler: bridge_hub_kusama_runtime::DmpQueue, - LocationToAccountId: bridge_hub_kusama_runtime::xcm_config::LocationToAccountId, - ParachainInfo: bridge_hub_kusama_runtime::ParachainInfo, - }, - pallets = { - PolkadotXcm: bridge_hub_kusama_runtime::PolkadotXcm, - } - }, pub struct PenpalWestendA { genesis = penpal::genesis(penpal::PARA_ID_A), on_init = { From 0d93435854db53dd80322b8d996ab2902741470c Mon Sep 17 00:00:00 2001 From: NachoPal Date: Mon, 16 Oct 2023 11:58:31 +0200 Subject: [PATCH 19/27] remove westend colletives & bidge --- cumulus/parachains/integration-tests/emulated/common/src/lib.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/cumulus/parachains/integration-tests/emulated/common/src/lib.rs b/cumulus/parachains/integration-tests/emulated/common/src/lib.rs index e974fbf2aaa43..e9a30aadedd49 100644 --- a/cumulus/parachains/integration-tests/emulated/common/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/common/src/lib.rs @@ -228,8 +228,6 @@ decl_test_networks! { relay_chain = Westend, parachains = vec![ AssetHubWestend, - CollectivesWestend, - BridgeHubWestend, PenpalWestendA, ], bridge = () From 0e0ca41d88224554a02632e627cbc6ba05113a1f Mon Sep 17 00:00:00 2001 From: NachoPal Date: Mon, 16 Oct 2023 12:43:16 +0200 Subject: [PATCH 20/27] fix conflicts --- Cargo.lock | 11 ----------- Cargo.toml | 1 - 2 files changed, 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 02f67f88e919b..b14bc129275c8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2581,17 +2581,6 @@ dependencies = [ "substrate-wasm-builder", ] -[[package]] -name = "collectives-westend-integration-tests" -version = "0.1.0" -dependencies = [ - "frame-support", - "integration-tests-common", - "parity-scale-codec", - "staging-xcm", - "xcm-emulator", -] - [[package]] name = "color-eyre" version = "0.6.2" diff --git a/Cargo.toml b/Cargo.toml index b415ca13fac51..9e8ead6cf7c9d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -62,7 +62,6 @@ members = [ "cumulus/parachains/common", "cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend", "cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo", - "cumulus/parachains/integration-tests/emulated/collectives/collectives-westend", "cumulus/parachains/integration-tests/emulated/common", "cumulus/parachains/pallets/parachain-info", "cumulus/parachains/pallets/ping", From 5b3638d6afc55ea12f6c59a76f70d7f31563498b Mon Sep 17 00:00:00 2001 From: NachoPal Date: Mon, 16 Oct 2023 13:07:20 +0200 Subject: [PATCH 21/27] fix conflicts 2 --- .../emulated/bridges/bridge-hub-rococo/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/lib.rs b/cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/lib.rs index 46be5885489fd..70c29a9b5bdf1 100644 --- a/cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/lib.rs @@ -22,9 +22,9 @@ pub use integration_tests_common::{ }, test_parachain_is_trusted_teleporter, xcm_helpers::{xcm_transact_paid_execution, xcm_transact_unpaid_execution}, - AssetHubRococo, AssetHubRococoReceiver, AssetHubWococo, BridgeHubPolkadot, - BridgeHubPolkadotReceiver, BridgeHubRococo, BridgeHubRococoPallet, BridgeHubRococoSender, - BridgeHubWococo, CollectivesPolkadot, CollectivesPolkadotReceiver, PenpalRococoA, Rococo, + AssetHubRococo, AssetHubRococoReceiver, AssetHubWococo, + BridgeHubRococo, BridgeHubRococoPallet, BridgeHubRococoSender, + BridgeHubWococo, PenpalRococoA, Rococo, RococoPallet, }; pub use parachains_common::{AccountId, Balance}; From 4c1c8e1030405b6853ca895ad9336ab3a23054aa Mon Sep 17 00:00:00 2001 From: NachoPal Date: Mon, 16 Oct 2023 13:08:22 +0200 Subject: [PATCH 22/27] fmt --- .../emulated/bridges/bridge-hub-rococo/src/lib.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/lib.rs b/cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/lib.rs index 70c29a9b5bdf1..80d0d3393616b 100644 --- a/cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/lib.rs @@ -22,10 +22,8 @@ pub use integration_tests_common::{ }, test_parachain_is_trusted_teleporter, xcm_helpers::{xcm_transact_paid_execution, xcm_transact_unpaid_execution}, - AssetHubRococo, AssetHubRococoReceiver, AssetHubWococo, - BridgeHubRococo, BridgeHubRococoPallet, BridgeHubRococoSender, - BridgeHubWococo, PenpalRococoA, Rococo, - RococoPallet, + AssetHubRococo, AssetHubRococoReceiver, AssetHubWococo, BridgeHubRococo, BridgeHubRococoPallet, + BridgeHubRococoSender, BridgeHubWococo, PenpalRococoA, Rococo, RococoPallet, }; pub use parachains_common::{AccountId, Balance}; pub use xcm::{ From 3414a52f5f77f17e8dbde64963ce117ed5437640 Mon Sep 17 00:00:00 2001 From: NachoPal Date: Mon, 16 Oct 2023 13:47:18 +0200 Subject: [PATCH 23/27] fix conflicts 3 --- .../emulated/bridges/bridge-hub-rococo/src/lib.rs | 2 +- .../runtimes/assets/asset-hub-westend/src/xcm_config.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/lib.rs b/cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/lib.rs index 80d0d3393616b..926e29092cb52 100644 --- a/cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/lib.rs @@ -17,7 +17,7 @@ pub use bp_messages::LaneId; pub use frame_support::assert_ok; pub use integration_tests_common::{ constants::{ - asset_hub_rococo::ED as ASSET_HUB_ROCOCO_ED, rococo::ED as ROCOCO_ED, PROOF_SIZE_THRESHOLD, + bridge_hub_rococo::ED as BRIDGE_HUB_ROCOCO_ED, rococo::ED as ROCOCO_ED, PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V3, }, test_parachain_is_trusted_teleporter, diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs index 467bc352b1725..b2f7deee73ee6 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs @@ -42,7 +42,7 @@ use xcm_builder::{ AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, CurrencyAdapter, DenyReserveTransferToRelayChain, DenyThenTry, DescribeFamily, DescribePalletTerminal, - EnsureXcmOrigin, FungiblesAdapter, HashedDescription, IsConcrete, LocalMint, NativeAsset, + EnsureXcmOrigin, FungiblesAdapter, HashedDescription, IsConcrete, LocalMint, NoChecking, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId, UsingComponents, From ca30c506bbdae24c333ec002ff3d9fecedbb14a6 Mon Sep 17 00:00:00 2001 From: NachoPal Date: Mon, 16 Oct 2023 13:48:35 +0200 Subject: [PATCH 24/27] fmt --- .../emulated/bridges/bridge-hub-rococo/src/lib.rs | 4 ++-- .../runtimes/assets/asset-hub-westend/src/xcm_config.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/lib.rs b/cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/lib.rs index 926e29092cb52..5ca6a9841bbad 100644 --- a/cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/lib.rs @@ -17,8 +17,8 @@ pub use bp_messages::LaneId; pub use frame_support::assert_ok; pub use integration_tests_common::{ constants::{ - bridge_hub_rococo::ED as BRIDGE_HUB_ROCOCO_ED, rococo::ED as ROCOCO_ED, PROOF_SIZE_THRESHOLD, - REF_TIME_THRESHOLD, XCM_V3, + bridge_hub_rococo::ED as BRIDGE_HUB_ROCOCO_ED, rococo::ED as ROCOCO_ED, + PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V3, }, test_parachain_is_trusted_teleporter, xcm_helpers::{xcm_transact_paid_execution, xcm_transact_unpaid_execution}, diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs index b2f7deee73ee6..b1ec6be5b7e52 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs @@ -42,8 +42,8 @@ use xcm_builder::{ AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, CurrencyAdapter, DenyReserveTransferToRelayChain, DenyThenTry, DescribeFamily, DescribePalletTerminal, - EnsureXcmOrigin, FungiblesAdapter, HashedDescription, IsConcrete, LocalMint, - NoChecking, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, + EnsureXcmOrigin, FungiblesAdapter, HashedDescription, IsConcrete, LocalMint, NoChecking, + ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId, UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic, From 7c40b8cf8fce6383bba7f68179885d6bd7097a33 Mon Sep 17 00:00:00 2001 From: NachoPal Date: Mon, 16 Oct 2023 14:51:39 +0200 Subject: [PATCH 25/27] add asset-hub-rococo to cargo.toml --- Cargo.lock | 11 +++++++++++ Cargo.toml | 1 + 2 files changed, 12 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index b14bc129275c8..f12e16276e78d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -792,6 +792,17 @@ dependencies = [ "substrate-wasm-builder", ] +[[package]] +name = "asset-hub-rococo-integration-tests" +version = "1.0.0" +dependencies = [ + "frame-support", + "integration-tests-common", + "parity-scale-codec", + "staging-xcm", + "xcm-emulator", +] + [[package]] name = "asset-hub-westend-integration-tests" version = "1.0.0" diff --git a/Cargo.toml b/Cargo.toml index 9e8ead6cf7c9d..6ec4a21f2195b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -60,6 +60,7 @@ members = [ "cumulus/parachain-template/pallets/template", "cumulus/parachain-template/runtime", "cumulus/parachains/common", + "cumulus/parachains/integration-tests/emulated/assets/asset-hub-rococo", "cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend", "cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo", "cumulus/parachains/integration-tests/emulated/common", From 4c4981114922a10617ec16e45252c4e60de0f52c Mon Sep 17 00:00:00 2001 From: NachoPal Date: Mon, 16 Oct 2023 15:19:07 +0200 Subject: [PATCH 26/27] fix --- .../emulated/assets/asset-hub-rococo/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-rococo/src/lib.rs b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-rococo/src/lib.rs index 155f6320e3809..482d3a8a9f710 100644 --- a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-rococo/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-rococo/src/lib.rs @@ -15,7 +15,7 @@ pub use frame_support::assert_ok; pub use integration_tests_common::{ - constants::asset_hub_polkadot::ED as ASSET_HUB_ROCOCO_ED, test_parachain_is_trusted_teleporter, + constants::asset_hub_rococo::ED as ASSET_HUB_ROCOCO_ED, test_parachain_is_trusted_teleporter, AssetHubRococo, AssetHubRococoPallet, AssetHubRococoSender, BridgeHubRococo, BridgeHubRococoReceiver, }; From d52181dd94293bb173163c83b971625d69e713c1 Mon Sep 17 00:00:00 2001 From: NachoPal Date: Mon, 16 Oct 2023 18:35:44 +0200 Subject: [PATCH 27/27] address comments --- cumulus/parachains/common/src/xcm_config.rs | 2 +- .../emulated/assets/asset-hub-rococo/src/lib.rs | 1 - .../emulated/assets/asset-hub-westend/src/lib.rs | 1 - .../emulated/assets/asset-hub-westend/src/tests/teleport.rs | 3 ++- .../emulated/bridges/bridge-hub-rococo/src/lib.rs | 1 - 5 files changed, 3 insertions(+), 5 deletions(-) diff --git a/cumulus/parachains/common/src/xcm_config.rs b/cumulus/parachains/common/src/xcm_config.rs index cfe2f2f5fffb8..534253b4aaeb1 100644 --- a/cumulus/parachains/common/src/xcm_config.rs +++ b/cumulus/parachains/common/src/xcm_config.rs @@ -96,7 +96,7 @@ impl> ContainsPair // Others _ => false, }; - matches!(asset.id, Concrete(id) if id == AssetLocation::get() && is_system) + matches!(asset.id, Concrete(id) if id == AssetLocation::get()) && is_system } } diff --git a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-rococo/src/lib.rs b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-rococo/src/lib.rs index 482d3a8a9f710..f8a917afe1b60 100644 --- a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-rococo/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-rococo/src/lib.rs @@ -23,5 +23,4 @@ pub use xcm::prelude::*; pub use xcm_emulator::{assert_expected_events, bx, Chain, Parachain, TestExt}; #[cfg(test)] -#[cfg(not(feature = "runtime-benchmarks"))] mod tests; diff --git a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs index 8355aed444f22..c25cc601fbefb 100644 --- a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs @@ -89,5 +89,4 @@ pub fn system_para_test_args( } #[cfg(test)] -#[cfg(not(feature = "runtime-benchmarks"))] mod tests; diff --git a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/tests/teleport.rs b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/tests/teleport.rs index 1014116cf8730..81471c401f396 100644 --- a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/tests/teleport.rs +++ b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/tests/teleport.rs @@ -358,7 +358,8 @@ fn teleport_native_assets_from_system_para_to_relay_fails() { assert_eq!(receiver_balance_after, receiver_balance_before); } -// TODO: uncomment when Collectives and BridgeHubWestend are implemented +// TODO: uncomment when CollectivesWestend and BridgeHubWestend are implemented +// https://github.com/paritytech/polkadot-sdk/pull/1737 (CollectivesWestend) // #[test] // fn teleport_to_other_system_parachains_works() { // let amount = ASSET_HUB_WESTEND_ED * 100; diff --git a/cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/lib.rs b/cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/lib.rs index 5ca6a9841bbad..3c4dbe18a9ac4 100644 --- a/cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/lib.rs @@ -64,5 +64,4 @@ pub fn relay_test_args(amount: Balance) -> TestArgs { } #[cfg(test)] -#[cfg(not(feature = "runtime-benchmarks"))] mod tests;