Skip to content

Commit

Permalink
Remove any XCM v2 reference in codebase (#3131)
Browse files Browse the repository at this point in the history
* test: ✅ use XCM v3 as default in runtime tests

* test: ✅ use XCM v3 as default in mocks

* test: ✅ remove unused XCM v2 compatibility function deposit_asset in TS tests
  • Loading branch information
manuelmauro authored Jan 15, 2025
1 parent dc75e3b commit 66ae110
Show file tree
Hide file tree
Showing 41 changed files with 47 additions and 65 deletions.
2 changes: 1 addition & 1 deletion pallets/xcm-transactor/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ impl WrapVersion for CustomVersionWrapper {
xcm: impl Into<VersionedXcm<RuntimeCall>>,
) -> Result<VersionedXcm<RuntimeCall>, ()> {
let xcm_version: u32 =
frame_support::storage::unhashed::get(XCM_VERSION_ROOT_KEY).unwrap_or(2);
frame_support::storage::unhashed::get(XCM_VERSION_ROOT_KEY).unwrap_or(3);
let xcm_converted = xcm.into().into_version(xcm_version)?;
Ok(xcm_converted)
}
Expand Down
4 changes: 2 additions & 2 deletions runtime/moonbase/tests/xcm_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2085,7 +2085,7 @@ fn test_automatic_versioning_on_runtime_upgrade_with_relay() {
// This sets the default version, for not known destinations
assert_ok!(RelayChainPalletXcm::force_default_xcm_version(
relay_chain::RuntimeOrigin::root(),
Some(2)
Some(3)
));

// Wrap version, which sets VersionedStorage
Expand Down Expand Up @@ -2214,7 +2214,7 @@ fn test_automatic_versioning_on_runtime_upgrade_with_para_b() {
// This sets the default version, for not known destinations
assert_ok!(ParachainPalletXcm::force_default_xcm_version(
parachain::RuntimeOrigin::root(),
Some(2)
Some(3)
));
// Wrap version, which sets VersionedStorage
assert_ok!(<ParachainPalletXcm as WrapVersion>::wrap_version(
Expand Down
2 changes: 1 addition & 1 deletion runtime/moonbeam/tests/xcm_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1960,7 +1960,7 @@ fn test_automatic_versioning_on_runtime_upgrade_with_relay() {
// This sets the default version, for not known destinations
assert_ok!(RelayChainPalletXcm::force_default_xcm_version(
relay_chain::RuntimeOrigin::root(),
Some(2)
Some(3)
));

// Wrap version, which sets VersionedStorage
Expand Down
4 changes: 2 additions & 2 deletions runtime/moonriver/tests/xcm_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2119,7 +2119,7 @@ fn test_automatic_versioning_on_runtime_upgrade_with_relay() {
// This sets the default version, for not known destinations
assert_ok!(RelayChainPalletXcm::force_default_xcm_version(
relay_chain::RuntimeOrigin::root(),
Some(2)
Some(3)
));

// Wrap version, which sets VersionedStorage
Expand Down Expand Up @@ -2249,7 +2249,7 @@ fn test_automatic_versioning_on_runtime_upgrade_with_para_b() {
// This sets the default version, for not known destinations
assert_ok!(ParachainPalletXcm::force_default_xcm_version(
parachain::RuntimeOrigin::root(),
Some(2)
Some(3)
));
// Wrap version, which sets VersionedStorage
assert_ok!(<ParachainPalletXcm as WrapVersion>::wrap_version(
Expand Down
20 changes: 1 addition & 19 deletions test/helpers/xcm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,25 +348,7 @@ export class XcmFragment {
}

// Add a `DepositAsset` instruction
deposit_asset(max_assets = 1n, network: "Any" | XcmV3JunctionNetworkId["type"] = "Any"): this {
if (this.config.beneficiary == null) {
console.warn("!Building a DepositAsset instruction without a configured beneficiary");
}
this.instructions.push({
DepositAsset: {
assets: { Wild: "All" },
maxAssets: max_assets,
beneficiary: {
parents: 0,
interior: { X1: { AccountKey20: { network, key: this.config.beneficiary } } },
},
},
});
return this;
}

// Add a `DepositAsset` instruction for xcm v3
deposit_asset_v3(max_assets = 1n, network: XcmV3JunctionNetworkId["type"] | null = null): this {
deposit_asset(max_assets = 1n, network: XcmV3JunctionNetworkId["type"] | null = null): this {
if (this.config.beneficiary == null) {
console.warn("!Building a DepositAsset instruction without a configured beneficiary");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describeSuite({
// But since there is no error, and the deposit is on the error handler, the assets
// will be trapped
.with(function () {
return this.set_error_handler_with([this.deposit_asset_v3]);
return this.set_error_handler_with([this.deposit_asset]);
})
.clear_origin()
.as_v3();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describeSuite({
// BuyExecution does not charge for fees because we registered it for not doing so
// As a consequence the trapped assets will be entirely credited
.with(function () {
return this.set_error_handler_with([this.deposit_asset_v3]);
return this.set_error_handler_with([this.deposit_asset]);
})
.trap()
.as_v3();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describeSuite({
.buy_execution()
// Set an appendix to be executed after the XCM message is executed. No matter if errors
.with(function () {
return this.set_appendix_with([this.deposit_asset_v3]);
return this.set_appendix_with([this.deposit_asset]);
})
.as_v3();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describeSuite({
// As a consequence the trapped assets will be entirely credited
// The goal is to show appendix runs even if there is an error
.with(function () {
return this.set_appendix_with([this.deposit_asset_v3]);
return this.set_appendix_with([this.deposit_asset]);
})
.trap()
.as_v3();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describeSuite({
// As a consequence the trapped assets will be entirely credited
// The goal is to show appendix runs even if there is an error
.with(function () {
return this.set_appendix_with([this.deposit_asset_v3]);
return this.set_appendix_with([this.deposit_asset]);
})
.trap()
.as_v3();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ describeSuite({
.claim_asset()
.buy_execution()
// Deposit assets, this time correctly, on Alith
.deposit_asset_v3()
.deposit_asset()
.as_v3();

const receivedMessage: XcmVersionedXcm = context
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ describeSuite({
.reserve_asset_deposited()
.clear_origin()
.buy_execution()
.deposit_asset_v3()
.deposit_asset()
.as_v3();

// Send an XCM and create block to execute it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ describeSuite({
.reserve_asset_deposited()
.clear_origin()
.buy_execution()
.deposit_asset_v3()
.deposit_asset()
.as_v3();

// Send an XCM and create block to execute it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ describeSuite({
.withdraw_asset()
.clear_origin()
.buy_execution()
.deposit_asset_v3()
.deposit_asset()
.as_v3();

// Send an XCM and create block to execute it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ describeSuite({
.withdraw_asset()
.clear_origin()
.buy_execution()
.deposit_asset_v3()
.deposit_asset()
.as_v3();

const chargedWeight = await weightMessage(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ describeSuite({
.reserve_asset_deposited()
.clear_origin()
.buy_execution(1) // buy execution with asset at index 1
.deposit_asset_v3(2n)
.deposit_asset(2n)
.as_v3();

// Send an XCM and create block to execute it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ describeSuite({
.reserve_asset_deposited()
.clear_origin()
.buy_execution()
.deposit_asset_v3(2n)
.deposit_asset(2n)
.as_v3();

// Send an XCM and create block to execute it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ describeSuite({
.reserve_asset_deposited()
.clear_origin()
.buy_execution()
.deposit_asset_v3()
.deposit_asset()
.as_v3()
) as any
);
Expand All @@ -114,7 +114,7 @@ describeSuite({
.reserve_asset_deposited()
.clear_origin()
.buy_execution()
.deposit_asset_v3()
.deposit_asset()
.as_v3();

// Send an XCM and create block to execute it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ describeSuite({
.withdraw_asset()
.clear_origin()
.buy_execution()
.deposit_asset_v3(2n)
.deposit_asset(2n)
.as_v3();

// Mock the reception of the xcm message
Expand Down Expand Up @@ -258,7 +258,7 @@ describeSuite({
.withdraw_asset()
.clear_origin()
.buy_execution()
.deposit_asset_v3(2n)
.deposit_asset(2n)
.as_v3();

// Mock the reception of the xcm message
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ describeSuite({
.withdraw_asset()
.clear_origin()
.buy_execution()
.deposit_asset_v3(2n)
.deposit_asset(2n)
.as_v3();

// Mock the reception of the xcm message
Expand Down Expand Up @@ -254,7 +254,7 @@ describeSuite({
const xcmMessageToClaimAssets = new XcmFragment(claimConfig)
.claim_asset()
.buy_execution()
.deposit_asset_v3()
.deposit_asset()
.as_v3();

const balanceBefore = (
Expand Down Expand Up @@ -325,7 +325,7 @@ describeSuite({
const xcmMessageFailedClaim = new XcmFragment(failedClaimConfig)
.claim_asset()
.buy_execution()
.deposit_asset_v3()
.deposit_asset()
.as_v3();

await injectHrmpMessageAndSeal(context, paraId, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ describeSuite({
.withdraw_asset()
.clear_origin()
.buy_execution()
.deposit_asset_v3(limit)
.deposit_asset(limit)
.as_v3(),
});

Expand Down
2 changes: 1 addition & 1 deletion test/suites/dev/moonbase/test-xcm-v3/test-xcm-erc20-v3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ describeSuite({
.withdraw_asset()
.clear_origin()
.buy_execution()
.deposit_asset_v3(2n)
.deposit_asset(2n)
.as_v3();

// Mock the reception of the xcm message
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ describeSuite({
.withdraw_asset()
.clear_origin()
.buy_execution()
.deposit_asset_v3()
.deposit_asset()
.as_v4();

// Inject an XCM message that should be included in the next block but not executed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describeSuite({
// But since there is no error, and the deposit is on the error handler, the assets
// will be trapped
.with(function () {
return this.set_error_handler_with([this.deposit_asset_v3]);
return this.set_error_handler_with([this.deposit_asset]);
})
.clear_origin()
.as_v4();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describeSuite({
// BuyExecution does not charge for fees because we registered it for not doing so
// As a consequence the trapped assets will be entirely credited
.with(function () {
return this.set_error_handler_with([this.deposit_asset_v3]);
return this.set_error_handler_with([this.deposit_asset]);
})
.trap()
.as_v4();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describeSuite({
.buy_execution()
// Set an appendix to be executed after the XCM message is executed. No matter if errors
.with(function () {
return this.set_appendix_with([this.deposit_asset_v3]);
return this.set_appendix_with([this.deposit_asset]);
})
.as_v4();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describeSuite({
// As a consequence the trapped assets will be entirely credited
// The goal is to show appendix runs even if there is an error
.with(function () {
return this.set_appendix_with([this.deposit_asset_v3]);
return this.set_appendix_with([this.deposit_asset]);
})
.trap()
.as_v4();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describeSuite({
// As a consequence the trapped assets will be entirely credited
// The goal is to show appendix runs even if there is an error
.with(function () {
return this.set_appendix_with([this.deposit_asset_v3]);
return this.set_appendix_with([this.deposit_asset]);
})
.trap()
.as_v4();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ describeSuite({
.claim_asset()
.buy_execution()
// Deposit assets, this time correctly, on Alith
.deposit_asset_v3()
.deposit_asset()
.as_v4();

const receivedMessage: XcmVersionedXcm = context
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ describeSuite({
.reserve_asset_deposited()
.clear_origin()
.buy_execution()
.deposit_asset_v3()
.deposit_asset()
.as_v4();

// Send an XCM and create block to execute it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ describeSuite({
.reserve_asset_deposited()
.clear_origin()
.buy_execution()
.deposit_asset_v3()
.deposit_asset()
.as_v4();

// Send an XCM and create block to execute it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ describeSuite({
.withdraw_asset()
.clear_origin()
.buy_execution()
.deposit_asset_v3()
.deposit_asset()
.as_v4();

// Send an XCM and create block to execute it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ describeSuite({
.withdraw_asset()
.clear_origin()
.buy_execution()
.deposit_asset_v3()
.deposit_asset()
.as_v4();

const chargedWeight = await weightMessage(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ describeSuite({
.reserve_asset_deposited()
.clear_origin()
.buy_execution(1) // buy execution with asset at index 1
.deposit_asset_v3(2n)
.deposit_asset(2n)
.as_v4();

// Send an XCM and create block to execute it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ describeSuite({
.reserve_asset_deposited()
.clear_origin()
.buy_execution()
.deposit_asset_v3(2n)
.deposit_asset(2n)
.as_v4();

// Send an XCM and create block to execute it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ describeSuite({
.reserve_asset_deposited()
.clear_origin()
.buy_execution()
.deposit_asset_v3()
.deposit_asset()
.as_v3();

const dryRunXcm = await polkadotJs.call.dryRunApi.dryRunXcm(
Expand Down
Loading

0 comments on commit 66ae110

Please sign in to comment.