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

Transfer asset via bridge #2013

Closed
wants to merge 341 commits into from
Closed

Transfer asset via bridge #2013

wants to merge 341 commits into from

Conversation

bkontur
Copy link
Contributor

@bkontur bkontur commented Dec 21, 2022

PR introduces:

  • new pallet to support transfer over bridge-hubs and (xcm) configuration
  • asset-hub-kusama configuration for sending/receiving assets (only KSM/DOT) over bridge-hub to asset-hub-polkadot
  • asset-hub-polkadot configuration for sending/receiving assets (only KSM/DOT) over bridge-hub to asset-hub-kusama
  • asset-hub-westend configuration for sending/receiving in assets over bridge-hub (kusama-local - for local testing, rococo local+live setup)

(even if pallet is configured in runtimes and deployed live, there is no way to initiate transfer unless HRMPs to bridge-hubs are opened)


  • fix Weight for fn universal_origin(_: &Junction) -> Weight {
  • UniversalAliases/TrustedBridgedNetworks - create some general pallet for on-chain cfg (something like bridge-asset-transfer has, maybe split)
  • move all usefull origin_conversion/barriers stuff to the polkadot/xcm-builder/xcm-executor - [xcm] Foreign global consensus parachain LocationToAccountId converter polkadot#7016
  • investigate/check/add RefundSurplus + ClearOrigin -> add to test where it is trapped (now, BuyExecution pays SA of remote statemine/t but assets are trapped to local bridge hub account, probably because of ClearOrigin)
  • verify and prepare test for ETH scenario - Transfer asset via bridge #2013 (comment)
  • setup both ways Statemine <-> Westmint
  • add integaration e2e/emulated tests for moving assets (native, trusted, foreign, foreign from different consensus, eth, ...)
  • fix SA - local-bridge-hub vs remote target location
  • fix benchmark
  • fix local run
  • open follow up PR with on-chain configuration by governance
  • allow set_storage for fee

Note: do not merge until #2642 is merged or remove TrailingSetTopicAsId from here and fix test

@command-bot
Copy link

command-bot bot commented Jun 14, 2023

@bkontur https://gitlab.parity.io/parity/mirrors/cumulus/-/jobs/2989180 was started for your command "$PIPELINE_SCRIPTS_DIR/commands/bench/bench.sh" xcm asset-hub-kusama assets pallet_xcm_benchmarks::generic. Check out https://gitlab.parity.io/parity/mirrors/cumulus/-/pipelines?page=1&scope=all&username=group_605_bot to know what else is being executed currently.

Comment bot cancel 2-cd0aa2c5-5abc-45b4-aee8-4a79b86637b1 to cancel this command or bot cancel to cancel all commands in this pull request.

@command-bot
Copy link

command-bot bot commented Jun 14, 2023

@bkontur https://gitlab.parity.io/parity/mirrors/cumulus/-/jobs/2989185 was started for your command "$PIPELINE_SCRIPTS_DIR/commands/bench/bench.sh" xcm asset-hub-westend assets pallet_xcm_benchmarks::generic. Check out https://gitlab.parity.io/parity/mirrors/cumulus/-/pipelines?page=1&scope=all&username=group_605_bot to know what else is being executed currently.

Comment bot cancel 3-7375da72-149c-47b4-91b7-2bd2cc92d871 to cancel this command or bot cancel to cancel all commands in this pull request.

@command-bot
Copy link

command-bot bot commented Jun 14, 2023

@bkontur https://gitlab.parity.io/parity/mirrors/cumulus/-/jobs/2989186 was started for your command "$PIPELINE_SCRIPTS_DIR/commands/bench/bench.sh" xcm asset-hub-polkadot assets pallet_xcm_benchmarks::generic. Check out https://gitlab.parity.io/parity/mirrors/cumulus/-/pipelines?page=1&scope=all&username=group_605_bot to know what else is being executed currently.

Comment bot cancel 4-2ae637d3-81d2-455d-84d6-a44f42f309de to cancel this command or bot cancel to cancel all commands in this pull request.

@command-bot
Copy link

command-bot bot commented Jun 14, 2023

@bkontur https://gitlab.parity.io/parity/mirrors/cumulus/-/jobs/2989187 was started for your command "$PIPELINE_SCRIPTS_DIR/commands/bench/bench.sh" pallet asset-hub-kusama assets pallet_bridge_transfer. Check out https://gitlab.parity.io/parity/mirrors/cumulus/-/pipelines?page=1&scope=all&username=group_605_bot to know what else is being executed currently.

Comment bot cancel 5-2f0935ad-249d-47e5-aea4-b17d3b1b13f6 to cancel this command or bot cancel to cancel all commands in this pull request.

@command-bot
Copy link

command-bot bot commented Jun 14, 2023

@bkontur Command was rescheduled and failed to finish (check for task id 6-9cc4ab57-ad64-4f36-adb6-f730fac246cf in the logs); execution will not automatically be restarted further.

@command-bot
Copy link

command-bot bot commented Jun 14, 2023

@bkontur Command was rescheduled and failed to finish (check for task id 7-13f27ea6-3924-4ce7-b175-de2d46c4f49b in the logs); execution will not automatically be restarted further.

@command-bot
Copy link

command-bot bot commented Jun 14, 2023

@bkontur Command "$PIPELINE_SCRIPTS_DIR/commands/bench/bench.sh" xcm asset-hub-kusama assets pallet_xcm_benchmarks::generic has finished. Result: https://gitlab.parity.io/parity/mirrors/cumulus/-/jobs/2989180 has finished. If any artifacts were generated, you can download them from https://gitlab.parity.io/parity/mirrors/cumulus/-/jobs/2989180/artifacts/download.

@command-bot
Copy link

command-bot bot commented Jun 14, 2023

@bkontur Command "$PIPELINE_SCRIPTS_DIR/commands/bench/bench.sh" xcm asset-hub-westend assets pallet_xcm_benchmarks::generic has finished. Result: https://gitlab.parity.io/parity/mirrors/cumulus/-/jobs/2989185 has finished. If any artifacts were generated, you can download them from https://gitlab.parity.io/parity/mirrors/cumulus/-/jobs/2989185/artifacts/download.

@command-bot
Copy link

command-bot bot commented Jun 14, 2023

@bkontur Command "$PIPELINE_SCRIPTS_DIR/commands/bench/bench.sh" xcm asset-hub-polkadot assets pallet_xcm_benchmarks::generic has finished. Result: https://gitlab.parity.io/parity/mirrors/cumulus/-/jobs/2989186 has finished. If any artifacts were generated, you can download them from https://gitlab.parity.io/parity/mirrors/cumulus/-/jobs/2989186/artifacts/download.

@command-bot
Copy link

command-bot bot commented Jun 14, 2023

@bkontur Command "$PIPELINE_SCRIPTS_DIR/commands/bench/bench.sh" pallet asset-hub-kusama assets pallet_bridge_transfer has finished. Result: https://gitlab.parity.io/parity/mirrors/cumulus/-/jobs/2989187 has finished. If any artifacts were generated, you can download them from https://gitlab.parity.io/parity/mirrors/cumulus/-/jobs/2989187/artifacts/download.

for IsTrustedBridgedReserveLocationForConcreteAsset<UniversalLocation, Reserves>
{
fn contains(asset: &MultiAsset, origin: &MultiLocation) -> bool {
let universal_source = UniversalLocation::get();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The beginning (~40 lines) of both IsTrustedBridgedReserveLocationForConcreteAsset::contains and IsAllowedReserveBasedTransferForConcreteAssetToBridgedLocation::contains is almost the same (ensure_is_remote(UniversalLocation::get(), _); let asset_location = ...). Maybe it could be extracted to a separate function?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I also realized that but I didnt come back to that,
I will check that

);

// call bridge
// TODO: check-parameter - should we handle `sender_cost` somehow ?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not an issue, just wanted to understand and clarify - maybe I'm missing something. IIUC, apart from the bundled assets, the sender pays for the:

  1. execution at the target chain in target tokens. This fee is configured at the source chain (here, where this code is executed). If the actual XCM weight is lower than the configured, the excess fee goes to the sovereign-account-of-this-chain-at-the-target-chain, right?
  2. regular transaction cost for the transfer_asset_via_bridge call at the source (this) chain.

The XcmpQueue at asset hubs is configured to have zero fee for sending messages to sibling chain (type PriceForSiblingDelivery = ();). So even if we'll start handling sender_cost here, it won't change anything, given current configuration, right?

Also - this means that we are controlling the whole fee (transport + execution) using this single constant AND the fee is only withdrawn when the message gets dispatched at the target chain. So it'll pass through 3 queues (Polkadot.AsssetHub -> Polkadot.BridgeHub, Polkadot.BridgeHub -> Kusama.BridgeHub, Kusama.BridgeHub -> Kusama.AssetHub) before dispatch and only then we'll charge sender. If one of queues is stalled, this would allow senders to keep filling up queues for free (except regular tx fee).

Just wanted to bring attention to that, because my understanding was that we'll be taking two fees. Execution using regular XCM BuyExecution mechanism and some constant "transport" fee when the message gets sent. The latter one will evolve to some non-constant value later.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you, Slava, I will fix this as we talked yesterday

@bkontur
Copy link
Contributor Author

bkontur commented Jun 16, 2023

bot rebase

@paritytech-processbot
Copy link

Rebased

@acatangiu acatangiu mentioned this pull request Jun 19, 2023
@bkontur
Copy link
Contributor Author

bkontur commented Aug 3, 2023

closing in favour of #2762 (for rococo/wococo we will provide new solution base on this new PR)

@bkontur bkontur closed this Aug 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review. B1-note_worthy Changes should be noted in the release notes C5-high PR touches the given topic and has a high impact on builders. D9-needsaudit 👮 PR contains changes to fund-managing logic that should be properly reviewed and externally audited T1-runtime This PR/Issue is related to the topic “runtime”. T6-XCM This PR/Issue is related to XCM. T8-bridges This PR/Issue is related to bridges.
Projects
Development

Successfully merging this pull request may close these issues.