Skip to content

Commit 613e00e

Browse files
authored
Revert "pallet-xcm: API changes to use VersionedAssetId instead of u32 to specify asset for fees" (#10458)
Reverts #10243 Following on the discussion at #10391, this change may find its place in future releases so reverting to not affect current master and to be reverted from stable2512 as well
1 parent a4b29e1 commit 613e00e

File tree

54 files changed

+623
-684
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+623
-684
lines changed

bridges/testing/environments/rococo-westend/bridges_rococo_westend.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ case "$1" in
367367
"$(jq --null-input '{ "V5": { "parents": 2, "interior": { "X2": [ { "GlobalConsensus": { ByGenesis: '$WESTEND_GENESIS_HASH' } }, { "Parachain": 1000 } ] } } }')" \
368368
"$(jq --null-input '{ "V5": { "parents": 0, "interior": { "X1": [{ "AccountId32": { "id": [212, 53, 147, 199, 21, 253, 211, 28, 97, 20, 26, 189, 4, 169, 159, 214, 130, 44, 133, 88, 133, 76, 205, 227, 154, 86, 132, 231, 165, 109, 162, 125] } }] } } }')" \
369369
"$(jq --null-input '{ "V5": [ { "id": { "parents": 1, "interior": "Here" }, "fun": { "Fungible": '$amount' } } ] }')" \
370-
"$(jq --null-input '{ "V5": { "parents": 1, "interior": "Here" } }')" \
370+
0 \
371371
"Unlimited"
372372
;;
373373
withdraw-reserve-assets-from-asset-hub-rococo-local)
@@ -380,7 +380,7 @@ case "$1" in
380380
"$(jq --null-input '{ "V5": { "parents": 2, "interior": { "X2": [ { "GlobalConsensus": { ByGenesis: '$WESTEND_GENESIS_HASH' } }, { "Parachain": 1000 } ] } } }')" \
381381
"$(jq --null-input '{ "V5": { "parents": 0, "interior": { "X1": [{ "AccountId32": { "id": [212, 53, 147, 199, 21, 253, 211, 28, 97, 20, 26, 189, 4, 169, 159, 214, 130, 44, 133, 88, 133, 76, 205, 227, 154, 86, 132, 231, 165, 109, 162, 125] } }] } } }')" \
382382
"$(jq --null-input '{ "V5": [ { "id": { "parents": 2, "interior": { "X1": [{ "GlobalConsensus": { ByGenesis: '$WESTEND_GENESIS_HASH' } }] } }, "fun": { "Fungible": '$amount' } } ] }')" \
383-
"$(jq --null-input '{ "V5": { "parents": 2, "interior": { "X1": [{ "GlobalConsensus": { ByGenesis: '$WESTEND_GENESIS_HASH' } }] } } }')" \
383+
0 \
384384
"Unlimited"
385385
;;
386386
reserve-transfer-assets-from-asset-hub-westend-local)
@@ -393,7 +393,7 @@ case "$1" in
393393
"$(jq --null-input '{ "V5": { "parents": 2, "interior": { "X2": [ { "GlobalConsensus": { ByGenesis: '$ROCOCO_GENESIS_HASH' } }, { "Parachain": 1000 } ] } } }')" \
394394
"$(jq --null-input '{ "V5": { "parents": 0, "interior": { "X1": [{ "AccountId32": { "id": [212, 53, 147, 199, 21, 253, 211, 28, 97, 20, 26, 189, 4, 169, 159, 214, 130, 44, 133, 88, 133, 76, 205, 227, 154, 86, 132, 231, 165, 109, 162, 125] } }] } } }')" \
395395
"$(jq --null-input '{ "V5": [ { "id": { "parents": 1, "interior": "Here" }, "fun": { "Fungible": '$amount' } } ] }')" \
396-
"$(jq --null-input '{ "V5": { "parents": 1, "interior": "Here" } }')" \
396+
0 \
397397
"Unlimited"
398398
;;
399399
withdraw-reserve-assets-from-asset-hub-westend-local)
@@ -406,7 +406,7 @@ case "$1" in
406406
"$(jq --null-input '{ "V5": { "parents": 2, "interior": { "X2": [ { "GlobalConsensus": { ByGenesis: '$ROCOCO_GENESIS_HASH' } }, { "Parachain": 1000 } ] } } }')" \
407407
"$(jq --null-input '{ "V5": { "parents": 0, "interior": { "X1": [{ "AccountId32": { "id": [212, 53, 147, 199, 21, 253, 211, 28, 97, 20, 26, 189, 4, 169, 159, 214, 130, 44, 133, 88, 133, 76, 205, 227, 154, 86, 132, 231, 165, 109, 162, 125] } }] } } }')" \
408408
"$(jq --null-input '{ "V5": [ { "id": { "parents": 2, "interior": { "X1": [{ "GlobalConsensus": { ByGenesis: '$ROCOCO_GENESIS_HASH' } }] } }, "fun": { "Fungible": '$amount' } } ] }')" \
409-
"$(jq --null-input '{ "V5": { "parents": 2, "interior": { "X1": [{ "GlobalConsensus": { ByGenesis: '$ROCOCO_GENESIS_HASH' } }] } } }')" \
409+
0 \
410410
"Unlimited"
411411
;;
412412
claim-rewards-bridge-hub-rococo-local)

