Skip to content

Commit 43425df

Browse files
paritytech-release-backport-bot[bot]franciscoaguirrekarolk91
authored
[stable2506] Backport #9544 (#9599)
Backport #9544 into `stable2506` 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 f8cb94c commit 43425df

File tree

21 files changed

+430
-141
lines changed

21 files changed

+430
-141
lines changed

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

Lines changed: 102 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -515,35 +515,86 @@ fn relay_to_para_reserve_transfer_assets(t: RelayToParaTest) -> DispatchResult {
515515
unimplemented!("Destination is not a parachain?")
516516
};
517517

518+
type Runtime = <Rococo as Chain>::Runtime;
519+
let remote_fee_id: AssetId = t
520+
.args
521+
.assets
522+
.clone()
523+
.into_inner()
524+
.get(t.args.fee_asset_item as usize)
525+
.ok_or(pallet_xcm::Error::<Runtime>::Empty)?
526+
.clone()
527+
.id;
528+
518529
Dmp::make_parachain_reachable(para_id);
519-
<Rococo as RococoPallet>::XcmPallet::limited_reserve_transfer_assets(
530+
<Rococo as RococoPallet>::XcmPallet::transfer_assets_using_type_and_then(
520531
t.signed_origin,
521532
bx!(t.args.dest.into()),
522-
bx!(t.args.beneficiary.into()),
523533
bx!(t.args.assets.into()),
524-
t.args.fee_asset_item,
534+
bx!(TransferType::LocalReserve),
535+
bx!(remote_fee_id.into()),
536+
bx!(TransferType::LocalReserve),
537+
bx!(VersionedXcm::from(
538+
Xcm::<()>::builder_unsafe()
539+
.deposit_asset(AllCounted(1), t.args.beneficiary)
540+
.build()
541+
)),
525542
t.args.weight_limit,
526543
)
527544
}
528545

