git.delta.rocks / unique-network / refs/commits / ae09c8df0c85

difftreelog

Merge branch 'develop' into feature/multi-assets-redone

Alexander Aksenov2022-09-15parents: #285030f #85b56f6.patch.diff
in: master

12 files changed

modified.github/workflows/ci-master.ymldiffbeforeafterboth
--- a/.github/workflows/ci-master.yml
+++ b/.github/workflows/ci-master.yml
@@ -18,16 +18,13 @@
     uses: ./.github/workflows/node-only-update_v2.yml
 
   forkless:
-    if: ${{ contains( github.event.pull_request.labels.*.name, 'forkless') }}
     uses: ./.github/workflows/forkless.yml
 
   canary:
-    if: ${{ contains( github.event.pull_request.labels.*.name, 'canary') }}
     uses: ./.github/workflows/canary.yml
     secrets: inherit # pass all secrets
 
   xcm:
-    if: ${{ contains( github.event.pull_request.labels.*.name, 'xcm') }}
     uses: ./.github/workflows/xcm.yml
     secrets: inherit # pass all secrets
 
deleted.github/workflows/market-test.ymldiffbeforeafterboth
--- a/.github/workflows/market-test.yml
+++ /dev/null
@@ -1,227 +0,0 @@
-name: market api tests
-
-# Controls when the action will run.
-on:
- # Triggers the workflow on push or pull request events but only for the master branch
-  pull_request:
-    branches:
-      - master
-    types:
-      - opened
-      - reopened
-      - synchronize   #commit(s) pushed to the pull request
-      - ready_for_review
-
-  # Allows you to run this workflow manually from the Actions tab
-  workflow_dispatch:
-
-
-concurrency:
-  group: ${{ github.workflow }}-${{ github.ref }}
-  cancel-in-progress: true
-
-# A workflow run is made up of one or more jobs that can run sequentially or in parallel
-jobs:
-
-  market_test:
-    # The type of runner that the job will run on
-    runs-on: [self-hosted-ci,large]
-    timeout-minutes: 1380
-    
-    strategy:
-      matrix:
-        include:
-          - network: "opal"
-            features: "opal-runtime"
-          - network: "quartz"
-            features: "quartz-runtime"
-          - network: "unique"
-            features: "unique-runtime"
-
-    name: draft job
-
-    continue-on-error: true         #Do not stop testing of matrix runs failed.  As it decided during PR review - it required 50/50& Let's check it with false.
-
-
-    steps:
-#      - name: Skip if pull request is in Draft
-        # `if: github.event.pull_request.draft == true` should be kept here, at
-        # the step level, rather than at the job level. The latter is not
-        # recommended because when the PR is moved from "Draft" to "Ready to
-        # review" the workflow will immediately be passing (since it was skipped),
-        # even though it hasn't actually ran, since it takes a few seconds for
-        # the workflow to start. This is also disclosed in:
-        # https://github.community/t/dont-run-actions-on-draft-pull-requests/16817/17
-        # That scenario would open an opportunity for the check to be bypassed:
-        # 1. Get your PR approved
-        # 2. Move it to Draft
-        # 3. Push whatever commits you want
-        # 4. Move it to "Ready for review"; now the workflow is passing (it was
-        #    skipped) and "Check reviews" is also passing (it won't be updated
-        #    until the workflow is finished)
-#        if: github.event.pull_request.draft == true
-#        run: exit 1
-
-      - name: Clean Workspace
-        uses: AutoModality/action-clean@v1.1.0
-
-      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
-      - name: Checkout master repo
-        uses: actions/checkout@master
-        with:
-          ref: ${{ github.head_ref }}  #Checking out head commit
-
-      - name: Checkout Market e2e tests
-        uses: actions/checkout@v3
-        with:
-          repository: 'UniqueNetwork/market-e2e-tests'
-          ssh-key: '${{ secrets.GH_PAT }}'
-          path: 'qa-tests'
-          ref: 'QA-65_maxandreev'
-
-      - name: Read .env file
-        uses: xom9ikk/dotenv@v1.0.2
-      
-      - name: Copy qa-tests/.env.example to qa-tests/.env
-        working-directory: qa-tests
-        run: cp .env.docker .env
-
-      - name: Show content of qa-test/.env
-        working-directory: qa-tests
-        run: cat .env
-
-      - name: Read qa -test .env file
-        uses: xom9ikk/dotenv@v1.0.2
-        with:
-          path: qa-tests/
-        
-      - name: Generate ENV related extend file for docker-compose
-        uses: cuchi/jinja2-action@v1.2.0
-        with:
-          template: qa-tests/.docker/docker-compose.tmp-market.j2
-          output_file: qa-tests/.docker/docker-compose.${{ matrix.network }}.yml
-          variables: |
-            REPO_URL=${{ github.server_url }}/${{ github.repository }}.git
-            RUST_TOOLCHAIN=${{ env.RUST_TOOLCHAIN }}
-            POLKADOT_BUILD_BRANCH=${{ env.POLKADOT_BUILD_BRANCH }}
-            FEATURE=${{ matrix.features }}
-            BRANCH=${{ github.head_ref }}
-
-
-      - name: Show build configuration
-        working-directory: qa-tests
-        run: cat .docker/docker-compose.${{ matrix.network }}.yml
-
-      - name: Start node-parachain
-        working-directory: qa-tests
-        run: docker-compose -f ".docker/docker-compose.market.yml" -f ".docker/docker-compose.${{ matrix.network }}.yml" up -d --build --remove-orphans --force-recreate node-parachain 
-
-      - name: Start nonce-app
-        working-directory: qa-tests
-        run: docker-compose -f ".docker/docker-compose.market.yml" up -d --build --remove-orphans --force-recreate nonce-app 
-     
-      - uses: actions/setup-node@v3
-        with:
-          node-version: 16
-
-      - name: Setup TypeScript
-        working-directory: qa-tests
-        run: |
-          npm install
-          npm install -g ts-node
-
-      - name: Copy qa-tests/.env.example to qa-tests/.env
-        working-directory: qa-tests
-        run: | 
-          rm -rf .env
-          cp .env.example .env
-      
-     
-      - name: Show content of qa-test/.env
-        working-directory: qa-tests
-        run: cat .env
-
-
-      - name: Read qa -test .env file
-        uses: xom9ikk/dotenv@v1.0.2
-        with:
-          path: qa-tests/
-
-      - name: Generate accounts
-        working-directory: qa-tests
-        run: ts-node ./src/scripts/create-market-accounts.ts
-
-      - name: Deploy contracts
-        run: |
-          cd qa-tests
-          ts-node ./src/scripts/deploy-contract.ts
-
-      - name: Import test data
-        working-directory: qa-tests
-        run: ts-node ./src/scripts/create-test-collections.ts
-
-      - name: Show content of qa-test .env
-        working-directory: qa-tests
-        run: cat .env
-
-      - name: Copy qa-tests/.env.example to qa-tests/.env
-        working-directory: qa-tests
-        run: |
-          rm -rf .env.docker
-          cp .env .env.docker
-          sed -i '/UNIQUE_WS_ENDPOINT/c UNIQUE_WS_ENDPOINT=ws://node-parachain:9944' .env.docker
-
-      - name: Read qa -test .env file
-        uses: xom9ikk/dotenv@v1.0.2
-        with:
-          path: qa-tests/
-
-      - name: local-market:start
-        run: docker-compose -f "qa-tests/.docker/docker-compose.market.yml" -f "qa-tests/.docker/docker-compose.${{ matrix.network }}.yml" up -d --build
-
-      - name: Wait for market readyness
-        working-directory: qa-tests
-        run: src/scripts/wait-market-ready.sh
-        shell: bash
-
-      - name: Install dependecies
-        working-directory: qa-tests
-        run: |
-          npm ci
-          npm install -D @playwright/test
-          npx playwright install-deps
-          npx playwright install
-          
-      - name: 
-        working-directory: qa-tests
-        run: |
-          npx playwright test --workers=8 --quiet .*.api.test.ts --reporter=github --config playwright.config.ts
-
-      - name: Show env variables
-        if: success() || failure()
-        run: printenv
-
-      - name: look up for report
-        if: success() || failure()
-        run: |
-          ls -la 
-          ls -la qa-tests/
-
-
-      - name: Stop running containers
-        if: always()                   # run this step always
-        run: docker-compose -f "qa-tests/.docker/docker-compose.market.yml" -f "qa-tests/.docker/docker-compose.${{ matrix.network }}.yml" down --volumes
-
-      - name: Remove builder cache
-        if: always()                   # run this step always
-        run: |
-          docker builder prune -f
-          docker system prune -f
-
-      - name: Clean Workspace
-        if: always()
-        uses: AutoModality/action-clean@v1.1.0
-
-
-
-
modified.github/workflows/market-test_v2.ymldiffbeforeafterboth
--- a/.github/workflows/market-test_v2.yml
+++ b/.github/workflows/market-test_v2.yml
@@ -45,7 +45,7 @@
           repository: 'UniqueNetwork/market-e2e-tests'
           ssh-key: ${{ secrets.GH_PAT }}
           path: 'qa-tests'
