git.delta.rocks / unique-network / refs/commits / 396344dac004

difftreelog

Merge pull request #908 from UniqueNetwork/fix/xcmv3-tests

Yaroslav Bolyukin2023-03-30parents: #39430dd #a21076b.patch.diff
in: master
Fix/xcmv3 tests

8 files changed

modified.docker/additional/xcm-rococo/Dockerfile-xcm-opal-rococo.tempdiffbeforeafterboth
1FROM uniquenetwork/builder-polkadot:{{ POLKADOT_BUILD_BRANCH }} as polkadot1FROM uniquenetwork/builder-polkadot:{{ UNIQUEWEST_MAINNET_BRANCH }} as polkadot
2FROM uniquenetwork/builder-cumulus:{{ STATEMINE_BUILD_BRANCH }} as cumulus2FROM uniquenetwork/builder-cumulus:{{ WESTMINT_BUILD_BRANCH }} as cumulus
33
4# ===== Rust builder =====4# ===== Rust builder =====
5FROM ubuntu:22.04 as rust-builder5FROM ubuntu:22.04 as rust-builder
60 yarn install60 yarn install
6161
62COPY --from=builder-unique /unique_parachain/.docker/additional/xcm-rococo/launch-config-xcm-opal-rococo.json /polkadot-launch/launch-config.json62COPY --from=builder-unique /unique_parachain/.docker/additional/xcm-rococo/launch-config-xcm-opal-rococo.json /polkadot-launch/launch-config.json
63COPY --from=builder-unique /unique_parachain/.docker/xcm-config/5validators.jsonnet /polkadot-launch/5validators.jsonnet
6364
64COPY --from=builder-unique /unique_parachain/target/release/unique-collator /unique-chain/target/release/65COPY --from=builder-unique /unique_parachain/target/release/unique-collator /unique-chain/target/release/
65COPY --from=polkadot /unique_parachain/polkadot/target/release/polkadot /polkadot/target/release/66COPY --from=polkadot /unique_parachain/polkadot/target/release/polkadot /polkadot/target/release/
modified.docker/additional/xcm-rococo/Dockerfile-xcm-quartz-rococo.tempdiffbeforeafterboth
--- a/.docker/additional/xcm-rococo/Dockerfile-xcm-quartz-rococo.temp
+++ b/.docker/additional/xcm-rococo/Dockerfile-xcm-quartz-rococo.temp
@@ -1,4 +1,4 @@
-FROM uniquenetwork/builder-polkadot:{{ POLKADOT_BUILD_BRANCH }} as polkadot
+FROM uniquenetwork/builder-polkadot:{{ KUSAMA_MAINNET_BRANCH }} as polkadot
 FROM uniquenetwork/builder-moonbeam:{{ MOONRIVER_BUILD_BRANCH }} as moonbeam
 FROM uniquenetwork/builder-cumulus:{{ STATEMINE_BUILD_BRANCH }} as cumulus
 FROM uniquenetwork/builder-acala:{{ KARURA_BUILD_BRANCH }} as acala
modified.docker/additional/xcm-rococo/Dockerfile-xcm-unique-rococo.tempdiffbeforeafterboth
--- a/.docker/additional/xcm-rococo/Dockerfile-xcm-unique-rococo.temp
+++ b/.docker/additional/xcm-rococo/Dockerfile-xcm-unique-rococo.temp
@@ -1,4 +1,4 @@
-FROM uniquenetwork/builder-polkadot:{{ POLKADOT_BUILD_BRANCH }} as polkadot
+FROM uniquenetwork/builder-polkadot:{{ POLKADOT_MAINNET_BRANCH }} as polkadot
 FROM uniquenetwork/builder-moonbeam:{{ MOONBEAM_BUILD_BRANCH }} as moonbeam
 FROM uniquenetwork/builder-cumulus:{{ STATEMINT_BUILD_BRANCH }} as cumulus
 FROM uniquenetwork/builder-acala:{{ ACALA_BUILD_BRANCH }} as acala
modified.envdiffbeforeafterboth
--- a/.env
+++ b/.env
@@ -3,22 +3,22 @@
 POLKADOT_LAUNCH_BRANCH=unique-network
 RELAY_CHAIN_TYPE=westend
 
