Skip to content

Commit 88b8057

Browse files
Pallet XCM - transfer_assets pre-ahm patch (#9137)
Addresses #9054 `transfer_assets` automatically figures out the reserve for a cross-chain transfer based on on-chain configurations like `IsReserve` and the asset ids. The Asset Hub Migration (AHM) will make it unable to return the correct reserve for the network native asset (DOT, KSM, WND, PAS) since its reserve will move from the Relay Chain to the Asset Hub. Before the migration, it'll be disabled to do network native reserve transfers via `transfer_assets`. After the migration, once everything is configured properly, it'll be patched to use the correct reserve. - [x] Patch - [x] Tests - [x] PRDoc
1 parent 93656ed commit 88b8057

11 files changed

Lines changed: 573 additions & 31 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cumulus/parachains/integration-tests/emulated/common/src/macros.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub use xcm::{
3939
},
4040
};
4141

42-
pub use xcm_executor::traits::DropAssets;
42+
pub use xcm_executor::traits::{DropAssets, TransferType};
4343

4444
// Cumulus
4545
pub use asset_test_utils;
@@ -851,16 +851,20 @@ macro_rules! test_dry_run_transfer_across_pk_bridge {
851851
// Give some initial funds.
852852
<Balances as $crate::macros::Mutate<_>>::set_balance(&who, initial_balance);
853853

854-
let call = RuntimeCall::PolkadotXcm($crate::macros::pallet_xcm::Call::transfer_assets {
855-
dest: Box::new($crate::macros::VersionedLocation::from($destination)),
856-
beneficiary: Box::new($crate::macros::VersionedLocation::from($crate::macros::Junction::AccountId32 {
854+
let beneficiary: $crate::macros::Location = $crate::macros::Junction::AccountId32 {
857855
id: who.clone().into(),
858856
network: None,
859-
})),
857+
}.into();
858+
859+
let call = RuntimeCall::PolkadotXcm($crate::macros::pallet_xcm::Call::transfer_assets_using_type_and_then {
860+
dest: Box::new($crate::macros::VersionedLocation::from($destination)),
860861
assets: Box::new($crate::macros::VersionedAssets::from(vec![
861862
($crate::macros::Parent, transfer_amount).into(),
862863
])),
863-
fee_asset_item: 0,
864+
assets_transfer_type: Box::new($crate::macros::TransferType::LocalReserve),
865+
remote_fees_id: Box::new($crate::macros::VersionedAssetId::from($crate::macros::Parent)),
866+
fees_transfer_type: Box::new($crate::macros::TransferType::LocalReserve),
867+
custom_xcm_on_dest: Box::new($crate::macros::VersionedXcm::<()>::from($crate::macros::Xcm::<()>::builder_unsafe().deposit_asset(AllCounted(1), beneficiary).build())),
864868
weight_limit: $crate::macros::Unlimited,
865869
});
866870
let origin = OriginCaller::system($crate::macros::RawOrigin::Signed(who));

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

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,23 +180,57 @@ fn system_para_limited_teleport_assets(t: SystemParaToRelayTest) -> DispatchResu
180180
}
181181

182182
fn para_to_system_para_transfer_assets(t: ParaToSystemParaTest) -> DispatchResult {
183-
<PenpalA as PenpalAPallet>::PolkadotXcm::transfer_assets(
183+
type Runtime = <PenpalA as Chain>::Runtime;
184+
let remote_fee_id: AssetId = t
185+
.args
186+
.assets
187+
.clone()
188+
.into_inner()
189+
.get(t.args.fee_asset_item as usize)
190+
.ok_or(pallet_xcm::Error::<Runtime>::Empty)?
191+
.clone()
192+
.id;
193+
194+
<PenpalA as PenpalAPallet>::PolkadotXcm::transfer_assets_using_type_and_then(
184195
t.signed_origin,
185196
bx!(t.args.dest.into()),
186-
bx!(t.args.beneficiary.into()),
187197
bx!(t.args.assets.into()),
188-
t.args.fee_asset_item,
198+
bx!(TransferType::Teleport),
199+
bx!(remote_fee_id.into()),
200+
bx!(TransferType::DestinationReserve),
201+
bx!(VersionedXcm::from(
202+
Xcm::<()>::builder_unsafe()
203+
.deposit_asset(AllCounted(2), t.args.beneficiary)
204+
.build()
205+
)),
189206
t.args.weight_limit,
190207
)
191208
}
192209

193210
fn system_para_to_para_transfer_assets(t: SystemParaToParaTest) -> DispatchResult {
194-
<AssetHubRococo as AssetHubRococoPallet>::PolkadotXcm::transfer_assets(
211+
type Runtime = <AssetHubRococo as Chain>::Runtime;
212+
let remote_fee_id: AssetId = t
213+
.args
214+
.assets
215+
.clone()
216+
.into_inner()
217+
.get(t.args.fee_asset_item as usize)
218+
.ok_or(pallet_xcm::Error::<Runtime>::Empty)?
219+
.clone()
220+
.id;
221+
222+
<AssetHubRococo as AssetHubRococoPallet>::PolkadotXcm::transfer_assets_using_type_and_then(
195223
t.signed_origin,
196224
bx!(t.args.dest.into()),
197-
bx!(t.args.beneficiary.into()),
198225
bx!(t.args.assets.into()),
199-
t.args.fee_asset_item,
226+
bx!(TransferType::Teleport),
227+
bx!(remote_fee_id.into()),
228+
bx!(TransferType::LocalReserve),
229+
bx!(VersionedXcm::from(
230+
Xcm::<()>::builder_unsafe()
231+
.deposit_asset(AllCounted(2), t.args.beneficiary)
232+
.build()
233+
)),
200234
t.args.weight_limit,
201235
)
202236
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ mod set_xcm_versions;
2626
mod swap;
2727
mod teleport;
2828
mod transact;
29+
mod transfer_assets_validation;
2930
mod treasury;
3031
mod xcm_fee_estimation;
3132

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

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -156,23 +156,57 @@ fn relay_to_system_para_limited_teleport_assets(t: RelayToSystemParaTest) -> Dis
156156
}
157157

158158
fn para_to_system_para_transfer_assets(t: ParaToSystemParaTest) -> DispatchResult {
159-
<PenpalA as PenpalAPallet>::PolkadotXcm::transfer_assets(
159+
type Runtime = <PenpalA as Chain>::Runtime;
160+
let remote_fee_id: AssetId = t
161+
.args
162+
.assets
163+
.clone()
164+
.into_inner()
165+
.get(t.args.fee_asset_item as usize)
166+
.ok_or(pallet_xcm::Error::<Runtime>::Empty)?
167+
.clone()
168+
.id;
169+
170+
<PenpalA as PenpalAPallet>::PolkadotXcm::transfer_assets_using_type_and_then(
160171
t.signed_origin,
161172
bx!(t.args.dest.into()),
162-
bx!(t.args.beneficiary.into()),
163173
bx!(t.args.assets.into()),
164-
t.args.fee_asset_item,
174+
bx!(TransferType::Teleport),
175+
bx!(remote_fee_id.into()),
176+
bx!(TransferType::DestinationReserve),
177+
bx!(VersionedXcm::from(
178+
Xcm::<()>::builder_unsafe()
179+
.deposit_asset(AllCounted(2), t.args.beneficiary)
180+
.build()
181+
)),
165182
t.args.weight_limit,
166183
)
167184
}
168185

169186
fn system_para_to_para_transfer_assets(t: SystemParaToParaTest) -> DispatchResult {
170-
<AssetHubWestend as AssetHubWestendPallet>::PolkadotXcm::transfer_assets(
187+
type Runtime = <AssetHubWestend as Chain>::Runtime;
188+
let remote_fee_id: AssetId = t
189+
.args
190+
.assets
191+
.clone()
192+
.into_inner()
193+
.get(t.args.fee_asset_item as usize)
194+
.ok_or(pallet_xcm::Error::<Runtime>::Empty)?
195+
.clone()
196+
.id;
197+
198+
<AssetHubWestend as AssetHubWestendPallet>::PolkadotXcm::transfer_assets_using_type_and_then(
171199
t.signed_origin,
172200
bx!(t.args.dest.into()),
173-
bx!(t.args.beneficiary.into()),
174201
bx!(t.args.assets.into()),
175-
t.args.fee_asset_item,
202+
bx!(TransferType::Teleport),
203+
bx!(remote_fee_id.into()),
204+
bx!(TransferType::LocalReserve),
205+
bx!(VersionedXcm::from(
206+
Xcm::<()>::builder_unsafe()
207+
.deposit_asset(AllCounted(2), t.args.beneficiary)
208+
.build()
209+
)),
176210
t.args.weight_limit,
177211
)
178212
}

0 commit comments

Comments
 (0)