-          ref: 'ci_test_v2'
+          ref: 'master'
 
       - name: Read .env file
         uses: xom9ikk/dotenv@v1.0.2
modified.github/workflows/node-only-update_v2.ymldiffbeforeafterboth
before ยท .github/workflows/node-only-update_v2.yml
1name: nodes-only update23# Controls when the action will run.4on:5  workflow_call:6#Define Workflow variables7env:8  REPO_URL: ${{ github.server_url }}/${{ github.repository }}910# A workflow run is made up of one or more jobs that can run sequentially or in parallel11jobs:1213  execution-marix:1415    name: execution matrix1617    runs-on: self-hosted-ci18    outputs:19      matrix: ${{ steps.create_matrix.outputs.matrix }}2021    steps:2223      - name: Clean Workspace24        uses: AutoModality/action-clean@v1.1.02526      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it27      - uses: actions/checkout@v328        with:29          ref: ${{ github.head_ref }}  #Checking out head commit3031      - name: Read .env file32        uses: xom9ikk/dotenv@v1.0.23334      - name: Create Execution matrix35        uses: fabiocaccamo/create-matrix-action@v236        id: create_matrix37        with:38          matrix: |39            network {opal}, runtime {opal}, features {opal-runtime}, mainnet_branch {${{ env.QUARTZ_MAINNET_TAG }}}40            network {quartz}, runtime {quartz}, features {quartz-runtime}, mainnet_branch {${{ env.QUARTZ_MAINNET_TAG }}}41            network {unique}, runtime {unique}, features {unique-runtime}, mainnet_branch {${{ env.UNIQUE_MAINNET_TAG }}}42434445  forkless-update-nodata:46    needs: execution-marix47    # The type of runner that the job will run on48    runs-on: [self-hosted-ci,large]49505152    timeout-minutes: 13805354    name: ${{ matrix.network }}5556    continue-on-error: true         #Do not stop testing of matrix runs failed.  As it decided during PR review - it required 50/50& Let's check it with false.5758    strategy:59      matrix:60        include: ${{fromJson(needs.prepare-execution-marix.outputs.matrix)}}6162    steps:6364      - name: Clean Workspace65        uses: AutoModality/action-clean@v1.1.06667      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it68      - uses: actions/checkout@v369        with:70          ref: ${{ github.head_ref }}  #Checking out head commit7172      - name: Read .env file73        uses: xom9ikk/dotenv@v1.0.27475      - name: Generate ENV related extend file for docker-compose76        uses: cuchi/jinja2-action@v1.2.077        with:78          template: .docker/docker-compose.tmp-node.j279          output_file: .docker/docker-compose.node.${{ matrix.network }}.yml80          variables: |81            REPO_URL=${{ github.server_url }}/${{ github.repository }}.git82            RUST_TOOLCHAIN=${{ env.RUST_TOOLCHAIN }}83            POLKADOT_BUILD_BRANCH=${{ env.POLKADOT_BUILD_BRANCH }}84            POLKADOT_MAINNET_BRANCH=${{ env.POLKADOT_MAINNET_BRANCH }}85            MAINNET_TAG=${{ matrix.mainnet_tag }}86            MAINNET_BRANCH=${{ matrix.mainnet_branch }}87            FEATURE=${{ matrix.features }}88            RUNTIME=${{ matrix.runtime }}89            BRANCH=${{ github.head_ref }}9091      - name: Show build configuration92        run: cat .docker/docker-compose.node.${{ matrix.network }}.yml9394      - name: Generate launch-config-forkless-nodata.json95        uses: cuchi/jinja2-action@v1.2.096        with:97          template: .docker/forkless-config/launch-config-forkless-nodata.j298          output_file: .docker/launch-config-forkless-nodata.json99          variables: |100            FEATURE=${{ matrix.features }}101            RUNTIME=${{ matrix.runtime }}102103      - name: Show launch-config-forkless configuration104        run: cat .docker/launch-config-forkless-nodata.json105106      - uses: actions/setup-node@v3107        with:108          node-version: 16109110      - name: Build the stack111        run: docker-compose -f ".docker/docker-compose-forkless.yml" -f ".docker/docker-compose.node.${{ matrix.network }}.yml" up -d --build --remove-orphans --force-recreate --timeout 300112113      #  ๐Ÿš€ POLKADOT LAUNCH COMPLETE ๐Ÿš€114      - name: Check if docker logs consist messages related to testing of Node Parachain Upgrade.115        if: success()116        run: |117          counter=160118          function check_container_status {119                docker inspect -f {{.State.Running}} node-parachain120          }121          function do_docker_logs {122                docker logs --details node-parachain  2>&1123          }124          function is_started {125                if [ "$(check_container_status)" == "true" ]; then126                        echo "Container: node-parachain RUNNING";127                        echo "Check Docker logs"128                        DOCKER_LOGS=$(do_docker_logs)129                        if [[ ${DOCKER_LOGS} = *"POLKADOT LAUNCH COMPLETE"* ]];then130                                echo "๐Ÿš€ POLKADOT LAUNCH COMPLETE ๐Ÿš€"131                                return 0132                        else133                                echo "Message not found in logs output, repeating..."134                                return 1135                        fi136                else137                        echo "Container node-parachain NOT RUNNING"138                        echo "Halting all future checks"139                        exit 1140                fi141          echo "something goes wrong"142          exit 1143          }144          while ! is_started; do145                echo "Waiting for special message in log files "146                sleep 30s147                counter=$(( $counter - 1 ))148                echo "Counter: $counter"149                if [ "$counter" -gt "0" ]; then150                         continue151                else152                         break153                fi154          done155          echo "Halting script"156          exit 0157        shell: bash158159      - name: Run tests before Node Parachain upgrade160        working-directory: tests161        run: |162          yarn install163          yarn add mochawesome164          node scripts/readyness.js165          echo "Ready to start tests"166          yarn polkadot-types167          NOW=$(date +%s) && yarn test --reporter mochawesome --reporter-options reportFilename=test-${NOW}168        env:169          RPC_URL: http://127.0.0.1:9933/170171      - name: Test Report Before Node upgrade172        uses: phoenix-actions/test-reporting@v8173        id: test-report-before174        if: success() || failure()    # run this step even if previous step failed175        with:176          name: Tests before node upgrade ${{ matrix.network }}            # Name of the check run which will be created177          path: tests/mochawesome-report/test-*.json    # Path to test results178          reporter: mochawesome-json179          fail-on-error: 'false'180181      - name: Send SIGUSR1 to polkadotlaunch process182        if: success() || failure()183        run: |184          #Get PID of polkadot-launch185          PID=$(docker exec node-parachain pidof 'polkadot-launch')186          echo "Polkadot-launch PID: $PID"187          #Send SIGUSR1 signal to $PID188          docker exec node-parachain kill -SIGUSR1 ${PID}189190      #  ๐ŸŒ— All parachain collators restarted with the new binaries.191      - name: Check if docker logs consist messages related to testing of Node Parachain Upgrade.192        if: success()193        run: |194          counter=160195          function check_container_status {196                docker inspect -f {{.State.Running}} node-parachain197          }198          function do_docker_logs {199                docker logs --details node-parachain  2>&1200          }201          function is_started {202                if [ "$(check_container_status)" == "true" ]; then203                        echo "Container: node-parachain RUNNING";204                        echo "Check Docker logs"205                        DOCKER_LOGS=$(do_docker_logs)206                        if [[ ${DOCKER_LOGS} = *"All parachain collators restarted with the new binaries."* ]];then207                                echo "๐ŸŒ— All parachain collators restarted with the new binaries."208                                return 0209                        else210                                echo "Message not found in logs output, repeating..."211                                return 1212                        fi213                else214                        echo "Container node-parachain NOT RUNNING"215                        echo "Halting all future checks"216                        exit 1217                fi218          echo "something goes wrong"219          exit 1220          }221          while ! is_started; do222                echo "Waiting for special message in log files "223                sleep 30s224                counter=$(( $counter - 1 ))225                echo "Counter: $counter"226                if [ "$counter" -gt "0" ]; then227                         continue228                else229                         break230                fi231          done232          echo "Halting script"233          exit 0234        shell: bash235236      - name: Run tests after Node Parachain upgrade237        working-directory: tests238        run: |239          yarn install240          yarn add mochawesome241          node scripts/readyness.js242          echo "Ready to start tests"243          yarn polkadot-types244          NOW=$(date +%s) && yarn test --reporter mochawesome --reporter-options reportFilename=test-${NOW}245        env:246          RPC_URL: http://127.0.0.1:9933/247248      - name: Test Report After Node upgrade249        uses: phoenix-actions/test-reporting@v8250        id: test-report-after251        if: success() || failure()    # run this step even if previous step failed252        with:253          name: Tests after node upgrade ${{ matrix.network }}            # Name of the check run which will be created254          path: tests/mochawesome-report/test-*.json    # Path to test results255          reporter: mochawesome-json256          fail-on-error: 'false'257258259      - name: Stop running containers260        if: always()                   # run this step always261        run: docker-compose -f ".docker/docker-compose-forkless.yml" -f ".docker/docker-compose.node.${{ matrix.network }}.yml" down --volumes262263      - name: Remove builder cache264        if: always()                   # run this step always265        run: |266          docker builder prune -f267          docker system prune -f268269      - name: Clean Workspace270        if: always()271        uses: AutoModality/action-clean@v1.1.0
modifiedCargo.lockdiffbeforeafterboth
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -6600,7 +6600,7 @@
 
 [[package]]
 name = "pallet-unique"