-POLKADOT_MAINNET_BRANCH=release-v0.9.36
-STATEMINT_BUILD_BRANCH=release-parachains-v9360
+POLKADOT_MAINNET_BRANCH=release-v0.9.37
+STATEMINT_BUILD_BRANCH=release-parachains-v9370
 ACALA_BUILD_BRANCH=2.12.0
-MOONBEAM_BUILD_BRANCH=runtime-2000
+MOONBEAM_BUILD_BRANCH=runtime-2100
 UNIQUE_MAINNET_BRANCH=release-v930033-fix-gas-price
 UNIQUE_REPLICA_FROM=wss://ws.unique.network:443
 
 KUSAMA_MAINNET_BRANCH=release-v0.9.37
-STATEMINE_BUILD_BRANCH=release-parachains-v9360
-KARURA_BUILD_BRANCH=release-karura-2.12.0
-MOONRIVER_BUILD_BRANCH=runtime-2100
+STATEMINE_BUILD_BRANCH=release-parachains-v9370
+KARURA_BUILD_BRANCH=release-karura-2.15.0
+MOONRIVER_BUILD_BRANCH=runtime-2201
 QUARTZ_MAINNET_BRANCH=release-v930034-fix-gas-price
 QUARTZ_REPLICA_FROM=wss://ws-quartz.unique.network:443
 
-UNIQUEWEST_MAINNET_BRANCH=release-v0.9.36
-WESTMINT_BUILD_BRANCH=parachains-v9370
+UNIQUEWEST_MAINNET_BRANCH=release-v0.9.40
+WESTMINT_BUILD_BRANCH=release-parachains-v9382
 OPAL_MAINNET_BRANCH=release-v937052
 OPAL_REPLICA_FROM=wss://ws-opal.unique.network:443
 
modified.github/workflows/xcm.ymldiffbeforeafterboth
--- a/.github/workflows/xcm.yml
+++ b/.github/workflows/xcm.yml
@@ -40,9 +40,9 @@
         id: create_matrix
         with:
           matrix: |
-            network {opal}, acala_version {${{ env.ACALA_BUILD_BRANCH }}}, moonbeam_version {${{ env.MOONBEAM_BUILD_BRANCH }}}, cumulus_version {${{ env.WESTMINT_BUILD_BRANCH }}}, runtest {testXcmOpal}
-            network {quartz}, acala_version {${{ env.KARURA_BUILD_BRANCH }}}, moonbeam_version {${{ env.MOONRIVER_BUILD_BRANCH }}}, cumulus_version {${{ env.STATEMINE_BUILD_BRANCH }}}, runtest {testXcmQuartz}
-            network {unique}, acala_version {${{ env.ACALA_BUILD_BRANCH }}}, moonbeam_version {${{ env.MOONBEAM_BUILD_BRANCH }}}, cumulus_version {${{ env.STATEMINT_BUILD_BRANCH }}}, runtest {testXcmUnique}
+            network {opal}, relay_branch {${{ env.UNIQUEWEST_MAINNET_BRANCH }}}, acala_version {${{ env.ACALA_BUILD_BRANCH }}}, moonbeam_version {${{ env.MOONBEAM_BUILD_BRANCH }}}, cumulus_version {${{ env.WESTMINT_BUILD_BRANCH }}}, runtest {testXcmOpal}
+            network {quartz}, relay_branch {${{ env.KUSAMA_MAINNET_BRANCH }}}, acala_version {${{ env.KARURA_BUILD_BRANCH }}}, moonbeam_version {${{ env.MOONRIVER_BUILD_BRANCH }}}, cumulus_version {${{ env.STATEMINE_BUILD_BRANCH }}}, runtest {testXcmQuartz}
+            network {unique}, relay_branch {${{ env.POLKADOT_MAINNET_BRANCH }}}, acala_version {${{ env.ACALA_BUILD_BRANCH }}}, moonbeam_version {${{ env.MOONBEAM_BUILD_BRANCH }}}, cumulus_version {${{ env.STATEMINT_BUILD_BRANCH }}}, runtest {testXcmUnique}
 
   xcm-build:
     
@@ -90,10 +90,10 @@
         uses: cuchi/jinja2-action@v1.2.0
         with:
           template: .docker/Dockerfile-polkadot.j2
