Skip to content

Commit 1e14e93

Browse files
paritytech-release-backport-bot[bot]franciscoaguirrekarolk91
authored
[stable2409] Backport #9544 (#9596)
Backport #9544 into `stable2409` from franciscoaguirre. See the [documentation](https://github.com/paritytech/polkadot-sdk/blob/master/docs/BACKPORT.md) on how to use this bot. <!-- # To be used by other automation, do not modify: original-pr-number: #${pull_number} --> Co-authored-by: Francisco Aguirre <[email protected]> Co-authored-by: Karol Kokoszka <[email protected]>
1 parent 7f3e151 commit 1e14e93

File tree

21 files changed

+441
-132
lines changed

21 files changed

+441
-132
lines changed

cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-rococo/src/tests/reserve_transfer.rs

Lines changed: 110 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -486,34 +486,89 @@ pub fn para_to_para_through_hop_receiver_assertions<Hop: Clone>(t: Test<PenpalA,
486486
}
487487

488488
fn relay_to_para_reserve_transfer_assets(t: RelayToParaTest) -> DispatchResult {
489-
<Rococo as RococoPallet>::XcmPallet::limited_reserve_transfer_assets(
489+
let Junction::Parachain(_) = *t.args.dest.chain_location().last().unwrap() else {
490+
unimplemented!("Destination is not a parachain?")
491+
};
492+
493+
type Runtime = <Rococo as Chain>::Runtime;
494+
let remote_fee_id: AssetId = t
495+
.args
496+
.assets
497+
.clone()
498+
.into_inner()
499+
.get(t.args.fee_asset_item as usize)
500+
.ok_or(pallet_xcm::Error::<Runtime>::Empty)?
501+
.clone()
502+
.id;
503+
504+
<Rococo as RococoPallet>::XcmPallet::transfer_assets_using_type_and_then(
490505
t.signed_origin,
491506
bx!(t.args.dest.into()),
492-
bx!(t.args.beneficiary.into()),
493507
bx!(t.args.assets.into()),
494-
t.args.fee_asset_item,
508+
bx!(TransferType::LocalReserve),
509+
bx!(remote_fee_id.into()),
510+
bx!(TransferType::LocalReserve),
511+
bx!(VersionedXcm::from(
512+
Xcm::<()>::builder_unsafe()
513+
.deposit_asset(AllCounted(1), t.args.beneficiary)
514+
.build()
515+
)),
495516
t.args.weight_limit,
496517
)
497518
}
498519

499520
fn para_to_relay_reserve_transfer_assets(t: ParaToRelayTest) -> DispatchResult {
500-
<PenpalA as PenpalAPallet>::PolkadotXcm::limited_reserve_transfer_assets(
521+
type Runtime = <PenpalA as Chain>::Runtime;
522+
let remote_fee_id: AssetId = t
523+
.args
524+
.assets
525+
.clone()
526+
.into_inner()
527+
.get(t.args.fee_asset_item as usize)
528+
.ok_or(pallet_xcm::Error::<Runtime>::Empty)?
529+
.clone()
530+
.id;
531+
532+
<PenpalA as PenpalAPallet>::PolkadotXcm::transfer_assets_using_type_and_then(
501533
t.signed_origin,
502534
bx!(t.args.dest.into()),
503-
bx!(t.args.beneficiary.into()),
504535
bx!(t.args.assets.into()),
505-
t.args.fee_asset_item,
536+
bx!(TransferType::DestinationReserve),
537+
bx!(remote_fee_id.into()),
538+
bx!(TransferType::DestinationReserve),
539+
bx!(VersionedXcm::from(
540+
Xcm::<()>::builder_unsafe()
541+
.deposit_asset(AllCounted(1), t.args.beneficiary)
542+
.build()
543+
)),
506544
t.args.weight_limit,
507545
)
508546
}
509547

510548
fn system_para_to_para_reserve_transfer_assets(t: SystemParaToParaTest) -> DispatchResult {
511-
<AssetHubRococo as AssetHubRococoPallet>::PolkadotXcm::limited_reserve_transfer_assets(
549+
type Runtime = <AssetHubRococo as Chain>::Runtime;
550+
let remote_fee_id: AssetId = t
551+
.args
552+
.assets
553+
.clone()
554+
.into_inner()
555+
.get(t.args.fee_asset_item as usize)
556+
.ok_or(pallet_xcm::Error::<Runtime>::Empty)?
557+
.clone()
558+
.id;
559+
560+
<AssetHubRococo as AssetHubRococoPallet>::PolkadotXcm::transfer_assets_using_type_and_then(
512561
t.signed_origin,
513562
bx!(t.args.dest.into()),
514-
bx!(t.args.beneficiary.into()),
515563
bx!(t.args.assets.into()),
516-
t.args.fee_asset_item,
564+
bx!(TransferType::LocalReserve),
565+
bx!(remote_fee_id.into()),
566+
bx!(TransferType::LocalReserve),
567+
bx!(VersionedXcm::from(
568+
Xcm::<()>::builder_unsafe()
569+
.deposit_asset(AllCounted(2), t.args.beneficiary)
570+
.build()
571+
)),
517572
t.args.weight_limit,
518573
)
519574
}
@@ -532,25 +587,65 @@ fn para_to_para_through_asset_hub_limited_reserve_transfer_assets(
532587
}
533588

534589
fn para_to_system_para_reserve_transfer_assets(t: ParaToSystemParaTest) -> DispatchResult {
535-
<PenpalA as PenpalAPallet>::PolkadotXcm::limited_reserve_transfer_assets(
590+
type Runtime = <PenpalA as Chain>::Runtime;
591+
let remote_fee_id: AssetId = t
592+
.args
593+
.assets
594+
.clone()
595+
.into_inner()
596+
.get(t.args.fee_asset_item as usize)
597+
.ok_or(pallet_xcm::Error::<Runtime>::Empty)?
598+
.clone()
599+
.id;
600+
601+
<PenpalA as PenpalAPallet>::PolkadotXcm::transfer_assets_using_type_and_then(
536602
t.signed_origin,
537603
bx!(t.args.dest.into()),
538-
bx!(t.args.beneficiary.into()),
539604
bx!(t.args.assets.into()),
540-
t.args.fee_asset_item,
605+
bx!(TransferType::DestinationReserve),
606+
bx!(remote_fee_id.into()),
607+
bx!(TransferType::DestinationReserve),
608+
bx!(VersionedXcm::from(
609+
Xcm::<()>::builder_unsafe()
610+
.deposit_asset(AllCounted(2), t.args.beneficiary)
611+
.build()
612+
)),
541613
t.args.weight_limit,
542614
)
543615
}
544616

545617
fn para_to_para_through_relay_limited_reserve_transfer_assets(
546618
t: ParaToParaThroughRelayTest,
547619
) -> DispatchResult {
548-
<PenpalA as PenpalAPallet>::PolkadotXcm::limited_reserve_transfer_assets(
620+
let Junction::Parachain(_) = *t.args.dest.chain_location().last().unwrap() else {
621+
unimplemented!("Destination is not a parachain?")
622+
};
623+
624+
type Runtime = <PenpalA as Chain>::Runtime;
625+
let remote_fee_id: AssetId = t
626+
.args
627+
.assets
628+
.clone()
629+
.into_inner()
630+
.get(t.args.fee_asset_item as usize)
631+
.ok_or(pallet_xcm::Error::<Runtime>::Empty)?
632+
.clone()
633+
.id;
634+
635+
let relay_location = VersionedLocation::from(Location::parent());
636+
637+
<PenpalA as PenpalAPallet>::PolkadotXcm::transfer_assets_using_type_and_then(
549638
t.signed_origin,
550639
bx!(t.args.dest.into()),
551-
bx!(t.args.beneficiary.into()),
552640
bx!(t.args.assets.into()),
553-
t.args.fee_asset_item,
641+
bx!(TransferType::RemoteReserve(relay_location.clone())),
642+
bx!(remote_fee_id.into()),
643+
bx!(TransferType::RemoteReserve(relay_location)),
644+
bx!(VersionedXcm::from(
645+
Xcm::<()>::builder_unsafe()
646+
.deposit_asset(AllCounted(1), t.args.beneficiary)
647+
.build()
648+
)),
554649
t.args.weight_limit,
555650
)
556651
}

cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/reserve_transfer.rs

Lines changed: 110 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -486,58 +486,153 @@ pub fn para_to_para_through_hop_receiver_assertions<Hop: Clone>(t: Test<PenpalA,
486486
}
487487

488488
fn relay_to_para_reserve_transfer_assets(t: RelayToParaTest) -> DispatchResult {
489-
<Westend as WestendPallet>::XcmPallet::limited_reserve_transfer_assets(
489+
let Junction::Parachain(_) = *t.args.dest.chain_location().last().unwrap() else {
490+
unimplemented!("Destination is not a parachain?")
491+
};
492+
493+
type Runtime = <Westend as Chain>::Runtime;
494+
let remote_fee_id: AssetId = t
495+
.args
496+
.assets
497+
.clone()
498+
.into_inner()
499+
.get(t.args.fee_asset_item as usize)
500+
.ok_or(pallet_xcm::Error::<Runtime>::Empty)?
501+
.clone()
502+
.id;
503+
504+
<Westend as WestendPallet>::XcmPallet::transfer_assets_using_type_and_then(
490505
t.signed_origin,
491506
bx!(t.args.dest.into()),
492-
bx!(t.args.beneficiary.into()),
493507
bx!(t.args.assets.into()),
494-
t.args.fee_asset_item,
508+
bx!(TransferType::LocalReserve),
509+
bx!(remote_fee_id.into()),
510+
bx!(TransferType::LocalReserve),
511+
bx!(VersionedXcm::from(
512+
Xcm::<()>::builder_unsafe()
513+
.deposit_asset(AllCounted(1), t.args.beneficiary)
514+
.build()
515+
)),
495516
t.args.weight_limit,
496517
)
497518
}
498519

499520
fn para_to_relay_reserve_transfer_assets(t: ParaToRelayTest) -> DispatchResult {
500-
<PenpalA as PenpalAPallet>::PolkadotXcm::limited_reserve_transfer_assets(
521+
type Runtime = <PenpalA as Chain>::Runtime;
522+
let remote_fee_id: AssetId = t
523+
.args
524+
.assets
525+
.clone()
526+
.into_inner()
527+
.get(t.args.fee_asset_item as usize)
528+
.ok_or(pallet_xcm::Error::<Runtime>::Empty)?
529+
.clone()
530+
.id;
531+
532+
<PenpalA as PenpalAPallet>::PolkadotXcm::transfer_assets_using_type_and_then(
501533
t.signed_origin,
502534
bx!(t.args.dest.into()),
503-
bx!(t.args.beneficiary.into()),
504535
bx!(t.args.assets.into()),
505-
t.args.fee_asset_item,
536+
bx!(TransferType::DestinationReserve),
537+
bx!(remote_fee_id.into()),
538+
bx!(TransferType::DestinationReserve),
539+
bx!(VersionedXcm::from(
540+
Xcm::<()>::builder_unsafe()
541+
.deposit_asset(AllCounted(1), t.args.beneficiary)
542+
.build()
543+
)),
506544
t.args.weight_limit,
507545
)
508546
}
509547

510548
fn system_para_to_para_reserve_transfer_assets(t: SystemParaToParaTest) -> DispatchResult {
511-
<AssetHubWestend as AssetHubWestendPallet>::PolkadotXcm::limited_reserve_transfer_assets(
549+
type Runtime = <AssetHubWestend as Chain>::Runtime;
550+
let remote_fee_id: AssetId = t
551+
.args
552+
.assets
553+
.clone()
554+
.into_inner()
555+
.get(t.args.fee_asset_item as usize)
556+
.ok_or(pallet_xcm::Error::<Runtime>::Empty)?
557+
.clone()
558+
.id;
559+
560+
<AssetHubWestend as AssetHubWestendPallet>::PolkadotXcm::transfer_assets_using_type_and_then(
512561
t.signed_origin,
513562
bx!(t.args.dest.into()),
514-
bx!(t.args.beneficiary.into()),
515563
bx!(t.args.assets.into()),
516-
t.args.fee_asset_item,
564+
bx!(TransferType::LocalReserve),
565+
bx!(remote_fee_id.into()),
566+
bx!(TransferType::LocalReserve),
567+
bx!(VersionedXcm::from(
568+
Xcm::<()>::builder_unsafe()
569+
.deposit_asset(AllCounted(2), t.args.beneficiary)
570+
.build()
571+
)),
517572
t.args.weight_limit,
518573
)
519574
}
520575

521576
fn para_to_system_para_reserve_transfer_assets(t: ParaToSystemParaTest) -> DispatchResult {
522-
<PenpalA as PenpalAPallet>::PolkadotXcm::limited_reserve_transfer_assets(
577+
type Runtime = <PenpalA as Chain>::Runtime;
578+
let remote_fee_id: AssetId = t
579+
.args
580+
.assets
581+
.clone()
582+
.into_inner()
583+
.get(t.args.fee_asset_item as usize)
584+
.ok_or(pallet_xcm::Error::<Runtime>::Empty)?
585+
.clone()
586+
.id;
587+
588+
<PenpalA as PenpalAPallet>::PolkadotXcm::transfer_assets_using_type_and_then(
523589
t.signed_origin,
524590
bx!(t.args.dest.into()),
525-
bx!(t.args.beneficiary.into()),
526591
bx!(t.args.assets.into()),
527-
t.args.fee_asset_item,
592+
bx!(TransferType::DestinationReserve),
593+
bx!(remote_fee_id.into()),
594+
bx!(TransferType::DestinationReserve),
595+
bx!(VersionedXcm::from(
596+
Xcm::<()>::builder_unsafe()
597+
.deposit_asset(AllCounted(2), t.args.beneficiary)
598+
.build()
599+
)),
528600
t.args.weight_limit,
529601
)
530602
}
531603

532604
fn para_to_para_through_relay_limited_reserve_transfer_assets(
533605
t: ParaToParaThroughRelayTest,
534606
) -> DispatchResult {
535-
<PenpalA as PenpalAPallet>::PolkadotXcm::limited_reserve_transfer_assets(
607+
let Junction::Parachain(_) = *t.args.dest.chain_location().last().unwrap() else {
608+
unimplemented!("Destination is not a parachain?")
609+
};
610+
611+
type Runtime = <PenpalA as Chain>::Runtime;
612+
let remote_fee_id: AssetId = t
613+
.args
614+
.assets
615+
.clone()
616+
.into_inner()
617+
.get(t.args.fee_asset_item as usize)
618+
.ok_or(pallet_xcm::Error::<Runtime>::Empty)?
619+
.clone()
620+
.id;
621+
622+
let relay_location = VersionedLocation::from(Location::parent());
623+
624+
<PenpalA as PenpalAPallet>::PolkadotXcm::transfer_assets_using_type_and_then(
536625
t.signed_origin,
537626
bx!(t.args.dest.into()),
538-
bx!(t.args.beneficiary.into()),
539627
bx!(t.args.assets.into()),
540-
t.args.fee_asset_item,
628+
bx!(TransferType::RemoteReserve(relay_location.clone())),
629+
bx!(remote_fee_id.into()),
630+
bx!(TransferType::RemoteReserve(relay_location)),
631+
bx!(VersionedXcm::from(
632+
Xcm::<()>::builder_unsafe()
633+
.deposit_asset(AllCounted(1), t.args.beneficiary)
634+
.build()
635+
)),
541636
t.args.weight_limit,
542637
)
543638
}

cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/asset_transfers.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ fn send_roc_usdt_and_weth_from_asset_hub_rococo_to_asset_hub_westend() {
146146
let assets: Assets =
147147
(Location::try_from(roc_at_asset_hub_rococo.clone()).unwrap(), amount).into();
148148
let fee_idx = 0;
149-
assert_ok!(send_assets_from_asset_hub_rococo(destination, assets, fee_idx));
149+
let transfer_type = TransferType::LocalReserve;
150+
assert_ok!(send_assets_from_asset_hub_rococo(destination, assets, fee_idx, transfer_type));
150151
});
151152

152153
// verify expected events on final destination
@@ -286,7 +287,8 @@ fn send_back_wnds_from_asset_hub_rococo_to_asset_hub_westend() {
286287
let destination = asset_hub_westend_location();
287288
let assets: Assets = (wnd_at_asset_hub_rococo.clone(), amount_to_send).into();
288289
let fee_idx = 0;
289-
assert_ok!(send_assets_from_asset_hub_rococo(destination, assets, fee_idx));
290+
let transfer_type = TransferType::DestinationReserve;
291+
assert_ok!(send_assets_from_asset_hub_rococo(destination, assets, fee_idx, transfer_type));
290292
});
291293

292294
AssetHubWestend::execute_with(|| {

cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/mod.rs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,19 +144,36 @@ pub(crate) fn send_assets_from_asset_hub_rococo(
144144
destination: Location,
145145
assets: Assets,
146146
fee_idx: u32,
147+
// For knowing what reserve to pick.
148+
// We only allow using the same transfer type for assets and fees right now.
149+
// And only `LocalReserve` or `DestinationReserve`.
150+
transfer_type: TransferType,
147151
) -> DispatchResult {
148152
let signed_origin =
149153
<AssetHubRococo as Chain>::RuntimeOrigin::signed(AssetHubRococoSender::get().into());
150154
let beneficiary: Location =
151155
AccountId32Junction { network: None, id: AssetHubWestendReceiver::get().into() }.into();
152156

157+
type Runtime = <AssetHubRococo as Chain>::Runtime;
158+
let remote_fee_id: AssetId = assets
159+
.clone()
160+
.into_inner()
161+
.get(fee_idx as usize)
162+
.ok_or(pallet_xcm::Error::<Runtime>::Empty)?
163+
.clone()
164+
.id;
165+
153166
AssetHubRococo::execute_with(|| {
154-
<AssetHubRococo as AssetHubRococoPallet>::PolkadotXcm::limited_reserve_transfer_assets(
167+
<AssetHubRococo as AssetHubRococoPallet>::PolkadotXcm::transfer_assets_using_type_and_then(
155168
signed_origin,
156169
bx!(destination.into()),
157-
bx!(beneficiary.into()),
158170
bx!(assets.into()),
159-
fee_idx,
171+
bx!(transfer_type.clone()),
172+
bx!(remote_fee_id.into()),
173+
bx!(transfer_type),
174+
bx!(VersionedXcm::from(
175+
Xcm::<()>::builder_unsafe().deposit_asset(AllCounted(1), beneficiary).build()
176+
)),
160177
WeightLimit::Unlimited,
161178
)
162179
})

0 commit comments

Comments
 (0)