Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Versioned*::from instead of concrete V* when using xcm::latest #6092

Merged
merged 8 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bridges/modules/xcm-bridge-hub-router/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -655,8 +655,8 @@ mod tests {
assert_eq!(
XcmBridgeHubRouter::get_messages(),
vec![(
VersionedLocation::V5((Parent, Parachain(1002)).into()),
vec![VersionedXcm::V5(
VersionedLocation::from(Location::new(1, Parachain(1002))),
vec![VersionedXcm::from(
Xcm::builder()
.withdraw_asset((Parent, 1_002_000))
.buy_execution((Parent, 1_002_000), Unlimited)
Expand Down
4 changes: 2 additions & 2 deletions bridges/modules/xcm-bridge-hub-router/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ impl InspectMessageQueues for TestToBridgeHubSender {
.iter()
.map(|(location, message)| {
(
VersionedLocation::V5(location.clone()),
vec![VersionedXcm::V5(message.clone())],
VersionedLocation::from(location.clone()),
vec![VersionedXcm::from(message.clone())],
)
})
.collect()
Expand Down
2 changes: 1 addition & 1 deletion cumulus/pallets/parachain-system/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1582,7 +1582,7 @@ impl<T: Config> InspectMessageQueues for Pallet<T> {
.map(|encoded_message| VersionedXcm::<()>::decode(&mut &encoded_message[..]).unwrap())
.collect();

vec![(VersionedLocation::V5(Parent.into()), messages)]
vec![(VersionedLocation::from(Location::parent()), messages)]
}
}

Expand Down
2 changes: 1 addition & 1 deletion cumulus/pallets/xcmp-queue/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,7 @@ impl<T: Config> InspectMessageQueues for Pallet<T> {
}

(
VersionedLocation::V5((Parent, Parachain(para_id.into())).into()),
VersionedLocation::from(Location::new(1, Parachain(para_id.into()))),
decoded_messages,
)
})
Expand Down
22 changes: 11 additions & 11 deletions cumulus/pallets/xcmp-queue/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ fn send_xcm_nested_works() {
XcmpQueue::take_outbound_messages(usize::MAX),
vec![(
HRMP_PARA_ID.into(),
(XcmpMessageFormat::ConcatenatedVersionedXcm, VersionedXcm::V5(good.clone()))
(XcmpMessageFormat::ConcatenatedVersionedXcm, VersionedXcm::from(good.clone()))
.encode(),
)]
);
Expand Down Expand Up @@ -512,7 +512,7 @@ fn hrmp_signals_are_prioritized() {
// Without a signal we get the messages in order:
let mut expected_msg = XcmpMessageFormat::ConcatenatedVersionedXcm.encode();
for _ in 0..31 {
expected_msg.extend(VersionedXcm::V5(message.clone()).encode());
expected_msg.extend(VersionedXcm::from(message.clone()).encode());
}

hypothetically!({
Expand Down Expand Up @@ -598,7 +598,7 @@ fn take_first_concatenated_xcm_good_recursion_depth_works() {
for _ in 0..MAX_XCM_DECODE_DEPTH - 1 {
good = Xcm(vec![SetAppendix(good)]);
}
let good = VersionedXcm::V5(good);
let good = VersionedXcm::from(good);

let page = good.encode();
assert_ok!(XcmpQueue::take_first_concatenated_xcm(&mut &page[..], &mut WeightMeter::new()));
Expand All @@ -611,7 +611,7 @@ fn take_first_concatenated_xcm_good_bad_depth_errors() {
for _ in 0..MAX_XCM_DECODE_DEPTH {
bad = Xcm(vec![SetAppendix(bad)]);
}
let bad = VersionedXcm::V5(bad);
let bad = VersionedXcm::from(bad);

let page = bad.encode();
assert_err!(
Expand Down Expand Up @@ -873,18 +873,18 @@ fn get_messages_works() {
queued_messages,
vec![
(
VersionedLocation::V5(other_destination),
VersionedLocation::from(other_destination),
vec![
VersionedXcm::V5(Xcm(vec![ClearOrigin])),
VersionedXcm::V5(Xcm(vec![ClearOrigin])),
VersionedXcm::from(Xcm(vec![ClearOrigin])),
VersionedXcm::from(Xcm(vec![ClearOrigin])),
],
),
(
VersionedLocation::V5(destination),
VersionedLocation::from(destination),
vec![
VersionedXcm::V5(Xcm(vec![ClearOrigin])),
VersionedXcm::V5(Xcm(vec![ClearOrigin])),
VersionedXcm::V5(Xcm(vec![ClearOrigin])),
VersionedXcm::from(Xcm(vec![ClearOrigin])),
VersionedXcm::from(Xcm(vec![ClearOrigin])),
VersionedXcm::from(Xcm(vec![ClearOrigin])),
],
),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -495,15 +495,15 @@ macro_rules! test_can_estimate_and_pay_exact_fees {
let local_xcm_weight = Runtime::query_xcm_weight(local_xcm).unwrap();
local_execution_fees = Runtime::query_weight_to_asset_fee(
local_xcm_weight,
VersionedAssetId::V5(Location::parent().into()),
VersionedAssetId::from(AssetId(Location::parent())),
)
.unwrap();
// We filter the result to get only the messages we are interested in.
let (destination_to_query, messages_to_query) = &result
.forwarded_xcms
.iter()
.find(|(destination, _)| {
*destination == VersionedLocation::V5(Location::new(1, [Parachain(1000)]))
*destination == VersionedLocation::from(Location::new(1, [Parachain(1000)]))
})
.unwrap();
assert_eq!(messages_to_query.len(), 1);
Expand All @@ -517,7 +517,7 @@ macro_rules! test_can_estimate_and_pay_exact_fees {
// These are set in the AssetHub closure.
let mut intermediate_execution_fees = 0;
let mut intermediate_delivery_fees = 0;
let mut intermediate_remote_message = VersionedXcm::V5(Xcm::<()>(Vec::new()));
let mut intermediate_remote_message = VersionedXcm::from(Xcm::<()>(Vec::new()));
<$asset_hub as TestExt>::execute_with(|| {
type Runtime = <$asset_hub as Chain>::Runtime;
type RuntimeCall = <$asset_hub as Chain>::RuntimeCall;
Expand All @@ -526,13 +526,13 @@ macro_rules! test_can_estimate_and_pay_exact_fees {
let weight = Runtime::query_xcm_weight(remote_message.clone()).unwrap();
intermediate_execution_fees = Runtime::query_weight_to_asset_fee(
weight,
VersionedAssetId::V5(Location::new(1, []).into()),
VersionedAssetId::from(AssetId(Location::new(1, []))),
)
.unwrap();

// We have to do this to turn `VersionedXcm<()>` into `VersionedXcm<RuntimeCall>`.
let xcm_program =
VersionedXcm::V5(Xcm::<RuntimeCall>::from(remote_message.clone().try_into().unwrap()));
VersionedXcm::from(Xcm::<RuntimeCall>::from(remote_message.clone().try_into().unwrap()));

// Now we get the delivery fees to the final destination.
let result =
Expand All @@ -541,7 +541,7 @@ macro_rules! test_can_estimate_and_pay_exact_fees {
.forwarded_xcms
.iter()
.find(|(destination, _)| {
*destination == VersionedLocation::V5(Location::new(1, [Parachain(2001)]))
*destination == VersionedLocation::from(Location::new(1, [Parachain(2001)]))
})
.unwrap();
// There's actually two messages here.
Expand All @@ -565,7 +565,7 @@ macro_rules! test_can_estimate_and_pay_exact_fees {

let weight = Runtime::query_xcm_weight(intermediate_remote_message.clone()).unwrap();
final_execution_fees =
Runtime::query_weight_to_asset_fee(weight, VersionedAssetId::V5(Parent.into()))
Runtime::query_weight_to_asset_fee(weight, VersionedAssetId::from(AssetId(Location::parent())))
.unwrap();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,12 @@ fn spend_roc_on_asset_hub() {
let teleport_call = RuntimeCall::Utility(pallet_utility::Call::<Runtime>::dispatch_as {
as_origin: bx!(RococoOriginCaller::system(RawOrigin::Signed(treasury_account))),
call: bx!(RuntimeCall::XcmPallet(pallet_xcm::Call::<Runtime>::teleport_assets {
dest: bx!(VersionedLocation::V5(asset_hub_location.clone())),
beneficiary: bx!(VersionedLocation::V5(treasury_location)),
assets: bx!(VersionedAssets::V5(
Asset { id: native_asset.clone().into(), fun: treasury_balance.into() }.into()
)),
dest: bx!(VersionedLocation::from(asset_hub_location.clone())),
beneficiary: bx!(VersionedLocation::from(treasury_location)),
assets: bx!(VersionedAssets::from(Assets::from(Asset {
id: native_asset.clone().into(),
fun: treasury_balance.into()
}))),
fee_asset_item: 0,
})),
});
Expand Down Expand Up @@ -115,7 +116,7 @@ fn spend_roc_on_asset_hub() {
asset_id: native_asset.into(),
}),
amount: treasury_spend_balance,
beneficiary: bx!(VersionedLocation::V5(alice_location)),
beneficiary: bx!(VersionedLocation::from(alice_location)),
valid_from: None,
});

Expand Down Expand Up @@ -173,7 +174,7 @@ fn create_and_claim_treasury_spend_in_usdt() {
let asset_hub_location =
v3::Location::new(0, v3::Junction::Parachain(AssetHubRococo::para_id().into()));
let root = <Rococo as Chain>::RuntimeOrigin::root();
// asset kind to be spend from the treasury.
// asset kind to be spent from the treasury.
let asset_kind = VersionedLocatableAsset::V3 {
location: asset_hub_location,
asset_id: v3::AssetId::Concrete(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ fn transfer_assets_para_to_para_through_ah_call(
dest: bx!(test.args.dest.into()),
assets: bx!(test.args.assets.clone().into()),
assets_transfer_type: bx!(TransferType::RemoteReserve(asset_hub_location.clone().into())),
remote_fees_id: bx!(VersionedAssetId::V5(AssetId(Location::new(1, [])))),
remote_fees_id: bx!(VersionedAssetId::from(AssetId(Location::new(1, [])))),
fees_transfer_type: bx!(TransferType::RemoteReserve(asset_hub_location.into())),
custom_xcm_on_dest: bx!(VersionedXcm::from(custom_xcm_on_dest)),
weight_limit: test.args.weight_limit,
Expand Down Expand Up @@ -139,7 +139,7 @@ fn multi_hop_works() {

// We get them from the PenpalA closure.
let mut delivery_fees_amount = 0;
let mut remote_message = VersionedXcm::V5(Xcm(Vec::new()));
let mut remote_message = VersionedXcm::from(Xcm(Vec::new()));
<PenpalA as TestExt>::execute_with(|| {
type Runtime = <PenpalA as Chain>::Runtime;
type OriginCaller = <PenpalA as Chain>::OriginCaller;
Expand All @@ -152,7 +152,7 @@ fn multi_hop_works() {
.forwarded_xcms
.iter()
.find(|(destination, _)| {
*destination == VersionedLocation::V5(Location::new(1, [Parachain(1000)]))
*destination == VersionedLocation::from(Location::new(1, [Parachain(1000)]))
})
.unwrap();
assert_eq!(messages_to_query.len(), 1);
Expand All @@ -166,7 +166,7 @@ fn multi_hop_works() {
// These are set in the AssetHub closure.
let mut intermediate_execution_fees = 0;
let mut intermediate_delivery_fees_amount = 0;
let mut intermediate_remote_message = VersionedXcm::V5(Xcm::<()>(Vec::new()));
let mut intermediate_remote_message = VersionedXcm::from(Xcm::<()>(Vec::new()));
<AssetHubRococo as TestExt>::execute_with(|| {
type Runtime = <AssetHubRococo as Chain>::Runtime;
type RuntimeCall = <AssetHubRococo as Chain>::RuntimeCall;
Expand All @@ -175,13 +175,14 @@ fn multi_hop_works() {
let weight = Runtime::query_xcm_weight(remote_message.clone()).unwrap();
intermediate_execution_fees = Runtime::query_weight_to_asset_fee(
weight,
VersionedAssetId::V5(Location::new(1, []).into()),
VersionedAssetId::from(AssetId(Location::new(1, []))),
)
.unwrap();

// We have to do this to turn `VersionedXcm<()>` into `VersionedXcm<RuntimeCall>`.
let xcm_program =
VersionedXcm::V5(Xcm::<RuntimeCall>::from(remote_message.clone().try_into().unwrap()));
let xcm_program = VersionedXcm::from(Xcm::<RuntimeCall>::from(
remote_message.clone().try_into().unwrap(),
));

// Now we get the delivery fees to the final destination.
let result =
Expand All @@ -190,7 +191,7 @@ fn multi_hop_works() {
.forwarded_xcms
.iter()
.find(|(destination, _)| {
*destination == VersionedLocation::V5(Location::new(1, [Parachain(2001)]))
*destination == VersionedLocation::from(Location::new(1, [Parachain(2001)]))
})
.unwrap();
// There's actually two messages here.
Expand All @@ -213,9 +214,11 @@ fn multi_hop_works() {
type Runtime = <PenpalA as Chain>::Runtime;

let weight = Runtime::query_xcm_weight(intermediate_remote_message.clone()).unwrap();
final_execution_fees =
Runtime::query_weight_to_asset_fee(weight, VersionedAssetId::V5(Parent.into()))
.unwrap();
final_execution_fees = Runtime::query_weight_to_asset_fee(
weight,
VersionedAssetId::from(AssetId(Location::parent())),
)
.unwrap();
});

// Dry-running is done.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fn create_and_claim_treasury_spend() {
ahw_xcm_config::LocationToAccountId::convert_location(&treasury_location).unwrap();
let asset_hub_location = Location::new(0, Parachain(AssetHubWestend::para_id().into()));
let root = <Westend as Chain>::RuntimeOrigin::root();
// asset kind to be spend from the treasury.
// asset kind to be spent from the treasury.
let asset_kind = VersionedLocatableAsset::V5 {
location: asset_hub_location,
asset_id: AssetId([PalletInstance(50), GeneralIndex(USDT_ID.into())].into()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ fn transfer_assets_para_to_para_through_ah_call(
dest: bx!(test.args.dest.into()),
assets: bx!(test.args.assets.clone().into()),
assets_transfer_type: bx!(TransferType::RemoteReserve(asset_hub_location.clone().into())),
remote_fees_id: bx!(VersionedAssetId::V5(AssetId(Location::parent()))),
remote_fees_id: bx!(VersionedAssetId::from(AssetId(Location::parent()))),
fees_transfer_type: bx!(TransferType::RemoteReserve(asset_hub_location.into())),
custom_xcm_on_dest: bx!(VersionedXcm::from(custom_xcm_on_dest)),
weight_limit: test.args.weight_limit,
Expand Down Expand Up @@ -141,7 +141,7 @@ fn multi_hop_works() {

// We get them from the PenpalA closure.
let mut delivery_fees_amount = 0;
let mut remote_message = VersionedXcm::V5(Xcm(Vec::new()));
let mut remote_message = VersionedXcm::from(Xcm(Vec::new()));
<PenpalA as TestExt>::execute_with(|| {
type Runtime = <PenpalA as Chain>::Runtime;
type OriginCaller = <PenpalA as Chain>::OriginCaller;
Expand All @@ -154,7 +154,7 @@ fn multi_hop_works() {
.forwarded_xcms
.iter()
.find(|(destination, _)| {
*destination == VersionedLocation::V5(Location::new(1, [Parachain(1000)]))
*destination == VersionedLocation::from(Location::new(1, [Parachain(1000)]))
})
.unwrap();
assert_eq!(messages_to_query.len(), 1);
Expand All @@ -168,7 +168,7 @@ fn multi_hop_works() {
// These are set in the AssetHub closure.
let mut intermediate_execution_fees = 0;
let mut intermediate_delivery_fees_amount = 0;
let mut intermediate_remote_message = VersionedXcm::V5(Xcm::<()>(Vec::new()));
let mut intermediate_remote_message = VersionedXcm::from(Xcm::<()>(Vec::new()));
<AssetHubWestend as TestExt>::execute_with(|| {
type Runtime = <AssetHubWestend as Chain>::Runtime;
type RuntimeCall = <AssetHubWestend as Chain>::RuntimeCall;
Expand All @@ -177,13 +177,14 @@ fn multi_hop_works() {
let weight = Runtime::query_xcm_weight(remote_message.clone()).unwrap();
intermediate_execution_fees = Runtime::query_weight_to_asset_fee(
weight,
VersionedAssetId::V5(Location::new(1, []).into()),
VersionedAssetId::from(AssetId(Location::new(1, []))),
)
.unwrap();

// We have to do this to turn `VersionedXcm<()>` into `VersionedXcm<RuntimeCall>`.
let xcm_program =
VersionedXcm::V5(Xcm::<RuntimeCall>::from(remote_message.clone().try_into().unwrap()));
let xcm_program = VersionedXcm::from(Xcm::<RuntimeCall>::from(
remote_message.clone().try_into().unwrap(),
));

// Now we get the delivery fees to the final destination.
let result =
Expand All @@ -192,7 +193,7 @@ fn multi_hop_works() {
.forwarded_xcms
.iter()
.find(|(destination, _)| {
*destination == VersionedLocation::V5(Location::new(1, [Parachain(2001)]))
*destination == VersionedLocation::from(Location::new(1, [Parachain(2001)]))
})
.unwrap();
// There's actually two messages here.
Expand All @@ -216,7 +217,7 @@ fn multi_hop_works() {

let weight = Runtime::query_xcm_weight(intermediate_remote_message.clone()).unwrap();
final_execution_fees =
Runtime::query_weight_to_asset_fee(weight, VersionedAssetId::V5(Parent.into()))
Runtime::query_weight_to_asset_fee(weight, VersionedAssetId::from(Location::parent()))
.unwrap();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -450,14 +450,14 @@ fn send_weth_asset_from_asset_hub_to_ethereum() {
)),
fun: Fungible(WETH_AMOUNT),
}];
let multi_assets = VersionedAssets::V5(Assets::from(assets));
let multi_assets = VersionedAssets::from(Assets::from(assets));

let destination = VersionedLocation::V5(Location::new(
let destination = VersionedLocation::from(Location::new(
2,
[GlobalConsensus(Ethereum { chain_id: CHAIN_ID })],
));

let beneficiary = VersionedLocation::V5(Location::new(
let beneficiary = VersionedLocation::from(Location::new(
0,
[AccountKey20 { network: None, key: ETHEREUM_DESTINATION_ADDRESS.into() }],
));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,14 +221,14 @@ fn send_weth_asset_from_asset_hub_to_ethereum() {
)),
fun: Fungible(TOKEN_AMOUNT),
}];
let versioned_assets = VersionedAssets::V5(Assets::from(assets));
let versioned_assets = VersionedAssets::from(Assets::from(assets));

let destination = VersionedLocation::V5(Location::new(
let destination = VersionedLocation::from(Location::new(
2,
[GlobalConsensus(Ethereum { chain_id: CHAIN_ID })],
));

let beneficiary = VersionedLocation::V5(Location::new(
let beneficiary = VersionedLocation::from(Location::new(
0,
[AccountKey20 { network: None, key: ETHEREUM_DESTINATION_ADDRESS.into() }],
));
Expand Down
Loading
Loading