-
Notifications
You must be signed in to change notification settings - Fork 0
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
Inbound queue v2 #3
Conversation
ca8e226
to
0e9cca0
Compare
MAX_XCM_DECODE_DEPTH, | ||
&mut message.xcm.as_ref(), | ||
) | ||
.map_err(|_| Error::<T>::InvalidPayload)?; |
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.
We should not fail on Invalid xcm. We should rather build the xcm payload without appending anything. This will allow the assets to get trapped on assethub.
&mut message.xcm.as_ref(), | ||
) | ||
.map_err(|_| Error::<T>::InvalidPayload)?; | ||
let xcm: Xcm<()> = versioned_xcm.try_into().map_err(|_| <Error<T>>::InvalidPayload)?; |
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.
Same here. Any issues parsing the XCM should result in assets getting trapped on Asset Hub.
// Todo: Deposit fee(in Ether) to RewardLeger which should cover all of: | ||
// T::RewardLeger::deposit(who, envelope.fee.into())?; | ||
// a. The submit extrinsic cost on BH | ||
// b. The delivery cost to AH |
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.
The xcm can be built here without the need for XCM v5 and we can re-do later when XCM v5 is ready.
You will need to parse the Assets in the ticket and build the following XCM to send to asset hub:
ReceiveTeleportedAsset(asset_hub_fees)
BuyExecution(fees: asset_hub_fees)
DescendOrigin(PalletInstance(inbound_queue_pallet_index))
UniversalOrigin(GlobalConsensus(network))
ReserveAssetDeposited(erc20_assets) // from assets that do not have tokenId
WithdrawAsset(pna_assets) // from assets that do have tokenId
DescendOrigin(msg_sender)
You can then append the xcm from the payload to this base xcm. If the xcm payload fails to be parsed, append nothing and send to asset hub anyway, this will cause the assets to get trapped on asset hub.
Addresses paritytech#4284 For V5, removed `required_weight_at_most` from `Transact`. The weigher now has to decode the call inside of a transaction in order to know it's dispatch weight. It's harder to make mistakes now, since the user no longer specifies a weight value which might be wrong.
…rigin on destination (paritytech#5971) Built on top of paritytech#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 <[email protected]> Co-authored-by: Francisco Aguirre <[email protected]> Co-authored-by: Branislav Kontur <[email protected]>
9492f1e
to
d359108
Compare
No description provided.