bridges/testing/framework/utils/bridges.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,15 +284,15 @@ function limited_reserve_transfer_assets() {
284284
local destination=$3
285285
local beneficiary=$4
286286
local assets=$5
287-
local fee_asset_id=$6
287+
local fee_asset_item=$6
288288
local weight_limit=$7
289289
echo " calling limited_reserve_transfer_assets:"
290290
echo " url: ${url}"
291291
echo " seed: ${seed}"
292292
echo " destination: ${destination}"
293293
echo " beneficiary: ${beneficiary}"
294294
echo " assets: ${assets}"
295-
echo " fee_asset_id: ${fee_asset_id}"
295+
echo " fee_asset_item: ${fee_asset_item}"
296296
echo " weight_limit: ${weight_limit}"
297297
echo ""
298298
echo "--------------------------------------------------"
@@ -304,7 +304,7 @@ function limited_reserve_transfer_assets() {
304304
"${destination}" \
305305
"${beneficiary}" \
306306
"${assets}" \
307-
"${fee_asset_id}" \
307+
"${fee_asset_item}" \
308308
"${weight_limit}"
309309
}
310310

cumulus/parachains/common/src/impls.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ where
182182
.into(),
183183
),
184184
Box::new((Parent, imbalance).into()),
185-
Box::new(Parent.into()),
185+
0,
186186
WeightLimit::Unlimited,
187187
);
188188

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,14 @@ pub use crate::{ASSETS_PALLET_ID, USDT_ID};
6565

