From 57b0be136d253c2a465aa6fc14860bcba3fae6a1 Mon Sep 17 00:00:00 2001 From: NachoPal Date: Thu, 6 Jul 2023 19:44:37 +0200 Subject: [PATCH 01/13] working for single receiver --- Cargo.lock | 1 + parachains/common/src/xcm_config.rs | 16 +++- .../assets/asset-hub-kusama/src/lib.rs | 4 +- .../asset-hub-kusama/src/tests/teleport.rs | 12 +++ .../emulated/common/src/lib.rs | 5 +- .../emulated/common/src/macros.rs | 75 +++++++++++++++++++ .../assets/asset-hub-kusama/src/xcm_config.rs | 12 ++- .../asset-hub-polkadot/src/xcm_config.rs | 12 ++- .../asset-hub-westend/src/xcm_config.rs | 12 ++- parachains/runtimes/assets/common/Cargo.toml | 1 + .../bridge-hub-kusama/src/xcm_config.rs | 7 +- .../bridge-hub-polkadot/src/xcm_config.rs | 7 +- .../bridge-hub-rococo/src/xcm_config.rs | 7 +- .../collectives-polkadot/src/xcm_config.rs | 7 +- .../contracts-rococo/src/xcm_config.rs | 6 +- 15 files changed, 159 insertions(+), 25 deletions(-) create mode 100644 parachains/integration-tests/emulated/common/src/macros.rs diff --git a/Cargo.lock b/Cargo.lock index 8ca1181e992..74168a9181d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -701,6 +701,7 @@ dependencies = [ "pallet-xcm", "parachains-common", "parity-scale-codec", + "paste", "scale-info", "sp-api", "sp-runtime", diff --git a/parachains/common/src/xcm_config.rs b/parachains/common/src/xcm_config.rs index 529822cff16..72ad87bbbfd 100644 --- a/parachains/common/src/xcm_config.rs +++ b/parachains/common/src/xcm_config.rs @@ -57,9 +57,23 @@ impl> ContainsPair for ConcreteNativeAssetFrom { fn contains(asset: &MultiAsset, origin: &MultiLocation) -> bool { - log::trace!(target: "xcm::filter_asset_location", + log::trace!(target: "xcm::contains", "ConcreteNativeAsset asset: {:?}, origin: {:?}, location: {:?}", asset, origin, Location::get()); matches!(asset.id, Concrete(ref id) if id == origin && origin == &Location::get()) } } + +/// Accepts an asset if it is a native asset from a System Parachain. +pub struct NativeAssetFromSystemParachain; +impl ContainsPair for NativeAssetFromSystemParachain { + fn contains(asset: &MultiAsset, origin: &MultiLocation) -> bool { + log::trace!(target: "xcm::contains", "NativeAssetFromSystemParachain asset: {:?}, origin: {:?}", asset, origin); + let is_system_para = match origin.interior() { + X1(Parachain(id)) if *id < 2000 => true, + _ => false, + }; + let parent = MultiLocation::parent(); + matches!(asset.id, Concrete(id) if id == parent && is_system_para) + } +} diff --git a/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/lib.rs b/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/lib.rs index b090432fa7c..a05bc5691d0 100644 --- a/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/lib.rs +++ b/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/lib.rs @@ -13,7 +13,6 @@ // You should have received a copy of the GNU General Public License // along with Cumulus. If not, see . - pub use codec::Encode; pub use frame_support::{ assert_ok, instances::Instance1, pallet_prelude::Weight, traits::fungibles::Inspect, @@ -22,8 +21,11 @@ pub use integration_tests_common::{ constants::{ accounts::{ALICE, BOB}, kusama::ED as KUSAMA_ED, + asset_hub_kusama::ED as ASSET_HUB_KUSAMA_ED, + bridge_hub_kusama::ED as BRIDGE_HUB_KUSAMA_ED, PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V3, }, + test_parachain_is_trusted_teleporter, AccountId, AssetHubKusama, AssetHubKusamaPallet, AssetHubKusamaReceiver, AssetHubKusamaSender, BridgeHubKusama, BridgeHubKusamaPallet, BridgeHubKusamaReceiver, BridgeHubKusamaSender, BridgeHubPolkadot, BridgeHubPolkadotPallet, BridgeHubPolkadotReceiver, BridgeHubPolkadotSender, diff --git a/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/tests/teleport.rs b/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/tests/teleport.rs index 16c0db907c3..d249bfb77be 100644 --- a/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/tests/teleport.rs +++ b/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/tests/teleport.rs @@ -78,3 +78,15 @@ fn teleport_native_assets_from_relay_to_assets_para() { assert_eq!(relay_sender_balance_before - amount, relay_sender_balance_after); assert!(para_sender_balance_after > para_receiver_balance_before); } + +#[test] +fn teleport_to_other_system_parachains() { + let amount = ASSET_HUB_KUSAMA_ED * 100; + let native_assets: VersionedMultiAssets = (Parent, amount).into(); + + test_parachain_is_trusted_teleporter!( + AssetHubKusama, + (native_assets, amount), + vec![BridgeHubKusama] + ); +} diff --git a/parachains/integration-tests/emulated/common/src/lib.rs b/parachains/integration-tests/emulated/common/src/lib.rs index d88f1ddd3e3..295847ef61f 100644 --- a/parachains/integration-tests/emulated/common/src/lib.rs +++ b/parachains/integration-tests/emulated/common/src/lib.rs @@ -1,5 +1,6 @@ pub mod constants; pub mod impls; +pub mod macros; pub use constants::{ accounts::{ALICE, BOB}, @@ -12,10 +13,10 @@ use frame_support::{parameter_types, sp_io, sp_tracing}; pub use parachains_common::{AccountId, AssetHubPolkadotAuraId, AuraId, Balance, BlockNumber}; pub use sp_core::{sr25519, storage::Storage, Get}; use xcm::prelude::*; -use xcm_emulator::{ +pub use xcm_emulator::{ decl_test_bridges, decl_test_networks, decl_test_parachains, decl_test_relay_chains, decl_test_sender_receiver_accounts_parameter_types, BridgeMessageHandler, Parachain, - RelayChain, TestExt, + RelayChain, TestExt, paste, }; use xcm_executor::traits::ConvertLocation; diff --git a/parachains/integration-tests/emulated/common/src/macros.rs b/parachains/integration-tests/emulated/common/src/macros.rs new file mode 100644 index 00000000000..b5ab6d5a9f5 --- /dev/null +++ b/parachains/integration-tests/emulated/common/src/macros.rs @@ -0,0 +1,75 @@ +// pub use crate::{ +// paste +// }; + +#[macro_export] +macro_rules! test_parachain_is_trusted_teleporter { + ( $sender_para:ty, ($assets:expr, $amount:expr), vec![$( $receiver_para:ty ),+] ) => { + $crate::paste::paste! { + // Origin + // let amount = KUSAMA_ED * 10; + let para_sender_balance_before = + <$sender_para>::account_data_of([<$sender_para Sender>]::get()).free; + let origin = <$sender_para as $crate::Parachain>::RuntimeOrigin::signed([<$sender_para Sender>]::get()); + + let para_receiver_balance_before = + BridgeHubKusama::account_data_of(BridgeHubKusamaReceiver::get()).free; + let para_destination: VersionedMultiLocation = + <$sender_para>::sibling_location_of(BridgeHubKusama::para_id()).into(); + let beneficiary: VersionedMultiLocation = + AccountId32 { network: None, id: BridgeHubKusamaReceiver::get().into() }.into(); + // let native_assets: VersionedMultiAssets = (Parent, amount).into(); + let fee_asset_item = 0; + let weight_limit = WeightLimit::Unlimited; + + // Send XCM message from Origin Parachain + <$sender_para>::execute_with(|| { + assert_ok!(<$sender_para as [<$sender_para Pallet>]>::PolkadotXcm::limited_teleport_assets( + origin, + bx!(para_destination), + bx!(beneficiary), + bx!($assets), + fee_asset_item, + weight_limit, + )); + + type RuntimeEvent = <$sender_para as $crate::Parachain>::RuntimeEvent; + + assert_expected_events!( + $sender_para, + vec![ + RuntimeEvent::PolkadotXcm( + pallet_xcm::Event::Attempted { outcome: Outcome::Complete { .. } } + ) => {}, + ] + ); + }); + + // Receive XCM message in Assets Parachain + BridgeHubKusama::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + BridgeHubKusama, + vec![ + RuntimeEvent::Balances(pallet_balances::Event::Deposit { who, .. }) => { + who: *who == BridgeHubKusamaReceiver::get().into(), + }, + ] + ); + }); + + // Check if balances are updated accordingly in Relay Chain and Assets Parachain + let para_sender_balance_after = + <$sender_para>::account_data_of([<$sender_para Sender>]::get()).free; + let para_receiver_balance_after = + BridgeHubKusama::account_data_of(BridgeHubKusamaReceiver::get()).free; + + assert_eq!(para_sender_balance_before - $amount, para_sender_balance_after); + assert!(para_receiver_balance_after > para_receiver_balance_before); + } + + }; +} + +// pub use test_system_para_is_trusted_teleporter; diff --git a/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs b/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs index 2cba64dcb9c..56d6f70cd5a 100644 --- a/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs +++ b/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs @@ -26,6 +26,7 @@ use frame_support::{ traits::{ConstU32, Contains, Everything, Nothing, PalletInfoAccess}, }; use frame_system::EnsureRoot; +use parachains_common::xcm_config::NativeAssetFromSystemParachain; use pallet_xcm::XcmPassthrough; use parachains_common::{impls::ToStakingPot, xcm_config::AssetFeeAsExistentialDepositMultiplier}; use polkadot_parachain::primitives::Sibling; @@ -376,6 +377,12 @@ pub type AssetFeeAsExistentialDepositMultiplierFeeCharger = AssetFeeAsExistentia TrustBackedAssetsInstance, >; +pub type TrustedTeleporters = ( + NativeAsset, + IsForeignConcreteAsset>>, + NativeAssetFromSystemParachain, +); + pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { type RuntimeCall = RuntimeCall; @@ -389,10 +396,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/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs b/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs index 956ada5ac3b..ff4a1922e9b 100644 --- a/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs +++ b/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs @@ -26,6 +26,7 @@ use frame_support::{ traits::{ConstU32, Contains, Everything, Nothing, PalletInfoAccess}, }; use frame_system::EnsureRoot; +use parachains_common::xcm_config::NativeAssetFromSystemParachain; use pallet_xcm::XcmPassthrough; use parachains_common::{impls::ToStakingPot, xcm_config::AssetFeeAsExistentialDepositMultiplier}; use polkadot_parachain::primitives::Sibling; @@ -383,6 +384,12 @@ pub type AssetFeeAsExistentialDepositMultiplierFeeCharger = AssetFeeAsExistentia TrustBackedAssetsInstance, >; +pub type TrustedTeleporters = ( + NativeAsset, + IsForeignConcreteAsset>>, + NativeAssetFromSystemParachain, +); + pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { type RuntimeCall = RuntimeCall; @@ -396,10 +403,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/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs b/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs index e3615705e20..e7142f555a3 100644 --- a/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs +++ b/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs @@ -27,6 +27,7 @@ use frame_support::{ traits::{ConstU32, Contains, Everything, Nothing, PalletInfoAccess}, }; use frame_system::EnsureRoot; +use parachains_common::xcm_config::NativeAssetFromSystemParachain; use pallet_xcm::XcmPassthrough; use parachains_common::{impls::ToStakingPot, xcm_config::AssetFeeAsExistentialDepositMultiplier}; use polkadot_parachain::primitives::Sibling; @@ -411,6 +412,12 @@ pub type AssetFeeAsExistentialDepositMultiplierFeeCharger = AssetFeeAsExistentia TrustBackedAssetsInstance, >; +pub type TrustedTeleporters = ( + NativeAsset, + IsForeignConcreteAsset>>, + NativeAssetFromSystemParachain, +); + pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { type RuntimeCall = RuntimeCall; @@ -424,10 +431,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/parachains/runtimes/assets/common/Cargo.toml b/parachains/runtimes/assets/common/Cargo.toml index 79937ec4363..63113155d77 100644 --- a/parachains/runtimes/assets/common/Cargo.toml +++ b/parachains/runtimes/assets/common/Cargo.toml @@ -9,6 +9,7 @@ description = "Assets common utilities" codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } scale-info = { version = "2.9.0", default-features = false, features = ["derive"] } log = { version = "0.4.19", default-features = false } +paste = "1.0.13" # Substrate frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs index 4326e35de2b..c7c8a99c5dc 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs +++ b/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::{ConcreteNativeAssetFrom, NativeAssetFromSystemParachain}}; use polkadot_parachain::primitives::Sibling; use xcm::latest::prelude::*; use xcm_builder::{ @@ -177,6 +177,9 @@ pub type Barrier = TrailingSetTopicAsId< >, >; +pub type TrustedTeleporters = + (ConcreteNativeAssetFrom, NativeAssetFromSystemParachain); + pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { type RuntimeCall = RuntimeCall; @@ -187,7 +190,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/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs index 118b0c6d71b..bef6a99255d 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs +++ b/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::{ConcreteNativeAssetFrom, NativeAssetFromSystemParachain}}; use polkadot_parachain::primitives::Sibling; use xcm::latest::prelude::*; use xcm_builder::{ @@ -178,6 +178,9 @@ pub type Barrier = DenyThenTry< ), >; +pub type TrustedTeleporters = + (ConcreteNativeAssetFrom, NativeAssetFromSystemParachain); + pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { type RuntimeCall = RuntimeCall; @@ -188,7 +191,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/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs index ac1f1119392..b6b34a894ef 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs +++ b/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::{ConcreteNativeAssetFrom, NativeAssetFromSystemParachain}}; use polkadot_parachain::primitives::Sibling; use sp_core::Get; use xcm::latest::prelude::*; @@ -224,6 +224,9 @@ pub type Barrier = TrailingSetTopicAsId< >, >; +pub type TrustedTeleporters = + (ConcreteNativeAssetFrom, NativeAssetFromSystemParachain); + pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { type RuntimeCall = RuntimeCall; @@ -234,7 +237,7 @@ impl xcm_executor::Config for XcmConfig { // 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/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs b/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs index 3c95da27dd8..dd5f53cf653 100644 --- a/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs +++ b/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::{ConcreteNativeAssetFrom, NativeAssetFromSystemParachain}}; use polkadot_parachain::primitives::Sibling; use xcm::latest::prelude::*; use xcm_builder::{ @@ -225,6 +225,9 @@ pub type Barrier = DenyThenTry< ), >; +pub type TrustedTeleporters = + (ConcreteNativeAssetFrom, NativeAssetFromSystemParachain); + pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { type RuntimeCall = RuntimeCall; @@ -235,7 +238,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/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs b/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs index cc095c9229f..9f5961ed48d 100644 --- a/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs +++ b/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::NativeAssetFromSystemParachain; use polkadot_parachain::primitives::Sibling; use xcm::latest::prelude::*; use xcm_builder::{ @@ -143,6 +144,9 @@ pub type Barrier = TrailingSetTopicAsId< >, >; +pub type TrustedTeleporter = + (NativeAsset, NativeAssetFromSystemParachain); + pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { type RuntimeCall = RuntimeCall; @@ -150,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 5fda08f49698fb93b4643d67ea0b36765b89f347 Mon Sep 17 00:00:00 2001 From: NachoPal Date: Fri, 7 Jul 2023 21:20:10 +0200 Subject: [PATCH 02/13] working --- Cargo.lock | 58 ++++++++ Cargo.toml | 2 + parachains/common/src/xcm_config.rs | 40 +++++- .../assets/asset-hub-kusama/src/lib.rs | 4 +- .../asset-hub-kusama/src/tests/teleport.rs | 9 +- .../assets/asset-hub-polkadot/src/lib.rs | 4 +- .../asset-hub-polkadot/src/tests/teleport.rs | 12 ++ .../assets/asset-hub-rococo/Cargo.toml | 38 +++++ .../assets/asset-hub-rococo/src/lib.rs | 32 +++++ .../assets/asset-hub-rococo/src/tests/mod.rs | 17 +++ .../asset-hub-rococo/src/tests/teleport.rs | 29 ++++ .../assets/asset-hub-westend/src/lib.rs | 4 +- .../asset-hub-westend/src/tests/teleport.rs | 12 ++ .../bridges/bridge-hub-rococo/src/lib.rs | 7 +- .../bridge-hub-rococo/src/tests/mod.rs | 1 + .../bridge-hub-rococo/src/tests/teleport.rs | 29 ++++ .../collectives-polkadot/Cargo.toml | 2 +- .../collectives-polkadot/src/lib.rs | 15 +- .../src/tests/fellowship.rs | 17 ++- .../collectives-polkadot/src/tests/mod.rs | 1 + .../src/tests/teleport.rs | 29 ++++ .../collectives-westend/Cargo.toml | 39 ++++++ .../collectives-westend/src/lib.rs | 32 +++++ .../collectives-westend/src/tests/mod.rs | 17 +++ .../collectives-westend/src/tests/teleport.rs | 29 ++++ .../emulated/common/Cargo.toml | 1 + .../emulated/common/src/lib.rs | 53 ++++++- .../emulated/common/src/macros.rs | 130 ++++++++++-------- .../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 +- xcm/xcm-emulator/src/lib.rs | 7 +- 37 files changed, 588 insertions(+), 114 deletions(-) create mode 100644 parachains/integration-tests/emulated/assets/asset-hub-rococo/Cargo.toml create mode 100644 parachains/integration-tests/emulated/assets/asset-hub-rococo/src/lib.rs create mode 100644 parachains/integration-tests/emulated/assets/asset-hub-rococo/src/tests/mod.rs create mode 100644 parachains/integration-tests/emulated/assets/asset-hub-rococo/src/tests/teleport.rs create mode 100644 parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/tests/teleport.rs create mode 100644 parachains/integration-tests/emulated/collectives/collectives-polkadot/src/tests/teleport.rs create mode 100644 parachains/integration-tests/emulated/collectives/collectives-westend/Cargo.toml create mode 100644 parachains/integration-tests/emulated/collectives/collectives-westend/src/lib.rs create mode 100644 parachains/integration-tests/emulated/collectives/collectives-westend/src/tests/mod.rs create mode 100644 parachains/integration-tests/emulated/collectives/collectives-westend/src/tests/teleport.rs diff --git a/Cargo.lock b/Cargo.lock index 74168a9181d..705283a7689 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -556,6 +556,34 @@ dependencies = [ "xcm-executor", ] +[[package]] +name = "asset-hub-rococo-integration-tests" +version = "0.1.0" +dependencies = [ + "asset-hub-polkadot-runtime", + "cumulus-pallet-xcmp-queue", + "frame-support", + "frame-system", + "integration-tests-common", + "pallet-assets", + "pallet-balances", + "pallet-core-fellowship", + "pallet-salary", + "pallet-xcm", + "parachains-common", + "parity-scale-codec", + "polkadot-core-primitives", + "polkadot-parachain", + "polkadot-runtime", + "polkadot-runtime-parachains", + "sp-core", + "sp-runtime", + "sp-weights", + "xcm", + "xcm-emulator", + "xcm-executor", +] + [[package]] name = "asset-hub-westend-integration-tests" version = "1.0.0" @@ -2011,6 +2039,35 @@ dependencies = [ "xcm-executor", ] +[[package]] +name = "collectives-westend-integration-tests" +version = "0.1.0" +dependencies = [ + "asset-hub-polkadot-runtime", + "collectives-polkadot-runtime", + "cumulus-pallet-xcmp-queue", + "frame-support", + "frame-system", + "integration-tests-common", + "pallet-assets", + "pallet-balances", + "pallet-core-fellowship", + "pallet-salary", + "pallet-xcm", + "parachains-common", + "parity-scale-codec", + "polkadot-core-primitives", + "polkadot-parachain", + "polkadot-runtime", + "polkadot-runtime-parachains", + "sp-core", + "sp-runtime", + "sp-weights", + "xcm", + "xcm-emulator", + "xcm-executor", +] + [[package]] name = "color-print" version = "0.3.4" @@ -5298,6 +5355,7 @@ dependencies = [ "bridge-hub-rococo-runtime", "bridge-runtime-common", "collectives-polkadot-runtime", + "cumulus-pallet-xcmp-queue", "cumulus-primitives-core", "frame-support", "frame-system", diff --git a/Cargo.toml b/Cargo.toml index a376d06f806..bf520444952 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -56,7 +56,9 @@ members = [ "parachains/integration-tests/emulated/assets/asset-hub-kusama", "parachains/integration-tests/emulated/assets/asset-hub-polkadot", "parachains/integration-tests/emulated/assets/asset-hub-westend", + "parachains/integration-tests/emulated/assets/asset-hub-rococo", "parachains/integration-tests/emulated/collectives/collectives-polkadot", + "parachains/integration-tests/emulated/collectives/collectives-westend", "parachains/integration-tests/emulated/bridges/bridge-hub-rococo", "test/client", "test/relay-sproof-builder", diff --git a/parachains/common/src/xcm_config.rs b/parachains/common/src/xcm_config.rs index 72ad87bbbfd..56f77213cec 100644 --- a/parachains/common/src/xcm_config.rs +++ b/parachains/common/src/xcm_config.rs @@ -65,15 +65,45 @@ impl> ContainsPair } /// Accepts an asset if it is a native asset from a System Parachain. -pub struct NativeAssetFromSystemParachain; -impl ContainsPair for NativeAssetFromSystemParachain { +pub struct NativeAssetFromSiblingSystemParachain; +impl ContainsPair for NativeAssetFromSiblingSystemParachain { fn contains(asset: &MultiAsset, origin: &MultiLocation) -> bool { - log::trace!(target: "xcm::contains", "NativeAssetFromSystemParachain asset: {:?}, origin: {:?}", asset, origin); - let is_system_para = match origin.interior() { - X1(Parachain(id)) if *id < 2000 => true, + log::trace!(target: "xcm::contains", "NativeAssetFromSiblingSystemParachain asset: {:?}, origin: {:?}", asset, origin); + let is_system_para = match origin { + MultiLocation { parents: 1, interior: X1(Parachain(id)) } if *id < 2000 => true, _ => false, }; let parent = MultiLocation::parent(); matches!(asset.id, Concrete(id) if id == parent && is_system_para) } } + + +#[cfg(test)] +mod tests { + use super::{MultiAsset, Parent, NativeAssetFromSiblingSystemParachain, MultiLocation, Parachain, ContainsPair, Here}; + + #[test] + fn native_asset_from_sibling_system_para_works() { + let expected_asset: MultiAsset = (Parent, 1000000).into(); + let expected_origin: MultiLocation = (Parent, Parachain(1000)).into(); + + assert!(NativeAssetFromSiblingSystemParachain::contains(&expected_asset, &expected_origin)); + } + + #[test] + fn native_asset_from_sibling_system_para_fails_for_wrong_asset() { + let unexpected_asset: MultiAsset = (Here, 1000000).into(); + let expected_origin: MultiLocation = (Parent, Parachain(1000)).into(); + + assert!(!NativeAssetFromSiblingSystemParachain::contains(&unexpected_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!(!NativeAssetFromSiblingSystemParachain::contains(&expected_asset, &unexpected_origin)); + } +} diff --git a/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/lib.rs b/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/lib.rs index a05bc5691d0..9a1af9c3076 100644 --- a/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/lib.rs +++ b/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/lib.rs @@ -29,8 +29,8 @@ pub use integration_tests_common::{ AccountId, AssetHubKusama, AssetHubKusamaPallet, AssetHubKusamaReceiver, AssetHubKusamaSender, BridgeHubKusama, BridgeHubKusamaPallet, BridgeHubKusamaReceiver, BridgeHubKusamaSender, BridgeHubPolkadot, BridgeHubPolkadotPallet, BridgeHubPolkadotReceiver, BridgeHubPolkadotSender, - Collectives, CollectivesPallet, CollectivesReceiver, CollectivesSender, Kusama, KusamaMockNet, - KusamaPallet, KusamaReceiver, KusamaSender, PenpalKusama, PenpalKusamaReceiver, + Kusama, KusamaMockNet, + KusamaPallet, KusamaReceiver, KusamaSender, PenpalKusama, PenpalKusamaPallet, PenpalKusamaReceiver, PenpalKusamaSender, PenpalPolkadot, PenpalPolkadotReceiver, PenpalPolkadotSender, Polkadot, PolkadotMockNet, PolkadotPallet, PolkadotReceiver, PolkadotSender, }; diff --git a/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/tests/teleport.rs b/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/tests/teleport.rs index d249bfb77be..c0aeafce27b 100644 --- a/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/tests/teleport.rs +++ b/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/tests/teleport.rs @@ -82,11 +82,12 @@ fn teleport_native_assets_from_relay_to_assets_para() { #[test] fn teleport_to_other_system_parachains() { let amount = ASSET_HUB_KUSAMA_ED * 100; - let native_assets: VersionedMultiAssets = (Parent, amount).into(); + let expected_asset: VersionedMultiAssets = (Parent, amount).into(); + // Works for the right origin and asset test_parachain_is_trusted_teleporter!( - AssetHubKusama, - (native_assets, amount), - vec![BridgeHubKusama] + AssetHubKusama, // Origin + vec![BridgeHubKusama], // Destinations + (expected_asset, amount) ); } diff --git a/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/lib.rs b/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/lib.rs index 70506d98cbc..ba1566560e2 100644 --- a/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/lib.rs +++ b/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/lib.rs @@ -22,13 +22,15 @@ pub use integration_tests_common::{ constants::{ accounts::{ALICE, BOB}, polkadot::ED as POLKADOT_ED, + asset_hub_polkadot::ED as ASSET_HUB_POLKADOT_ED, PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V3, }, + test_parachain_is_trusted_teleporter, AccountId, AssetHubKusama, AssetHubKusamaPallet, AssetHubKusamaReceiver, AssetHubKusamaSender, AssetHubPolkadot, AssetHubPolkadotPallet, AssetHubPolkadotReceiver, AssetHubPolkadotSender, BridgeHubKusama, BridgeHubKusamaPallet, BridgeHubKusamaReceiver, BridgeHubKusamaSender, BridgeHubPolkadot, BridgeHubPolkadotPallet, BridgeHubPolkadotReceiver, BridgeHubPolkadotSender, - Collectives, CollectivesPallet, CollectivesReceiver, CollectivesSender, Kusama, KusamaMockNet, + CollectivesPolkadot, CollectivesPolkadotPallet, CollectivesPolkadotReceiver, CollectivesPolkadotSender, Kusama, KusamaMockNet, KusamaPallet, KusamaReceiver, KusamaSender, PenpalKusama, PenpalKusamaReceiver, PenpalKusamaSender, PenpalPolkadot, PenpalPolkadotReceiver, PenpalPolkadotSender, Polkadot, PolkadotMockNet, PolkadotPallet, PolkadotReceiver, PolkadotSender, diff --git a/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/teleport.rs b/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/teleport.rs index 6b799096054..25c16d70959 100644 --- a/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/teleport.rs +++ b/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/teleport.rs @@ -76,3 +76,15 @@ fn teleport_native_assets_from_relay_to_assets_para() { assert_eq!(relay_sender_balance_before - amount, relay_sender_balance_after); assert!(para_sender_balance_after > para_receiver_balance_before); } + +#[test] +fn teleport_to_other_system_parachains() { + 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/parachains/integration-tests/emulated/assets/asset-hub-rococo/Cargo.toml b/parachains/integration-tests/emulated/assets/asset-hub-rococo/Cargo.toml new file mode 100644 index 00000000000..9bbabad8c05 --- /dev/null +++ b/parachains/integration-tests/emulated/assets/asset-hub-rococo/Cargo.toml @@ -0,0 +1,38 @@ +[package] +name = "asset-hub-rococo-integration-tests" +version = "0.1.0" +authors = ["Parity Technologies "] +edition = "2021" +description = "Asset Hub Rococo parachain runtime integration tests based on xcm-emulator" + +[dependencies] +codec = { package = "parity-scale-codec", version = "3.4.0", default-features = false } + +# Substrate +sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } +frame-support = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } +frame-system = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } +sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } +sp-weights = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } +pallet-balances = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } +pallet-assets = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } +pallet-core-fellowship = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } +pallet-salary = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } + +# Polkadot +polkadot-core-primitives = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "master" } +polkadot-parachain = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "master" } +polkadot-runtime-parachains = { git = "https://github.com/paritytech/polkadot", branch = "master" } +polkadot-runtime = { git = "https://github.com/paritytech/polkadot", branch = "master" } +xcm = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "master" } +xcm-executor = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "master" } +pallet-xcm = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "master" } + +# Cumulus +parachains-common = { path = "../../../../common" } +cumulus-pallet-xcmp-queue = { default-features = false, path = "../../../../../pallets/xcmp-queue" } +asset-hub-polkadot-runtime = { path = "../../../../runtimes/assets/asset-hub-polkadot" } + +# Local +xcm-emulator = { default-features = false, path = "../../../../../xcm/xcm-emulator" } +integration-tests-common = { default-features = false, path = "../../common" } diff --git a/parachains/integration-tests/emulated/assets/asset-hub-rococo/src/lib.rs b/parachains/integration-tests/emulated/assets/asset-hub-rococo/src/lib.rs new file mode 100644 index 00000000000..6b3c50e5fb8 --- /dev/null +++ b/parachains/integration-tests/emulated/assets/asset-hub-rococo/src/lib.rs @@ -0,0 +1,32 @@ +// 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 . + +//! Collectives Parachain integration tests based on xcm-emulator. + +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, + AccountId, AssetHubRococo, AssetHubRococoSender, + AssetHubRococoPallet, BridgeHubRococo, BridgeHubRococoReceiver +}; +pub use xcm::prelude::*; +pub use xcm_emulator::{TestExt, bx, assert_expected_events, Parachain}; + +#[cfg(test)] +mod tests; diff --git a/parachains/integration-tests/emulated/assets/asset-hub-rococo/src/tests/mod.rs b/parachains/integration-tests/emulated/assets/asset-hub-rococo/src/tests/mod.rs new file mode 100644 index 00000000000..6abcf5b25ce --- /dev/null +++ b/parachains/integration-tests/emulated/assets/asset-hub-rococo/src/tests/mod.rs @@ -0,0 +1,17 @@ +// 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 . + +mod teleport; diff --git a/parachains/integration-tests/emulated/assets/asset-hub-rococo/src/tests/teleport.rs b/parachains/integration-tests/emulated/assets/asset-hub-rococo/src/tests/teleport.rs new file mode 100644 index 00000000000..b6e3ad0451f --- /dev/null +++ b/parachains/integration-tests/emulated/assets/asset-hub-rococo/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() { + 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/parachains/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs b/parachains/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs index e3d33dabaa2..a7de2a07de3 100644 --- a/parachains/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs +++ b/parachains/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs @@ -22,10 +22,12 @@ pub use integration_tests_common::{ constants::{ accounts::{ALICE, BOB}, polkadot::ED as POLKADOT_ED, + asset_hub_westend::ED as ASSET_HUB_WESTEND_ED, PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V3, }, + test_parachain_is_trusted_teleporter, AccountId, AssetHubWestend, AssetHubWestendPallet, AssetHubWestendReceiver, - AssetHubWestendSender, Collectives, CollectivesPallet, CollectivesReceiver, CollectivesSender, + AssetHubWestendSender, CollectivesWestend, CollectivesWestendPallet, CollectivesWestendReceiver, CollectivesWestendSender, PenpalWestend, PenpalWestendPallet, PenpalWestendReceiver, PenpalWestendSender, Westend, WestendPallet, WestendReceiver, WestendSender, }; diff --git a/parachains/integration-tests/emulated/assets/asset-hub-westend/src/tests/teleport.rs b/parachains/integration-tests/emulated/assets/asset-hub-westend/src/tests/teleport.rs index c8a57933b05..9fe2a2f323f 100644 --- a/parachains/integration-tests/emulated/assets/asset-hub-westend/src/tests/teleport.rs +++ b/parachains/integration-tests/emulated/assets/asset-hub-westend/src/tests/teleport.rs @@ -76,3 +76,15 @@ fn teleport_native_assets_from_relay_to_assets_para() { assert_eq!(relay_sender_balance_before - amount, relay_sender_balance_after); assert!(para_sender_balance_after > para_receiver_balance_before); } + +#[test] +fn teleport_to_other_system_parachains() { + 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/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/lib.rs b/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/lib.rs index 105212b1907..cb247308702 100644 --- a/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/lib.rs +++ b/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/lib.rs @@ -21,12 +21,13 @@ pub use integration_tests_common::{ constants::{ accounts::{ALICE, BOB}, rococo::{ED as ROCOCO_ED, ED as WOCOCO_ED}, + bridge_hub_rococo::ED as BRIDGE_HUB_ROCOCO_ED, PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V3, }, - AccountId, AssetHubWococo, BridgeHubPolkadot, BridgeHubPolkadotPallet, + test_parachain_is_trusted_teleporter, + AccountId, AssetHubWococo, AssetHubRococo, AssetHubRococoReceiver, BridgeHubPolkadot, BridgeHubPolkadotPallet, BridgeHubPolkadotReceiver, BridgeHubPolkadotSender, BridgeHubRococo, BridgeHubRococoPallet, - BridgeHubRococoReceiver, BridgeHubRococoSender, BridgeHubWococo, Collectives, - CollectivesPallet, CollectivesReceiver, CollectivesSender, Kusama, KusamaPallet, + BridgeHubRococoReceiver, BridgeHubRococoSender, BridgeHubWococo, Kusama, KusamaPallet, PenpalPolkadot, PenpalPolkadotReceiver, PenpalPolkadotSender, Polkadot, PolkadotMockNet, PolkadotPallet, PolkadotReceiver, PolkadotSender, Rococo, RococoMockNet, RococoPallet, RococoReceiver, RococoSender, diff --git a/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/tests/mod.rs b/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/tests/mod.rs index 532e31aa1a6..8d9b9d8092d 100644 --- a/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/tests/mod.rs +++ b/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/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/tests/teleport.rs b/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/tests/teleport.rs new file mode 100644 index 00000000000..1e886036476 --- /dev/null +++ b/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/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() { + 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/parachains/integration-tests/emulated/collectives/collectives-polkadot/Cargo.toml b/parachains/integration-tests/emulated/collectives/collectives-polkadot/Cargo.toml index 2f81d34b51a..b6410c1d7d5 100644 --- a/parachains/integration-tests/emulated/collectives/collectives-polkadot/Cargo.toml +++ b/parachains/integration-tests/emulated/collectives/collectives-polkadot/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Parity Technologies "] edition = "2021" description = "Polkadot Collectives parachain runtime integration tests based on xcm-emulator" -[dev-dependencies] +[dependencies] codec = { package = "parity-scale-codec", version = "3.4.0", default-features = false } # Substrate diff --git a/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/lib.rs b/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/lib.rs index d83ddfffd99..52b11dd4fef 100644 --- a/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/lib.rs +++ b/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/lib.rs @@ -16,15 +16,20 @@ //! Collectives Parachain integration tests based on xcm-emulator. -#![cfg(test)] - pub use frame_support::assert_ok; pub use integration_tests_common::{ - constants::accounts::ALICE, AccountId, AssetHubPolkadot as AssetHub, - AssetHubPolkadotPallet as AssetHubPallet, Collectives, CollectivesPallet, Polkadot, + constants::{ + accounts::ALICE, + collectives::ED as COLLECTIVES_POLKADOT_ED, + }, + test_parachain_is_trusted_teleporter, + AccountId, AssetHubPolkadot, AssetHubPolkadotReceiver, + BridgeHubPolkadot, BridgeHubPolkadotReceiver, + AssetHubPolkadotPallet, CollectivesPolkadot, CollectivesPolkadotSender, CollectivesPolkadotPallet, Polkadot, PolkadotMockNet, }; pub use xcm::prelude::*; -pub use xcm_emulator::{assert_expected_events, Parachain}; +pub use xcm_emulator::{TestExt, bx, assert_expected_events, Parachain}; +#[cfg(test)] mod tests; diff --git a/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/tests/fellowship.rs b/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/tests/fellowship.rs index 233fd67083d..c03af6717bd 100644 --- a/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/tests/fellowship.rs +++ b/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/tests/fellowship.rs @@ -23,7 +23,6 @@ use frame_support::traits::{ tokens::Pay, }; use sp_core::crypto::Ss58Codec; -use xcm_emulator::TestExt; #[test] fn pay_salary() { @@ -34,8 +33,8 @@ fn pay_salary() { let pay_to = Polkadot::account_id_of(ALICE); let pay_amount = 9000; - AssetHub::execute_with(|| { - type AssetHubAssets = ::Assets; + AssetHubPolkadot::execute_with(|| { + type AssetHubAssets = ::Assets; assert_ok!(>::create( asset_id, @@ -46,23 +45,23 @@ 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 { .. }) => {}, ] ); }); - AssetHub::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; + AssetHubPolkadot::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; assert_expected_events!( - AssetHub, + AssetHubPolkadot, vec![ RuntimeEvent::Assets(pallet_assets::Event::Transferred { asset_id: id, from, to, amount }) => { asset_id: id == &asset_id, diff --git a/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/tests/mod.rs b/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/tests/mod.rs index 1ede78b5979..3ea94171b66 100644 --- a/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/tests/mod.rs +++ b/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/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/tests/teleport.rs b/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/tests/teleport.rs new file mode 100644 index 00000000000..dbdd9b51891 --- /dev/null +++ b/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() { + 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/parachains/integration-tests/emulated/collectives/collectives-westend/Cargo.toml b/parachains/integration-tests/emulated/collectives/collectives-westend/Cargo.toml new file mode 100644 index 00000000000..08307702d18 --- /dev/null +++ b/parachains/integration-tests/emulated/collectives/collectives-westend/Cargo.toml @@ -0,0 +1,39 @@ +[package] +name = "collectives-westend-integration-tests" +version = "0.1.0" +authors = ["Parity Technologies "] +edition = "2021" +description = "Westend Collectives parachain runtime integration tests based on xcm-emulator" + +[dependencies] +codec = { package = "parity-scale-codec", version = "3.4.0", default-features = false } + +# Substrate +sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } +frame-support = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } +frame-system = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } +sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } +sp-weights = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } +pallet-balances = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } +pallet-assets = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } +pallet-core-fellowship = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } +pallet-salary = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } + +# Polkadot +polkadot-core-primitives = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "master" } +polkadot-parachain = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "master" } +polkadot-runtime-parachains = { git = "https://github.com/paritytech/polkadot", branch = "master" } +polkadot-runtime = { git = "https://github.com/paritytech/polkadot", branch = "master" } +xcm = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "master" } +xcm-executor = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "master" } +pallet-xcm = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "master" } + +# Cumulus +parachains-common = { path = "../../../../common" } +cumulus-pallet-xcmp-queue = { default-features = false, path = "../../../../../pallets/xcmp-queue" } +collectives-polkadot-runtime = { path = "../../../../runtimes/collectives/collectives-polkadot" } +asset-hub-polkadot-runtime = { path = "../../../../runtimes/assets/asset-hub-polkadot" } + +# Local +xcm-emulator = { default-features = false, path = "../../../../../xcm/xcm-emulator" } +integration-tests-common = { default-features = false, path = "../../common" } diff --git a/parachains/integration-tests/emulated/collectives/collectives-westend/src/lib.rs b/parachains/integration-tests/emulated/collectives/collectives-westend/src/lib.rs new file mode 100644 index 00000000000..95c73664477 --- /dev/null +++ b/parachains/integration-tests/emulated/collectives/collectives-westend/src/lib.rs @@ -0,0 +1,32 @@ +// 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 . + +//! Collectives Parachain integration tests based on xcm-emulator. + +pub use frame_support::assert_ok; +pub use integration_tests_common::{ + constants::{ + collectives::ED as COLLECTIVES_WESTEND_ED, + }, + test_parachain_is_trusted_teleporter, + AccountId, AssetHubWestend, AssetHubWestendReceiver, + AssetHubWestendPallet, CollectivesWestend, CollectivesWestendSender, CollectivesWestendPallet, +}; +pub use xcm::prelude::*; +pub use xcm_emulator::{TestExt, bx, assert_expected_events, Parachain}; + +#[cfg(test)] +mod tests; diff --git a/parachains/integration-tests/emulated/collectives/collectives-westend/src/tests/mod.rs b/parachains/integration-tests/emulated/collectives/collectives-westend/src/tests/mod.rs new file mode 100644 index 00000000000..6abcf5b25ce --- /dev/null +++ b/parachains/integration-tests/emulated/collectives/collectives-westend/src/tests/mod.rs @@ -0,0 +1,17 @@ +// 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 . + +mod teleport; diff --git a/parachains/integration-tests/emulated/collectives/collectives-westend/src/tests/teleport.rs b/parachains/integration-tests/emulated/collectives/collectives-westend/src/tests/teleport.rs new file mode 100644 index 00000000000..5741bb1960d --- /dev/null +++ b/parachains/integration-tests/emulated/collectives/collectives-westend/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() { + 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/parachains/integration-tests/emulated/common/Cargo.toml b/parachains/integration-tests/emulated/common/Cargo.toml index ec9f0c24e1e..bc76c8dad71 100644 --- a/parachains/integration-tests/emulated/common/Cargo.toml +++ b/parachains/integration-tests/emulated/common/Cargo.toml @@ -45,6 +45,7 @@ pallet-xcm = { default-features = false, git = "https://github.com/paritytech/po parachains-common = { path = "../../../common" } parachain-info = { path = "../../../pallets/parachain-info" } cumulus-primitives-core = { path = "../../../../primitives/core" } +cumulus-pallet-xcmp-queue = { default-features = false, path = "../../../../pallets/xcmp-queue" } penpal-runtime = { path = "../../../runtimes/testing/penpal" } asset-hub-polkadot-runtime = { path = "../../../runtimes/assets/asset-hub-polkadot" } asset-hub-kusama-runtime = { path = "../../../runtimes/assets/asset-hub-kusama" } diff --git a/parachains/integration-tests/emulated/common/src/lib.rs b/parachains/integration-tests/emulated/common/src/lib.rs index 295847ef61f..753d5f96142 100644 --- a/parachains/integration-tests/emulated/common/src/lib.rs +++ b/parachains/integration-tests/emulated/common/src/lib.rs @@ -19,6 +19,9 @@ pub use xcm_emulator::{ RelayChain, TestExt, paste, }; use xcm_executor::traits::ConvertLocation; +pub use pallet_xcm; +pub use cumulus_pallet_xcmp_queue; +pub use pallet_balances; decl_test_relay_chains! { #[api_version(5)] @@ -144,7 +147,7 @@ decl_test_parachains! { Assets: asset_hub_polkadot_runtime::Assets, } }, - pub struct Collectives { + pub struct CollectivesPolkadot { genesis = collectives::genesis(), on_init = (), runtime = { @@ -293,6 +296,26 @@ decl_test_parachains! { AssetConversion: asset_hub_westend_runtime::AssetConversion, } }, + pub struct CollectivesWestend { + genesis = collectives::genesis(), + on_init = (), + runtime = { + Runtime: collectives_polkadot_runtime::Runtime, + RuntimeOrigin: collectives_polkadot_runtime::RuntimeOrigin, + RuntimeCall: collectives_polkadot_runtime::RuntimeCall, + RuntimeEvent: collectives_polkadot_runtime::RuntimeEvent, + XcmpMessageHandler: collectives_polkadot_runtime::XcmpQueue, + DmpMessageHandler: collectives_polkadot_runtime::DmpQueue, + LocationToAccountId: collectives_polkadot_runtime::xcm_config::LocationToAccountId, + System: collectives_polkadot_runtime::System, + Balances: collectives_polkadot_runtime::Balances, + ParachainSystem: collectives_polkadot_runtime::ParachainSystem, + ParachainInfo: collectives_polkadot_runtime::ParachainInfo, + }, + pallets_extra = { + PolkadotXcm: collectives_polkadot_runtime::PolkadotXcm, + } + }, pub struct PenpalWestend { genesis = penpal::genesis(penpal::PARA_ID), on_init = (), @@ -356,6 +379,27 @@ decl_test_parachains! { Assets: asset_hub_polkadot_runtime::Assets, } }, + pub struct PenpalRococo { + genesis = penpal::genesis(penpal::PARA_ID), + on_init = (), + runtime = { + Runtime: penpal_runtime::Runtime, + RuntimeOrigin: penpal_runtime::RuntimeOrigin, + RuntimeCall: penpal_runtime::RuntimeCall, + RuntimeEvent: penpal_runtime::RuntimeEvent, + XcmpMessageHandler: penpal_runtime::XcmpQueue, + DmpMessageHandler: penpal_runtime::DmpQueue, + LocationToAccountId: penpal_runtime::xcm_config::LocationToAccountId, + System: penpal_runtime::System, + Balances: penpal_runtime::Balances, + ParachainSystem: penpal_runtime::ParachainSystem, + ParachainInfo: penpal_runtime::ParachainInfo, + }, + pallets_extra = { + PolkadotXcm: penpal_runtime::PolkadotXcm, + Assets: penpal_runtime::Assets, + } + }, // Wococo Parachains pub struct BridgeHubWococo { genesis = bridge_hub_rococo::genesis(), @@ -406,7 +450,7 @@ decl_test_networks! { parachains = vec![ AssetHubPolkadot, PenpalPolkadot, - Collectives, + CollectivesPolkadot, BridgeHubPolkadot, ], // TODO: uncomment when https://github.com/paritytech/cumulus/pull/2528 is merged @@ -428,6 +472,7 @@ decl_test_networks! { relay_chain = Westend, parachains = vec![ AssetHubWestend, + CollectivesWestend, PenpalWestend, ], bridge = () @@ -437,6 +482,7 @@ decl_test_networks! { parachains = vec![ AssetHubRococo, BridgeHubRococo, + PenpalRococo, ], bridge = RococoWococoMockBridge }, @@ -488,7 +534,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/parachains/integration-tests/emulated/common/src/macros.rs b/parachains/integration-tests/emulated/common/src/macros.rs index b5ab6d5a9f5..1cb66efb046 100644 --- a/parachains/integration-tests/emulated/common/src/macros.rs +++ b/parachains/integration-tests/emulated/common/src/macros.rs @@ -1,75 +1,85 @@ -// pub use crate::{ -// paste -// }; - #[macro_export] macro_rules! test_parachain_is_trusted_teleporter { - ( $sender_para:ty, ($assets:expr, $amount:expr), vec![$( $receiver_para:ty ),+] ) => { + ( $sender_para:ty, vec![$( $receiver_para:ty ),+], ($assets:expr, $amount:expr) ) => { $crate::paste::paste! { - // Origin - // let amount = KUSAMA_ED * 10; - let para_sender_balance_before = - <$sender_para>::account_data_of([<$sender_para Sender>]::get()).free; - let origin = <$sender_para as $crate::Parachain>::RuntimeOrigin::signed([<$sender_para Sender>]::get()); - - let para_receiver_balance_before = - BridgeHubKusama::account_data_of(BridgeHubKusamaReceiver::get()).free; - let para_destination: VersionedMultiLocation = - <$sender_para>::sibling_location_of(BridgeHubKusama::para_id()).into(); - let beneficiary: VersionedMultiLocation = - AccountId32 { network: None, id: BridgeHubKusamaReceiver::get().into() }.into(); - // let native_assets: VersionedMultiAssets = (Parent, amount).into(); + // init Origin variables + let sender = [<$sender_para Sender>]::get(); + let mut para_sender_balance_before = + <$sender_para>::account_data_of(sender.clone()).free; + let origin = <$sender_para as $crate::Parachain>::RuntimeOrigin::signed(sender.clone()); let fee_asset_item = 0; let weight_limit = WeightLimit::Unlimited; - // Send XCM message from Origin Parachain - <$sender_para>::execute_with(|| { - assert_ok!(<$sender_para as [<$sender_para Pallet>]>::PolkadotXcm::limited_teleport_assets( - origin, - bx!(para_destination), - bx!(beneficiary), - bx!($assets), - fee_asset_item, - weight_limit, - )); + $( + { + // init Destination variables + let receiver = [<$receiver_para Receiver>]::get(); + let para_receiver_balance_before = + <$receiver_para>::account_data_of(receiver.clone()).free; + let para_destination: VersionedMultiLocation = + <$sender_para>::sibling_location_of(<$receiver_para>::para_id()).into(); + let beneficiary: VersionedMultiLocation = + AccountId32 { network: None, id: receiver.clone().into() }.into(); - type RuntimeEvent = <$sender_para as $crate::Parachain>::RuntimeEvent; + // 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(), + )); - assert_expected_events!( - $sender_para, - vec![ - RuntimeEvent::PolkadotXcm( - pallet_xcm::Event::Attempted { outcome: Outcome::Complete { .. } } - ) => {}, - ] - ); - }); + type RuntimeEvent = <$sender_para as $crate::Parachain>::RuntimeEvent; - // Receive XCM message in Assets Parachain - BridgeHubKusama::execute_with(|| { - type RuntimeEvent = ::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 } + ) => {}, + ] + ); + }); - assert_expected_events!( - BridgeHubKusama, - vec![ - RuntimeEvent::Balances(pallet_balances::Event::Deposit { who, .. }) => { - who: *who == BridgeHubKusamaReceiver::get().into(), - }, - ] - ); - }); + // Receive XCM message in Destination Parachain + <$receiver_para>::execute_with(|| { + type RuntimeEvent = <$receiver_para as $crate::Parachain>::RuntimeEvent; - // Check if balances are updated accordingly in Relay Chain and Assets Parachain - let para_sender_balance_after = - <$sender_para>::account_data_of([<$sender_para Sender>]::get()).free; - let para_receiver_balance_after = - BridgeHubKusama::account_data_of(BridgeHubKusamaReceiver::get()).free; + assert_expected_events!( + $receiver_para, + vec![ + RuntimeEvent::Balances( + $crate::pallet_balances::Event::Deposit { who: receiver, .. } + ) => {}, + RuntimeEvent::XcmpQueue( + $crate::cumulus_pallet_xcmp_queue::Event::Success { .. } + ) => {}, + ] + ); + }); - assert_eq!(para_sender_balance_before - $amount, para_sender_balance_after); - assert!(para_receiver_balance_after > para_receiver_balance_before); - } + // Check if balances are updated accordingly in Origin and Destination Parachains + let para_sender_balance_after = + <$sender_para>::account_data_of(sender.clone()).free; + let para_receiver_balance_after = + <$receiver_para>::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>::account_data_of(sender.clone()).free; + } + )+ + } }; } - -// pub use test_system_para_is_trusted_teleporter; diff --git a/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs b/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs index 56d6f70cd5a..7f9c34ecbec 100644 --- a/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs +++ b/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs @@ -26,7 +26,7 @@ use frame_support::{ traits::{ConstU32, Contains, Everything, Nothing, PalletInfoAccess}, }; use frame_system::EnsureRoot; -use parachains_common::xcm_config::NativeAssetFromSystemParachain; +use parachains_common::xcm_config::NativeAssetFromSiblingSystemParachain; use pallet_xcm::XcmPassthrough; use parachains_common::{impls::ToStakingPot, xcm_config::AssetFeeAsExistentialDepositMultiplier}; use polkadot_parachain::primitives::Sibling; @@ -380,7 +380,7 @@ pub type AssetFeeAsExistentialDepositMultiplierFeeCharger = AssetFeeAsExistentia pub type TrustedTeleporters = ( NativeAsset, IsForeignConcreteAsset>>, - NativeAssetFromSystemParachain, + NativeAssetFromSiblingSystemParachain, ); pub struct XcmConfig; diff --git a/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs b/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs index ff4a1922e9b..e733002f2f3 100644 --- a/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs +++ b/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs @@ -26,7 +26,7 @@ use frame_support::{ traits::{ConstU32, Contains, Everything, Nothing, PalletInfoAccess}, }; use frame_system::EnsureRoot; -use parachains_common::xcm_config::NativeAssetFromSystemParachain; +use parachains_common::xcm_config::NativeAssetFromSiblingSystemParachain; use pallet_xcm::XcmPassthrough; use parachains_common::{impls::ToStakingPot, xcm_config::AssetFeeAsExistentialDepositMultiplier}; use polkadot_parachain::primitives::Sibling; @@ -387,7 +387,7 @@ pub type AssetFeeAsExistentialDepositMultiplierFeeCharger = AssetFeeAsExistentia pub type TrustedTeleporters = ( NativeAsset, IsForeignConcreteAsset>>, - NativeAssetFromSystemParachain, + NativeAssetFromSiblingSystemParachain, ); pub struct XcmConfig; diff --git a/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs b/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs index e7142f555a3..3314f27818e 100644 --- a/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs +++ b/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs @@ -27,7 +27,7 @@ use frame_support::{ traits::{ConstU32, Contains, Everything, Nothing, PalletInfoAccess}, }; use frame_system::EnsureRoot; -use parachains_common::xcm_config::NativeAssetFromSystemParachain; +use parachains_common::xcm_config::NativeAssetFromSiblingSystemParachain; use pallet_xcm::XcmPassthrough; use parachains_common::{impls::ToStakingPot, xcm_config::AssetFeeAsExistentialDepositMultiplier}; use polkadot_parachain::primitives::Sibling; @@ -415,7 +415,7 @@ pub type AssetFeeAsExistentialDepositMultiplierFeeCharger = AssetFeeAsExistentia pub type TrustedTeleporters = ( NativeAsset, IsForeignConcreteAsset>>, - NativeAssetFromSystemParachain, + NativeAssetFromSiblingSystemParachain, ); pub struct XcmConfig; diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs index c7c8a99c5dc..ed4f762e8ab 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs +++ b/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, NativeAssetFromSystemParachain}}; +use parachains_common::{impls::ToStakingPot, xcm_config::{ConcreteNativeAssetFrom, NativeAssetFromSiblingSystemParachain}}; use polkadot_parachain::primitives::Sibling; use xcm::latest::prelude::*; use xcm_builder::{ @@ -178,7 +178,7 @@ pub type Barrier = TrailingSetTopicAsId< >; pub type TrustedTeleporters = - (ConcreteNativeAssetFrom, NativeAssetFromSystemParachain); + (ConcreteNativeAssetFrom, NativeAssetFromSiblingSystemParachain); pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs index bef6a99255d..a0816556eba 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs +++ b/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, NativeAssetFromSystemParachain}}; +use parachains_common::{impls::ToStakingPot, xcm_config::{ConcreteNativeAssetFrom, NativeAssetFromSiblingSystemParachain}}; use polkadot_parachain::primitives::Sibling; use xcm::latest::prelude::*; use xcm_builder::{ @@ -179,7 +179,7 @@ pub type Barrier = DenyThenTry< >; pub type TrustedTeleporters = - (ConcreteNativeAssetFrom, NativeAssetFromSystemParachain); + (ConcreteNativeAssetFrom, NativeAssetFromSiblingSystemParachain); pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs index b6b34a894ef..2392f70feab 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs +++ b/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, NativeAssetFromSystemParachain}}; +use parachains_common::{impls::ToStakingPot, xcm_config::{ConcreteNativeAssetFrom, NativeAssetFromSiblingSystemParachain}}; use polkadot_parachain::primitives::Sibling; use sp_core::Get; use xcm::latest::prelude::*; @@ -225,7 +225,7 @@ pub type Barrier = TrailingSetTopicAsId< >; pub type TrustedTeleporters = - (ConcreteNativeAssetFrom, NativeAssetFromSystemParachain); + (ConcreteNativeAssetFrom, NativeAssetFromSiblingSystemParachain); pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { diff --git a/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs b/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs index dd5f53cf653..2134baa3b7e 100644 --- a/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs +++ b/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, NativeAssetFromSystemParachain}}; +use parachains_common::{impls::ToStakingPot, xcm_config::{ConcreteNativeAssetFrom, NativeAssetFromSiblingSystemParachain}}; use polkadot_parachain::primitives::Sibling; use xcm::latest::prelude::*; use xcm_builder::{ @@ -226,7 +226,7 @@ pub type Barrier = DenyThenTry< >; pub type TrustedTeleporters = - (ConcreteNativeAssetFrom, NativeAssetFromSystemParachain); + (ConcreteNativeAssetFrom, NativeAssetFromSiblingSystemParachain); pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { diff --git a/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs b/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs index 9f5961ed48d..5eb8e090224 100644 --- a/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs +++ b/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::NativeAssetFromSystemParachain; +use parachains_common::xcm_config::NativeAssetFromSiblingSystemParachain; use polkadot_parachain::primitives::Sibling; use xcm::latest::prelude::*; use xcm_builder::{ @@ -145,7 +145,7 @@ pub type Barrier = TrailingSetTopicAsId< >; pub type TrustedTeleporter = - (NativeAsset, NativeAssetFromSystemParachain); + (NativeAsset, NativeAssetFromSiblingSystemParachain); pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { diff --git a/xcm/xcm-emulator/src/lib.rs b/xcm/xcm-emulator/src/lib.rs index 170ec1e6fb4..b8ed00bfa43 100644 --- a/xcm/xcm-emulator/src/lib.rs +++ b/xcm/xcm-emulator/src/lib.rs @@ -319,7 +319,7 @@ macro_rules! decl_test_relay_chains { use $mq as message_queue; use $runtime_event as runtime_event; - Self::execute_with(|| { + Self::ext_wrapper(|| { <$mq as EnqueueMessage>::enqueue_message( msg.try_into().expect("Message too long"), AggregateMessageOrigin::Ump(UmpQueueId::Para(para.clone())) @@ -555,7 +555,7 @@ macro_rules! __impl_xcm_handlers_for_parachain { ) -> $crate::Weight { use $crate::{TestExt, XcmpMessageHandler}; - $name::execute_with(|| { + $name::ext_wrapper(|| { ::XcmpMessageHandler::handle_xcmp_messages(iter, max_weight) }) } @@ -568,7 +568,7 @@ macro_rules! __impl_xcm_handlers_for_parachain { ) -> $crate::Weight { use $crate::{DmpMessageHandler, TestExt}; - $name::execute_with(|| { + $name::ext_wrapper(|| { ::DmpMessageHandler::handle_dmp_messages(iter, max_weight) }) } @@ -634,7 +634,6 @@ macro_rules! __impl_test_ext_for_parachain { }) }); - let r = $ext_name.with(|v| v.borrow_mut().execute_with(execute)); // send messages if needed From a71e0cb2eb59e6f324a6ab588835bc197962b387 Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Fri, 7 Jul 2023 19:24:01 +0000 Subject: [PATCH 03/13] ".git/.scripts/commands/fmt/fmt.sh" --- parachains/common/src/xcm_config.rs | 16 ++++++++++++---- .../emulated/assets/asset-hub-kusama/src/lib.rs | 13 ++++++------- .../asset-hub-kusama/src/tests/teleport.rs | 2 +- .../assets/asset-hub-polkadot/src/lib.rs | 16 ++++++++-------- .../asset-hub-polkadot/src/tests/teleport.rs | 2 +- .../emulated/assets/asset-hub-rococo/src/lib.rs | 11 ++++------- .../asset-hub-rococo/src/tests/teleport.rs | 2 +- .../emulated/assets/asset-hub-westend/src/lib.rs | 12 ++++++------ .../asset-hub-westend/src/tests/teleport.rs | 2 +- .../bridges/bridge-hub-rococo/src/lib.rs | 16 ++++++++-------- .../bridge-hub-rococo/src/tests/teleport.rs | 2 +- .../collectives/collectives-polkadot/src/lib.rs | 15 +++++---------- .../collectives-polkadot/src/tests/teleport.rs | 2 +- .../collectives/collectives-westend/src/lib.rs | 11 ++++------- .../collectives-westend/src/tests/teleport.rs | 2 +- .../integration-tests/emulated/common/src/lib.rs | 10 +++++----- .../assets/asset-hub-kusama/src/xcm_config.rs | 6 ++++-- .../assets/asset-hub-polkadot/src/xcm_config.rs | 6 ++++-- .../assets/asset-hub-westend/src/xcm_config.rs | 6 ++++-- .../bridge-hub-kusama/src/xcm_config.rs | 5 ++++- .../bridge-hub-polkadot/src/xcm_config.rs | 5 ++++- .../bridge-hub-rococo/src/xcm_config.rs | 5 ++++- .../collectives-polkadot/src/xcm_config.rs | 5 ++++- .../contracts/contracts-rococo/src/xcm_config.rs | 3 +-- 24 files changed, 94 insertions(+), 81 deletions(-) diff --git a/parachains/common/src/xcm_config.rs b/parachains/common/src/xcm_config.rs index 56f77213cec..4263340aa32 100644 --- a/parachains/common/src/xcm_config.rs +++ b/parachains/common/src/xcm_config.rs @@ -78,10 +78,12 @@ impl ContainsPair for NativeAssetFromSiblingSystemPar } } - #[cfg(test)] mod tests { - use super::{MultiAsset, Parent, NativeAssetFromSiblingSystemParachain, MultiLocation, Parachain, ContainsPair, Here}; + use super::{ + ContainsPair, Here, MultiAsset, MultiLocation, NativeAssetFromSiblingSystemParachain, + Parachain, Parent, + }; #[test] fn native_asset_from_sibling_system_para_works() { @@ -96,7 +98,10 @@ mod tests { let unexpected_asset: MultiAsset = (Here, 1000000).into(); let expected_origin: MultiLocation = (Parent, Parachain(1000)).into(); - assert!(!NativeAssetFromSiblingSystemParachain::contains(&unexpected_asset, &expected_origin)); + assert!(!NativeAssetFromSiblingSystemParachain::contains( + &unexpected_asset, + &expected_origin + )); } #[test] @@ -104,6 +109,9 @@ mod tests { let expected_asset: MultiAsset = (Parent, 1000000).into(); let unexpected_origin: MultiLocation = (Parent, Parachain(2000)).into(); - assert!(!NativeAssetFromSiblingSystemParachain::contains(&expected_asset, &unexpected_origin)); + assert!(!NativeAssetFromSiblingSystemParachain::contains( + &expected_asset, + &unexpected_origin + )); } } diff --git a/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/lib.rs b/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/lib.rs index 9a1af9c3076..ca9100b4370 100644 --- a/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/lib.rs +++ b/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/lib.rs @@ -20,17 +20,16 @@ pub use frame_support::{ pub use integration_tests_common::{ constants::{ accounts::{ALICE, BOB}, - kusama::ED as KUSAMA_ED, asset_hub_kusama::ED as ASSET_HUB_KUSAMA_ED, bridge_hub_kusama::ED as BRIDGE_HUB_KUSAMA_ED, + kusama::ED as KUSAMA_ED, PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V3, }, - test_parachain_is_trusted_teleporter, - AccountId, AssetHubKusama, AssetHubKusamaPallet, AssetHubKusamaReceiver, AssetHubKusamaSender, - BridgeHubKusama, BridgeHubKusamaPallet, BridgeHubKusamaReceiver, BridgeHubKusamaSender, - BridgeHubPolkadot, BridgeHubPolkadotPallet, BridgeHubPolkadotReceiver, BridgeHubPolkadotSender, - Kusama, KusamaMockNet, - KusamaPallet, KusamaReceiver, KusamaSender, PenpalKusama, PenpalKusamaPallet, PenpalKusamaReceiver, + test_parachain_is_trusted_teleporter, AccountId, AssetHubKusama, AssetHubKusamaPallet, + AssetHubKusamaReceiver, AssetHubKusamaSender, BridgeHubKusama, BridgeHubKusamaPallet, + BridgeHubKusamaReceiver, BridgeHubKusamaSender, BridgeHubPolkadot, BridgeHubPolkadotPallet, + BridgeHubPolkadotReceiver, BridgeHubPolkadotSender, Kusama, KusamaMockNet, KusamaPallet, + KusamaReceiver, KusamaSender, PenpalKusama, PenpalKusamaPallet, PenpalKusamaReceiver, PenpalKusamaSender, PenpalPolkadot, PenpalPolkadotReceiver, PenpalPolkadotSender, Polkadot, PolkadotMockNet, PolkadotPallet, PolkadotReceiver, PolkadotSender, }; diff --git a/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/tests/teleport.rs b/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/tests/teleport.rs index c0aeafce27b..d2a5d62e75e 100644 --- a/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/tests/teleport.rs +++ b/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/tests/teleport.rs @@ -86,7 +86,7 @@ fn teleport_to_other_system_parachains() { // Works for the right origin and asset test_parachain_is_trusted_teleporter!( - AssetHubKusama, // Origin + AssetHubKusama, // Origin vec![BridgeHubKusama], // Destinations (expected_asset, amount) ); diff --git a/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/lib.rs b/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/lib.rs index ba1566560e2..91f94e84abc 100644 --- a/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/lib.rs +++ b/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/lib.rs @@ -21,17 +21,17 @@ pub use frame_support::{ pub use integration_tests_common::{ constants::{ accounts::{ALICE, BOB}, - polkadot::ED as POLKADOT_ED, 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, - AccountId, AssetHubKusama, AssetHubKusamaPallet, AssetHubKusamaReceiver, AssetHubKusamaSender, - AssetHubPolkadot, AssetHubPolkadotPallet, AssetHubPolkadotReceiver, AssetHubPolkadotSender, - BridgeHubKusama, BridgeHubKusamaPallet, BridgeHubKusamaReceiver, BridgeHubKusamaSender, - BridgeHubPolkadot, BridgeHubPolkadotPallet, BridgeHubPolkadotReceiver, BridgeHubPolkadotSender, - CollectivesPolkadot, CollectivesPolkadotPallet, CollectivesPolkadotReceiver, CollectivesPolkadotSender, Kusama, KusamaMockNet, - KusamaPallet, KusamaReceiver, KusamaSender, PenpalKusama, PenpalKusamaReceiver, + test_parachain_is_trusted_teleporter, AccountId, AssetHubKusama, AssetHubKusamaPallet, + AssetHubKusamaReceiver, AssetHubKusamaSender, AssetHubPolkadot, AssetHubPolkadotPallet, + AssetHubPolkadotReceiver, AssetHubPolkadotSender, BridgeHubKusama, BridgeHubKusamaPallet, + BridgeHubKusamaReceiver, BridgeHubKusamaSender, BridgeHubPolkadot, BridgeHubPolkadotPallet, + BridgeHubPolkadotReceiver, BridgeHubPolkadotSender, CollectivesPolkadot, + CollectivesPolkadotPallet, CollectivesPolkadotReceiver, CollectivesPolkadotSender, Kusama, + KusamaMockNet, KusamaPallet, KusamaReceiver, KusamaSender, PenpalKusama, PenpalKusamaReceiver, PenpalKusamaSender, PenpalPolkadot, PenpalPolkadotReceiver, PenpalPolkadotSender, Polkadot, PolkadotMockNet, PolkadotPallet, PolkadotReceiver, PolkadotSender, }; diff --git a/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/teleport.rs b/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/teleport.rs index 25c16d70959..acb92032ef4 100644 --- a/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/teleport.rs +++ b/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/teleport.rs @@ -83,7 +83,7 @@ fn teleport_to_other_system_parachains() { let native_asset: VersionedMultiAssets = (Parent, amount).into(); test_parachain_is_trusted_teleporter!( - AssetHubPolkadot, // Origin + AssetHubPolkadot, // Origin vec![CollectivesPolkadot, BridgeHubPolkadot], // Destinations (native_asset, amount) ); diff --git a/parachains/integration-tests/emulated/assets/asset-hub-rococo/src/lib.rs b/parachains/integration-tests/emulated/assets/asset-hub-rococo/src/lib.rs index 6b3c50e5fb8..f89d9ab4fb7 100644 --- a/parachains/integration-tests/emulated/assets/asset-hub-rococo/src/lib.rs +++ b/parachains/integration-tests/emulated/assets/asset-hub-rococo/src/lib.rs @@ -18,15 +18,12 @@ 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, - AccountId, AssetHubRococo, AssetHubRococoSender, - AssetHubRococoPallet, BridgeHubRococo, BridgeHubRococoReceiver + constants::asset_hub_polkadot::ED as ASSET_HUB_ROCOCO_ED, test_parachain_is_trusted_teleporter, + AccountId, AssetHubRococo, AssetHubRococoPallet, AssetHubRococoSender, BridgeHubRococo, + BridgeHubRococoReceiver, }; pub use xcm::prelude::*; -pub use xcm_emulator::{TestExt, bx, assert_expected_events, Parachain}; +pub use xcm_emulator::{assert_expected_events, bx, Parachain, TestExt}; #[cfg(test)] mod tests; diff --git a/parachains/integration-tests/emulated/assets/asset-hub-rococo/src/tests/teleport.rs b/parachains/integration-tests/emulated/assets/asset-hub-rococo/src/tests/teleport.rs index b6e3ad0451f..ffd231e6729 100644 --- a/parachains/integration-tests/emulated/assets/asset-hub-rococo/src/tests/teleport.rs +++ b/parachains/integration-tests/emulated/assets/asset-hub-rococo/src/tests/teleport.rs @@ -22,7 +22,7 @@ fn teleport_to_other_system_parachains() { let native_asset: VersionedMultiAssets = (Parent, amount).into(); test_parachain_is_trusted_teleporter!( - AssetHubRococo, // Origin + AssetHubRococo, // Origin vec![BridgeHubRococo], // Destinations (native_asset, amount) ); diff --git a/parachains/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs b/parachains/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs index a7de2a07de3..642077945b0 100644 --- a/parachains/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs +++ b/parachains/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs @@ -21,15 +21,15 @@ pub use frame_support::{ pub use integration_tests_common::{ constants::{ accounts::{ALICE, BOB}, - polkadot::ED as POLKADOT_ED, asset_hub_westend::ED as ASSET_HUB_WESTEND_ED, + polkadot::ED as POLKADOT_ED, PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V3, }, - test_parachain_is_trusted_teleporter, - AccountId, AssetHubWestend, AssetHubWestendPallet, AssetHubWestendReceiver, - AssetHubWestendSender, CollectivesWestend, CollectivesWestendPallet, CollectivesWestendReceiver, CollectivesWestendSender, - PenpalWestend, PenpalWestendPallet, PenpalWestendReceiver, PenpalWestendSender, Westend, - WestendPallet, WestendReceiver, WestendSender, + test_parachain_is_trusted_teleporter, AccountId, AssetHubWestend, AssetHubWestendPallet, + AssetHubWestendReceiver, AssetHubWestendSender, CollectivesWestend, CollectivesWestendPallet, + CollectivesWestendReceiver, CollectivesWestendSender, PenpalWestend, PenpalWestendPallet, + PenpalWestendReceiver, PenpalWestendSender, Westend, WestendPallet, WestendReceiver, + WestendSender, }; pub use polkadot_core_primitives::InboundDownwardMessage; pub use xcm::{ diff --git a/parachains/integration-tests/emulated/assets/asset-hub-westend/src/tests/teleport.rs b/parachains/integration-tests/emulated/assets/asset-hub-westend/src/tests/teleport.rs index 9fe2a2f323f..f2bf419db30 100644 --- a/parachains/integration-tests/emulated/assets/asset-hub-westend/src/tests/teleport.rs +++ b/parachains/integration-tests/emulated/assets/asset-hub-westend/src/tests/teleport.rs @@ -83,7 +83,7 @@ fn teleport_to_other_system_parachains() { let native_asset: VersionedMultiAssets = (Parent, amount).into(); test_parachain_is_trusted_teleporter!( - AssetHubWestend, // Origin + AssetHubWestend, // Origin vec![CollectivesWestend], // Destinations (native_asset, amount) ); diff --git a/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/lib.rs b/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/lib.rs index cb247308702..266b6c8c77a 100644 --- a/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/lib.rs +++ b/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/lib.rs @@ -20,17 +20,17 @@ pub use frame_support::{assert_ok, pallet_prelude::Weight}; pub use integration_tests_common::{ constants::{ accounts::{ALICE, BOB}, - rococo::{ED as ROCOCO_ED, ED as WOCOCO_ED}, bridge_hub_rococo::ED as BRIDGE_HUB_ROCOCO_ED, + rococo::{ED as ROCOCO_ED, ED as WOCOCO_ED}, PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V3, }, - test_parachain_is_trusted_teleporter, - AccountId, AssetHubWococo, AssetHubRococo, AssetHubRococoReceiver, BridgeHubPolkadot, BridgeHubPolkadotPallet, - BridgeHubPolkadotReceiver, BridgeHubPolkadotSender, BridgeHubRococo, BridgeHubRococoPallet, - BridgeHubRococoReceiver, BridgeHubRococoSender, BridgeHubWococo, Kusama, KusamaPallet, - PenpalPolkadot, PenpalPolkadotReceiver, PenpalPolkadotSender, Polkadot, PolkadotMockNet, - PolkadotPallet, PolkadotReceiver, PolkadotSender, Rococo, RococoMockNet, RococoPallet, - RococoReceiver, RococoSender, + test_parachain_is_trusted_teleporter, AccountId, AssetHubRococo, AssetHubRococoReceiver, + AssetHubWococo, BridgeHubPolkadot, BridgeHubPolkadotPallet, BridgeHubPolkadotReceiver, + BridgeHubPolkadotSender, BridgeHubRococo, BridgeHubRococoPallet, BridgeHubRococoReceiver, + BridgeHubRococoSender, BridgeHubWococo, Kusama, KusamaPallet, PenpalPolkadot, + PenpalPolkadotReceiver, PenpalPolkadotSender, Polkadot, PolkadotMockNet, PolkadotPallet, + PolkadotReceiver, PolkadotSender, Rococo, RococoMockNet, RococoPallet, RococoReceiver, + RococoSender, }; // pub use polkadot_core_primitives::InboundDownwardMessage; pub use xcm::{ diff --git a/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/tests/teleport.rs b/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/tests/teleport.rs index 1e886036476..e61400405cc 100644 --- a/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/tests/teleport.rs +++ b/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/tests/teleport.rs @@ -22,7 +22,7 @@ fn teleport_to_other_system_parachains() { let native_asset: VersionedMultiAssets = (Parent, amount).into(); test_parachain_is_trusted_teleporter!( - BridgeHubRococo, // Origin + BridgeHubRococo, // Origin vec![AssetHubRococo], // Destinations (native_asset, amount) ); diff --git a/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/lib.rs b/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/lib.rs index 52b11dd4fef..50c485c4200 100644 --- a/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/lib.rs +++ b/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/lib.rs @@ -18,18 +18,13 @@ pub use frame_support::assert_ok; pub use integration_tests_common::{ - constants::{ - accounts::ALICE, - collectives::ED as COLLECTIVES_POLKADOT_ED, - }, - test_parachain_is_trusted_teleporter, - AccountId, AssetHubPolkadot, AssetHubPolkadotReceiver, - BridgeHubPolkadot, BridgeHubPolkadotReceiver, - AssetHubPolkadotPallet, CollectivesPolkadot, CollectivesPolkadotSender, CollectivesPolkadotPallet, Polkadot, - PolkadotMockNet, + constants::{accounts::ALICE, collectives::ED as COLLECTIVES_POLKADOT_ED}, + test_parachain_is_trusted_teleporter, AccountId, AssetHubPolkadot, AssetHubPolkadotPallet, + AssetHubPolkadotReceiver, BridgeHubPolkadot, BridgeHubPolkadotReceiver, CollectivesPolkadot, + CollectivesPolkadotPallet, CollectivesPolkadotSender, Polkadot, PolkadotMockNet, }; pub use xcm::prelude::*; -pub use xcm_emulator::{TestExt, bx, assert_expected_events, Parachain}; +pub use xcm_emulator::{assert_expected_events, bx, Parachain, TestExt}; #[cfg(test)] mod tests; diff --git a/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/tests/teleport.rs b/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/tests/teleport.rs index dbdd9b51891..75ba98c10e8 100644 --- a/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/tests/teleport.rs +++ b/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/tests/teleport.rs @@ -22,7 +22,7 @@ fn teleport_to_other_system_parachains() { let native_asset: VersionedMultiAssets = (Parent, amount).into(); test_parachain_is_trusted_teleporter!( - CollectivesPolkadot, // Origin + CollectivesPolkadot, // Origin vec![AssetHubPolkadot, BridgeHubPolkadot], // Destinations (native_asset, amount) ); diff --git a/parachains/integration-tests/emulated/collectives/collectives-westend/src/lib.rs b/parachains/integration-tests/emulated/collectives/collectives-westend/src/lib.rs index 95c73664477..6889157648e 100644 --- a/parachains/integration-tests/emulated/collectives/collectives-westend/src/lib.rs +++ b/parachains/integration-tests/emulated/collectives/collectives-westend/src/lib.rs @@ -18,15 +18,12 @@ pub use frame_support::assert_ok; pub use integration_tests_common::{ - constants::{ - collectives::ED as COLLECTIVES_WESTEND_ED, - }, - test_parachain_is_trusted_teleporter, - AccountId, AssetHubWestend, AssetHubWestendReceiver, - AssetHubWestendPallet, CollectivesWestend, CollectivesWestendSender, CollectivesWestendPallet, + constants::collectives::ED as COLLECTIVES_WESTEND_ED, test_parachain_is_trusted_teleporter, + AccountId, AssetHubWestend, AssetHubWestendPallet, AssetHubWestendReceiver, CollectivesWestend, + CollectivesWestendPallet, CollectivesWestendSender, }; pub use xcm::prelude::*; -pub use xcm_emulator::{TestExt, bx, assert_expected_events, Parachain}; +pub use xcm_emulator::{assert_expected_events, bx, Parachain, TestExt}; #[cfg(test)] mod tests; diff --git a/parachains/integration-tests/emulated/collectives/collectives-westend/src/tests/teleport.rs b/parachains/integration-tests/emulated/collectives/collectives-westend/src/tests/teleport.rs index 5741bb1960d..8e085679c87 100644 --- a/parachains/integration-tests/emulated/collectives/collectives-westend/src/tests/teleport.rs +++ b/parachains/integration-tests/emulated/collectives/collectives-westend/src/tests/teleport.rs @@ -22,7 +22,7 @@ fn teleport_to_other_system_parachains() { let native_asset: VersionedMultiAssets = (Parent, amount).into(); test_parachain_is_trusted_teleporter!( - CollectivesWestend, // Origin + CollectivesWestend, // Origin vec![AssetHubWestend], // Destinations (native_asset, amount) ); diff --git a/parachains/integration-tests/emulated/common/src/lib.rs b/parachains/integration-tests/emulated/common/src/lib.rs index 753d5f96142..f6e1579ba5a 100644 --- a/parachains/integration-tests/emulated/common/src/lib.rs +++ b/parachains/integration-tests/emulated/common/src/lib.rs @@ -9,19 +9,19 @@ pub use constants::{ }; pub use impls::{RococoWococoMessageHandler, WococoRococoMessageHandler}; +pub use cumulus_pallet_xcmp_queue; use frame_support::{parameter_types, sp_io, sp_tracing}; +pub use pallet_balances; +pub use pallet_xcm; pub use parachains_common::{AccountId, AssetHubPolkadotAuraId, AuraId, Balance, BlockNumber}; pub use sp_core::{sr25519, storage::Storage, Get}; use xcm::prelude::*; pub use xcm_emulator::{ decl_test_bridges, decl_test_networks, decl_test_parachains, decl_test_relay_chains, - decl_test_sender_receiver_accounts_parameter_types, BridgeMessageHandler, Parachain, - RelayChain, TestExt, paste, + decl_test_sender_receiver_accounts_parameter_types, paste, BridgeMessageHandler, Parachain, + RelayChain, TestExt, }; use xcm_executor::traits::ConvertLocation; -pub use pallet_xcm; -pub use cumulus_pallet_xcmp_queue; -pub use pallet_balances; decl_test_relay_chains! { #[api_version(5)] diff --git a/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs b/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs index 7f9c34ecbec..2c9eb81d002 100644 --- a/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs +++ b/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs @@ -26,9 +26,11 @@ use frame_support::{ traits::{ConstU32, Contains, Everything, Nothing, PalletInfoAccess}, }; use frame_system::EnsureRoot; -use parachains_common::xcm_config::NativeAssetFromSiblingSystemParachain; use pallet_xcm::XcmPassthrough; -use parachains_common::{impls::ToStakingPot, xcm_config::AssetFeeAsExistentialDepositMultiplier}; +use parachains_common::{ + impls::ToStakingPot, + xcm_config::{AssetFeeAsExistentialDepositMultiplier, NativeAssetFromSiblingSystemParachain}, +}; use polkadot_parachain::primitives::Sibling; use sp_runtime::traits::ConvertInto; use xcm::latest::prelude::*; diff --git a/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs b/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs index e733002f2f3..a70e99eca5b 100644 --- a/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs +++ b/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs @@ -26,9 +26,11 @@ use frame_support::{ traits::{ConstU32, Contains, Everything, Nothing, PalletInfoAccess}, }; use frame_system::EnsureRoot; -use parachains_common::xcm_config::NativeAssetFromSiblingSystemParachain; use pallet_xcm::XcmPassthrough; -use parachains_common::{impls::ToStakingPot, xcm_config::AssetFeeAsExistentialDepositMultiplier}; +use parachains_common::{ + impls::ToStakingPot, + xcm_config::{AssetFeeAsExistentialDepositMultiplier, NativeAssetFromSiblingSystemParachain}, +}; use polkadot_parachain::primitives::Sibling; use sp_runtime::traits::ConvertInto; use xcm::latest::prelude::*; diff --git a/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs b/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs index 3314f27818e..efbb40739b4 100644 --- a/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs +++ b/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs @@ -27,9 +27,11 @@ use frame_support::{ traits::{ConstU32, Contains, Everything, Nothing, PalletInfoAccess}, }; use frame_system::EnsureRoot; -use parachains_common::xcm_config::NativeAssetFromSiblingSystemParachain; use pallet_xcm::XcmPassthrough; -use parachains_common::{impls::ToStakingPot, xcm_config::AssetFeeAsExistentialDepositMultiplier}; +use parachains_common::{ + impls::ToStakingPot, + xcm_config::{AssetFeeAsExistentialDepositMultiplier, NativeAssetFromSiblingSystemParachain}, +}; use polkadot_parachain::primitives::Sibling; use sp_runtime::traits::ConvertInto; use xcm::latest::prelude::*; diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs index ed4f762e8ab..927f6d5a7c8 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs @@ -24,7 +24,10 @@ use frame_support::{ }; use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; -use parachains_common::{impls::ToStakingPot, xcm_config::{ConcreteNativeAssetFrom, NativeAssetFromSiblingSystemParachain}}; +use parachains_common::{ + impls::ToStakingPot, + xcm_config::{ConcreteNativeAssetFrom, NativeAssetFromSiblingSystemParachain}, +}; use polkadot_parachain::primitives::Sibling; use xcm::latest::prelude::*; use xcm_builder::{ diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs index a0816556eba..760a23e0d9e 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs @@ -24,7 +24,10 @@ use frame_support::{ }; use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; -use parachains_common::{impls::ToStakingPot, xcm_config::{ConcreteNativeAssetFrom, NativeAssetFromSiblingSystemParachain}}; +use parachains_common::{ + impls::ToStakingPot, + xcm_config::{ConcreteNativeAssetFrom, NativeAssetFromSiblingSystemParachain}, +}; use polkadot_parachain::primitives::Sibling; use xcm::latest::prelude::*; use xcm_builder::{ diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs index 2392f70feab..774f0d7ecfc 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs @@ -30,7 +30,10 @@ use frame_support::{ }; use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; -use parachains_common::{impls::ToStakingPot, xcm_config::{ConcreteNativeAssetFrom, NativeAssetFromSiblingSystemParachain}}; +use parachains_common::{ + impls::ToStakingPot, + xcm_config::{ConcreteNativeAssetFrom, NativeAssetFromSiblingSystemParachain}, +}; use polkadot_parachain::primitives::Sibling; use sp_core::Get; use xcm::latest::prelude::*; diff --git a/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs b/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs index 2134baa3b7e..abe02eb627c 100644 --- a/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs +++ b/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs @@ -24,7 +24,10 @@ use frame_support::{ }; use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; -use parachains_common::{impls::ToStakingPot, xcm_config::{ConcreteNativeAssetFrom, NativeAssetFromSiblingSystemParachain}}; +use parachains_common::{ + impls::ToStakingPot, + xcm_config::{ConcreteNativeAssetFrom, NativeAssetFromSiblingSystemParachain}, +}; use polkadot_parachain::primitives::Sibling; use xcm::latest::prelude::*; use xcm_builder::{ diff --git a/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs b/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs index 5eb8e090224..da454bf982a 100644 --- a/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs +++ b/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs @@ -144,8 +144,7 @@ pub type Barrier = TrailingSetTopicAsId< >, >; -pub type TrustedTeleporter = - (NativeAsset, NativeAssetFromSiblingSystemParachain); +pub type TrustedTeleporter = (NativeAsset, NativeAssetFromSiblingSystemParachain); pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { From b6a0a9ddb9c402ecf58d33815bd6e936363a5ba7 Mon Sep 17 00:00:00 2001 From: NachoPal Date: Tue, 11 Jul 2023 11:04:54 +0200 Subject: [PATCH 04/13] address comments --- Cargo.lock | 1 - .../emulated/assets/asset-hub-kusama/src/lib.rs | 1 - .../runtimes/assets/asset-hub-kusama/src/xcm_config.rs | 6 +++--- .../runtimes/assets/asset-hub-polkadot/src/xcm_config.rs | 6 +++--- .../runtimes/assets/asset-hub-westend/src/xcm_config.rs | 6 +++--- parachains/runtimes/assets/common/Cargo.toml | 1 - .../bridge-hubs/bridge-hub-kusama/src/xcm_config.rs | 3 ++- .../bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs | 3 ++- .../bridge-hubs/bridge-hub-rococo/src/xcm_config.rs | 3 ++- .../collectives/collectives-polkadot/src/xcm_config.rs | 3 ++- 10 files changed, 17 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 705283a7689..9d622955357 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -729,7 +729,6 @@ dependencies = [ "pallet-xcm", "parachains-common", "parity-scale-codec", - "paste", "scale-info", "sp-api", "sp-runtime", diff --git a/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/lib.rs b/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/lib.rs index ca9100b4370..65232b36ec0 100644 --- a/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/lib.rs +++ b/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/lib.rs @@ -21,7 +21,6 @@ pub use integration_tests_common::{ constants::{ accounts::{ALICE, BOB}, asset_hub_kusama::ED as ASSET_HUB_KUSAMA_ED, - bridge_hub_kusama::ED as BRIDGE_HUB_KUSAMA_ED, kusama::ED as KUSAMA_ED, PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V3, }, diff --git a/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs b/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs index 2c9eb81d002..e91c249465c 100644 --- a/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs +++ b/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs @@ -379,6 +379,9 @@ pub type AssetFeeAsExistentialDepositMultiplierFeeCharger = AssetFeeAsExistentia TrustBackedAssetsInstance, >; +/// Cases where a remote origin is accepted as trusted Teleporter: +/// - teleportation of KSM from the parent Relay Chain and sibling parachains. +/// - teleportation of sibling parachain's assets (as ForeignCreators) pub type TrustedTeleporters = ( NativeAsset, IsForeignConcreteAsset>>, @@ -395,9 +398,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/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs b/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs index a70e99eca5b..3891ab23f51 100644 --- a/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs +++ b/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs @@ -386,6 +386,9 @@ pub type AssetFeeAsExistentialDepositMultiplierFeeCharger = AssetFeeAsExistentia TrustBackedAssetsInstance, >; +/// Cases where a remote origin is accepted as trusted Teleporter: +/// - teleportation of DOT from the parent Relay Chain and sibling parachains. +/// - teleportation of sibling parachain's assets (as ForeignCreators) pub type TrustedTeleporters = ( NativeAsset, IsForeignConcreteAsset>>, @@ -402,9 +405,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/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs b/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs index efbb40739b4..8f40da6232f 100644 --- a/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs +++ b/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs @@ -414,6 +414,9 @@ pub type AssetFeeAsExistentialDepositMultiplierFeeCharger = AssetFeeAsExistentia TrustBackedAssetsInstance, >; +/// Cases where a remote origin is accepted as trusted Teleporter: +/// - teleportation of WND from the parent Relay Chain and sibling parachains. +/// - teleportation of sibling parachain's assets (as ForeignCreators) pub type TrustedTeleporters = ( NativeAsset, IsForeignConcreteAsset>>, @@ -430,9 +433,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/parachains/runtimes/assets/common/Cargo.toml b/parachains/runtimes/assets/common/Cargo.toml index 63113155d77..79937ec4363 100644 --- a/parachains/runtimes/assets/common/Cargo.toml +++ b/parachains/runtimes/assets/common/Cargo.toml @@ -9,7 +9,6 @@ description = "Assets common utilities" codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } scale-info = { version = "2.9.0", default-features = false, features = ["derive"] } log = { version = "0.4.19", default-features = false } -paste = "1.0.13" # Substrate frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs index 927f6d5a7c8..6c5d69d25f5 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs @@ -180,6 +180,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. pub type TrustedTeleporters = (ConcreteNativeAssetFrom, NativeAssetFromSiblingSystemParachain); @@ -192,7 +194,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/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs index 760a23e0d9e..7746fe7cb16 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs @@ -181,6 +181,8 @@ pub type Barrier = DenyThenTry< ), >; +/// Cases where a remote origin is accepted as trusted Teleporter: +/// - teleportation of DOT from the parent Relay Chain and sibling parachains. pub type TrustedTeleporters = (ConcreteNativeAssetFrom, NativeAssetFromSiblingSystemParachain); @@ -193,7 +195,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/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs index 774f0d7ecfc..7878616a4f5 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs @@ -227,6 +227,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. pub type TrustedTeleporters = (ConcreteNativeAssetFrom, NativeAssetFromSiblingSystemParachain); @@ -239,7 +241,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/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs b/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs index abe02eb627c..dcaa54da83e 100644 --- a/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs +++ b/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs @@ -228,6 +228,8 @@ pub type Barrier = DenyThenTry< ), >; +/// Cases where a remote origin is accepted as trusted Teleporter: +/// - teleportation of DOT from the parent Relay Chain and sibling parachains. pub type TrustedTeleporters = (ConcreteNativeAssetFrom, NativeAssetFromSiblingSystemParachain); @@ -240,7 +242,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 51b7d88b02a3aa7a9c86818b4cdf6f93f2c267ea Mon Sep 17 00:00:00 2001 From: NachoPal Date: Wed, 12 Jul 2023 13:38:26 +0200 Subject: [PATCH 05/13] rename struct + more tests --- parachains/common/src/xcm_config.rs | 33 +++++++++++-------- .../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, 36 insertions(+), 29 deletions(-) diff --git a/parachains/common/src/xcm_config.rs b/parachains/common/src/xcm_config.rs index 4263340aa32..e5b233f6596 100644 --- a/parachains/common/src/xcm_config.rs +++ b/parachains/common/src/xcm_config.rs @@ -65,10 +65,10 @@ impl> ContainsPair } /// Accepts an asset if it is a native asset from a System Parachain. -pub struct NativeAssetFromSiblingSystemParachain; -impl ContainsPair for NativeAssetFromSiblingSystemParachain { +pub struct ConcreteNativeAssetFromSiblingSystemParachain; +impl ContainsPair for ConcreteNativeAssetFromSiblingSystemParachain { fn contains(asset: &MultiAsset, origin: &MultiLocation) -> bool { - log::trace!(target: "xcm::contains", "NativeAssetFromSiblingSystemParachain asset: {:?}, origin: {:?}", asset, origin); + log::trace!(target: "xcm::contains", "ConcreteNativeAssetFromSiblingSystemParachain asset: {:?}, origin: {:?}", asset, origin); let is_system_para = match origin { MultiLocation { parents: 1, interior: X1(Parachain(id)) } if *id < 2000 => true, _ => false, @@ -81,27 +81,34 @@ impl ContainsPair for NativeAssetFromSiblingSystemPar #[cfg(test)] mod tests { use super::{ - ContainsPair, Here, MultiAsset, MultiLocation, NativeAssetFromSiblingSystemParachain, - Parachain, Parent, + ContainsPair, Here, MultiAsset, MultiLocation, ConcreteNativeAssetFromSiblingSystemParachain, + Parachain, Parent, GeneralIndex, PalletInstance, }; #[test] fn native_asset_from_sibling_system_para_works() { let expected_asset: MultiAsset = (Parent, 1000000).into(); - let expected_origin: MultiLocation = (Parent, Parachain(1000)).into(); + let expected_origin: MultiLocation = (Parent, Parachain(1999)).into(); - assert!(NativeAssetFromSiblingSystemParachain::contains(&expected_asset, &expected_origin)); + assert!(ConcreteNativeAssetFromSiblingSystemParachain::contains(&expected_asset, &expected_origin)); } #[test] fn native_asset_from_sibling_system_para_fails_for_wrong_asset() { - let unexpected_asset: MultiAsset = (Here, 1000000).into(); + 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(); - assert!(!NativeAssetFromSiblingSystemParachain::contains( - &unexpected_asset, - &expected_origin - )); + unexpected_assets.iter().for_each(|asset| { + assert!(!ConcreteNativeAssetFromSiblingSystemParachain::contains( + asset, + &expected_origin + )); + }); + } #[test] @@ -109,7 +116,7 @@ mod tests { let expected_asset: MultiAsset = (Parent, 1000000).into(); let unexpected_origin: MultiLocation = (Parent, Parachain(2000)).into(); - assert!(!NativeAssetFromSiblingSystemParachain::contains( + assert!(!ConcreteNativeAssetFromSiblingSystemParachain::contains( &expected_asset, &unexpected_origin )); diff --git a/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs b/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs index e91c249465c..aa908d80fa1 100644 --- a/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs +++ b/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs @@ -29,7 +29,7 @@ use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; use parachains_common::{ impls::ToStakingPot, - xcm_config::{AssetFeeAsExistentialDepositMultiplier, NativeAssetFromSiblingSystemParachain}, + xcm_config::{AssetFeeAsExistentialDepositMultiplier, ConcreteNativeAssetFromSiblingSystemParachain}, }; use polkadot_parachain::primitives::Sibling; use sp_runtime::traits::ConvertInto; @@ -385,7 +385,7 @@ pub type AssetFeeAsExistentialDepositMultiplierFeeCharger = AssetFeeAsExistentia pub type TrustedTeleporters = ( NativeAsset, IsForeignConcreteAsset>>, - NativeAssetFromSiblingSystemParachain, + ConcreteNativeAssetFromSiblingSystemParachain, ); pub struct XcmConfig; diff --git a/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs b/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs index 3891ab23f51..05f41fdae82 100644 --- a/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs +++ b/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, NativeAssetFromSiblingSystemParachain}, + xcm_config::{AssetFeeAsExistentialDepositMultiplier, ConcreteNativeAssetFromSiblingSystemParachain}, }; use polkadot_parachain::primitives::Sibling; use sp_runtime::traits::ConvertInto; @@ -392,7 +392,7 @@ pub type AssetFeeAsExistentialDepositMultiplierFeeCharger = AssetFeeAsExistentia pub type TrustedTeleporters = ( NativeAsset, IsForeignConcreteAsset>>, - NativeAssetFromSiblingSystemParachain, + ConcreteNativeAssetFromSiblingSystemParachain, ); pub struct XcmConfig; diff --git a/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs b/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs index 8f40da6232f..15a24a8f0bc 100644 --- a/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs +++ b/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs @@ -30,7 +30,7 @@ use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; use parachains_common::{ impls::ToStakingPot, - xcm_config::{AssetFeeAsExistentialDepositMultiplier, NativeAssetFromSiblingSystemParachain}, + xcm_config::{AssetFeeAsExistentialDepositMultiplier, ConcreteNativeAssetFromSiblingSystemParachain}, }; use polkadot_parachain::primitives::Sibling; use sp_runtime::traits::ConvertInto; @@ -420,7 +420,7 @@ pub type AssetFeeAsExistentialDepositMultiplierFeeCharger = AssetFeeAsExistentia pub type TrustedTeleporters = ( NativeAsset, IsForeignConcreteAsset>>, - NativeAssetFromSiblingSystemParachain, + ConcreteNativeAssetFromSiblingSystemParachain, ); pub struct XcmConfig; diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs index 6c5d69d25f5..5d333407cf3 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs @@ -26,7 +26,7 @@ use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; use parachains_common::{ impls::ToStakingPot, - xcm_config::{ConcreteNativeAssetFrom, NativeAssetFromSiblingSystemParachain}, + xcm_config::{ConcreteNativeAssetFrom, ConcreteNativeAssetFromSiblingSystemParachain}, }; use polkadot_parachain::primitives::Sibling; use xcm::latest::prelude::*; @@ -183,7 +183,7 @@ 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 = - (ConcreteNativeAssetFrom, NativeAssetFromSiblingSystemParachain); + (ConcreteNativeAssetFrom, ConcreteNativeAssetFromSiblingSystemParachain); pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs index 7746fe7cb16..e4961311c98 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs @@ -26,7 +26,7 @@ use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; use parachains_common::{ impls::ToStakingPot, - xcm_config::{ConcreteNativeAssetFrom, NativeAssetFromSiblingSystemParachain}, + xcm_config::{ConcreteNativeAssetFrom, ConcreteNativeAssetFromSiblingSystemParachain}, }; use polkadot_parachain::primitives::Sibling; use xcm::latest::prelude::*; @@ -184,7 +184,7 @@ pub type Barrier = DenyThenTry< /// Cases where a remote origin is accepted as trusted Teleporter: /// - teleportation of DOT from the parent Relay Chain and sibling parachains. pub type TrustedTeleporters = - (ConcreteNativeAssetFrom, NativeAssetFromSiblingSystemParachain); + (ConcreteNativeAssetFrom, ConcreteNativeAssetFromSiblingSystemParachain); pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs index 7878616a4f5..38f3c4b5066 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs @@ -32,7 +32,7 @@ use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; use parachains_common::{ impls::ToStakingPot, - xcm_config::{ConcreteNativeAssetFrom, NativeAssetFromSiblingSystemParachain}, + xcm_config::{ConcreteNativeAssetFrom, ConcreteNativeAssetFromSiblingSystemParachain}, }; use polkadot_parachain::primitives::Sibling; use sp_core::Get; @@ -230,7 +230,7 @@ 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 = - (ConcreteNativeAssetFrom, NativeAssetFromSiblingSystemParachain); + (ConcreteNativeAssetFrom, ConcreteNativeAssetFromSiblingSystemParachain); pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { diff --git a/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs b/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs index dcaa54da83e..3cdf6de746d 100644 --- a/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs +++ b/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs @@ -26,7 +26,7 @@ use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; use parachains_common::{ impls::ToStakingPot, - xcm_config::{ConcreteNativeAssetFrom, NativeAssetFromSiblingSystemParachain}, + xcm_config::{ConcreteNativeAssetFrom, ConcreteNativeAssetFromSiblingSystemParachain}, }; use polkadot_parachain::primitives::Sibling; use xcm::latest::prelude::*; @@ -231,7 +231,7 @@ pub type Barrier = DenyThenTry< /// Cases where a remote origin is accepted as trusted Teleporter: /// - teleportation of DOT from the parent Relay Chain and sibling parachains. pub type TrustedTeleporters = - (ConcreteNativeAssetFrom, NativeAssetFromSiblingSystemParachain); + (ConcreteNativeAssetFrom, ConcreteNativeAssetFromSiblingSystemParachain); pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { diff --git a/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs b/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs index da454bf982a..288e6415394 100644 --- a/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs +++ b/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::NativeAssetFromSiblingSystemParachain; +use parachains_common::xcm_config::ConcreteNativeAssetFromSiblingSystemParachain; use polkadot_parachain::primitives::Sibling; use xcm::latest::prelude::*; use xcm_builder::{ @@ -144,7 +144,7 @@ pub type Barrier = TrailingSetTopicAsId< >, >; -pub type TrustedTeleporter = (NativeAsset, NativeAssetFromSiblingSystemParachain); +pub type TrustedTeleporter = (NativeAsset, ConcreteNativeAssetFromSiblingSystemParachain); pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { From efe55220779e2ed60b1098657f290fcf24a0bb87 Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Wed, 12 Jul 2023 11:40:06 +0000 Subject: [PATCH 06/13] ".git/.scripts/commands/fmt/fmt.sh" --- parachains/common/src/xcm_config.rs | 10 ++++++---- .../runtimes/assets/asset-hub-kusama/src/xcm_config.rs | 4 +++- .../assets/asset-hub-polkadot/src/xcm_config.rs | 4 +++- .../assets/asset-hub-westend/src/xcm_config.rs | 4 +++- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/parachains/common/src/xcm_config.rs b/parachains/common/src/xcm_config.rs index e5b233f6596..eea6efc567e 100644 --- a/parachains/common/src/xcm_config.rs +++ b/parachains/common/src/xcm_config.rs @@ -81,8 +81,8 @@ impl ContainsPair for ConcreteNativeAssetFromSiblingS #[cfg(test)] mod tests { use super::{ - ContainsPair, Here, MultiAsset, MultiLocation, ConcreteNativeAssetFromSiblingSystemParachain, - Parachain, Parent, GeneralIndex, PalletInstance, + ConcreteNativeAssetFromSiblingSystemParachain, ContainsPair, GeneralIndex, Here, + MultiAsset, MultiLocation, PalletInstance, Parachain, Parent, }; #[test] @@ -90,7 +90,10 @@ mod tests { let expected_asset: MultiAsset = (Parent, 1000000).into(); let expected_origin: MultiLocation = (Parent, Parachain(1999)).into(); - assert!(ConcreteNativeAssetFromSiblingSystemParachain::contains(&expected_asset, &expected_origin)); + assert!(ConcreteNativeAssetFromSiblingSystemParachain::contains( + &expected_asset, + &expected_origin + )); } #[test] @@ -108,7 +111,6 @@ mod tests { &expected_origin )); }); - } #[test] diff --git a/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs b/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs index aa908d80fa1..07c4a4792cf 100644 --- a/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs +++ b/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs @@ -29,7 +29,9 @@ use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; use parachains_common::{ impls::ToStakingPot, - xcm_config::{AssetFeeAsExistentialDepositMultiplier, ConcreteNativeAssetFromSiblingSystemParachain}, + xcm_config::{ + AssetFeeAsExistentialDepositMultiplier, ConcreteNativeAssetFromSiblingSystemParachain, + }, }; use polkadot_parachain::primitives::Sibling; use sp_runtime::traits::ConvertInto; diff --git a/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs b/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs index 05f41fdae82..c3d408f4b26 100644 --- a/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs +++ b/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs @@ -29,7 +29,9 @@ use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; use parachains_common::{ impls::ToStakingPot, - xcm_config::{AssetFeeAsExistentialDepositMultiplier, ConcreteNativeAssetFromSiblingSystemParachain}, + xcm_config::{ + AssetFeeAsExistentialDepositMultiplier, ConcreteNativeAssetFromSiblingSystemParachain, + }, }; use polkadot_parachain::primitives::Sibling; use sp_runtime::traits::ConvertInto; diff --git a/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs b/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs index 15a24a8f0bc..c49a1610cb8 100644 --- a/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs +++ b/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs @@ -30,7 +30,9 @@ use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; use parachains_common::{ impls::ToStakingPot, - xcm_config::{AssetFeeAsExistentialDepositMultiplier, ConcreteNativeAssetFromSiblingSystemParachain}, + xcm_config::{ + AssetFeeAsExistentialDepositMultiplier, ConcreteNativeAssetFromSiblingSystemParachain, + }, }; use polkadot_parachain::primitives::Sibling; use sp_runtime::traits::ConvertInto; From 220d76a6049e37b0f01a4796e771e47e2d02ac96 Mon Sep 17 00:00:00 2001 From: Ignacio Palacios Date: Wed, 12 Jul 2023 13:58:21 +0200 Subject: [PATCH 07/13] Update parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> --- parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs b/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs index 07c4a4792cf..9b426ae7c82 100644 --- a/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs +++ b/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs @@ -382,8 +382,8 @@ pub type AssetFeeAsExistentialDepositMultiplierFeeCharger = AssetFeeAsExistentia >; /// Cases where a remote origin is accepted as trusted Teleporter: -/// - teleportation of KSM from the parent Relay Chain and sibling parachains. -/// - teleportation of sibling parachain's assets (as ForeignCreators) +/// - teleportation of KSM from the parent Relay Chain and sibling system parachains; and +/// - teleportation of sibling parachain's assets (as ForeignCreators). pub type TrustedTeleporters = ( NativeAsset, IsForeignConcreteAsset>>, From 295e2090b7df185354071b2671a7762fe9a986bd Mon Sep 17 00:00:00 2001 From: Ignacio Palacios Date: Wed, 12 Jul 2023 13:58:28 +0200 Subject: [PATCH 08/13] Update parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> --- .../runtimes/assets/asset-hub-polkadot/src/xcm_config.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs b/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs index c3d408f4b26..77d02ef2183 100644 --- a/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs +++ b/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs @@ -389,8 +389,8 @@ pub type AssetFeeAsExistentialDepositMultiplierFeeCharger = AssetFeeAsExistentia >; /// Cases where a remote origin is accepted as trusted Teleporter: -/// - teleportation of DOT from the parent Relay Chain and sibling parachains. -/// - teleportation of sibling parachain's assets (as ForeignCreators) +/// - teleportation of DOT from the parent Relay Chain and sibling system parachains; and +/// - teleportation of sibling parachain's assets (as ForeignCreators). pub type TrustedTeleporters = ( NativeAsset, IsForeignConcreteAsset>>, From ddcf3c6c677e8eb68616293138d438a3c757819a Mon Sep 17 00:00:00 2001 From: Ignacio Palacios Date: Wed, 12 Jul 2023 13:58:44 +0200 Subject: [PATCH 09/13] Update parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> --- .../runtimes/assets/asset-hub-westend/src/xcm_config.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs b/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs index c49a1610cb8..41ee5a1cfae 100644 --- a/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs +++ b/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs @@ -417,8 +417,8 @@ pub type AssetFeeAsExistentialDepositMultiplierFeeCharger = AssetFeeAsExistentia >; /// Cases where a remote origin is accepted as trusted Teleporter: -/// - teleportation of WND from the parent Relay Chain and sibling parachains. -/// - teleportation of sibling parachain's assets (as ForeignCreators) +/// - teleportation of WND from the parent Relay Chain and sibling system parachains; and +/// - teleportation of sibling parachain's assets (as ForeignCreators). pub type TrustedTeleporters = ( NativeAsset, IsForeignConcreteAsset>>, From d7df8c1f8e251cf3c7ea9ca013d336a82bbb4439 Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Fri, 11 Aug 2023 15:40:14 +0000 Subject: [PATCH 10/13] ".git/.scripts/commands/fmt/fmt.sh" --- .../assets/asset-hub-kusama/src/lib.rs | 14 +++++++------- .../assets/asset-hub-polkadot/src/lib.rs | 17 +++++++++-------- .../assets/asset-hub-westend/src/lib.rs | 12 ++++++------ .../bridges/bridge-hub-rococo/src/lib.rs | 15 ++++++++------- .../collectives-polkadot/src/lib.rs | 17 +++++++++-------- .../collectives/collectives-westend/src/lib.rs | 2 +- .../emulated/common/src/lib.rs | 18 +++++++++--------- 7 files changed, 49 insertions(+), 46 deletions(-) diff --git a/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/lib.rs b/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/lib.rs index 89df1db21b5..b88cd417da1 100644 --- a/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/lib.rs +++ b/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/lib.rs @@ -28,13 +28,13 @@ pub use integration_tests_common::{ kusama::ED as KUSAMA_ED, PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V3, }, - lazy_static::lazy_static, test_parachain_is_trusted_teleporter, - xcm_transact_paid_execution, xcm_transact_unpaid_execution, AssetHubKusama, - AssetHubKusamaPallet, AssetHubKusamaReceiver, AssetHubKusamaSender, BridgeHubKusama, - BridgeHubKusamaPallet, BridgeHubKusamaReceiver, BridgeHubKusamaSender, BridgeHubPolkadot, - BridgeHubPolkadotPallet, BridgeHubPolkadotReceiver, BridgeHubPolkadotSender, CollectivesPolkadot, - CollectivesPolkadotPallet, CollectivesPolkadotReceiver, CollectivesPolkadotSender, - Kusama, KusamaMockNet, KusamaPallet, + lazy_static::lazy_static, + test_parachain_is_trusted_teleporter, xcm_transact_paid_execution, + xcm_transact_unpaid_execution, AssetHubKusama, AssetHubKusamaPallet, AssetHubKusamaReceiver, + AssetHubKusamaSender, BridgeHubKusama, BridgeHubKusamaPallet, BridgeHubKusamaReceiver, + BridgeHubKusamaSender, BridgeHubPolkadot, BridgeHubPolkadotPallet, BridgeHubPolkadotReceiver, + BridgeHubPolkadotSender, CollectivesPolkadot, CollectivesPolkadotPallet, + CollectivesPolkadotReceiver, CollectivesPolkadotSender, Kusama, KusamaMockNet, KusamaPallet, KusamaReceiver, KusamaSender, PenpalKusamaA, PenpalKusamaAPallet, PenpalKusamaAReceiver, PenpalKusamaASender, PenpalKusamaB, PenpalKusamaBPallet, PenpalKusamaBReceiver, PenpalKusamaBSender, PenpalPolkadotA, PenpalPolkadotAReceiver, PenpalPolkadotASender, Polkadot, diff --git a/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/lib.rs b/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/lib.rs index 4cf98f50a2b..a24cb3e5347 100644 --- a/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/lib.rs +++ b/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/lib.rs @@ -29,14 +29,15 @@ pub use integration_tests_common::{ polkadot::ED as POLKADOT_ED, PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V3, }, - lazy_static::lazy_static, test_parachain_is_trusted_teleporter, - xcm_transact_paid_execution, xcm_transact_unpaid_execution, AssetHubPolkadot, - AssetHubPolkadotPallet, AssetHubPolkadotReceiver, AssetHubPolkadotSender, BridgeHubPolkadot, - BridgeHubPolkadotPallet, BridgeHubPolkadotReceiver, BridgeHubPolkadotSender, CollectivesPolkadot, - CollectivesPolkadotPallet, CollectivesPolkadotReceiver, CollectivesPolkadotSender, PenpalPolkadotA, - PenpalPolkadotAPallet, PenpalPolkadotAReceiver, PenpalPolkadotASender, PenpalPolkadotB, - PenpalPolkadotBPallet, PenpalPolkadotBReceiver, PenpalPolkadotBSender, Polkadot, - PolkadotMockNet, PolkadotPallet, PolkadotReceiver, PolkadotSender, + lazy_static::lazy_static, + test_parachain_is_trusted_teleporter, xcm_transact_paid_execution, + xcm_transact_unpaid_execution, AssetHubPolkadot, AssetHubPolkadotPallet, + AssetHubPolkadotReceiver, AssetHubPolkadotSender, BridgeHubPolkadot, BridgeHubPolkadotPallet, + BridgeHubPolkadotReceiver, BridgeHubPolkadotSender, CollectivesPolkadot, + CollectivesPolkadotPallet, CollectivesPolkadotReceiver, CollectivesPolkadotSender, + PenpalPolkadotA, PenpalPolkadotAPallet, PenpalPolkadotAReceiver, PenpalPolkadotASender, + PenpalPolkadotB, PenpalPolkadotBPallet, PenpalPolkadotBReceiver, PenpalPolkadotBSender, + Polkadot, PolkadotMockNet, PolkadotPallet, PolkadotReceiver, PolkadotSender, }; pub use parachains_common::{AccountId, Balance}; pub use polkadot_core_primitives::InboundDownwardMessage; diff --git a/parachains/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs b/parachains/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs index 2d460c4e630..9523b193ee6 100644 --- a/parachains/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs +++ b/parachains/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs @@ -30,12 +30,12 @@ pub use integration_tests_common::{ westend::ED as WESTEND_ED, PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V3, }, - lazy_static::lazy_static, test_parachain_is_trusted_teleporter, - xcm_transact_paid_execution, xcm_transact_unpaid_execution, AssetHubWestend, - AssetHubWestendPallet, AssetHubWestendReceiver, AssetHubWestendSender, CollectivesPolkadot, - CollectivesPolkadotPallet, CollectivesPolkadotReceiver, CollectivesPolkadotSender, - CollectivesWestend, CollectivesWestendPallet, CollectivesWestendReceiver, CollectivesWestendSender, - PenpalWestendA, + lazy_static::lazy_static, + test_parachain_is_trusted_teleporter, xcm_transact_paid_execution, + xcm_transact_unpaid_execution, AssetHubWestend, AssetHubWestendPallet, AssetHubWestendReceiver, + AssetHubWestendSender, CollectivesPolkadot, CollectivesPolkadotPallet, + CollectivesPolkadotReceiver, CollectivesPolkadotSender, CollectivesWestend, + CollectivesWestendPallet, CollectivesWestendReceiver, CollectivesWestendSender, PenpalWestendA, PenpalWestendAPallet, PenpalWestendAReceiver, PenpalWestendASender, Westend, WestendMockNet, WestendPallet, WestendReceiver, WestendSender, }; diff --git a/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/lib.rs b/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/lib.rs index 115440c1fe7..68098b7fe9e 100644 --- a/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/lib.rs +++ b/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/lib.rs @@ -31,13 +31,14 @@ pub use integration_tests_common::{ kusama::ED as ROCOCO_ED, PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V3, }, - lazy_static::lazy_static, test_parachain_is_trusted_teleporter, - xcm_transact_paid_execution, xcm_transact_unpaid_execution, AssetHubRococo, - AssetHubRococoPallet, AssetHubRococoReceiver, AssetHubRococoSender, AssetHubWococo, - AssetHubWococoPallet, AssetHubWococoReceiver, AssetHubWococoSender, BridgeHubRococo, - BridgeHubRococoPallet, BridgeHubRococoReceiver, BridgeHubRococoSender, BridgeHubWococo, - BridgeHubWococoPallet, BridgeHubWococoReceiver, BridgeHubWococoSender, CollectivesPolkadot, - CollectivesPolkadotPallet, CollectivesPolkadotReceiver, CollectivesPolkadotSender, PenpalRococoA, PenpalRococoAPallet, + lazy_static::lazy_static, + test_parachain_is_trusted_teleporter, xcm_transact_paid_execution, + xcm_transact_unpaid_execution, AssetHubRococo, AssetHubRococoPallet, AssetHubRococoReceiver, + AssetHubRococoSender, AssetHubWococo, AssetHubWococoPallet, AssetHubWococoReceiver, + AssetHubWococoSender, BridgeHubRococo, BridgeHubRococoPallet, BridgeHubRococoReceiver, + BridgeHubRococoSender, BridgeHubWococo, BridgeHubWococoPallet, BridgeHubWococoReceiver, + BridgeHubWococoSender, CollectivesPolkadot, CollectivesPolkadotPallet, + CollectivesPolkadotReceiver, CollectivesPolkadotSender, PenpalRococoA, PenpalRococoAPallet, PenpalRococoAReceiver, PenpalRococoASender, Rococo, RococoMockNet, RococoPallet, RococoReceiver, RococoSender, Wococo, WococoMockNet, WococoPallet, WococoReceiver, WococoSender, diff --git a/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/lib.rs b/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/lib.rs index 4a4822a0e4c..5a6e231d2a6 100644 --- a/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/lib.rs +++ b/parachains/integration-tests/emulated/collectives/collectives-polkadot/src/lib.rs @@ -30,14 +30,15 @@ pub use integration_tests_common::{ polkadot::ED as POLKADOT_ED, PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V3, }, - lazy_static::lazy_static, test_parachain_is_trusted_teleporter, - xcm_transact_paid_execution, xcm_transact_unpaid_execution, AssetHubPolkadot, - AssetHubPolkadotPallet, AssetHubPolkadotReceiver, AssetHubPolkadotSender, BridgeHubPolkadot, - BridgeHubPolkadotPallet, BridgeHubPolkadotReceiver, BridgeHubPolkadotSender, CollectivesPolkadot, - CollectivesPolkadotPallet, CollectivesPolkadotReceiver, CollectivesPolkadotSender, PenpalPolkadotA, - PenpalPolkadotAPallet, PenpalPolkadotAReceiver, PenpalPolkadotASender, PenpalPolkadotB, - PenpalPolkadotBPallet, PenpalPolkadotBReceiver, PenpalPolkadotBSender, Polkadot, - PolkadotMockNet, PolkadotPallet, PolkadotReceiver, PolkadotSender, + lazy_static::lazy_static, + test_parachain_is_trusted_teleporter, xcm_transact_paid_execution, + xcm_transact_unpaid_execution, AssetHubPolkadot, AssetHubPolkadotPallet, + AssetHubPolkadotReceiver, AssetHubPolkadotSender, BridgeHubPolkadot, BridgeHubPolkadotPallet, + BridgeHubPolkadotReceiver, BridgeHubPolkadotSender, CollectivesPolkadot, + CollectivesPolkadotPallet, CollectivesPolkadotReceiver, CollectivesPolkadotSender, + PenpalPolkadotA, PenpalPolkadotAPallet, PenpalPolkadotAReceiver, PenpalPolkadotASender, + PenpalPolkadotB, PenpalPolkadotBPallet, PenpalPolkadotBReceiver, PenpalPolkadotBSender, + Polkadot, PolkadotMockNet, PolkadotPallet, PolkadotReceiver, PolkadotSender, }; pub use parachains_common::{AccountId, Balance}; pub use polkadot_core_primitives::InboundDownwardMessage; diff --git a/parachains/integration-tests/emulated/collectives/collectives-westend/src/lib.rs b/parachains/integration-tests/emulated/collectives/collectives-westend/src/lib.rs index ba02772b353..ec35c324b34 100644 --- a/parachains/integration-tests/emulated/collectives/collectives-westend/src/lib.rs +++ b/parachains/integration-tests/emulated/collectives/collectives-westend/src/lib.rs @@ -23,7 +23,7 @@ pub use integration_tests_common::{ CollectivesWestendPallet, CollectivesWestendSender, }; pub use xcm::prelude::*; -pub use xcm_emulator::{assert_expected_events, bx, Parachain, TestExt, Chain}; +pub use xcm_emulator::{assert_expected_events, bx, Chain, Parachain, TestExt}; #[cfg(test)] mod tests; diff --git a/parachains/integration-tests/emulated/common/src/lib.rs b/parachains/integration-tests/emulated/common/src/lib.rs index 9b3b6518988..ca63efa7290 100644 --- a/parachains/integration-tests/emulated/common/src/lib.rs +++ b/parachains/integration-tests/emulated/common/src/lib.rs @@ -3,9 +3,6 @@ pub mod constants; pub mod impls; pub mod macros; -pub use pallet_balances; -pub use pallet_xcm; -pub use cumulus_pallet_xcmp_queue; pub use codec::Encode; pub use constants::{ accounts::{ALICE, BOB}, @@ -13,21 +10,18 @@ pub use constants::{ bridge_hub_polkadot, bridge_hub_rococo, collectives, kusama, penpal, polkadot, rococo, westend, PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, }; +pub use cumulus_pallet_xcmp_queue; use frame_support::{ assert_ok, instances::Instance1, parameter_types, sp_tracing, traits::fungibles::Inspect, }; pub use impls::{RococoWococoMessageHandler, WococoRococoMessageHandler}; +pub use pallet_balances; +pub use pallet_xcm; pub use parachains_common::{AccountId, Balance}; pub use paste; use polkadot_parachain::primitives::HrmpChannelId; pub use polkadot_runtime_parachains::inclusion::{AggregateMessageOrigin, UmpQueueId}; pub use sp_core::{sr25519, storage::Storage, Get}; -pub use xcm_emulator::{ - assert_expected_events, bx, decl_test_bridges, decl_test_networks, decl_test_parachains, - decl_test_relay_chains, decl_test_sender_receiver_accounts_parameter_types, - helpers::weight_within_threshold, BridgeMessageHandler, Chain, DefaultMessageProcessor, ParaId, - Parachain, RelayChain, TestExt, -}; pub use xcm::{ prelude::{ AccountId32, All, BuyExecution, DepositAsset, MultiAsset, MultiAssets, MultiLocation, @@ -37,6 +31,12 @@ pub use xcm::{ v3::Error, DoubleEncoded, }; +pub use xcm_emulator::{ + assert_expected_events, bx, decl_test_bridges, decl_test_networks, decl_test_parachains, + decl_test_relay_chains, decl_test_sender_receiver_accounts_parameter_types, + helpers::weight_within_threshold, BridgeMessageHandler, Chain, DefaultMessageProcessor, ParaId, + Parachain, RelayChain, TestExt, +}; decl_test_relay_chains! { #[api_version(5)] From 1cd66596b6a2c1ffb7a4bfba0bcec8a2df46d381 Mon Sep 17 00:00:00 2001 From: NachoPal Date: Fri, 11 Aug 2023 18:02:20 +0200 Subject: [PATCH 11/13] leftover fix --- .../emulated/assets/asset-hub-rococo/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parachains/integration-tests/emulated/assets/asset-hub-rococo/src/lib.rs b/parachains/integration-tests/emulated/assets/asset-hub-rococo/src/lib.rs index f89d9ab4fb7..03d67498cec 100644 --- a/parachains/integration-tests/emulated/assets/asset-hub-rococo/src/lib.rs +++ b/parachains/integration-tests/emulated/assets/asset-hub-rococo/src/lib.rs @@ -23,7 +23,7 @@ pub use integration_tests_common::{ BridgeHubRococoReceiver, }; pub use xcm::prelude::*; -pub use xcm_emulator::{assert_expected_events, bx, Parachain, TestExt}; +pub use xcm_emulator::{assert_expected_events, bx, Chain, Parachain, TestExt}; #[cfg(test)] mod tests; From 72314996603a28ac5c4efa0c62c5ab954ca7bc9f Mon Sep 17 00:00:00 2001 From: joe petrowski <25483142+joepetrowski@users.noreply.github.com> Date: Mon, 14 Aug 2023 14:35:39 +0200 Subject: [PATCH 12/13] combine NativeAsset into ConcreteNativeAssetFromSystem (#3002) --- parachains/common/src/xcm_config.rs | 35 ++++++++----------- .../assets/asset-hub-kusama/src/xcm_config.rs | 11 +++--- .../asset-hub-polkadot/src/xcm_config.rs | 11 +++--- .../asset-hub-westend/src/xcm_config.rs | 9 ++--- .../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 | 4 +-- 9 files changed, 36 insertions(+), 66 deletions(-) diff --git a/parachains/common/src/xcm_config.rs b/parachains/common/src/xcm_config.rs index eea6efc567e..e8227d3f5bf 100644 --- a/parachains/common/src/xcm_config.rs +++ b/parachains/common/src/xcm_config.rs @@ -65,24 +65,28 @@ impl> ContainsPair } /// Accepts an asset if it is a native asset from a System Parachain. -pub struct ConcreteNativeAssetFromSiblingSystemParachain; -impl ContainsPair for ConcreteNativeAssetFromSiblingSystemParachain { +pub struct ConcreteNativeAssetFromSystem; +impl ContainsPair for ConcreteNativeAssetFromSystem { fn contains(asset: &MultiAsset, origin: &MultiLocation) -> bool { - log::trace!(target: "xcm::contains", "ConcreteNativeAssetFromSiblingSystemParachain asset: {:?}, origin: {:?}", asset, origin); - let is_system_para = match origin { + 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, }; - let parent = MultiLocation::parent(); - matches!(asset.id, Concrete(id) if id == parent && is_system_para) + matches!(asset.id, Concrete(id) if id == parent && is_system) } } #[cfg(test)] mod tests { use super::{ - ConcreteNativeAssetFromSiblingSystemParachain, ContainsPair, GeneralIndex, Here, - MultiAsset, MultiLocation, PalletInstance, Parachain, Parent, + ConcreteNativeAssetFromSystem, ContainsPair, GeneralIndex, Here, MultiAsset, MultiLocation, + PalletInstance, Parachain, Parent, }; #[test] @@ -90,10 +94,7 @@ mod tests { let expected_asset: MultiAsset = (Parent, 1000000).into(); let expected_origin: MultiLocation = (Parent, Parachain(1999)).into(); - assert!(ConcreteNativeAssetFromSiblingSystemParachain::contains( - &expected_asset, - &expected_origin - )); + assert!(ConcreteNativeAssetFromSystem::contains(&expected_asset, &expected_origin)); } #[test] @@ -106,10 +107,7 @@ mod tests { let expected_origin: MultiLocation = (Parent, Parachain(1000)).into(); unexpected_assets.iter().for_each(|asset| { - assert!(!ConcreteNativeAssetFromSiblingSystemParachain::contains( - asset, - &expected_origin - )); + assert!(!ConcreteNativeAssetFromSystem::contains(asset, &expected_origin)); }); } @@ -118,9 +116,6 @@ mod tests { let expected_asset: MultiAsset = (Parent, 1000000).into(); let unexpected_origin: MultiLocation = (Parent, Parachain(2000)).into(); - assert!(!ConcreteNativeAssetFromSiblingSystemParachain::contains( - &expected_asset, - &unexpected_origin - )); + assert!(!ConcreteNativeAssetFromSystem::contains(&expected_asset, &unexpected_origin)); } } diff --git a/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs b/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs index 9b426ae7c82..ed2c4c85c4d 100644 --- a/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs +++ b/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs @@ -29,9 +29,7 @@ use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; use parachains_common::{ impls::ToStakingPot, - xcm_config::{ - AssetFeeAsExistentialDepositMultiplier, ConcreteNativeAssetFromSiblingSystemParachain, - }, + xcm_config::{AssetFeeAsExistentialDepositMultiplier, ConcreteNativeAssetFromSystem}, }; use polkadot_parachain::primitives::Sibling; use sp_runtime::traits::ConvertInto; @@ -40,8 +38,8 @@ use xcm_builder::{ AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, CurrencyAdapter, DenyReserveTransferToRelayChain, DenyThenTry, DescribeAllTerminal, DescribeFamily, - EnsureXcmOrigin, FungiblesAdapter, HashedDescription, IsConcrete, LocalMint, NativeAsset, - 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, @@ -385,9 +383,8 @@ pub type AssetFeeAsExistentialDepositMultiplierFeeCharger = AssetFeeAsExistentia /// - teleportation of KSM from the parent Relay Chain and sibling system parachains; and /// - teleportation of sibling parachain's assets (as ForeignCreators). pub type TrustedTeleporters = ( - NativeAsset, IsForeignConcreteAsset>>, - ConcreteNativeAssetFromSiblingSystemParachain, + ConcreteNativeAssetFromSystem, ); pub struct XcmConfig; diff --git a/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs b/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs index be7ebc58758..08370140c6b 100644 --- a/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs +++ b/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs @@ -29,9 +29,7 @@ use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; use parachains_common::{ impls::ToStakingPot, - xcm_config::{ - AssetFeeAsExistentialDepositMultiplier, ConcreteNativeAssetFromSiblingSystemParachain, - }, + xcm_config::{AssetFeeAsExistentialDepositMultiplier, ConcreteNativeAssetFromSystem}, }; use polkadot_parachain::primitives::Sibling; use sp_runtime::traits::ConvertInto; @@ -40,8 +38,8 @@ use xcm_builder::{ AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, CurrencyAdapter, DenyReserveTransferToRelayChain, DenyThenTry, DescribeFamily, DescribePalletTerminal, - EnsureXcmOrigin, FungiblesAdapter, HashedDescription, IsConcrete, LocalMint, NativeAsset, - 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, @@ -396,9 +394,8 @@ pub type AssetFeeAsExistentialDepositMultiplierFeeCharger = AssetFeeAsExistentia /// - teleportation of DOT from the parent Relay Chain and sibling system parachains; and /// - teleportation of sibling parachain's assets (as ForeignCreators). pub type TrustedTeleporters = ( - NativeAsset, IsForeignConcreteAsset>>, - ConcreteNativeAssetFromSiblingSystemParachain, + ConcreteNativeAssetFromSystem, ); pub struct XcmConfig; diff --git a/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs b/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs index 9e7e6184753..65e3ea2c291 100644 --- a/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs +++ b/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs @@ -33,9 +33,7 @@ use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; use parachains_common::{ impls::ToStakingPot, - xcm_config::{ - AssetFeeAsExistentialDepositMultiplier, ConcreteNativeAssetFromSiblingSystemParachain, - }, + xcm_config::{AssetFeeAsExistentialDepositMultiplier, ConcreteNativeAssetFromSystem}, }; use polkadot_parachain::primitives::Sibling; use sp_runtime::traits::ConvertInto; @@ -44,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, @@ -452,9 +450,8 @@ pub type AssetFeeAsExistentialDepositMultiplierFeeCharger = AssetFeeAsExistentia /// - teleportation of WND from the parent Relay Chain and sibling system parachains; and /// - teleportation of sibling parachain's assets (as ForeignCreators). pub type TrustedTeleporters = ( - NativeAsset, IsForeignConcreteAsset>>, - ConcreteNativeAssetFromSiblingSystemParachain, + ConcreteNativeAssetFromSystem, ); pub struct XcmConfig; diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs index 5d333407cf3..71af1f8f6f4 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs @@ -24,10 +24,7 @@ use frame_support::{ }; use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; -use parachains_common::{ - impls::ToStakingPot, - xcm_config::{ConcreteNativeAssetFrom, ConcreteNativeAssetFromSiblingSystemParachain}, -}; +use parachains_common::{impls::ToStakingPot, xcm_config::ConcreteNativeAssetFromSystem}; use polkadot_parachain::primitives::Sibling; use xcm::latest::prelude::*; use xcm_builder::{ @@ -182,8 +179,7 @@ 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 = - (ConcreteNativeAssetFrom, ConcreteNativeAssetFromSiblingSystemParachain); +pub type TrustedTeleporters = ConcreteNativeAssetFromSystem; pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs index fb588f4cba0..5c954bdce69 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs @@ -24,10 +24,7 @@ use frame_support::{ }; use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; -use parachains_common::{ - impls::ToStakingPot, - xcm_config::{ConcreteNativeAssetFrom, ConcreteNativeAssetFromSiblingSystemParachain}, -}; +use parachains_common::{impls::ToStakingPot, xcm_config::ConcreteNativeAssetFromSystem}; use polkadot_parachain::primitives::Sibling; use xcm::latest::prelude::*; use xcm_builder::{ @@ -185,8 +182,7 @@ 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 = - (ConcreteNativeAssetFrom, ConcreteNativeAssetFromSiblingSystemParachain); +pub type TrustedTeleporters = ConcreteNativeAssetFromSystem; pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs index 38f3c4b5066..d3bab5bd520 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs @@ -30,10 +30,7 @@ use frame_support::{ }; use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; -use parachains_common::{ - impls::ToStakingPot, - xcm_config::{ConcreteNativeAssetFrom, ConcreteNativeAssetFromSiblingSystemParachain}, -}; +use parachains_common::{impls::ToStakingPot, xcm_config::ConcreteNativeAssetFromSystem}; use polkadot_parachain::primitives::Sibling; use sp_core::Get; use xcm::latest::prelude::*; @@ -229,8 +226,7 @@ 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 = - (ConcreteNativeAssetFrom, ConcreteNativeAssetFromSiblingSystemParachain); +pub type TrustedTeleporters = ConcreteNativeAssetFromSystem; pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { diff --git a/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs b/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs index 553c8080d5f..c5151a0fec8 100644 --- a/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs +++ b/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs @@ -24,10 +24,7 @@ use frame_support::{ }; use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; -use parachains_common::{ - impls::ToStakingPot, - xcm_config::{ConcreteNativeAssetFrom, ConcreteNativeAssetFromSiblingSystemParachain}, -}; +use parachains_common::{impls::ToStakingPot, xcm_config::ConcreteNativeAssetFromSystem}; use polkadot_parachain::primitives::Sibling; use xcm::latest::prelude::*; use xcm_builder::{ @@ -232,8 +229,7 @@ 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 = - (ConcreteNativeAssetFrom, ConcreteNativeAssetFromSiblingSystemParachain); +pub type TrustedTeleporters = ConcreteNativeAssetFromSystem; pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { diff --git a/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs b/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs index 288e6415394..2b242a762e8 100644 --- a/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs +++ b/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::ConcreteNativeAssetFromSiblingSystemParachain; +use parachains_common::xcm_config::ConcreteNativeAssetFromSystem; use polkadot_parachain::primitives::Sibling; use xcm::latest::prelude::*; use xcm_builder::{ @@ -144,7 +144,7 @@ pub type Barrier = TrailingSetTopicAsId< >, >; -pub type TrustedTeleporter = (NativeAsset, ConcreteNativeAssetFromSiblingSystemParachain); +pub type TrustedTeleporter = ConcreteNativeAssetFromSystem; pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { From 9641dec703905af050eda7b37502ed5bcc5805fa Mon Sep 17 00:00:00 2001 From: joepetrowski Date: Mon, 14 Aug 2023 14:46:08 +0200 Subject: [PATCH 13/13] fix docs --- parachains/common/src/xcm_config.rs | 2 +- .../runtimes/assets/asset-hub-kusama/src/xcm_config.rs | 7 ++++--- .../runtimes/assets/asset-hub-polkadot/src/xcm_config.rs | 7 ++++--- .../runtimes/assets/asset-hub-westend/src/xcm_config.rs | 7 ++++--- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/parachains/common/src/xcm_config.rs b/parachains/common/src/xcm_config.rs index e8227d3f5bf..3861db5f5af 100644 --- a/parachains/common/src/xcm_config.rs +++ b/parachains/common/src/xcm_config.rs @@ -64,7 +64,7 @@ impl> ContainsPair } } -/// Accepts an asset if it is a native asset from a System Parachain. +/// 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 { diff --git a/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs b/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs index ed2c4c85c4d..aa8a1ea4074 100644 --- a/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs +++ b/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs @@ -379,12 +379,13 @@ pub type AssetFeeAsExistentialDepositMultiplierFeeCharger = AssetFeeAsExistentia TrustBackedAssetsInstance, >; -/// Cases where a remote origin is accepted as trusted Teleporter: +/// 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 parachain's assets (as ForeignCreators). +/// - teleportation of sibling parachains' assets (as `ForeignCreators`). pub type TrustedTeleporters = ( - IsForeignConcreteAsset>>, ConcreteNativeAssetFromSystem, + IsForeignConcreteAsset>>, ); pub struct XcmConfig; diff --git a/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs b/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs index 08370140c6b..fd81b8f1d5a 100644 --- a/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs +++ b/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs @@ -390,12 +390,13 @@ pub type AssetFeeAsExistentialDepositMultiplierFeeCharger = AssetFeeAsExistentia TrustBackedAssetsInstance, >; -/// Cases where a remote origin is accepted as trusted Teleporter: +/// 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 parachain's assets (as ForeignCreators). +/// - teleportation of sibling parachains' assets (as `ForeignCreators`). pub type TrustedTeleporters = ( - IsForeignConcreteAsset>>, ConcreteNativeAssetFromSystem, + IsForeignConcreteAsset>>, ); pub struct XcmConfig; diff --git a/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs b/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs index 65e3ea2c291..1e235962127 100644 --- a/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs +++ b/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs @@ -446,12 +446,13 @@ pub type AssetFeeAsExistentialDepositMultiplierFeeCharger = AssetFeeAsExistentia TrustBackedAssetsInstance, >; -/// Cases where a remote origin is accepted as trusted Teleporter: +/// 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 parachain's assets (as ForeignCreators). +/// - teleportation of sibling parachains' assets (as `ForeignCreators`). pub type TrustedTeleporters = ( - IsForeignConcreteAsset>>, ConcreteNativeAssetFromSystem, + IsForeignConcreteAsset>>, ); pub struct XcmConfig;