-          output_file: .docker/Dockerfile-polkadot.${{ env.POLKADOT_BUILD_BRANCH }}.yml
+          output_file: .docker/Dockerfile-polkadot.${{ matrix.relay_branch }}.yml
           variables: |
             RUST_TOOLCHAIN=${{ env.RUST_TOOLCHAIN }}
-            POLKADOT_BUILD_BRANCH=${{ env.POLKADOT_BUILD_BRANCH }}
+            POLKADOT_BUILD_BRANCH=${{ matrix.relay_branch }}
 
       - name: Check if the dockerhub repository contains the needed version POLKADOT
         run: |
@@ -107,14 +107,14 @@
             echo "POLKADOT TAGS:"
             echo $POLKADOT_TAGS
           # Check correct version POLKADOT and build it if it doesn't exist in POLKADOT TAGS
-            if [[ ${POLKADOT_TAGS[*]} =~ (^|[[:space:]])"${{ env.POLKADOT_BUILD_BRANCH }}"($|[[:space:]]) ]]; then
+            if [[ ${POLKADOT_TAGS[*]} =~ (^|[[:space:]])"${{ matrix.relay_branch }}"($|[[:space:]]) ]]; then
                 echo "Repository has needed POLKADOT version";
-                docker pull uniquenetwork/builder-polkadot:${{ env.POLKADOT_BUILD_BRANCH }}
+                docker pull uniquenetwork/builder-polkadot:${{ matrix.relay_branch }}
             else
                 echo "Repository has not needed POLKADOT version, so build it";
-                cd .docker/ && docker build --no-cache --file ./Dockerfile-polkadot.${{ env.POLKADOT_BUILD_BRANCH }}.yml --tag uniquenetwork/builder-polkadot:${{ env.POLKADOT_BUILD_BRANCH }} .
+                cd .docker/ && docker build --no-cache --file ./Dockerfile-polkadot.${{ matrix.relay_branch }}.yml --tag uniquenetwork/builder-polkadot:${{ matrix.relay_branch }} .
                 echo "Push needed POLKADOT version to the repository";
-                docker push uniquenetwork/builder-polkadot:${{ env.POLKADOT_BUILD_BRANCH }}
+                docker push uniquenetwork/builder-polkadot:${{ matrix.relay_branch }}
             fi
         shell: bash
 
@@ -238,7 +238,7 @@
           variables: |
             RUST_TOOLCHAIN=${{ env.RUST_TOOLCHAIN }}
             NETWORK=${{ matrix.network }}
-            POLKADOT_BUILD_BRANCH=${{ env.POLKADOT_BUILD_BRANCH }}
+            POLKADOT_BUILD_BRANCH=${{ matrix.relay_branch }}
             POLKADOT_LAUNCH_BRANCH=${{ env.POLKADOT_LAUNCH_BRANCH }}           
             BRANCH=${{ github.head_ref }}
             ACALA_BUILD_BRANCH=${{ matrix.acala_version }}
modifiedtests/src/util/playgrounds/unique.tsdiffbeforeafterboth
--- a/tests/src/util/playgrounds/unique.ts
+++ b/tests/src/util/playgrounds/unique.ts
@@ -2951,6 +2951,10 @@
     await this.helper.executeExtrinsic(signer, `api.tx.${this.palletName}.limitedReserveTransferAssets`, [destination, beneficiary, assets, feeAssetItem, weightLimit], true);
   }
 
+  async setSafeXcmVersion(signer: TSigner, version: number) {
+    await this.helper.executeExtrinsic(signer, `api.tx.${this.palletName}.forceDefaultXcmVersion`, [version], true);
+  }
+
   async teleportAssets(signer: TSigner, destination: any, beneficiary: any, assets: any, feeAssetItem: number) {
     await this.helper.executeExtrinsic(signer, `api.tx.${this.palletName}.teleportAssets`, [destination, beneficiary, assets, feeAssetItem], true);
   }
modifiedtests/src/xcm/xcmQuartz.test.tsdiffbeforeafterboth
--- a/tests/src/xcm/xcmQuartz.test.ts
+++ b/tests/src/xcm/xcmQuartz.test.ts
@@ -49,6 +49,8 @@
 const USDT_ASSET_METADATA_MINIMAL_BALANCE = 1n;
 const USDT_ASSET_AMOUNT = 10_000_000_000_000_000_000_000_000n;
 
