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>
parent
29654a4d
Pipeline
#413006
passed with warnings
with stages
in
1 hour, 32 minutes, and 2 seconds
Stage:
Stage:
Stage:
Stage:
Stage:
Stage:
Showing
- Cargo.lock 5 additions, 0 deletionsCargo.lock
- cumulus/parachain-template/runtime/src/xcm_config.rs 0 additions, 7 deletionscumulus/parachain-template/runtime/src/xcm_config.rs
- cumulus/parachains/integration-tests/emulated/chains/parachains/assets/asset-hub-rococo/src/lib.rs 3 additions, 3 deletions...ated/chains/parachains/assets/asset-hub-rococo/src/lib.rs
- cumulus/parachains/integration-tests/emulated/chains/parachains/assets/asset-hub-westend/src/lib.rs 3 additions, 3 deletions...ted/chains/parachains/assets/asset-hub-westend/src/lib.rs
- cumulus/parachains/integration-tests/emulated/chains/parachains/assets/asset-hub-wococo/src/lib.rs 3 additions, 3 deletions...ated/chains/parachains/assets/asset-hub-wococo/src/lib.rs
- cumulus/parachains/integration-tests/emulated/chains/parachains/bridges/bridge-hub-rococo/src/lib.rs 1 addition, 1 deletion...ed/chains/parachains/bridges/bridge-hub-rococo/src/lib.rs
- cumulus/parachains/integration-tests/emulated/chains/parachains/bridges/bridge-hub-westend/src/lib.rs 1 addition, 1 deletion...d/chains/parachains/bridges/bridge-hub-westend/src/lib.rs
- cumulus/parachains/integration-tests/emulated/chains/parachains/bridges/bridge-hub-wococo/src/lib.rs 1 addition, 1 deletion...ed/chains/parachains/bridges/bridge-hub-wococo/src/lib.rs
- cumulus/parachains/integration-tests/emulated/chains/parachains/testing/penpal/Cargo.toml 1 addition, 0 deletions...ests/emulated/chains/parachains/testing/penpal/Cargo.toml
- cumulus/parachains/integration-tests/emulated/chains/parachains/testing/penpal/src/lib.rs 9 additions, 3 deletions...ests/emulated/chains/parachains/testing/penpal/src/lib.rs
- cumulus/parachains/integration-tests/emulated/chains/relays/westend/src/lib.rs 1 addition, 1 deletion...tegration-tests/emulated/chains/relays/westend/src/lib.rs
- cumulus/parachains/integration-tests/emulated/common/src/impls.rs 7 additions, 7 deletions...parachains/integration-tests/emulated/common/src/impls.rs
- cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-rococo/Cargo.toml 3 additions, 1 deletion...n-tests/emulated/tests/assets/asset-hub-rococo/Cargo.toml
- cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-rococo/src/lib.rs 14 additions, 11 deletions...n-tests/emulated/tests/assets/asset-hub-rococo/src/lib.rs
- cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-rococo/src/tests/reserve_transfer.rs 279 additions, 216 deletions...sts/assets/asset-hub-rococo/src/tests/reserve_transfer.rs
- cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-rococo/src/tests/teleport.rs 11 additions, 7 deletions...lated/tests/assets/asset-hub-rococo/src/tests/teleport.rs
- cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/lib.rs 2 additions, 2 deletions...-tests/emulated/tests/assets/asset-hub-westend/src/lib.rs
- cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/reserve_transfer.rs 76 additions, 283 deletions...ts/assets/asset-hub-westend/src/tests/reserve_transfer.rs
- cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/teleport.rs 1 addition, 1 deletion...ated/tests/assets/asset-hub-westend/src/tests/teleport.rs
- cumulus/parachains/runtimes/assets/asset-hub-kusama/src/lib.rs 35 additions, 1 deletion...us/parachains/runtimes/assets/asset-hub-kusama/src/lib.rs
Please register or sign in to comment