pallet-xcm: add extrinsic to allow withdrawal of reserve-based assets#1430
pallet-xcm: add extrinsic to allow withdrawal of reserve-based assets#1430acatangiu wants to merge 5 commits intoparitytech:masterfrom
Conversation
pallet-xcm already offers `reserve_transfer_assets()` call for easy reserve-based asset transfer, where original assets are reserved in some reserve location and equivalent assets are minted at destination. This commit adds `reserve_withdraw_assets()` call for users to be able to do the operation reverse too: burn equivalent assets and release original ones from reserve location. Co-authored-by: Aleksandr Krupenkin <mail@akru.me>
|
bot bench polkadot-pallet --pallet=pallet_xcm |
|
@acatangiu Command |
a6cf8c2 to
2d4ac96
Compare
|
So I'm not 100% sure that we should have a separate extrinsic for this. We actually found out that In other words, if the goal for introducing |
No, the goal is not to work around any limitations (none present afaik) of TLDR: Long-winded explanation of abovereserve_transfer_assetMy understanding of the purpose of Where So (at least afaik) it can only be used for the original reserve asset, not for derivatives (assets based on original reserve). It clearly "reserves" an asset by placing in local SA of So the point of it is to turn an/any asset into a reserve asset, reserve it locally in the ownership of dest, and let dest know about it (which usually means dest mints some dest-local derivative equivalent asset). (Let chain A be the local use of reserve_withdraw_assetTo do the reversed operation (reversed as in "undo", not as in mirrored), user would call
A (poorish) analogy I can think of on the spot is a
I guess we could build a more complex extrinsic that could do both "push" and "pop" and figure out the intention of its user based on parameters or built-in (opaque) logic, but ultimately it still has to run different XCM instructions ( Maybe I'm missing something, WDYT? |
That's what it isn't supposed to do -- we fully intended it to be a function that allows you to burn a derivative, send an onwards message to the reserve, transfer the reserve asset underlying the derivative to the SA of the destination, and finally notifying the destination chain. The extrinsic as it stands now doesn't burn anything via This would then solve your other issue as well, since there is no "reverse direction" anymore -- it's all just the same function that you call. What I also imagine it to be doing is to be smart and know that if e.g. the destination and the reserve location are the same, it'll just know not to forward a |
|
Sorry I'm a bit confused so I will answer to both interpretations to your comment:
"The extrinsic" you refer to is
|
|
I still think the way xtokens handles it is significantly better. i.e. a |
This isn't necessary -- that was an oversight, and |
|
This pull request has been mentioned on Polkadot Forum. There might be relevant details there: https://forum.polkadot.network/t/polkadot-kusama-bridge/2971/5 |
Opened #1584 to detail the proposed solution - will close this PR on behalf of alternative described there. |
I'll look at the |
|
closing in favor of #1672 |
…tTargetChain is used) (#1430) * reintroduce From<SourceChain>InboundLaneApi * impl From<Chain>InboundLaneApi for testnet runtimes * use inboundlaneapi in relay * remove unused OutboundXcmWeigher * spelling * added the only test to messages pallet * fmt
Description
Motivation
pallet-xcmis the main user-facing interface for XCM functionality, including assets manipulation functions liketeleportAssets()andreserve_transfer_assets()calls.While
teleportAsset()works both ways,reserve_transfer_assets()works only for sending reserve-based assets to a remote destination and beneficiary, but there is no user-facing extrinsic for burning reserved-based assets and getting back the original reserved assets.Solution
This PR adds
(limited_)reserve_withdraw_assets()extrinsics that builds and locally executes XCM program containingInitiateReserveWithdrawXCVM instruction to burn synthetic asset on (local) chain and send notification to destination (reserve chain) for releasing locked asset.Testing
Added synthetic
pallet-xcmunit-test for testing extrinsic when used with native asset, andAssetHubs runtime unit-tests that test extrinsic when used with foreign asset.Partially fixes paritytech/parity-bridges-common#2405
Checklist
Trequired)
If this PR alters any external APIs or interfaces used by Polkadot, the corresponding Polkadot PR is ready as wellas the corresponding Cumulus PR (optional)