[pallet-xcm] fix transport fees for remote reserve transfers (#3792)

Currently `transfer_assets` from pallet-xcm covers 4 main different
transfer types:
- `localReserve`
- `DestinationReserve`
- `Teleport`
- `RemoteReserve`

For the first three, the local execution and the remote message sending
are separated, and fees are deducted in pallet-xcm itself:
https://github.com/paritytech/polkadot-sdk/blob/3410dfb3929462da88be2da813f121d8b1cf46b3/polkadot/xcm/pallet-xcm/src/lib.rs#L1758.

For the 4th case `RemoteReserve`, pallet-xcm is still relying on the
xcm-executor itself to send the message (through the
`initiateReserveWithdraw` instruction). In this case, if delivery fees
need to be charged, it is not possible to do so because the
`jit_withdraw` mode has not being set.

This PR proposes to still use the `initiateReserveWithdraw` but
prepending a `setFeesMode { jit_withdraw: true }` to make sure delivery
fees can be paid.

A test-case is also added to present the aforementioned case

---------

Co-authored-by: Adrian Catangiu <adrian@parity.io>
This commit is contained in:
girazoki
2024-03-22 19:48:15 +01:00
committed by GitHub
parent 2f59e9efa8
commit 9a04ebbfb0
17 changed files with 291 additions and 164 deletions
@@ -155,7 +155,7 @@ fn limited_teleport_native_assets_from_relay_to_system_para_works() {
test.assert();
let delivery_fees = Rococo::execute_with(|| {
xcm_helpers::transfer_assets_delivery_fees::<
xcm_helpers::teleport_assets_delivery_fees::<
<RococoXcmConfig as xcm_executor::Config>::XcmSender,
>(test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest)
});
@@ -204,7 +204,7 @@ fn limited_teleport_native_assets_back_from_system_para_to_relay_works() {
let receiver_balance_after = test.receiver.balance;
let delivery_fees = PeopleRococo::execute_with(|| {
xcm_helpers::transfer_assets_delivery_fees::<
xcm_helpers::teleport_assets_delivery_fees::<
<PeopleRococoXcmConfig as xcm_executor::Config>::XcmSender,
>(test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest)
});
@@ -248,7 +248,7 @@ fn limited_teleport_native_assets_from_system_para_to_relay_fails() {
let receiver_balance_after = test.receiver.balance;
let delivery_fees = PeopleRococo::execute_with(|| {
xcm_helpers::transfer_assets_delivery_fees::<
xcm_helpers::teleport_assets_delivery_fees::<
<PeopleRococoXcmConfig as xcm_executor::Config>::XcmSender,
>(test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest)
});