Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

[PoC] pallet_xcm::reserve_transfer_assets with DestinationFees handling #7456

Closed
wants to merge 14 commits into from

Conversation

bkontur
Copy link
Contributor

@bkontur bkontur commented Jul 4, 2023

Relates to: paritytech/cumulus#2762

Motivation:
Right now, user chooses fee_asset_item to cover fees on destination using BuyExecution(fees).
But the problem is that selected fees may not be valid on the destination.

e.g. transfer KSM over bridge from AssetHubKusama to AssetHubPolkadot -> problems like KSM is not sufficient (ForeignAsset) on AssetHubPolkadot or there are no wrappedKSM yet on AssetHubPolkadot (very first transfer).

non-bridge e.g.: any foreign asset transfer between two paras on Polkadot without requiring user to also transfer DOT to pay for execution on destination.

Proposal:

This PR introduces a PoC mechanism for reserve_transfer_assets to handle fees / BuyExecution on destination chain.
Runtime which provides pallet_xcm can configure for particular destination and user's selected fee_asset_item/fees how the fees will be handled:

  • paid by origin (as-is now)
    • this is exactly how it is now, user selects fee_asset_item and fees(KSM) are put to BuyExecution(KSM) and it is paid from ReserveAssetDeposited(KSM) on destination
  • paid by UniversalLocation
    • user selects fee_asset_item and fees(KSM), but runtime can have configuration that for particular destination and fees_asset_id and can decide that:
      • it will take some portion of fees_asset_id on source chain (means to withdraw KSM from user account and deposit to some UniversalLocation's account - treasury, staking_pot, ...)
      • recalculate proportional amonut in different asset e.g. DOT, which goes to the WithdrawAsset(DOT) / BuyExecution(DOT) which is executed on destination chain, means that DOTs are withdrawn from UniversalLocation's sovereign account on destination

More description:
https://hackmd.io/-Ec-WUk0QuGPnrIGuXdH7g?view


TL;DR: PR introduces mechanism that allows Runtime as UniversalLocation to help origin to pay on destination from UniversalLocation's sovereign account (in DOTs), but for that it charges origin with some proportional amount in source chain (in KSMs)


TODOs:

  • verify this approach
  • verify fix for AliasOrigin (if it is ok, to use effective_origin)
  • fix weight for extrinsics reserve_transfer_assets / limited_reserve_transfer_assets
  • add the same logic to do_teleport_assets

Alternatives:

  1. Is this approach with Pay fees on destination from SA of source UniversalLocation ok?
  2. If so, is this implementation with AliasOrigin ok?
  • Another option would be to change executor to have a runtime-specific T::FeeTransactor::append() inject WithdrawAsset, BuyExecution in-between (or before)ReserveAssetDeposited/ReserveAssetTeleported and ClearOrigin.
  1. Can we change the Barrier above? Should we create new Barrier? (PoC added new dedicated barrier)
  2. New xcm instuction? (We hope that we would be able to do this with XCMv3)
  3. is_sufficient for wrapped assets would fix issue and we dont need pallet_xcm customization

@paritytech-cicd-pr
Copy link

The CI pipeline was cancelled due to failure one of the required jobs.
Job name: test-linux-stable
Logs: https://gitlab.parity.io/parity/mirrors/polkadot/-/jobs/3119281

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants