-
Notifications
You must be signed in to change notification settings - Fork 684
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[xcm-v5] implement RFC#100: add new InitiateTransfer instruction #5876
Conversation
…coco --target_dir=polkadot --pallet=pallet_xcm_benchmarks::generic
…stend --target_dir=polkadot --pallet=pallet_xcm_benchmarks::generic
…retime-westend --runtime_dir=coretime --target_dir=cumulus --pallet=pallet_xcm_benchmarks::generic
…set-hub-rococo --runtime_dir=assets --target_dir=cumulus --pallet=pallet_xcm_benchmarks::generic
…set-hub-westend --runtime_dir=assets --target_dir=cumulus --pallet=pallet_xcm_benchmarks::generic
…retime-rococo --runtime_dir=coretime --target_dir=cumulus --pallet=pallet_xcm_benchmarks::generic
…idge-hub-rococo --runtime_dir=bridge-hubs --target_dir=cumulus --pallet=pallet_xcm_benchmarks::generic
…idge-hub-westend --runtime_dir=bridge-hubs --target_dir=cumulus --pallet=pallet_xcm_benchmarks::generic
…ople-westend --runtime_dir=people --target_dir=cumulus --pallet=pallet_xcm_benchmarks::generic
…coco --target_dir=polkadot --pallet=pallet_xcm_benchmarks::fungible
@franciscoaguirre Command |
…idge-hub-rococo --runtime_dir=bridge-hubs --target_dir=cumulus --pallet=pallet_xcm_benchmarks::fungible
…retime-westend --runtime_dir=coretime --target_dir=cumulus --pallet=pallet_xcm_benchmarks::fungible
@franciscoaguirre Command |
…set-hub-rococo --runtime_dir=assets --target_dir=cumulus --pallet=pallet_xcm_benchmarks::fungible
…retime-rococo --runtime_dir=coretime --target_dir=cumulus --pallet=pallet_xcm_benchmarks::fungible
@franciscoaguirre Command |
@franciscoaguirre Command |
@franciscoaguirre Command |
…idge-hub-westend --runtime_dir=bridge-hubs --target_dir=cumulus --pallet=pallet_xcm_benchmarks::fungible
…ople-rococo --runtime_dir=people --target_dir=cumulus --pallet=pallet_xcm_benchmarks::fungible
@franciscoaguirre Command |
@franciscoaguirre Command |
…ople-westend --runtime_dir=people --target_dir=cumulus --pallet=pallet_xcm_benchmarks::fungible
@franciscoaguirre Command |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
...ains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/hybrid_transfers.rs
Outdated
Show resolved
Hide resolved
...ains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/hybrid_transfers.rs
Outdated
Show resolved
Hide resolved
…rigin on destination (#5971) Built on top of #5876 # Description Currently, all XCM asset transfer instructions ultimately clear the origin in the remote XCM message by use of the `ClearOrigin` instruction. This is done for security considerations to ensure that subsequent (user-controlled) instructions cannot command the authority of the sending chain. The problem with this approach is that it limits what can be achieved on remote chains through XCM. Most XCM operations require having an origin, and following any asset transfer the origin is lost, meaning not much can be done other than depositing the transferred assets to some local account or transferring them onward to another chain. For example, we cannot transfer some funds for buying execution, then do a `Transact` (all in the same XCM message). In the case of XCM programs going from source-chain directly to dest-chain without an intermediary hop, we can enable scenarios such as above by using the AliasOrigin instruction instead of the ClearOrigin instruction. Instead of clearing the source-chain origin, the destination chain shall attempt to alias source-chain to "original origin" on the source chain. Most common such origin aliasing would be X1(Parachain(source-chain)) -> X2(Parachain(source-chain), AccountId32(origin-account)) for the case of a single hop transfer where the initiator is a (signed/pure/proxy) account origin-account on source-chain. This is equivalent to using the DescendOrigin instruction in this case, but also usable in the multi hop case. This allows an actor on chain A to Transact on chain B without having to prefund its SA account on chain B, instead they can simply transfer the required fees in the same XCM program as the Transact. As long as the asset transfer has the same XCM route/hops as the rest of the program, this pattern of usage can be composed across multiple hops, to ultimately Transact on the final hop using the original origin on the source chain, effectively abstracting away any intermediary hops. ### XCM `InitiateAssetsTransfer` instruction changes A new parameter `preserve_origin` to be added to the `InitiateAssetsTransfer` XCM instruction that specifies if the original origin should be preserved or cleared. ```diff InitiateAssetsTransfer { destination: Location, assets: Vec<AssetTransferFilter>, remote_fees: Option<AssetTransferFilter>, + preserve_origin: bool, remote_xcm: Xcm<()>, } ``` This parameter is explicitly necessary because the instruction should be usable between any two chains regardless of their origin-aliasing trust relationship. Preserving the origin requires some level of trust, while clearing it works regardless of that relationship. Specifying `preserve_origin: false` will always work regardless of the configured alias filters of the involved chains. # Testing - [x] e2e test: User on PenpalA registers foreign token (transacts) on PenpalB through XCM, while paying all fees using USDT (meaning XCM has to go through AssetHub) - AH carries over the original origin, effectively being a transparent proxy, - [x] e2e test: User/contract on Ethereum registers foreign token (transacts) on Polkadot-PenpalA through XCM (over bridge), while paying all fees using DOT (has to go through AssetHub) - AH carries over the original origin, effectively being a transparent proxy for Ethereum, --------- Signed-off-by: Adrian Catangiu <adrian@parity.io> Co-authored-by: Francisco Aguirre <franciscoaguirreperez@gmail.com> Co-authored-by: Branislav Kontur <bkontur@gmail.com>
# Context This PR aims to introduce XCMv5, for now it's in progress and will be updated over time. This branch will serve as a milestone branch for merging in all features we want to add to XCM, roughly outlined [here](polkadot-fellows/xcm-format#60). More features could be added. ## TODO - [x] Migrate foreign assets from v3 to v4 - [x] Setup v5 skeleton - [x] Remove XCMv2 - [x] #5390 - [x] #5585 - [x] #5420 - [x] #5876 - [x] #5971 - [x] #6148 - [x] #6228 Fixes #3434 Fixes #4190 Fixes #5209 Fixes #5241 Fixes #4284 --------- Signed-off-by: Adrian Catangiu <adrian@parity.io> Co-authored-by: Adrian Catangiu <adrian@parity.io> Co-authored-by: Andrii <ndk@parity.io> Co-authored-by: Branislav Kontur <bkontur@gmail.com> Co-authored-by: Joseph Zhao <65984904+programskillforverification@users.noreply.github.com> Co-authored-by: Nazar Mokrynskyi <nazar@mokrynskyi.com> Co-authored-by: Bastian Köcher <git@kchr.de> Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com> Co-authored-by: command-bot <> Co-authored-by: GitHub Action <action@github.com> Co-authored-by: Serban Iorga <serban@parity.io>
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