mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 03:01:07 +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:
@@ -301,9 +301,21 @@ case "$1" in
|
||||
0 \
|
||||
"Unlimited"
|
||||
;;
|
||||
withdraw-reserve-assets-from-asset-hub-rococo-local)
|
||||
ensure_polkadot_js_api
|
||||
# send back only 100000000000 wrappedWNDs to Alice account on AHW
|
||||
limited_reserve_transfer_assets \
|
||||
"ws://127.0.0.1:9910" \
|
||||
"//Alice" \
|
||||
"$(jq --null-input '{ "V3": { "parents": 2, "interior": { "X2": [ { "GlobalConsensus": "Westend" }, { "Parachain": 1000 } ] } } }')" \
|
||||
"$(jq --null-input '{ "V3": { "parents": 0, "interior": { "X1": { "AccountId32": { "id": [212, 53, 147, 199, 21, 253, 211, 28, 97, 20, 26, 189, 4, 169, 159, 214, 130, 44, 133, 88, 133, 76, 205, 227, 154, 86, 132, 231, 165, 109, 162, 125] } } } } }')" \
|
||||
"$(jq --null-input '{ "V3": [ { "id": { "Concrete": { "parents": 2, "interior": { "X1": { "GlobalConsensus": "Westend" } } } }, "fun": { "Fungible": 140000000000 } } ] }')" \
|
||||
0 \
|
||||
"Unlimited"
|
||||
;;
|
||||
reserve-transfer-assets-from-asset-hub-westend-local)
|
||||
ensure_polkadot_js_api
|
||||
# send WOCs to Alice account on AHR
|
||||
# send WNDs to Alice account on AHR
|
||||
limited_reserve_transfer_assets \
|
||||
"ws://127.0.0.1:9010" \
|
||||
"//Alice" \
|
||||
@@ -313,6 +325,18 @@ case "$1" in
|
||||
0 \
|
||||
"Unlimited"
|
||||
;;
|
||||
withdraw-reserve-assets-from-asset-hub-westend-local)
|
||||
ensure_polkadot_js_api
|
||||
# send back only 100000000000 wrappedROCs to Alice account on AHR
|
||||
limited_reserve_transfer_assets \
|
||||
"ws://127.0.0.1:9010" \
|
||||
"//Alice" \
|
||||
"$(jq --null-input '{ "V3": { "parents": 2, "interior": { "X2": [ { "GlobalConsensus": "Rococo" }, { "Parachain": 1000 } ] } } }')" \
|
||||
"$(jq --null-input '{ "V3": { "parents": 0, "interior": { "X1": { "AccountId32": { "id": [212, 53, 147, 199, 21, 253, 211, 28, 97, 20, 26, 189, 4, 169, 159, 214, 130, 44, 133, 88, 133, 76, 205, 227, 154, 86, 132, 231, 165, 109, 162, 125] } } } } }')" \
|
||||
"$(jq --null-input '{ "V3": [ { "id": { "Concrete": { "parents": 2, "interior": { "X1": { "GlobalConsensus": "Rococo" } } } }, "fun": { "Fungible": 100000000000 } } ] }')" \
|
||||
0 \
|
||||
"Unlimited"
|
||||
;;
|
||||
claim-rewards-bridge-hub-rococo-local)
|
||||
ensure_polkadot_js_api
|
||||
# bhwd -> [62, 68, 77, 64] -> 0x62687764
|
||||
@@ -360,7 +384,9 @@ case "$1" in
|
||||
- init-asset-hub-westend-local
|
||||
- init-bridge-hub-westend-local
|
||||
- reserve-transfer-assets-from-asset-hub-rococo-local
|
||||
- withdraw-reserve-assets-from-asset-hub-rococo-local
|
||||
- reserve-transfer-assets-from-asset-hub-westend-local
|
||||
- withdraw-reserve-assets-from-asset-hub-westend-local
|
||||
- claim-rewards-bridge-hub-rococo-local
|
||||
- claim-rewards-bridge-hub-westend-local";
|
||||
exit 1
|
||||
|
||||
Reference in New Issue
Block a user