+const SAFE_XCM_VERSION = 2;
+
 describeXCM('[XCM] Integration test: Exchanging USDT with Statemine', () => {
   let alice: IKeyringPair;
   let bob: IKeyringPair;
@@ -69,9 +71,12 @@
 
 
   before(async () => {
-    await usingPlaygrounds(async (_helper, privateKey) => {
+    await usingPlaygrounds(async (helper, privateKey) => {
       alice = await privateKey('//Alice');
       bob = await privateKey('//Bob'); // sovereign account on Statemine(t) funds donor
+
+      // Set the default version to wrap the first message to other chains.
+      await helper.getSudo().xcm.setSafeXcmVersion(alice, SAFE_XCM_VERSION);
     });
 
     await usingRelayPlaygrounds(relayUrl, async (helper) => {
@@ -145,7 +150,7 @@
     // (fee for USDT XCM are paid in relay tokens)
     await usingRelayPlaygrounds(relayUrl, async (helper) => {
       const destination = {
-        V2: {
+        V1: {
           parents: 0,
           interior: {X1: {
             Parachain: QUARTZ_CHAIN,
@@ -154,7 +159,7 @@
         }};
 
       const beneficiary = {
-        V2: {
+        V1: {
           parents: 0,
           interior: {X1: {
             AccountId32: {
@@ -166,7 +171,7 @@
       };
 
       const assets = {
-        V2: [
+        V1: [
           {
             id: {
               Concrete: {
@@ -191,7 +196,7 @@
   itSub('Should connect and send USDT from Statemine to Quartz', async ({helper}) => {
     await usingStateminePlaygrounds(statemineUrl, async (helper) => {
       const dest = {
-        V2: {
+        V1: {
           parents: 1,
           interior: {X1: {
             Parachain: QUARTZ_CHAIN,
@@ -200,7 +205,7 @@
         }};
 
       const beneficiary = {
-        V2: {
+        V1: {
           parents: 0,
           interior: {X1: {
             AccountId32: {
@@ -212,7 +217,7 @@
       };
 
       const assets = {
-        V2: [
+        V1: [
           {
             id: {
               Concrete: {
@@ -314,7 +319,7 @@
 
     // the commission has been paid in parachain native token
     balanceQuartzFinal = await helper.balance.getSubstrate(alice.address);
-    console.log('[Quartz -> Statemine] transaction fees on Quartz: %s QTZ', helper.util.bigIntToDecimals(balanceQuartzFinal - balanceQuartzAfter));
+    console.log('[Quartz -> Statemine] transaction fees on Quartz: %s QTZ', helper.util.bigIntToDecimals(balanceQuartzAfter - balanceQuartzFinal));
     expect(balanceQuartzAfter > balanceQuartzFinal).to.be.true;
 
     await usingStateminePlaygrounds(statemineUrl, async (helper) => {
@@ -332,7 +337,7 @@
 
     await usingRelayPlaygrounds(relayUrl, async (helper) => {
       const destination = {
-        V2: {
+        V1: {
           parents: 0,
           interior: {X1: {
             Parachain: QUARTZ_CHAIN,
@@ -341,7 +346,7 @@
         }};
 
       const beneficiary = {
-        V2: {
+        V1: {
           parents: 0,
           interior: {X1: {
             AccountId32: {
@@ -353,7 +358,7 @@
       };
 
       const assets = {
-        V2: [
+        V1: [
           {
             id: {
               Concrete: {
@@ -466,11 +471,14 @@
     await usingPlaygrounds(async (helper, privateKey) => {
       alice = await privateKey('//Alice');
       [randomAccount] = await helper.arrange.createAccounts([0n], alice);
+
+      // Set the default version to wrap the first message to other chains.
+      await helper.getSudo().xcm.setSafeXcmVersion(alice, SAFE_XCM_VERSION);
     });
 
     await usingKaruraPlaygrounds(karuraUrl, async (helper) => {
       const destination = {
-        V2: {
+        V1: {
           parents: 1,
           interior: {
             X1: {
@@ -580,7 +588,7 @@
   itSub('Should connect to Karura and send QTZ back', async ({helper}) => {
     await usingKaruraPlaygrounds(karuraUrl, async (helper) => {
       const destination = {
-        V2: {
+        V1: {
           parents: 1,
           interior: {
             X2: [
@@ -636,15 +644,18 @@
   let alice: IKeyringPair;
 
   before(async () => {
-    await usingPlaygrounds(async (_helper, privateKey) => {
+    await usingPlaygrounds(async (helper, privateKey) => {
       alice = await privateKey('//Alice');
+
+      // Set the default version to wrap the first message to other chains.
+      await helper.getSudo().xcm.setSafeXcmVersion(alice, SAFE_XCM_VERSION);
     });
   });
 
   itSub('Quartz rejects KAR tokens from Karura', async ({helper}) => {
     await usingKaruraPlaygrounds(karuraUrl, async (helper) => {
       const destination = {
-        V2: {
+        V1: {
           parents: 1,
           interior: {
             X2: [
@@ -726,6 +737,10 @@
       [randomAccountQuartz] = await helper.arrange.createAccounts([0n], quartzDonor);
 
       balanceForeignQtzTokenInit = 0n;
+      
+      // Set the default version to wrap the first message to other chains.
+      const alice = quartzDonor;
+      await helper.getSudo().xcm.setSafeXcmVersion(alice, SAFE_XCM_VERSION);
     });
 
     await usingMoonriverPlaygrounds(moonriverUrl, async (helper) => {
@@ -905,7 +920,7 @@
   itSub('Should connect to Moonriver and send QTZ back', async ({helper}) => {
     await usingMoonriverPlaygrounds(moonriverUrl, async (helper) => {
       const asset = {
-        V2: {
+        V1: {
           id: {
             Concrete: {
               parents: 1,
@@ -920,7 +935,7 @@
         },
       };
       const destination = {
-        V2: {
+        V1: {
           parents: 1,
           interior: {
             X2: [
modifiedtests/src/xcm/xcmUnique.test.tsdiffbeforeafterboth
--- a/tests/src/xcm/xcmUnique.test.ts
+++ b/tests/src/xcm/xcmUnique.test.ts
@@ -49,6 +49,8 @@
 const USDT_ASSET_METADATA_MINIMAL_BALANCE = 1n;
 const USDT_ASSET_AMOUNT = 10_000_000_000_000_000_000_000_000n;
 
+const SAFE_XCM_VERSION = 2;
+
 describeXCM('[XCM] Integration test: Exchanging USDT with Statemint', () => {
   let alice: IKeyringPair;
   let bob: IKeyringPair;
@@ -69,9 +71,12 @@
 
 
   before(async () => {
-    await usingPlaygrounds(async (_helper, privateKey) => {
+    await usingPlaygrounds(async (helper, privateKey) => {
       alice = await privateKey('//Alice');
       bob = await privateKey('//Bob'); // sovereign account on Statemint funds donor
+
+      // Set the default version to wrap the first message to other chains.
+      await helper.getSudo().xcm.setSafeXcmVersion(alice, SAFE_XCM_VERSION);
     });
 
     await usingRelayPlaygrounds(relayUrl, async (helper) => {
@@ -145,7 +150,7 @@
     // (fee for USDT XCM are paid in relay tokens)
     await usingRelayPlaygrounds(relayUrl, async (helper) => {
       const destination = {
-        V2: {
+        V1: {
           parents: 0,
           interior: {X1: {
             Parachain: UNIQUE_CHAIN,
@@ -154,7 +159,7 @@
         }};
 
       const beneficiary = {
-        V2: {
+        V1: {
           parents: 0,
           interior: {X1: {
             AccountId32: {
@@ -166,7 +171,7 @@
       };
 
       const assets = {
-        V2: [
+        V1: [
           {
             id: {
               Concrete: {
@@ -191,7 +196,7 @@
   itSub('Should connect and send USDT from Statemint to Unique', async ({helper}) => {
     await usingStatemintPlaygrounds(statemintUrl, async (helper) => {
       const dest = {
-        V2: {
+        V1: {
           parents: 1,
           interior: {X1: {
             Parachain: UNIQUE_CHAIN,
@@ -200,7 +205,7 @@
         }};
 
       const beneficiary = {
-        V2: {
+        V1: {
           parents: 0,
           interior: {X1: {
             AccountId32: {
@@ -212,7 +217,7 @@
       };
 
       const assets = {
-        V2: [
+        V1: [
           {
             id: {
               Concrete: {
@@ -314,7 +319,7 @@
 
     // the commission has been paid in parachain native token
     balanceUniqueFinal = await helper.balance.getSubstrate(alice.address);
-    console.log('[Unique -> Statemint] transaction fees on Unique: %s UNQ', helper.util.bigIntToDecimals(balanceUniqueFinal - balanceUniqueAfter));
+    console.log('[Unique -> Statemint] transaction fees on Unique: %s UNQ', helper.util.bigIntToDecimals(balanceUniqueAfter - balanceUniqueFinal));
     expect(balanceUniqueAfter > balanceUniqueFinal).to.be.true;
 
     await usingStatemintPlaygrounds(statemintUrl, async (helper) => {
@@ -332,7 +337,7 @@
 
     await usingRelayPlaygrounds(relayUrl, async (helper) => {
       const destination = {
-        V2: {
+        V1: {
           parents: 0,
           interior: {X1: {
             Parachain: UNIQUE_CHAIN,
@@ -341,7 +346,7 @@
         }};
 
       const beneficiary = {
-        V2: {
+        V1: {
           parents: 0,
           interior: {X1: {
             AccountId32: {
@@ -353,7 +358,7 @@
       };
 
       const assets = {
-        V2: [
+        V1: [
           {
             id: {
               Concrete: {
@@ -466,11 +471,14 @@
     await usingPlaygrounds(async (helper, privateKey) => {
       alice = await privateKey('//Alice');
       [randomAccount] = await helper.arrange.createAccounts([0n], alice);
+
+      // Set the default version to wrap the first message to other chains.
+      await helper.getSudo().xcm.setSafeXcmVersion(alice, SAFE_XCM_VERSION);
     });
 
     await usingAcalaPlaygrounds(acalaUrl, async (helper) => {
       const destination = {
-        V2: {
+        V1: {
           parents: 1,
           interior: {
             X1: {
@@ -581,7 +589,7 @@
   itSub('Should connect to Acala and send UNQ back', async ({helper}) => {
     await usingAcalaPlaygrounds(acalaUrl, async (helper) => {
       const destination = {
-        V2: {
+        V1: {
           parents: 1,
           interior: {
             X2: [
@@ -637,15 +645,18 @@
   let alice: IKeyringPair;
 
   before(async () => {
-    await usingPlaygrounds(async (_helper, privateKey) => {
+    await usingPlaygrounds(async (helper, privateKey) => {
       alice = await privateKey('//Alice');
+
+      // Set the default version to wrap the first message to other chains.
+      await helper.getSudo().xcm.setSafeXcmVersion(alice, SAFE_XCM_VERSION);
     });
   });
 
   itSub('Unique rejects ACA tokens from Acala', async ({helper}) => {
     await usingAcalaPlaygrounds(acalaUrl, async (helper) => {
       const destination = {
-        V2: {
+        V1: {
           parents: 1,
           interior: {
             X2: [
@@ -727,6 +738,10 @@
       [randomAccountUnique] = await helper.arrange.createAccounts([0n], uniqueDonor);
 
       balanceForeignUnqTokenInit = 0n;
+
+      // Set the default version to wrap the first message to other chains.
+      const alice = uniqueDonor;
+      await helper.getSudo().xcm.setSafeXcmVersion(alice, SAFE_XCM_VERSION);
     });
 
     await usingMoonbeamPlaygrounds(moonbeamUrl, async (helper) => {
@@ -907,7 +922,7 @@
   itSub('Should connect to Moonbeam and send UNQ back', async ({helper}) => {
     await usingMoonbeamPlaygrounds(moonbeamUrl, async (helper) => {
       const asset = {
-        V2: {
+        V1: {
           id: {
             Concrete: {
               parents: 1,
@@ -922,7 +937,7 @@
         },
       };
       const destination = {
-        V2: {
+        V1: {
           parents: 1,
           interior: {
             X2: [