-version = "0.1.4"
+version = "0.2.0"
 dependencies = [
  "ethereum",
  "evm-coder",
modifiedpallets/app-promotion/src/lib.rsdiffbeforeafterboth
--- a/pallets/app-promotion/src/lib.rs
+++ b/pallets/app-promotion/src/lib.rs
@@ -594,14 +594,14 @@
 								last_id,
 								*income_acc.borrow(),
 								ExistenceRequirement::KeepAlive,
-							)
-							.and_then(|_| {
-								Self::add_lock_balance(last_id, *income_acc.borrow())?;
-								<TotalStaked<T>>::try_mutate(|staked| {
-									staked
-										.checked_add(&*income_acc.borrow())
-										.ok_or(ArithmeticError::Overflow.into())
-								})
+							)?;
+
+							Self::add_lock_balance(last_id, *income_acc.borrow())?;
+							<TotalStaked<T>>::try_mutate(|staked| -> DispatchResult {
+								*staked = staked
+									.checked_add(&*income_acc.borrow())
+									.ok_or(ArithmeticError::Overflow)?;
+								Ok(())
 							})?;
 
 							Self::deposit_event(Event::StakingRecalculation(
modifiedruntime/common/mod.rsdiffbeforeafterboth
--- a/runtime/common/mod.rs
+++ b/runtime/common/mod.rs
@@ -82,7 +82,7 @@
 
 pub type SignedExtra = (
 	frame_system::CheckSpecVersion<Runtime>,
-	// system::CheckTxVersion<Runtime>,
+	frame_system::CheckTxVersion<Runtime>,
 	frame_system::CheckGenesis<Runtime>,
 	frame_system::CheckEra<Runtime>,
 	frame_system::CheckNonce<Runtime>,
modifiedruntime/opal/src/lib.rsdiffbeforeafterboth
--- a/runtime/opal/src/lib.rs
+++ b/runtime/opal/src/lib.rs
@@ -50,7 +50,7 @@
 	spec_name: create_runtime_str!(RUNTIME_NAME),
 	impl_name: create_runtime_str!(RUNTIME_NAME),
 	authoring_version: 1,
-	spec_version: 927020,
+	spec_version: 927030,
 	impl_version: 0,
 	apis: RUNTIME_API_VERSIONS,
 	transaction_version: 2,
modifiedruntime/quartz/src/lib.rsdiffbeforeafterboth
--- a/runtime/quartz/src/lib.rs
+++ b/runtime/quartz/src/lib.rs
@@ -50,7 +50,7 @@
 	spec_name: create_runtime_str!(RUNTIME_NAME),
 	impl_name: create_runtime_str!(RUNTIME_NAME),
 	authoring_version: 1,
-	spec_version: 927020,
+	spec_version: 927030,
 	impl_version: 0,
 	apis: RUNTIME_API_VERSIONS,
 	transaction_version: 2,
modifiedruntime/unique/src/lib.rsdiffbeforeafterboth
--- a/runtime/unique/src/lib.rs
+++ b/runtime/unique/src/lib.rs
@@ -50,7 +50,7 @@
 	spec_name: create_runtime_str!(RUNTIME_NAME),
 	impl_name: create_runtime_str!(RUNTIME_NAME),
 	authoring_version: 1,
-	spec_version: 927020,
+	spec_version: 927030,
 	impl_version: 0,
 	apis: RUNTIME_API_VERSIONS,
 	transaction_version: 2,
modifiedtests/src/app-promotion.test.tsdiffbeforeafterboth
--- a/tests/src/app-promotion.test.ts
+++ b/tests/src/app-promotion.test.ts
@@ -661,6 +661,26 @@
     });
   });
 
