[xcm-v5] implement RFC#100: add new InitiateTransfer instruction #5876
+948
−103
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
A new instruction
InitiateTransfer
is introduced that initiates an assets transfer from the chain it is executed on, to another chain. The executed transfer is point-to-point (chain-to-chain) with all of the transfer properties specified in the instruction parameters. The instruction also allows specifying another XCM program to be executed on the remote chain.If a transfer requires going through multiple hops, an XCM program can compose this instruction to be used at every chain along the path, on each hop describing that specific leg of the transfer.
Note: Transferring assets that require different paths (chains along the way) is not supported within same XCM because of the async nature of cross chain messages. This new instruction, however, enables initiating transfers for multiple assets that take the same path even if they require different transfer types along that path.
The usage and composition model of
InitiateTransfer
is the same as with existingDepositReserveAsset
,InitiateReserveWithdraw
andInitiateTeleport
instructions. The main difference comes from the ability to handle assets that have different point-to-point transfer type between A and B. The other benefit is that it also allows specifying remote fee payment and transparently appends the required remote fees logic to the remote XCM.We can specify the desired transfer type for some asset(s) using:
This PR adds 1 new XCM instruction:
An
InitiateTransfer { .. }
instruction shall transfer todest
, all assets in theholding
register that match the providedassets
andremote_fees
filters.These filters identify the assets to be transferred as well as the transfer type to be used for transferring them.
It shall handle the local side of the transfer, then forward an onward XCM to
dest
for handling the remote side of the transfer.It should do so using same mechanisms as existing
DepositReserveAsset
,InitiateReserveWithdraw
,InitiateTeleport
instructions but practically combining all required XCM instructions to be remotely executed into a single remote XCM program to be sent over todest
.Furthermore, through
remote_fees: Option<AssetTransferFilter>
, it shall allow specifying a single asset to be used for fees ondest
chain. This single asset shall be remotely handled/received by the first instruction in the onward XCM and shall be followed by aBuyExecution
instruction using it.If
remote_fees
is set toNone
, the first instruction in the onward XCM shall be aUnpaidExecution
instruction. The rest of the assets shall be handled by subsequent instructions, thus also finally allowing single asset buy execution barrier security recommendation.The
BuyExecution
appended to the onward XCM specifiesWeightLimit::Unlimited
, thus being limited only by theremote_fees
asset "amount". This is a deliberate decision for enhancing UX - in practice, people/dApps care about limiting the amount of fee asset used and not the actually used weight.The onward XCM, following the assets transfers instructions,
ClearOrigin
orDescendOrigin
instructions shall be appended to stop acting on behalf of the source chain, then the caller-providedremote_xcm
shall also be appended, allowing the caller to control what to do with the transferred assets.Closes #5209