529546
fn para_to_relay_reserve_transfer_assets(t: ParaToRelayTest) -> DispatchResult {
530-
<PenpalA as PenpalAPallet>::PolkadotXcm::limited_reserve_transfer_assets(
547+
type Runtime = <PenpalA as Chain>::Runtime;
548+
let remote_fee_id: AssetId = t
549+
.args
550+
.assets
551+
.clone()
552+
.into_inner()
553+
.get(t.args.fee_asset_item as usize)
554+
.ok_or(pallet_xcm::Error::<Runtime>::Empty)?
555+
.clone()
556+
.id;
557+
558+
<PenpalA as PenpalAPallet>::PolkadotXcm::transfer_assets_using_type_and_then(
531559
t.signed_origin,
532560
bx!(t.args.dest.into()),
533-
bx!(t.args.beneficiary.into()),
534561
bx!(t.args.assets.into()),
535-
t.args.fee_asset_item,
562+
bx!(TransferType::DestinationReserve),
563+
bx!(remote_fee_id.into()),
564+
bx!(TransferType::DestinationReserve),
565+
bx!(VersionedXcm::from(
566+
Xcm::<()>::builder_unsafe()
567+
.deposit_asset(AllCounted(1), t.args.beneficiary)
568+
.build()
569+
)),
536570
t.args.weight_limit,
537571
)
538572
}
539573

540574
fn system_para_to_para_reserve_transfer_assets(t: SystemParaToParaTest) -> DispatchResult {
541-
<AssetHubRococo as AssetHubRococoPallet>::PolkadotXcm::limited_reserve_transfer_assets(
575+
type Runtime = <AssetHubRococo as Chain>::Runtime;
576+
let remote_fee_id: AssetId = t
577+
.args
578+
.assets
579+
.clone()
580+
.into_inner()
581+
.get(t.args.fee_asset_item as usize)
582+
.ok_or(pallet_xcm::Error::<Runtime>::Empty)?
583+
.clone()
584+
.id;
585+
586+
<AssetHubRococo as AssetHubRococoPallet>::PolkadotXcm::transfer_assets_using_type_and_then(
542587
t.signed_origin,
543588
bx!(t.args.dest.into()),
544-
bx!(t.args.beneficiary.into()),
545589
bx!(t.args.assets.into()),
546-
t.args.fee_asset_item,
590+
bx!(TransferType::LocalReserve),
591+
bx!(remote_fee_id.into()),
592+
bx!(TransferType::LocalReserve),
593+
bx!(VersionedXcm::from(
594+
Xcm::<()>::builder_unsafe()
595+
.deposit_asset(AllCounted(2), t.args.beneficiary)
596+
.build()
597+
)),
547598
t.args.weight_limit,
548599
)
549600
}
@@ -562,12 +613,29 @@ fn para_to_para_through_asset_hub_limited_reserve_transfer_assets(
562613
}
563614

564615
fn para_to_system_para_reserve_transfer_assets(t: ParaToSystemParaTest) -> DispatchResult {
565-
<PenpalA as PenpalAPallet>::PolkadotXcm::limited_reserve_transfer_assets(
616+
type Runtime = <PenpalA as Chain>::Runtime;
617+
let remote_fee_id: AssetId = t
618+
.args
619+
.assets
620+
.clone()
621+
.into_inner()
622+
.get(t.args.fee_asset_item as usize)
623+
.ok_or(pallet_xcm::Error::<Runtime>::Empty)?
624+
.clone()
625+
.id;
626+
627+
<PenpalA as PenpalAPallet>::PolkadotXcm::transfer_assets_using_type_and_then(
566628
t.signed_origin,
567629
bx!(t.args.dest.into()),
568-
bx!(t.args.beneficiary.into()),
569630
bx!(t.args.assets.into()),
570-
t.args.fee_asset_item,
631+
bx!(TransferType::DestinationReserve),
632+
bx!(remote_fee_id.into()),
633+
bx!(TransferType::DestinationReserve),
634+
bx!(VersionedXcm::from(
635+
Xcm::<()>::builder_unsafe()
636+
.deposit_asset(AllCounted(2), t.args.beneficiary)
637+
.build()
638+
)),
571639
t.args.weight_limit,
572640
)
573641
}
@@ -579,15 +647,34 @@ fn para_to_para_through_relay_limited_reserve_transfer_assets(
579647
unimplemented!("Destination is not a parachain?")
580648
};
581649

650+
type Runtime = <PenpalA as Chain>::Runtime;
651+
let remote_fee_id: AssetId = t
652+
.args
653+
.assets
654+
.clone()
655+
.into_inner()
656+
.get(t.args.fee_asset_item as usize)
657+
.ok_or(pallet_xcm::Error::<Runtime>::Empty)?
658+
.clone()
659+
.id;
660+
661+
let relay_location = VersionedLocation::from(Location::parent());
662+
582663
Rococo::ext_wrapper(|| {
583664
Dmp::make_parachain_reachable(para_id);
584665
});
585-
<PenpalA as PenpalAPallet>::PolkadotXcm::limited_reserve_transfer_assets(
666+
<PenpalA as PenpalAPallet>::PolkadotXcm::transfer_assets_using_type_and_then(
586667
t.signed_origin,
587668
bx!(t.args.dest.into()),
588-
bx!(t.args.beneficiary.into()),
589669
bx!(t.args.assets.into()),
590-
t.args.fee_asset_item,
670+
bx!(TransferType::RemoteReserve(relay_location.clone())),
671+
bx!(remote_fee_id.into()),
672+
bx!(TransferType::RemoteReserve(relay_location)),
673+
bx!(VersionedXcm::from(
674+
Xcm::<()>::builder_unsafe()
675+
.deposit_asset(AllCounted(1), t.args.beneficiary)
676+
.build()
677+
)),
591678
t.args.weight_limit,
592679
)
593680
}

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

Lines changed: 102 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -526,46 +526,114 @@ fn relay_to_para_reserve_transfer_assets(t: RelayToParaTest) -> DispatchResult {
526526
unimplemented!("Destination is not a parachain?")
527527
};
528528

529+
type Runtime = <Westend as Chain>::Runtime;
530+
let remote_fee_id: AssetId = t
531+
.args
532+
.assets
533+
.clone()
534+
.into_inner()
535+
.get(t.args.fee_asset_item as usize)
536+
.ok_or(pallet_xcm::Error::<Runtime>::Empty)?
537+
.clone()
538+
.id;
539+
529540
Dmp::make_parachain_reachable(para_id);
530-
<Westend as WestendPallet>::XcmPallet::limited_reserve_transfer_assets(
541+
<Westend as WestendPallet>::XcmPallet::transfer_assets_using_type_and_then(
531542
t.signed_origin,
532543
bx!(t.args.dest.into()),
533-
bx!(t.args.beneficiary.into()),
534544
bx!(t.args.assets.into()),
535-
t.args.fee_asset_item,
545+
bx!(TransferType::LocalReserve),
546+
bx!(remote_fee_id.into()),
547+
bx!(TransferType::LocalReserve),
548+
bx!(VersionedXcm::from(
549+
Xcm::<()>::builder_unsafe()
550+
.deposit_asset(AllCounted(1), t.args.beneficiary)
551+
.build()
552+
)),
536553
t.args.weight_limit,
537554
)
538555
}
539556

540557
fn para_to_relay_reserve_transfer_assets(t: ParaToRelayTest) -> DispatchResult {
541-
<PenpalA as PenpalAPallet>::PolkadotXcm::limited_reserve_transfer_assets(
558+
type Runtime = <PenpalA as Chain>::Runtime;
559+
let remote_fee_id: AssetId = t
560+
.args
561+
.assets
562+
.clone()
563+
.into_inner()
564+
.get(t.args.fee_asset_item as usize)
565+
.ok_or(pallet_xcm::Error::<Runtime>::Empty)?
566+
.clone()
567+
.id;
568+
569+
<PenpalA as PenpalAPallet>::PolkadotXcm::transfer_assets_using_type_and_then(
542570
t.signed_origin,
543571
bx!(t.args.dest.into()),
544-
bx!(t.args.beneficiary.into()),
545572
bx!(t.args.assets.into()),
546-
t.args.fee_asset_item,
573+
bx!(TransferType::DestinationReserve),
574+
bx!(remote_fee_id.into()),
575+
bx!(TransferType::DestinationReserve),
576+
bx!(VersionedXcm::from(
577+
Xcm::<()>::builder_unsafe()
578+
.deposit_asset(AllCounted(1), t.args.beneficiary)
579+
.build()
580+
)),
547581
t.args.weight_limit,
548582
)
549583
}
550584

551585
fn system_para_to_para_reserve_transfer_assets(t: SystemParaToParaTest) -> DispatchResult {
552-
<AssetHubWestend as AssetHubWestendPallet>::PolkadotXcm::limited_reserve_transfer_assets(
586+
type Runtime = <AssetHubWestend as Chain>::Runtime;
587+
let remote_fee_id: AssetId = t
588+
.args
589+
.assets
590+
.clone()
591+
.into_inner()
592+
.get(t.args.fee_asset_item as usize)
593+
.ok_or(pallet_xcm::Error::<Runtime>::Empty)?
594+
.clone()
595+
.id;
596+
597+
<AssetHubWestend as AssetHubWestendPallet>::PolkadotXcm::transfer_assets_using_type_and_then(
553598
t.signed_origin,
554599
bx!(t.args.dest.into()),
555-
bx!(t.args.beneficiary.into()),
556600
bx!(t.args.assets.into()),
557-
t.args.fee_asset_item,
601+
bx!(TransferType::LocalReserve),
602+
bx!(remote_fee_id.into()),
603+
bx!(TransferType::LocalReserve),
604+
bx!(VersionedXcm::from(
605+
Xcm::<()>::builder_unsafe()
606+
.deposit_asset(AllCounted(2), t.args.beneficiary)
607+
.build()
608+
)),
558609
t.args.weight_limit,
559610
)
560611
}
561612

562613
fn para_to_system_para_reserve_transfer_assets(t: ParaToSystemParaTest) -> DispatchResult {
563-
<PenpalA as PenpalAPallet>::PolkadotXcm::limited_reserve_transfer_assets(
614+
type Runtime = <PenpalA as Chain>::Runtime;
615+
let remote_fee_id: AssetId = t
616+
.args
617+
.assets
618+
.clone()
619+
.into_inner()
620+
.get(t.args.fee_asset_item as usize)
621+
.ok_or(pallet_xcm::Error::<Runtime>::Empty)?
622+
.clone()
623+
.id;
624+
625+
<PenpalA as PenpalAPallet>::PolkadotXcm::transfer_assets_using_type_and_then(
564626
t.signed_origin,
565627
bx!(t.args.dest.into()),
566-
bx!(t.args.beneficiary.into()),
567628
bx!(t.args.assets.into()),
568-
t.args.fee_asset_item,
629+
bx!(TransferType::DestinationReserve),
630+
bx!(remote_fee_id.into()),
631+
bx!(TransferType::DestinationReserve),
632+
bx!(VersionedXcm::from(
633+
Xcm::<()>::builder_unsafe()
634+
.deposit_asset(AllCounted(2), t.args.beneficiary)
635+
.build()
636+
)),
569637
t.args.weight_limit,
570638
)
571639
}
@@ -577,15 +645,34 @@ fn para_to_para_through_relay_limited_reserve_transfer_assets(
577645
unimplemented!("Destination is not a parachain?")
578646
};
579647

648+
type Runtime = <PenpalA as Chain>::Runtime;
649+
let remote_fee_id: AssetId = t
650+
.args
651+
.assets
652+
.clone()
653+
.into_inner()
654+
.get(t.args.fee_asset_item as usize)
655+
.ok_or(pallet_xcm::Error::<Runtime>::Empty)?
656+
.clone()
657+
.id;
658+
659+
let relay_location = VersionedLocation::from(Location::parent());
660+
580661
Westend::ext_wrapper(|| {
581662
Dmp::make_parachain_reachable(para_id);
582663
});
583-
<PenpalA as PenpalAPallet>::PolkadotXcm::limited_reserve_transfer_assets(
664+
<PenpalA as PenpalAPallet>::PolkadotXcm::transfer_assets_using_type_and_then(
584665
t.signed_origin,
585666
bx!(t.args.dest.into()),
586-
bx!(t.args.beneficiary.into()),
587667
bx!(t.args.assets.into()),
588-
t.args.fee_asset_item,
668+
bx!(TransferType::RemoteReserve(relay_location.clone())),
669+
bx!(remote_fee_id.into()),
670+
bx!(TransferType::RemoteReserve(relay_location)),
671+
bx!(VersionedXcm::from(
672+
Xcm::<()>::builder_unsafe()
673+
.deposit_asset(AllCounted(1), t.args.beneficiary)
674+
.build()
675+
)),
589676
t.args.weight_limit,
590677
)
591678
}

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
@@ -131,7 +131,8 @@ fn send_roc_from_asset_hub_rococo_to_asset_hub_westend() {
131131
let destination = asset_hub_westend_location();
132132
let assets: Assets = (roc_at_asset_hub_rococo.clone(), amount).into();
133133
let fee_idx = 0;
134-
assert_ok!(send_assets_from_asset_hub_rococo(destination, assets, fee_idx));
134+
let transfer_type = TransferType::LocalReserve;
135+
assert_ok!(send_assets_from_asset_hub_rococo(destination, assets, fee_idx, transfer_type));
135136
});
136137

137138
// verify expected events on final destination
@@ -210,7 +211,8 @@ fn send_back_wnds_usdt_and_weth_from_asset_hub_rococo_to_asset_hub_westend() {
210211
let destination = asset_hub_westend_location();
211212
let assets: Assets = (wnd_at_asset_hub_rococo.clone(), amount_to_send).into();
212213
let fee_idx = 0;
213-
assert_ok!(send_assets_from_asset_hub_rococo(destination, assets, fee_idx));
214+
let transfer_type = TransferType::DestinationReserve;
215+
assert_ok!(send_assets_from_asset_hub_rococo(destination, assets, fee_idx, transfer_type));
214216
});
215217

216218
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
@@ -173,19 +173,36 @@ pub(crate) fn send_assets_from_asset_hub_rococo(
173173
destination: Location,
174174
assets: Assets,
175175
fee_idx: u32,
176+
// For knowing what reserve to pick.
177+
// We only allow using the same transfer type for assets and fees right now.
178+
// And only `LocalReserve` or `DestinationReserve`.
179+
transfer_type: TransferType,
176180
) -> DispatchResult {
177181
let signed_origin =
178182
<AssetHubRococo as Chain>::RuntimeOrigin::signed(AssetHubRococoSender::get());
179183
let beneficiary: Location =
180184
AccountId32Junction { network: None, id: AssetHubWestendReceiver::get().into() }.into();
181185

186+
type Runtime = <AssetHubRococo as Chain>::Runtime;
187+
let remote_fee_id: AssetId = assets
188+
.clone()
189+
.into_inner()
190+
.get(fee_idx as usize)
191+
.ok_or(pallet_xcm::Error::<Runtime>::Empty)?
192+
.clone()
193+
.id;
194+
182195
AssetHubRococo::execute_with(|| {
183-
<AssetHubRococo as AssetHubRococoPallet>::PolkadotXcm::limited_reserve_transfer_assets(
196+
<AssetHubRococo as AssetHubRococoPallet>::PolkadotXcm::transfer_assets_using_type_and_then(
184197
signed_origin,
185198
bx!(destination.into()),
186-
bx!(beneficiary.into()),
187199
bx!(assets.into()),
188-
fee_idx,
200+
bx!(transfer_type.clone()),
201+
bx!(remote_fee_id.into()),
202+
bx!(transfer_type),
203+
bx!(VersionedXcm::from(
204+
Xcm::<()>::builder_unsafe().deposit_asset(AllCounted(1), beneficiary).build()
205+
)),
189206
WeightLimit::Unlimited,
190207
)
191208
})

0 commit comments

Comments
 (0)