+  it('should increase total staked', async() => {
+    await usingPlaygrounds(async (helper) => {
+      const staker = accounts.pop()!;
+      const totalStakedBefore = await helper.staking.getTotalStaked();
+      await helper.staking.stake(staker, 100n * nominal);
+
+      // Wait for rewards and pay
+      const stakedInBlock = (await helper.staking.getTotalStakedPerBlock({Substrate: staker.address}))[0][0];
+      await helper.wait.forRelayBlockNumber(rewardAvailableInBlock(stakedInBlock));
+      await helper.signTransaction(palletAdmin, helper.api!.tx.appPromotion.payoutStakers(100));
+
+      const totalStakedAfter = await helper.staking.getTotalStaked();
+      expect(totalStakedAfter >= totalStakedBefore + calculateIncome(100n * nominal, 10n)).to.be.true;
+
+      // staker can unstake
+      await helper.staking.unstake(staker);
+      expect(await helper.staking.getTotalStaked()).to.be.equal(totalStakedAfter - calculateIncome(100n * nominal, 10n));
+    });
+  });
+
   it('should credit 0.05% for staking period', async () => {    
     await usingPlaygrounds(async helper => {
       const staker = accounts.pop()!;
addedtests/src/tx-version-presence.test.tsdiffbeforeafterboth
--- /dev/null
+++ b/tests/src/tx-version-presence.test.ts
@@ -0,0 +1,32 @@
+// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
+// This file is part of Unique Network.
+
+// Unique Network is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// Unique Network is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
+
+import { Metadata } from '@polkadot/types';
+import {itSub, usingPlaygrounds, expect} from './util/playgrounds';
+
+let metadata: Metadata;
+
+describe('TxVersion is present', () => {
+  before(async () => {
+    await usingPlaygrounds(async helper => {
+      metadata = await helper.api!.rpc.state.getMetadata();
+    });
+  });
+
+  itSub('Signed extension CheckTxVersion is present', async () => {
+    expect(metadata.asLatest.extrinsic.signedExtensions.map(se => se.identifier.toString())).to.include('CheckTxVersion');
+  });
+});