6666
#[macro_export]
6767
macro_rules! test_parachain_is_trusted_teleporter {
68-
( $sender_para:ty, vec![$( $receiver_para:ty ),+], ($assets:expr, $amount:expr), $fee_asset_id:expr, $xcm_call:ident ) => {
68+
( $sender_para:ty, vec![$( $receiver_para:ty ),+], ($assets:expr, $amount:expr), $xcm_call:ident ) => {
6969
$crate::macros::paste::paste! {
7070
// init Origin variables
7171
let sender = [<$sender_para Sender>]::get();
7272
let mut para_sender_balance_before =
7373
<$sender_para as $crate::macros::Chain>::account_data_of(sender.clone()).free;
7474
let origin = <$sender_para as $crate::macros::Chain>::RuntimeOrigin::signed(sender.clone());
75+
let fee_asset_item = 0;
7576
let weight_limit = $crate::macros::WeightLimit::Unlimited;
7677

7778
$(
@@ -92,7 +93,7 @@ macro_rules! test_parachain_is_trusted_teleporter {
9293
dest: Box::new(para_destination.clone().into()),
9394
beneficiary: Box::new(beneficiary.clone().into()),
9495
assets: Box::new($assets.clone().into()),
95-
fee_asset_id: Box::new($fee_asset_id.clone().into()),
96+
fee_asset_item: fee_asset_item,
9697
weight_limit: weight_limit.clone(),
9798
});
9899

@@ -207,14 +208,13 @@ macro_rules! test_parachain_is_trusted_teleporter {
207208

208209
#[macro_export]
209210
macro_rules! test_relay_is_trusted_teleporter {
210-
( $sender_relay:ty, vec![$( $receiver_para:ty ),+], $amount:expr, $xcm_call:ident ) => {
211+
( $sender_relay:ty, vec![$( $receiver_para:ty ),+], ($assets:expr, $amount:expr), $xcm_call:ident ) => {
211212
$crate::macros::paste::paste! {
212213
// init Origin variables
213214
let sender = [<$sender_relay Sender>]::get();
214215
let mut relay_sender_balance_before =
215216
<$sender_relay as $crate::macros::Chain>::account_data_of(sender.clone()).free;
216-
let assets: $crate::macros::Assets = ($crate::macros::Here, $amount).into();
217-
let fee_asset_id: $crate::macros::AssetId = ($crate::macros::Here).into();
217+
let fee_asset_item = 0;
218218
let weight_limit = $crate::macros::WeightLimit::Unlimited;
219219

220220
$(
@@ -234,8 +234,8 @@ macro_rules! test_relay_is_trusted_teleporter {
234234
$crate::macros::pallet_xcm::Call::$xcm_call {
235235
dest: Box::new(para_destination.clone().into()),
236236
beneficiary: Box::new(beneficiary.clone().into()),
237-
assets: Box::new(assets.clone().into()),
238-
fee_asset_id: Box::new(fee_asset_id.clone().into()),
237+
assets: Box::new($assets.clone().into()),
238+
fee_asset_item: fee_asset_item,
239239
weight_limit: weight_limit.clone(),
240240
});
241241

@@ -362,7 +362,7 @@ macro_rules! test_parachain_is_trusted_teleporter_for_relay {
362362
<$sender_para as $crate::macros::Chain>::account_data_of(sender.clone()).free;
363363
let origin = <$sender_para as $crate::macros::Chain>::RuntimeOrigin::signed(sender.clone());
364364
let assets: $crate::macros::Assets = ($crate::macros::Parent, $amount).into();
365-
let fee_asset_id: $crate::macros::AssetId = ($crate::macros::Parent).into();
365+
let fee_asset_item = 0;
366366
let weight_limit = $crate::macros::WeightLimit::Unlimited;
367367

368368
// We need to mint funds into the checking account of `$receiver_relay`
@@ -388,7 +388,7 @@ macro_rules! test_parachain_is_trusted_teleporter_for_relay {
388388
dest: Box::new(relay_destination.clone().into()),
389389
beneficiary: Box::new(beneficiary.clone().into()),
390390
assets: Box::new(assets.clone().into()),
391-
fee_asset_id: Box::new(fee_asset_id.clone().into()),
391+
fee_asset_item: fee_asset_item,
392392
weight_limit: weight_limit.clone(),
393393
});
394394

@@ -685,7 +685,7 @@ macro_rules! test_can_estimate_and_pay_exact_fees {
685685
$amount,
686686
($asset_id, $amount).into(),
687687
None,
688-
($asset_id).into(),
688+
0,
689689
),
690690
};
691691
let mut test = ParaToParaThroughAHTest::new(test_args);

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,18 +67,18 @@ pub fn xcm_transact_unpaid_execution(
6767
}
6868

6969
/// Helper method to get the non-fee asset used in multiple assets transfer
70-
pub fn non_fee_asset(assets: &Assets, fee_asset_id: &AssetId) -> Option<(Location, u128)> {
71-
let asset = assets.inner().into_iter().find(|a| a.id != *fee_asset_id)?;
70+
pub fn non_fee_asset(assets: &Assets, fee_idx: usize) -> Option<(Location, u128)> {
71+
let asset = assets.inner().into_iter().enumerate().find(|a| a.0 != fee_idx)?.1.clone();
7272
let asset_amount = match asset.fun {
7373
Fungible(amount) => amount,
7474
_ => return None,
7575
};
76-
Some((asset.id.0.clone(), asset_amount))
76+
Some((asset.id.0, asset_amount))
7777
}
7878

7979
/// Helper method to get the fee asset used in multiple assets transfer
80-
pub fn fee_asset(assets: &Assets, fee_asset_id: &AssetId) -> Option<(Location, u128)> {
81-
let asset = assets.inner().iter().find(|a| a.id == *fee_asset_id)?;
80+
pub fn fee_asset(assets: &Assets, fee_idx: usize) -> Option<(Location, u128)> {
81+
let asset = assets.get(fee_idx)?;
8282
let asset_amount = match asset.fun {
8383
Fungible(amount) => amount,
8484
_ => return None,

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

Lines changed: 18 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,8 @@ fn para_to_para_assethub_hop_assertions(t: ParaToParaThroughAHTest) {
5252
}
5353

5454
fn ah_to_para_transfer_assets(t: SystemParaToParaTest) -> DispatchResult {
55-
let fee: Asset = t
56-
.args
57-
.assets
58-
.inner()
59-
.iter()
60-
.find(|a| a.id == t.args.fee_asset_id)
61-
.cloned()
62-
.unwrap();
55+
let fee_idx = t.args.fee_asset_item as usize;
56+
let fee: Asset = t.args.assets.inner().get(fee_idx).cloned().unwrap();
6357
let custom_xcm_on_dest = Xcm::<()>(vec![DepositAsset {
6458
assets: Wild(AllCounted(t.args.assets.len() as u32)),
6559
beneficiary: t.args.beneficiary,
@@ -77,14 +71,8 @@ fn ah_to_para_transfer_assets(t: SystemParaToParaTest) -> DispatchResult {
7771
}
7872

7973
fn para_to_ah_transfer_assets(t: ParaToSystemParaTest) -> DispatchResult {
80-
let fee: Asset = t
81-
.args
82-
.assets
83-
.inner()
84-
.iter()
85-
.find(|a| a.id == t.args.fee_asset_id)
86-
.cloned()
87-
.unwrap();
74+
let fee_idx = t.args.fee_asset_item as usize;
75+
let fee: Asset = t.args.assets.inner().get(fee_idx).cloned().unwrap();
8876
let custom_xcm_on_dest = Xcm::<()>(vec![DepositAsset {
8977
assets: Wild(AllCounted(t.args.assets.len() as u32)),
9078
beneficiary: t.args.beneficiary,
@@ -102,14 +90,8 @@ fn para_to_ah_transfer_assets(t: ParaToSystemParaTest) -> DispatchResult {
10290
}
10391

10492
fn para_to_para_transfer_assets_through_ah(t: ParaToParaThroughAHTest) -> DispatchResult {
105-
let fee: Asset = t
106-
.args
107-
.assets
108-
.inner()
109-
.iter()
110-
.find(|a| a.id == t.args.fee_asset_id)
111-
.cloned()
112-
.unwrap();
93+
let fee_idx = t.args.fee_asset_item as usize;
94+
let fee: Asset = t.args.assets.inner().get(fee_idx).cloned().unwrap();
11395
let asset_hub_location: Location = PenpalA::sibling_location_of(AssetHubRococo::para_id());
11496
let custom_xcm_on_dest = Xcm::<()>(vec![DepositAsset {
11597
assets: Wild(AllCounted(t.args.assets.len() as u32)),
@@ -128,14 +110,8 @@ fn para_to_para_transfer_assets_through_ah(t: ParaToParaThroughAHTest) -> Dispat
128110
}
129111

130112
fn para_to_asset_hub_teleport_foreign_assets(t: ParaToSystemParaTest) -> DispatchResult {
131-
let fee: Asset = t
132-
.args
133-
.assets
134-
.inner()
135-
.iter()
136-
.find(|a| a.id == t.args.fee_asset_id)
137-
.cloned()
138-
.unwrap();
113+
let fee_idx = t.args.fee_asset_item as usize;
114+
let fee: Asset = t.args.assets.inner().get(fee_idx).cloned().unwrap();
139115
let custom_xcm_on_dest = Xcm::<()>(vec![DepositAsset {
140116
assets: Wild(AllCounted(t.args.assets.len() as u32)),
141117
beneficiary: t.args.beneficiary,
@@ -153,14 +129,8 @@ fn para_to_asset_hub_teleport_foreign_assets(t: ParaToSystemParaTest) -> Dispatc
153129
}
154130

155131
fn asset_hub_to_para_teleport_foreign_assets(t: SystemParaToParaTest) -> DispatchResult {
156-
let fee: Asset = t
157-
.args
158-
.assets
159-
.inner()
160-
.iter()
161-
.find(|a| a.id == t.args.fee_asset_id)
162-
.cloned()
163-
.unwrap();
132+
let fee_idx = t.args.fee_asset_item as usize;
133+
let fee: Asset = t.args.assets.inner().get(fee_idx).cloned().unwrap();
164134
let custom_xcm_on_dest = Xcm::<()>(vec![DepositAsset {
165135
assets: Wild(AllCounted(t.args.assets.len() as u32)),
166136
beneficiary: t.args.beneficiary,
@@ -232,6 +202,7 @@ fn transfer_foreign_assets_from_asset_hub_to_para() {
232202
(wnd_at_rococo_parachains.clone(), foreign_amount_to_send).into(),
233203
];
234204
let fee_asset_id = AssetId(Parent.into());
205+
let fee_asset_item = assets.iter().position(|a| a.id == fee_asset_id).unwrap() as u32;
235206

236207
// Init Test
237208
let test_args = TestContext {
@@ -243,7 +214,7 @@ fn transfer_foreign_assets_from_asset_hub_to_para() {
243214
native_amount_to_send,
244215
assets.into(),
245216
None,
246-
fee_asset_id,
217+
fee_asset_item,
247218
),
248219
};
249220
let mut test = SystemParaToParaTest::new(test_args);
@@ -386,6 +357,7 @@ fn transfer_foreign_assets_from_para_to_asset_hub() {
386357
(wnd_at_rococo_parachains.clone(), foreign_amount_to_send).into(),
387358
];
388359
let fee_asset_id = AssetId(Parent.into());
360+
let fee_asset_item = assets.iter().position(|a| a.id == fee_asset_id).unwrap() as u32;
389361

390362
// Init Test
391363
let test_args = TestContext {
@@ -397,7 +369,7 @@ fn transfer_foreign_assets_from_para_to_asset_hub() {
397369
native_amount_to_send,
398370
assets.into(),
399371
None,
400-
fee_asset_id,
372+
fee_asset_item,
401373
),
402374
};
403375
let mut test = ParaToSystemParaTest::new(test_args);
@@ -553,6 +525,7 @@ fn transfer_foreign_assets_from_para_to_para_through_asset_hub() {
553525
(wnd_at_rococo_parachains.clone(), wnd_to_send).into(),
554526
];
555527
let fee_asset_id: AssetId = roc_location.clone().into();
528+
let fee_asset_item = assets.iter().position(|a| a.id == fee_asset_id).unwrap() as u32;
556529

557530
// Init Test
558531
let test_args = TestContext {
@@ -564,7 +537,7 @@ fn transfer_foreign_assets_from_para_to_para_through_asset_hub() {
564537
roc_to_send,
565538
assets.into(),
566539
None,
567-
fee_asset_id,
540+
fee_asset_item,
568541
),
569542
};
570543
let mut test = ParaToParaThroughAHTest::new(test_args);
@@ -777,14 +750,8 @@ fn transfer_native_asset_from_relay_to_para_through_asset_hub() {
777750
);
778751
}
779752
fn transfer_assets_dispatchable(t: RelayToParaThroughAHTest) -> DispatchResult {
780-
let fee: Asset = t
781-
.args
782-
.assets
783-
.inner()
784-
.iter()
785-
.find(|a| a.id == t.args.fee_asset_id)
786-
.cloned()
787-
.unwrap();
753+
let fee_idx = t.args.fee_asset_item as usize;
754+
let fee: Asset = t.args.assets.inner().get(fee_idx).cloned().unwrap();
788755
let asset_hub_location = Rococo::child_location_of(AssetHubRococo::para_id());
789756
let context = RococoUniversalLocation::get();
790757

0 commit comments

Comments
 (0)