mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 21:31:02 +00:00
pallet-xcm: enhance reserve_transfer_assets to support remote reserves (#1672)
## Motivation `pallet-xcm` is the main user-facing interface for XCM functionality, including assets manipulation functions like `teleportAssets()` and `reserve_transfer_assets()` calls. While `teleportAsset()` works both ways, `reserve_transfer_assets()` works only for sending reserve-based assets to a remote destination and beneficiary when the reserve is the _local chain_. ## Solution This PR enhances `pallet_xcm::(limited_)reserve_withdraw_assets` to support transfers when reserves are other chains. This will allow complete, **bi-directional** reserve-based asset transfers user stories using `pallet-xcm`. Enables following scenarios: - transferring assets with local reserve (was previously supported iff asset used as fee also had local reserve - now it works in all cases), - transferring assets with reserve on destination, - transferring assets with reserve on remote/third-party chain (iff assets and fees have same remote reserve), - transferring assets with reserve different than the reserve of the asset to be used as fees - meaning can be used to transfer random asset with local/dest reserve while using DOT for fees on all involved chains, even if DOT local/dest reserve doesn't match asset reserve, - transferring assets with any type of local/dest reserve while using fees which can be teleported between involved chains. All of the above is done by pallet inner logic without the user having to specify which scenario/reserves/teleports/etc. The correct scenario and corresponding XCM programs are identified, and respectively, built automatically based on runtime configuration of trusted teleporters and trusted reserves. #### Current limitations: - while `fees` and "non-fee" `assets` CAN have different reserves (or fees CAN be teleported), the remaining "non-fee" `assets` CANNOT, among themselves, have different reserve locations (this is also implicitly enforced by `MAX_ASSETS_FOR_TRANSFER=2`, but this can be safely increased in the future). - `fees` and "non-fee" `assets` CANNOT have **different remote** reserves (this could also be supported in the future, but adds even more complexity while possibly not being worth it - we'll see what the future holds). Fixes https://github.com/paritytech/polkadot-sdk/issues/1584 Fixes https://github.com/paritytech/polkadot-sdk/issues/2055 --------- Co-authored-by: Francisco Aguirre <franciscoaguirreperez@gmail.com> Co-authored-by: Branislav Kontur <bkontur@gmail.com>
This commit is contained in:
+3
-3
@@ -21,7 +21,7 @@ use frame_support::traits::OnInitialize;
|
||||
// Cumulus
|
||||
use emulated_integration_tests_common::{
|
||||
impl_accounts_helpers_for_parachain, impl_assert_events_helpers_for_parachain,
|
||||
impl_assets_helpers_for_system_parachain, xcm_emulator::decl_test_parachains,
|
||||
impl_assets_helpers_for_parachain, xcm_emulator::decl_test_parachains,
|
||||
};
|
||||
use rococo_emulated_chain::Rococo;
|
||||
|
||||
@@ -51,5 +51,5 @@ decl_test_parachains! {
|
||||
|
||||
// AssetHubRococo implementation
|
||||
impl_accounts_helpers_for_parachain!(AssetHubRococo);
|
||||
impl_assert_events_helpers_for_parachain!(AssetHubRococo);
|
||||
impl_assets_helpers_for_system_parachain!(AssetHubRococo, Rococo);
|
||||
impl_assert_events_helpers_for_parachain!(AssetHubRococo, false);
|
||||
impl_assets_helpers_for_parachain!(AssetHubRococo, Rococo);
|
||||
|
||||
+3
-3
@@ -21,7 +21,7 @@ use frame_support::traits::OnInitialize;
|
||||
// Cumulus
|
||||
use emulated_integration_tests_common::{
|
||||
impl_accounts_helpers_for_parachain, impl_assert_events_helpers_for_parachain,
|
||||
impl_assets_helpers_for_system_parachain, xcm_emulator::decl_test_parachains,
|
||||
impl_assets_helpers_for_parachain, xcm_emulator::decl_test_parachains,
|
||||
};
|
||||
use westend_emulated_chain::Westend;
|
||||
|
||||
@@ -51,5 +51,5 @@ decl_test_parachains! {
|
||||
|
||||
// AssetHubWestend implementation
|
||||
impl_accounts_helpers_for_parachain!(AssetHubWestend);
|
||||
impl_assert_events_helpers_for_parachain!(AssetHubWestend);
|
||||
impl_assets_helpers_for_system_parachain!(AssetHubWestend, Westend);
|
||||
impl_assert_events_helpers_for_parachain!(AssetHubWestend, false);
|
||||
impl_assets_helpers_for_parachain!(AssetHubWestend, Westend);
|
||||
|
||||
+3
-3
@@ -19,7 +19,7 @@ use frame_support::traits::OnInitialize;
|
||||
// Cumulus
|
||||
use emulated_integration_tests_common::{
|
||||
impl_accounts_helpers_for_parachain, impl_assert_events_helpers_for_parachain,
|
||||
impl_assets_helpers_for_system_parachain, xcm_emulator::decl_test_parachains,
|
||||
impl_assets_helpers_for_parachain, xcm_emulator::decl_test_parachains,
|
||||
};
|
||||
use wococo_emulated_chain::Wococo;
|
||||
|
||||
@@ -49,5 +49,5 @@ decl_test_parachains! {
|
||||
|
||||
// AssetHubWococo implementation
|
||||
impl_accounts_helpers_for_parachain!(AssetHubWococo);
|
||||
impl_assert_events_helpers_for_parachain!(AssetHubWococo);
|
||||
impl_assets_helpers_for_system_parachain!(AssetHubWococo, Wococo);
|
||||
impl_assert_events_helpers_for_parachain!(AssetHubWococo, false);
|
||||
impl_assets_helpers_for_parachain!(AssetHubWococo, Wococo);
|
||||
|
||||
+1
-1
@@ -46,4 +46,4 @@ decl_test_parachains! {
|
||||
|
||||
// BridgeHubRococo implementation
|
||||
impl_accounts_helpers_for_parachain!(BridgeHubRococo);
|
||||
impl_assert_events_helpers_for_parachain!(BridgeHubRococo);
|
||||
impl_assert_events_helpers_for_parachain!(BridgeHubRococo, false);
|
||||
|
||||
+1
-1
@@ -46,4 +46,4 @@ decl_test_parachains! {
|
||||
|
||||
// BridgeHubWestend implementation
|
||||
impl_accounts_helpers_for_parachain!(BridgeHubWestend);
|
||||
impl_assert_events_helpers_for_parachain!(BridgeHubWestend);
|
||||
impl_assert_events_helpers_for_parachain!(BridgeHubWestend, false);
|
||||
|
||||
+1
-1
@@ -44,4 +44,4 @@ decl_test_parachains! {
|
||||
|
||||
// BridgeHubWococo implementation
|
||||
impl_accounts_helpers_for_parachain!(BridgeHubWococo);
|
||||
impl_assert_events_helpers_for_parachain!(BridgeHubWococo);
|
||||
impl_assert_events_helpers_for_parachain!(BridgeHubWococo, false);
|
||||
|
||||
+1
@@ -22,3 +22,4 @@ parachains-common = { path = "../../../../../../../parachains/common" }
|
||||
cumulus-primitives-core = { path = "../../../../../../../primitives/core", default-features = false }
|
||||
emulated-integration-tests-common = { path = "../../../../common", default-features = false }
|
||||
penpal-runtime = { path = "../../../../../../runtimes/testing/penpal" }
|
||||
rococo-emulated-chain = { path = "../../../relays/rococo" }
|
||||
|
||||
+9
-3
@@ -21,8 +21,10 @@ use frame_support::traits::OnInitialize;
|
||||
|
||||
// Cumulus
|
||||
use emulated_integration_tests_common::{
|
||||
impl_assert_events_helpers_for_parachain, xcm_emulator::decl_test_parachains,
|
||||
impl_accounts_helpers_for_parachain, impl_assert_events_helpers_for_parachain,
|
||||
impl_assets_helpers_for_parachain, xcm_emulator::decl_test_parachains,
|
||||
};
|
||||
use rococo_emulated_chain::Rococo;
|
||||
|
||||
// Penpal Parachain declaration
|
||||
decl_test_parachains! {
|
||||
@@ -40,6 +42,7 @@ decl_test_parachains! {
|
||||
pallets = {
|
||||
PolkadotXcm: penpal_runtime::PolkadotXcm,
|
||||
Assets: penpal_runtime::Assets,
|
||||
Balances: penpal_runtime::Balances,
|
||||
}
|
||||
},
|
||||
pub struct PenpalB {
|
||||
@@ -56,10 +59,13 @@ decl_test_parachains! {
|
||||
pallets = {
|
||||
PolkadotXcm: penpal_runtime::PolkadotXcm,
|
||||
Assets: penpal_runtime::Assets,
|
||||
Balances: penpal_runtime::Balances,
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
// Penpal implementation
|
||||
impl_assert_events_helpers_for_parachain!(PenpalA);
|
||||
impl_assert_events_helpers_for_parachain!(PenpalB);
|
||||
impl_accounts_helpers_for_parachain!(PenpalA);
|
||||
impl_assets_helpers_for_parachain!(PenpalA, Rococo);
|
||||
impl_assert_events_helpers_for_parachain!(PenpalA, true);
|
||||
impl_assert_events_helpers_for_parachain!(PenpalB, true);
|
||||
|
||||
Reference in New Issue
Block a user