xcm-executor: take transport fee from transferred assets if necessary (#4834)
# Description Sending XCM messages to other chains requires paying a "transport fee". This can be paid either: - from `origin` local account if `jit_withdraw = true`, - taken from Holding register otherwise. This currently works for following hops/scenarios: 1. On destination no transport fee needed (only sending costs, not receiving), 2. Local/originating chain: just set JIT=true and fee will be paid from signed account, 3. Intermediary hops - only if intermediary is acting as reserve between two untrusted chains (aka only for `DepositReserveAsset` instruction) - this was fixed in https://github.com/paritytech/polkadot-sdk/pull/3142 But now we're seeing more complex asset transfers that are mixing reserve transfers with teleports depending on the involved chains. # Example E.g. transferring DOT between Relay and parachain, but through AH (using AH instead of the Relay chain as parachain's DOT reserve). In the `Parachain --1--> AssetHub --2--> Relay` scenario, DOT has to be reserve-withdrawn in leg `1`, then teleported in leg `2`. On the intermediary hop (AssetHub), `InitiateTeleport` fails to send onward message because of missing transport fees. We also can't rely on `jit_withdraw` because the original origin is lost on the way, and even if it weren't we can't rely on the user having funded accounts on each hop along the way. # Solution/Changes - Charge the transport fee in the executor from the transferred assets (if available), - Only charge from transferred assets if JIT_WITHDRAW was not set, - Only charge from transferred assets if unless using XCMv5 `PayFees` where we do not have this problem. # Testing Added regression tests in emulated transfers. Fixes https://github.com/paritytech/polkadot-sdk/issues/4832 Fixes https://github.com/paritytech/polkadot-sdk/issues/6637 --------- Signed-off-by:Adrian Catangiu <adrian@parity.io> Co-authored-by:
Francisco Aguirre <franciscoaguirreperez@gmail.com>
parent
4198dc95
Showing
- bridges/snowbridge/primitives/router/src/inbound/mod.rs 3 additions, 1 deletionbridges/snowbridge/primitives/router/src/inbound/mod.rs
- cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-rococo/src/tests/reserve_transfer.rs 3 additions, 3 deletions...sts/assets/asset-hub-rococo/src/tests/reserve_transfer.rs
- cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/lib.rs 1 addition, 0 deletions...-tests/emulated/tests/assets/asset-hub-westend/src/lib.rs
- cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/hybrid_transfers.rs 136 additions, 5 deletions...ts/assets/asset-hub-westend/src/tests/hybrid_transfers.rs
- cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/reserve_transfer.rs 3 additions, 3 deletions...ts/assets/asset-hub-westend/src/tests/reserve_transfer.rs
- cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/transact.rs 1 addition, 1 deletion...ated/tests/assets/asset-hub-westend/src/tests/transact.rs
- cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/asset_transfers.rs 1 addition, 1 deletion...ts/bridges/bridge-hub-rococo/src/tests/asset_transfers.rs
- cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/register_bridged_assets.rs 1 addition, 1 deletion...es/bridge-hub-rococo/src/tests/register_bridged_assets.rs
- cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/send_xcm.rs 1 addition, 1 deletion...ted/tests/bridges/bridge-hub-rococo/src/tests/send_xcm.rs
- cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-westend/src/tests/asset_transfers.rs 2 additions, 2 deletions...s/bridges/bridge-hub-westend/src/tests/asset_transfers.rs
- cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-westend/src/tests/register_bridged_assets.rs 1 addition, 1 deletion...s/bridge-hub-westend/src/tests/register_bridged_assets.rs
- cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-westend/src/tests/send_xcm.rs 1 addition, 1 deletion...ed/tests/bridges/bridge-hub-westend/src/tests/send_xcm.rs
- cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-westend/src/tests/transact.rs 1 addition, 1 deletion...ed/tests/bridges/bridge-hub-westend/src/tests/transact.rs
- polkadot/xcm/xcm-executor/src/lib.rs 60 additions, 23 deletionspolkadot/xcm/xcm-executor/src/lib.rs
- prdoc/pr_4834.prdoc 15 additions, 0 deletionsprdoc/pr_4834.prdoc