From 8e1521c444dddbba7f63da9b64b412fb0e986900 Mon Sep 17 00:00:00 2001 From: b-yap <2826165+b-yap@users.noreply.github.com> Date: Tue, 12 Mar 2024 23:31:12 +0800 Subject: [PATCH 01/27] added a script for cleaning up commits and the srtool --- .github/workflows/sr-tool.yml | 76 +++++++++++++++++++ ...levant_commit_of_runtime_since_last_tag.sh | 56 ++++++++++++++ 2 files changed, 132 insertions(+) create mode 100644 .github/workflows/sr-tool.yml create mode 100755 scripts/get_relevant_commit_of_runtime_since_last_tag.sh diff --git a/.github/workflows/sr-tool.yml b/.github/workflows/sr-tool.yml new file mode 100644 index 000000000..4eb267fc5 --- /dev/null +++ b/.github/workflows/sr-tool.yml @@ -0,0 +1,76 @@ +name: Srtool build + +env: + SUBWASM_VERSION: 0.20.0 + +on: + pull_request: + types: [opened, edited, synchronize] + branches: + - main + +jobs: + build: + if: "contains(github.event.pull_request.title, 'Release')" + name: Build ${{ matrix.chain }} ${{ github.event.inputs.ref }} + strategy: + fail-fast: false + matrix: + chain: ["amplitude", "pendulum"] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.inputs.ref }} + fetch-depth: 0 + + - name: Srtool build + id: srtool_build + uses: chevdor/srtool-actions@v0.9.2 + with: + chain: ${{ matrix.chain }} + runtime_dir: runtime/${{ matrix.chain }} + # this is important to avoid build fail. See https://github.com/paritytech/srtool/issues/62 + tag: 1.66.1 + - name: Summary + run: | + echo '${{ steps.srtool_build.outputs.json }}' | jq > ${{ matrix.chain }}-srtool-digest.json + cat ${{ matrix.chain }}-srtool-digest.json + echo "Runtime location: ${{ steps.srtool_build.outputs.wasm }}" + + # it takes a while to build the runtime, so let's save the artifact as soon as we have it + - name: Archive Artifacts for ${{ matrix.chain }} + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.chain }}-runtime + path: | + ${{ steps.srtool_build.outputs.wasm }} + ${{ steps.srtool_build.outputs.wasm_compressed }} + ${{ matrix.chain }}-srtool-digest.json + + # We now get extra information thanks to subwasm, + - name: Install subwasm ${{ env.SUBWASM_VERSION }} + run: | + wget https://github.com/chevdor/subwasm/releases/download/v${{ env.SUBWASM_VERSION }}/subwasm_linux_amd64_v${{ env.SUBWASM_VERSION }}.deb + sudo dpkg -i subwasm_linux_amd64_v${{ env.SUBWASM_VERSION }}.deb + subwasm --version + - name: Show Runtime information + run: | + subwasm info ${{ steps.srtool_build.outputs.wasm }} + subwasm info ${{ steps.srtool_build.outputs.wasm_compressed }} + subwasm --json info ${{ steps.srtool_build.outputs.wasm }} > ${{ matrix.chain }}-info.json + subwasm --json info ${{ steps.srtool_build.outputs.wasm_compressed }} > ${{ matrix.chain }}-info_compressed.json + - name: Extract the metadata + run: | + subwasm meta ${{ steps.srtool_build.outputs.wasm }} + subwasm --json meta ${{ steps.srtool_build.outputs.wasm }} > ${{ matrix.chain }}-metadata.json + + - name: Archive Subwasm results + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.chain }}-runtime-${{ github.sha }} + path: | + ${{ matrix.chain }}-info.json + ${{ matrix.chain }}-info_compressed.json + ${{ matrix.chain }}-metadata.json + ${{ matrix.chain }}-diff.txt diff --git a/scripts/get_relevant_commit_of_runtime_since_last_tag.sh b/scripts/get_relevant_commit_of_runtime_since_last_tag.sh new file mode 100755 index 000000000..a65529440 --- /dev/null +++ b/scripts/get_relevant_commit_of_runtime_since_last_tag.sh @@ -0,0 +1,56 @@ +#!/bin/bash + +chosenRuntime="$1" +## forcefully set to lowercase +chosenRuntime=$( echo "$chosenRuntime" | tr -s '[:upper:]' '[:lower:]') + + +## list of runtimes available +runtimesList=("foucoco" "amplitude" "pendulum") + +excludeRuntimes='' +## will make comparison case-insensitive +for runtime in "${runtimesList[@]}"; do + ## exclude runtimes that is NOT chosen + if [[ "$runtime" != "$chosenRuntime" ]]; then + if [ -z "${excludeRuntimes}" ]; then + excludeRuntimes=$runtime + else + excludeRuntimes="$excludeRuntimes|$runtime" + fi + fi +done + +if [ -z "${excludeRuntimes}" ]; then + echo "unsupported runtime "$chosenRuntime + exit +fi + +## get the latest tag of this runtime +lastVersionName=$(git describe --abbrev=0 --tags --always `git rev-list --tags` | grep -i "$chosenRuntime*" -m 1) +echo "last version: "$lastVersionName + +## extract the version number of the version +lastVersionNumber=$(echo $lastVersionName | sed 's/[^0-9]*//g') +newVersionName=$chosenRuntime-release-$((lastVersionNumber+1)) +echo "new version: "$newVersionName +fileName="commits_for_"$newVersionName + +## remove the file if existed +if test -f $fileName; then + rm $fileName +fi + +## get the commits since the last tag +latestCommitOfLastVersion=$(git log $lastVersionName --oneline --max-count=1 | cut -c1-7) + +if [ -z "${latestCommitOfLastVersion}" ]; then + echo "last version is up to date." + exit +fi + +## only list commits related to this runtime and the general code changes +## save to file commits_for_-release-.txt +git log $latestCommitOfLastVersion..origin --oneline | grep -i -Ev "$excludeRuntimes" |cut -c1-7 >> $fileName + + From e58821cf3dd521d290145c1e37c58cb6eb7ab693 Mon Sep 17 00:00:00 2001 From: b-yap <2826165+b-yap@users.noreply.github.com> Date: Thu, 14 Mar 2024 17:42:22 +0800 Subject: [PATCH 02/27] update the yml to run only on push --- .github/workflows/release.yml | 153 ++++++++++++++++++++++++++++++++++ .github/workflows/sr-tool.yml | 76 ----------------- 2 files changed, 153 insertions(+), 76 deletions(-) create mode 100644 .github/workflows/release.yml delete mode 100644 .github/workflows/sr-tool.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..26c04acdf --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,153 @@ +name: Release + +env: + SUBWASM_VERSION: 0.20.0 + +on: + pull_request: + types: + - closed + branches: + - 'main' + +jobs: + srtool: + if: ${{ github.event.pull_request.merged == true && contains(github.event.pull_request.title, 'release:') }} + name: SrTool check on ${{ matrix.chain }} ${{ github.event.inputs.ref }} + strategy: + fail-fast: false + matrix: + chain: ["amplitude", "pendulum"] + shouldReleaseAmp: + - ${{ contains(github.event.pull_request.title, 'amplitude') }} + shouldReleasePen: + - ${{ contains(github.event.pull_request.title, 'pendulum') }} + exclude: + - shouldReleaseAmp: false + chain: "amplitude" + - shouldReleasePen: false + chain: "pendulum" + outputs: + releaseAmp: ${{ matrix.shouldReleaseAmp }} + releasePen: ${{ matrix.shouldReleasePen }} + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.inputs.ref }} + fetch-depth: 0 + + - name: Srtool build + id: srtool_build + uses: chevdor/srtool-actions@v0.9.2 + with: + chain: ${{ matrix.chain }} + runtime_dir: runtime/${{ matrix.chain }} + # this is important to avoid build fail. See https://github.com/paritytech/srtool/issues/62 + tag: 1.66.1 + - name: Summary + run: | + echo '${{ steps.srtool_build.outputs.json }}' | jq > ${{ matrix.chain }}-srtool-digest.json + cat ${{ matrix.chain }}-srtool-digest.json + echo "Runtime location: ${{ steps.srtool_build.outputs.wasm }}" + + # it takes a while to build the runtime, so let's save the artifact as soon as we have it + - name: Archive Artifacts for ${{ matrix.chain }} + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.chain }}-runtime + path: | + ${{ steps.srtool_build.outputs.wasm }} + ${{ steps.srtool_build.outputs.wasm_compressed }} + ${{ matrix.chain }}-srtool-digest.json + + # We now get extra information thanks to subwasm, + - name: Install subwasm ${{ env.SUBWASM_VERSION }} + run: | + wget https://github.com/chevdor/subwasm/releases/download/v${{ env.SUBWASM_VERSION }}/subwasm_linux_amd64_v${{ env.SUBWASM_VERSION }}.deb + sudo dpkg -i subwasm_linux_amd64_v${{ env.SUBWASM_VERSION }}.deb + subwasm --version + - name: Show Runtime information + run: | + subwasm info ${{ steps.srtool_build.outputs.wasm }} + subwasm info ${{ steps.srtool_build.outputs.wasm_compressed }} + subwasm --json info ${{ steps.srtool_build.outputs.wasm }} > ${{ matrix.chain }}-info.json + subwasm --json info ${{ steps.srtool_build.outputs.wasm_compressed }} > ${{ matrix.chain }}-info_compressed.json + - name: Extract the metadata + run: | + subwasm meta ${{ steps.srtool_build.outputs.wasm }} + subwasm --json meta ${{ steps.srtool_build.outputs.wasm }} > ${{ matrix.chain }}-metadata.json + + - name: Archive Subwasm results + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.chain }}-runtime-${{ github.sha }} + path: | + ${{ matrix.chain }}-info.json + ${{ matrix.chain }}-info_compressed.json + ${{ matrix.chain }}-metadata.json + ${{ matrix.chain }}-diff.txt + + build: + needs: srtool + runs-on: ubuntu-latest + + steps: + - name: Freeing up more disk space + run: | + sudo swapoff -a + sudo rm -f /mnt/swapfile + free -h + docker rmi $(docker image ls -aq) + sudo rm -rf /usr/local/lib/android # will release about 10 GB if you don't need Android + sudo rm -rf /usr/share/dotnet # will release about 20GB if you don't need .NET + sudo rm -rf /opt/ghc + sudo rm -rf /usr/local/share/boost + sudo rm -rf /opt/hostedtoolcache + sudo rm -rf "$AGENT_TOOLSDIRECTORY" + sudo apt-get remove -y 'php.*' --fix-missing + sudo apt-get remove -y '^mongodb-.*' --fix-missing + sudo apt-get remove -y '^mysql-.*' --fix-missing + sudo apt-get remove -y azure-cli google-chrome-stable firefox powershell mono-devel libgl1-mesa-dri --fix-missing + sudo apt-get remove -y google-cloud-sdk --fix-missing + sudo apt-get remove -y google-cloud-cli --fix-missing + sudo apt-get autoremove -y + sudo apt-get clean + df -h + + - name: Install package + run: | + echo 'APT::Get::Always-Include-Phased-Updates "false";' | sudo tee /etc/apt/apt.conf.d/99-phased-updates + sudo apt-get update && sudo apt-get upgrade -y + sudo apt-get install -y protobuf-compiler libprotobuf-dev + + - name: Checkout Code + uses: actions/checkout@v3 + + # Steps taken from https://github.com/actions/cache/blob/master/examples.md#rust---cargo + - name: Cache cargo registry + uses: actions/cache@v3 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} + + - name: Install toolchain + # Call `rustup show` as a hack so that the toolchain defined in rust-toolchain.toml.toml is installed + run: rustup install nightly-2022-12-12 + + - name: Install Protoc + uses: arduino/setup-protoc@v1 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Install Amplitude + if: ${{ needs.srtool.outputs.releaseAmp == 'true' }} + run: cargo build -p amplitude-runtime --release + + - name: Install Pendulum + if: ${{ needs.srtool.outputs.releasePen == 'true' }} + run: cargo build -p pendulum-runtime --release \ No newline at end of file diff --git a/.github/workflows/sr-tool.yml b/.github/workflows/sr-tool.yml deleted file mode 100644 index 4eb267fc5..000000000 --- a/.github/workflows/sr-tool.yml +++ /dev/null @@ -1,76 +0,0 @@ -name: Srtool build - -env: - SUBWASM_VERSION: 0.20.0 - -on: - pull_request: - types: [opened, edited, synchronize] - branches: - - main - -jobs: - build: - if: "contains(github.event.pull_request.title, 'Release')" - name: Build ${{ matrix.chain }} ${{ github.event.inputs.ref }} - strategy: - fail-fast: false - matrix: - chain: ["amplitude", "pendulum"] - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - ref: ${{ github.event.inputs.ref }} - fetch-depth: 0 - - - name: Srtool build - id: srtool_build - uses: chevdor/srtool-actions@v0.9.2 - with: - chain: ${{ matrix.chain }} - runtime_dir: runtime/${{ matrix.chain }} - # this is important to avoid build fail. See https://github.com/paritytech/srtool/issues/62 - tag: 1.66.1 - - name: Summary - run: | - echo '${{ steps.srtool_build.outputs.json }}' | jq > ${{ matrix.chain }}-srtool-digest.json - cat ${{ matrix.chain }}-srtool-digest.json - echo "Runtime location: ${{ steps.srtool_build.outputs.wasm }}" - - # it takes a while to build the runtime, so let's save the artifact as soon as we have it - - name: Archive Artifacts for ${{ matrix.chain }} - uses: actions/upload-artifact@v4 - with: - name: ${{ matrix.chain }}-runtime - path: | - ${{ steps.srtool_build.outputs.wasm }} - ${{ steps.srtool_build.outputs.wasm_compressed }} - ${{ matrix.chain }}-srtool-digest.json - - # We now get extra information thanks to subwasm, - - name: Install subwasm ${{ env.SUBWASM_VERSION }} - run: | - wget https://github.com/chevdor/subwasm/releases/download/v${{ env.SUBWASM_VERSION }}/subwasm_linux_amd64_v${{ env.SUBWASM_VERSION }}.deb - sudo dpkg -i subwasm_linux_amd64_v${{ env.SUBWASM_VERSION }}.deb - subwasm --version - - name: Show Runtime information - run: | - subwasm info ${{ steps.srtool_build.outputs.wasm }} - subwasm info ${{ steps.srtool_build.outputs.wasm_compressed }} - subwasm --json info ${{ steps.srtool_build.outputs.wasm }} > ${{ matrix.chain }}-info.json - subwasm --json info ${{ steps.srtool_build.outputs.wasm_compressed }} > ${{ matrix.chain }}-info_compressed.json - - name: Extract the metadata - run: | - subwasm meta ${{ steps.srtool_build.outputs.wasm }} - subwasm --json meta ${{ steps.srtool_build.outputs.wasm }} > ${{ matrix.chain }}-metadata.json - - - name: Archive Subwasm results - uses: actions/upload-artifact@v4 - with: - name: ${{ matrix.chain }}-runtime-${{ github.sha }} - path: | - ${{ matrix.chain }}-info.json - ${{ matrix.chain }}-info_compressed.json - ${{ matrix.chain }}-metadata.json - ${{ matrix.chain }}-diff.txt From 2b57b3b190f41939a843cee07cdcb735ea847f0b Mon Sep 17 00:00:00 2001 From: b-yap <2826165+b-yap@users.noreply.github.com> Date: Fri, 15 Mar 2024 00:50:57 +0800 Subject: [PATCH 03/27] rename to srtool-build.yml; ONLY performs srtool build. --- .../{release.yml => srtool-build.yml} | 67 +------------------ 1 file changed, 2 insertions(+), 65 deletions(-) rename .github/workflows/{release.yml => srtool-build.yml} (56%) diff --git a/.github/workflows/release.yml b/.github/workflows/srtool-build.yml similarity index 56% rename from .github/workflows/release.yml rename to .github/workflows/srtool-build.yml index 26c04acdf..9f4acb450 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/srtool-build.yml @@ -82,72 +82,9 @@ jobs: - name: Archive Subwasm results uses: actions/upload-artifact@v4 with: - name: ${{ matrix.chain }}-runtime-${{ github.sha }} + name: ${{ matrix.chain }}-runtime path: | ${{ matrix.chain }}-info.json ${{ matrix.chain }}-info_compressed.json ${{ matrix.chain }}-metadata.json - ${{ matrix.chain }}-diff.txt - - build: - needs: srtool - runs-on: ubuntu-latest - - steps: - - name: Freeing up more disk space - run: | - sudo swapoff -a - sudo rm -f /mnt/swapfile - free -h - docker rmi $(docker image ls -aq) - sudo rm -rf /usr/local/lib/android # will release about 10 GB if you don't need Android - sudo rm -rf /usr/share/dotnet # will release about 20GB if you don't need .NET - sudo rm -rf /opt/ghc - sudo rm -rf /usr/local/share/boost - sudo rm -rf /opt/hostedtoolcache - sudo rm -rf "$AGENT_TOOLSDIRECTORY" - sudo apt-get remove -y 'php.*' --fix-missing - sudo apt-get remove -y '^mongodb-.*' --fix-missing - sudo apt-get remove -y '^mysql-.*' --fix-missing - sudo apt-get remove -y azure-cli google-chrome-stable firefox powershell mono-devel libgl1-mesa-dri --fix-missing - sudo apt-get remove -y google-cloud-sdk --fix-missing - sudo apt-get remove -y google-cloud-cli --fix-missing - sudo apt-get autoremove -y - sudo apt-get clean - df -h - - - name: Install package - run: | - echo 'APT::Get::Always-Include-Phased-Updates "false";' | sudo tee /etc/apt/apt.conf.d/99-phased-updates - sudo apt-get update && sudo apt-get upgrade -y - sudo apt-get install -y protobuf-compiler libprotobuf-dev - - - name: Checkout Code - uses: actions/checkout@v3 - - # Steps taken from https://github.com/actions/cache/blob/master/examples.md#rust---cargo - - name: Cache cargo registry - uses: actions/cache@v3 - with: - path: | - ~/.cargo/registry - ~/.cargo/git - target - key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} - - - name: Install toolchain - # Call `rustup show` as a hack so that the toolchain defined in rust-toolchain.toml.toml is installed - run: rustup install nightly-2022-12-12 - - - name: Install Protoc - uses: arduino/setup-protoc@v1 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - - - name: Install Amplitude - if: ${{ needs.srtool.outputs.releaseAmp == 'true' }} - run: cargo build -p amplitude-runtime --release - - - name: Install Pendulum - if: ${{ needs.srtool.outputs.releasePen == 'true' }} - run: cargo build -p pendulum-runtime --release \ No newline at end of file + ${{ matrix.chain }}-diff.txt \ No newline at end of file From 831301363322f4c622355e16ac92c5ddf40dcaf1 Mon Sep 17 00:00:00 2001 From: b-yap <2826165+b-yap@users.noreply.github.com> Date: Sat, 16 Mar 2024 02:27:38 +0800 Subject: [PATCH 04/27] remove sub-directories show only info of compressed-wasm --- .github/workflows/srtool-build.yml | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/.github/workflows/srtool-build.yml b/.github/workflows/srtool-build.yml index 9f4acb450..b98c62f5d 100644 --- a/.github/workflows/srtool-build.yml +++ b/.github/workflows/srtool-build.yml @@ -17,16 +17,20 @@ jobs: strategy: fail-fast: false matrix: - chain: ["amplitude", "pendulum"] + chain: ["amplitude", "pendulum", "foucoco"] shouldReleaseAmp: - ${{ contains(github.event.pull_request.title, 'amplitude') }} shouldReleasePen: - ${{ contains(github.event.pull_request.title, 'pendulum') }} + shouldReleaseFou: + - ${{ contains(github.event.pull_request.title, 'foucoco') }} exclude: - shouldReleaseAmp: false chain: "amplitude" - shouldReleasePen: false chain: "pendulum" + - shouldReleaseFou: false + chain: "foucoco" outputs: releaseAmp: ${{ matrix.shouldReleaseAmp }} releasePen: ${{ matrix.shouldReleasePen }} @@ -51,15 +55,17 @@ jobs: echo '${{ steps.srtool_build.outputs.json }}' | jq > ${{ matrix.chain }}-srtool-digest.json cat ${{ matrix.chain }}-srtool-digest.json echo "Runtime location: ${{ steps.srtool_build.outputs.wasm }}" - + echo '${{ steps.srtool_build.outputs.json }}' + cp ${{ steps.srtool_build.outputs.wasm }} ${{ matrix.chain }}_runtime.compact.wasm + cp ${{ steps.srtool_build.outputs.wasm_compressed }} ${{ matrix.chain }}_runtime.compact.compressed.wasm # it takes a while to build the runtime, so let's save the artifact as soon as we have it - name: Archive Artifacts for ${{ matrix.chain }} uses: actions/upload-artifact@v4 with: name: ${{ matrix.chain }}-runtime path: | - ${{ steps.srtool_build.outputs.wasm }} - ${{ steps.srtool_build.outputs.wasm_compressed }} + ${{ matrix.chain }}_runtime.compact.wasm + ${{ matrix.chain }}_runtime.compact.compressed.wasm ${{ matrix.chain }}-srtool-digest.json # We now get extra information thanks to subwasm, @@ -70,7 +76,6 @@ jobs: subwasm --version - name: Show Runtime information run: | - subwasm info ${{ steps.srtool_build.outputs.wasm }} subwasm info ${{ steps.srtool_build.outputs.wasm_compressed }} subwasm --json info ${{ steps.srtool_build.outputs.wasm }} > ${{ matrix.chain }}-info.json subwasm --json info ${{ steps.srtool_build.outputs.wasm_compressed }} > ${{ matrix.chain }}-info_compressed.json @@ -82,7 +87,7 @@ jobs: - name: Archive Subwasm results uses: actions/upload-artifact@v4 with: - name: ${{ matrix.chain }}-runtime + name: ${{ matrix.chain }}-runtime-${{ github.sha }} path: | ${{ matrix.chain }}-info.json ${{ matrix.chain }}-info_compressed.json From 04ddb0a2ebe99290f283ada3511b39f203fb1fa7 Mon Sep 17 00:00:00 2001 From: b-yap <2826165+b-yap@users.noreply.github.com> Date: Wed, 20 Mar 2024 14:35:32 +0800 Subject: [PATCH 05/27] add the script for auth upgrade --- .../{srtool-build.yml => release.yml} | 51 ++- ...levant_commit_of_runtime_since_last_tag.sh | 0 .github/workflows/scripts/js/common.js | 346 ++++++++++++++++++ .github/workflows/scripts/js/constants.js | 154 ++++++++ .github/workflows/scripts/js/package.json | 13 + .../scripts/js/parachain_authorize_upgrade.js | 38 ++ .github/workflows/scripts/js/signatories.json | 30 ++ 7 files changed, 627 insertions(+), 5 deletions(-) rename .github/workflows/{srtool-build.yml => release.yml} (72%) rename {scripts => .github/workflows/scripts}/get_relevant_commit_of_runtime_since_last_tag.sh (100%) create mode 100644 .github/workflows/scripts/js/common.js create mode 100644 .github/workflows/scripts/js/constants.js create mode 100644 .github/workflows/scripts/js/package.json create mode 100644 .github/workflows/scripts/js/parachain_authorize_upgrade.js create mode 100644 .github/workflows/scripts/js/signatories.json diff --git a/.github/workflows/srtool-build.yml b/.github/workflows/release.yml similarity index 72% rename from .github/workflows/srtool-build.yml rename to .github/workflows/release.yml index b98c62f5d..2f7365f40 100644 --- a/.github/workflows/srtool-build.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,4 @@ -name: Release +name: Release and Upgrade Preparation env: SUBWASM_VERSION: 0.20.0 @@ -31,9 +31,6 @@ jobs: chain: "pendulum" - shouldReleaseFou: false chain: "foucoco" - outputs: - releaseAmp: ${{ matrix.shouldReleaseAmp }} - releasePen: ${{ matrix.shouldReleasePen }} runs-on: ubuntu-latest steps: @@ -58,6 +55,7 @@ jobs: echo '${{ steps.srtool_build.outputs.json }}' cp ${{ steps.srtool_build.outputs.wasm }} ${{ matrix.chain }}_runtime.compact.wasm cp ${{ steps.srtool_build.outputs.wasm_compressed }} ${{ matrix.chain }}_runtime.compact.compressed.wasm + # it takes a while to build the runtime, so let's save the artifact as soon as we have it - name: Archive Artifacts for ${{ matrix.chain }} uses: actions/upload-artifact@v4 @@ -92,4 +90,47 @@ jobs: ${{ matrix.chain }}-info.json ${{ matrix.chain }}-info_compressed.json ${{ matrix.chain }}-metadata.json - ${{ matrix.chain }}-diff.txt \ No newline at end of file + ${{ matrix.chain }}-diff.txt + + upgrade_prep: + if: ${{ success() }} + needs: srtool + name: Perform runtime upgrade on ${{ matrix.chain }} ${{ github.event.inputs.ref }} + runs-on: ubuntu-latest + strategy: + matrix: + chain: ["amplitude", "pendulum"] + shouldReleaseAmp: + - ${{ contains(github.event.pull_request.title, 'amplitude') }} + shouldReleasePen: + - ${{ contains(github.event.pull_request.title, 'pendulum') }} + exclude: + - shouldReleaseAmp: false + chain: "amplitude" + - shouldReleasePen: false + chain: "pendulum" + + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.inputs.ref }} + fetch-depth: 0 + + - name: download artifact + uses: actions/download-artifact@v4 + with: + name: ${{ matrix.chain }}-runtime + + - name: prepare Node + uses: actions/setup-node@v4 + with: + node-version: '21.x' + - name: Install dependencies + run: | + cd .github/scripts/js + npm init -y + npm install + - name: run script for parachain upgrade + run: | + node --version + node .github/scripts/js/parachain_authorize_upgrade.js ${{ matrix.chain }} ${{ matrix.chain }}_runtime.compact.compressed.wasm \ No newline at end of file diff --git a/scripts/get_relevant_commit_of_runtime_since_last_tag.sh b/.github/workflows/scripts/get_relevant_commit_of_runtime_since_last_tag.sh similarity index 100% rename from scripts/get_relevant_commit_of_runtime_since_last_tag.sh rename to .github/workflows/scripts/get_relevant_commit_of_runtime_since_last_tag.sh diff --git a/.github/workflows/scripts/js/common.js b/.github/workflows/scripts/js/common.js new file mode 100644 index 000000000..990484147 --- /dev/null +++ b/.github/workflows/scripts/js/common.js @@ -0,0 +1,346 @@ +const { ApiPromise, WsProvider } = require("@polkadot/api"); +const { Keyring } = require("@polkadot/api"); +const readline = require("node:readline/promises"); +const { stdin, stdout } = require("node:process"); + +const rl = readline.createInterface({ input: stdin, output: stdout }); + +// if keypair is undefined, then dryRun must be true +async function submitExtrinsic(transaction, keypair, dryRun) { + console.log("Submit transaction"); + if (dryRun) { + console.log("Dry run"); + console.log("Transaction size\n", (transaction.inner.toHex().length - 2) / 2); + console.log("Transaction data:"); + console.log(transaction.inner.toHex()); + + if (!dryRun) await multisigTransaction.signAndSend(initiatingSignatory); + + console.log("\n\nTransaction hash:", `0x${Buffer.from(transaction.inner.hash).toString("hex")}`); + + return; + } + + await new Promise((resolve, reject) => { + transaction.signAndSend(keypair, ({ status, dispatchError }) => { + // status would still be set, but in the case of error we can shortcut + // to just check it (so an error would indicate InBlock or Finalized) + if (dispatchError) { + if (dispatchError.isModule) { + // for module errors, we have the section indexed, lookup + const decoded = api.registry.findMetaError(dispatchError.asModule); + const { docs, name, section } = decoded; + + console.log(`${section}.${name}: ${docs.join(" ")}`); + } else { + // Other, CannotLookup, BadOrigin, no extra info + console.log(dispatchError.toString()); + } + reject(); + } + + if (status.isInBlock) { + console.log("Success: transaction in block"); + resolve(); + } + + if (status.isFinalized) { + console.log("Transaction finalized"); + } + }); + }); +} + +async function democracyProposal(call, type, deposit, submitPreimage, { api, submitterKeypair, dryRun }) { + console.log("Preimage data", call.inner.toHex()); + console.log("Preimage hash", `0x${Buffer.from(call.inner.hash).toString("hex")}`); + + if (submitPreimage) { + const submitPreimageTransaction = api.tx.preimage.notePreimage(call.inner.toHex()); + // await submitExtrinsic(submitPreimageTransaction, submitterKeypair, dryRun); + } + + switch (type) { + case "public": + const submitProposalTransaction = api.tx.democracy.propose(call.inner.hash, deposit); + // await submitExtrinsic(submitProposalTransaction, submitterKeypair, dryRun); + break; + + case "external": + case "externalMajority": + case "externalDefault": + let externalProposeTransaction; + let threshold; + + const callLength = (call.inner.toHex().length - 2) / 2; + + switch (type) { + case "external": + externalProposeTransaction = api.tx.democracy.externalPropose({ + Lookup: { hash: call.inner.hash, len: callLength }, + }); + threshold = 3; + break; + case "externalMajority": + externalProposeTransaction = api.tx.democracy.externalProposeMajority({ + Lookup: { hash: call.inner.hash, len: callLength }, + }); + threshold = 3; + break; + case "externalDefault": + externalProposeTransaction = api.tx.democracy.externalProposeDefault({ + Lookup: { hash: call.inner.hash, len: callLength }, + }); + threshold = 5; + break; + } + + const councilTransaction = api.tx.council.propose( + threshold, + externalProposeTransaction, + (externalProposeTransaction.toHex().length - 2) / 2 + ); + // await submitExtrinsic(councilTransaction, submitterKeypair, dryRun); + break; + } +} + +function rawKeyString(rawKey) { + return Array.from(rawKey) + .map((entry) => entry.toString(16).padStart(2, "0")) + .join(""); +} + +// if dryRun is true, then initiatingSignatory is the account address of the first signatory to submit the transaction +// if dryRun is false, then initiatingSignatory is the key pair of the first signatory to submit the transaction +async function multisig(transaction, signatories, initiatingSignatory, threshold, { api, keyring, dryRun }) { + const submitterAddress = dryRun ? initiatingSignatory : initiatingSignatory.addressRaw; + + const otherSignatories = signatories + .map((signer) => keyring.decodeAddress(signer)) + .filter((addressRaw) => rawKeyString(addressRaw) !== rawKeyString(submitterAddress)) + .sort((a, b) => (rawKeyString(a) < rawKeyString(b) ? -1 : 1)); + + const multisigTransaction = api.tx.multisig.asMulti(threshold, otherSignatories, undefined, transaction, { + ref_time: 1e9, + proof_size: 1e5, + }); + + console.log("Transaction size\n", (transaction.inner.toHex().length - 2) / 2); + console.log("Transaction data:"); + console.log(transaction.inner.toHex()); + + if (!dryRun) { + const result = await multisigTransaction.signAndSend(initiatingSignatory); + console.log("\nResult of submission", JSON.stringify(result, null, 2)); + } + + console.log("\n\nTransaction hash:", `0x${Buffer.from(transaction.inner.hash).toString("hex")}`); +} + +// if dryRun is true, then initiatingSignatory is the account address of the first signatory to submit the transaction +// if dryRun is false, then initiatingSignatory is the key pair of the first signatory to submit the transaction +async function simpleSudo(transaction, submitterKeypair, { api, keyring, dryRun }) { + console.log("Transaction size\n", (transaction.inner.toHex().length - 2) / 2); + console.log("Transaction data:"); + console.log(transaction.inner.toHex()); + + if (!dryRun) { + const result = await transaction.signAndSend(submitterKeypair); + console.log("\nResult of submission", JSON.stringify(result, null, 2)); + } + + console.log("\n\nTransaction hash:", `0x${Buffer.from(transaction.inner.hash).toString("hex")}`); +} + +function sudo(transaction, { api }) { + return api.tx.sudo.sudoUncheckedWeight(transaction, 0); +} + +exports.submitTransaction = async function (call, governanceMode, { api, definitions, unit, dryRun }) { + if (governanceMode === "direct") { + console.log("Transaction size\n", (call.inner.toHex().length - 2) / 2); + console.log("Transaction data:"); + console.log(call.inner.toHex()); + console.log("\n\nTransaction hash:", `0x${Buffer.from(call.inner.hash).toString("hex")}`); + return; + } + + const keyring = new Keyring({ type: "sr25519" }); + + const { signatoryAddresses, multisigThreshold } = definitions; + + let secretQuery; + switch (governanceMode) { + case "democracy": + secretQuery = dryRun ? undefined : "Enter the secret mnemonic seed of the council member: "; + break; + + case "sudo": + case "simpleSudo": + secretQuery = dryRun + ? "Enter the address of the sudo signatory: " + : "Enter the secret mnemonic seed of the sudo signatory: "; + break; + + case "multisig": + secretQuery = dryRun + ? "Enter the address of the initiating signatory: " + : "Enter the secret mnemonic seed of the multisig account signatory: "; + break; + } + + let submitterKeypair; + + if (secretQuery) { + const submitterSecret = await rl.question(secretQuery); + submitterKeypair = dryRun ? submitterSecret.trim() : keyring.addFromUri(submitterSecret.trim()); + } + + switch (governanceMode) { + case "democracy": + await democracyProposal(call, "externalMajority", unit, true, { + api, + submitterKeypair, + dryRun, + }); + break; + + case "sudo": + { + const sudoTransaction = sudo(call, { api }); + await multisig(sudoTransaction, signatoryAddresses.fixed, submitterKeypair, multisigThreshold, { + api, + keyring, + dryRun, + }); + } + break; + + case "simpleSudo": + { + const sudoTransaction = sudo(call, { api }); + await simpleSudo(sudoTransaction, submitterKeypair, { + api, + keyring, + dryRun, + }); + } + break; + + case "multisig": + { + await multisig(call, signatoryAddresses.fixed, submitterKeypair, multisigThreshold, { + api, + keyring, + dryRun, + }); + } + break; + } +}; + +exports.submitTransactionFor = async function (call, address, ss58Prefix, dryRun) { + const keyring = new Keyring({ type: "sr25519", ss58Format: ss58Prefix }); + + secretKey = await rl.question(`Enter the secret mnemonic seed of address "${address}": `); + const keypair = keyring.addFromUri(secretKey.trim()); + if (keypair.address !== address) { + throw new Error(`Incorrect private key for address: expected ${address}, got: ${keypair.address}`); + } + + await submitExtrinsic(call, keypair, dryRun); +}; + + +async function createRelayChainXcmTransaction( + createInnerTransaction, + maximumFeePaidOnRelayChain, + { api, definitions: { paraId, relayChainWebsocketUrl } } +) { + if (paraId === undefined) return undefined; + if (relayChainWebsocketUrl === undefined) return undefined; + + const relayChainWsProvider = new WsProvider(relayChainWebsocketUrl); + const relayChainApi = await ApiPromise.create({ + provider: relayChainWsProvider, + }); + + const innerTransaction = createInnerTransaction(relayChainApi); + + const innerCallEncoded = innerTransaction.inner.toU8a(); + const innerCallInfo = await relayChainApi.call.transactionPaymentCallApi.queryCallInfo( + innerCallEncoded, + innerCallEncoded.length + ); + + const destination = { + v2: { parents: 1, interior: "Here" }, + }; + + const transaction = api.tx.polkadotXcm.send(destination, { + v2: [ + { + WithdrawAsset: [ + { + id: { + Concrete: { + parents: 0, + interior: "Here", + }, + }, + fun: { + Fungible: maximumFeePaidOnRelayChain, + }, + }, + ], + }, + { + BuyExecution: { + fees: { + id: { + Concrete: { + parents: 0, + interior: "Here", + }, + }, + fun: { + Fungible: maximumFeePaidOnRelayChain, + }, + }, + weightLimit: "Unlimited", + }, + }, + { + Transact: { + originType: "Native", + requireWeightAtMost: innerCallInfo.weight.refTime, + call: { + encoded: innerTransaction.inner.toHex(), + }, + }, + }, + { RefundSurplus: {} }, + { + DepositAsset: { + assets: { + Wild: "All", + }, + maxAssets: 1, + beneficiary: { + parents: 0, + interior: { + X1: { + Parachain: paraId, + }, + }, + }, + }, + }, + ], + }); + + return transaction; +} + + diff --git a/.github/workflows/scripts/js/constants.js b/.github/workflows/scripts/js/constants.js new file mode 100644 index 000000000..3705a8bcb --- /dev/null +++ b/.github/workflows/scripts/js/constants.js @@ -0,0 +1,154 @@ +const { + foucocoSignatories, + amplitudeSignatories, + pendulumSignatories, +} = require("./signatories.json"); + +const localDefinition = { + websocketUrl: "ws://127.0.0.1:9944", + relayChainWebsocketUrl: undefined, + genesisAccount: "6hESxBrhZ9ThDDsB1kGWpzj1jc3RMeb6QTGuHx6cb3F4YH2S", + secondsPerBlock: 6, + multisigThreshold: 3, + signatoryAddresses: foucocoSignatories, + existentialDeposit: 500n, + unit: 10n ** 12n, + distributionAccounts: { + crowdloanReserve: "6nHM6jraY47FQqKvCY6yHGDiB2U1JMhhKbKeDv2DCc68A5Gh", + ecosystemDevelopment: "6hZFMaTFbRkqwuZ7B4zEDWUQe11UvAE4KbPNsTjZEu13w9vz", + liquidityIncentives: "6nAgoYasDAzqYZVN67zwWUgNdTcTV4bKDhYmqs1iaDXcKeLZ", + protocolInitiatives: "6hpW4pn1pMoaPwKGwzbDNuv6v7tD8fnWqpMzkYaiUNNZdA23", + marketing: "6kYPzPsBbNun6LXrTbq9UwZPh7sn6zQkX1p8BezX54BqEGqH", + }, + sudo: "6ftBYTotU4mmCuvUqJvk6qEP7uCzzz771pTMoxcbHFb9rcPv", + initialStakingCollators: [], + ss58Prefix: 42, + paraId: undefined, + otherParaIds: undefined, +}; + +const foucocoDefinition = { + websocketUrl: "wss://rpc-foucoco.pendulumchain.tech", + relayChainWebsocketUrl: "wss://rococo-rpc.polkadot.io", + // Moonbase Alpha urls + // websocketUrl: "wss://moonbeam-00.pendulumchain.tech", + // relayChainWebsocketUrl: "wss://frag-moonbase-relay-rpc-ws.g.moonbase.moonbeam.network", + genesisAccount: "6hESxBrhZ9ThDDsB1kGWpzj1jc3RMeb6QTGuHx6cb3F4YH2S", + secondsPerBlock: 12, + multisigThreshold: 3, + signatoryAddresses: foucocoSignatories, + existentialDeposit: 1_000_000_000n, + unit: 10n ** 12n, + relaychainUnit: 10n ** 12n, + distributionAccounts: { + crowdloanReserve: "6nHM6jraY47FQqKvCY6yHGDiB2U1JMhhKbKeDv2DCc68A5Gh", + ecosystemDevelopment: "6hZFMaTFbRkqwuZ7B4zEDWUQe11UvAE4KbPNsTjZEu13w9vz", + liquidityIncentives: "6nAgoYasDAzqYZVN67zwWUgNdTcTV4bKDhYmqs1iaDXcKeLZ", + protocolInitiatives: "6hpW4pn1pMoaPwKGwzbDNuv6v7tD8fnWqpMzkYaiUNNZdA23", + marketing: "6kYPzPsBbNun6LXrTbq9UwZPh7sn6zQkX1p8BezX54BqEGqH", + }, + initialStakingCollators: [ + "6ihktBwyFJYjE1LKdqoAWzo5VDPJJGso9D5iASZyhuN5JvGH", + "6mbXa9Qca6B6cX51cbtfWWLhup84rMoMFCxNHjso15GBFyGh", + "6mMdv2wmb4Cp8PAtDLF1WTh1wLPwPbETwtcjqgJLskdB8EYo", + "6kL1dzcBJiLgMdAT1qDFD79CLupX1gCCF8RSg5Dh5qRgQeCx", + ], + ss58Prefix: 57, + paraId: 2124, + otherParaIds: { + statemine: 1000, + moonbase: 1000, + bifrost: 2030, + }, +}; + +const amplitudeDefinition = { + websocketUrl: "wss://rpc-amplitude.pendulumchain.tech", + relayChainWebsocketUrl: "wss://kusama-rpc.dwellir.com", + genesisAccount: "6nCzN2oTHkm5VV5CW2q9StXtd3J4CpuRHtQaYiBssCLxq6Dv", + secondsPerBlock: 12, + multisigThreshold: 3, + signatoryAddresses: amplitudeSignatories, + existentialDeposit: 1_000_000_000n, + unit: 10n ** 12n, + relaychainUnit: 10n ** 12n, + distributionAccounts: { + crowdloanReserve: "6kkrogmET4ULqTYXWa8UVqhaYgZMTEf2C7MgQtpFH3CXB783", + ecosystemDevelopment: "6kw7NZVJMWh6fgwUSzzSUhf9pQSxBXCzJPrm7cRrN3ZzWuJS", + liquidityIncentives: "6i6pdBXuzNH9m2bM4ipdiMGWSpfz3uDMriHCBdAVXTtzBNPA", + protocolInitiatives: "6hj43L8TpPqFTLuyUTVqfQJPow57oi1ArNTJs5spVYAkFVqJ", + marketing: "6kToZCN5iATwXSR3CKQeHDMcR543FMDUtp1fr5AA9RK6mygn", + }, + initialStakingCollators: [ + "6mTATq7Ug9RPk4s8aMv5H7WVZ7RvwrJ1JitbYMXWPhanzqiv", + "6n8WiWqjEB8nCNRo5mxXc89FqhuMd2dgXNSrzuPxoZSnatnL", + "6ic56zZmjqo746yifWzcNxxzxLe3pRo8WNitotniUQvgKnyU", + "6gvFApEyYj4EavJP26mwbVu7YxFBYZ9gaJFB7gv5gA6vNfze", + "6mz3ymVAsfHotEhHphVRvLLBhMZ2frnwbuvW5QZiMRwJghxE", + "6mpD3zcHcUBkxCjTsGg2tMTfmQZdXLVYZnk4UkN2XAUTLkRe", + "6mGcZntk59RK2JfxfdmprgDJeByVUgaffMQYkp1ZeoEKeBJA", + "6jq7obxC7AxhWeJNzopwYidKNNe48cLrbGSgB2zs2SuRTWGA", + ], + ss58Prefix: 57, + paraId: 2124, + otherParaIds: { + statemine: 1000, + bifrost: 2001, + picasso: 2087, + }, +}; + +const pendulumDefinition = { + websocketUrl: "wss://rpc-pendulum.prd.pendulumchain.tech", + relayChainWebsocketUrl: "wss://polkadot-rpc.dwellir.com", + genesisAccount: "6cY3Zrb2gr1xt3BczzJ3xoMpF7UyrcGNfR3cjkjcF7auq2Y9", + secondsPerBlock: 12, + multisigThreshold: 4, + signatoryAddresses: pendulumSignatories, + existentialDeposit: 1_000_000_000n, + unit: 10n ** 12n, + relaychainUnit: 10n ** 10n, // strange but that's how it is + distributionAccounts: { + genesis: "6cY3Zrb2gr1xt3BczzJ3xoMpF7UyrcGNfR3cjkjcF7auq2Y9", + team: "6gfLdZvfW2w6fDaPpVfUs53W8Aay17s1bjwcFaqDaBVt7Muo", + crowdloanReserve: "6biLQnLREwRd9aSPiN9xxR2UDCPa1XL3ZSwqNUxNEr3QvGDk", + liquidityIncentives: "6eiGivQB9dtQUMs1VpxATipDYrewWSr4kGsvgjELgqnvRYyx", + marketing: "6gKuTtzLBtgYyW3SP6jh7DnXbNU8fDVFG2AxHCLbGYqaspe7", + treasury: "6dZRnXfN7nnrAUDWykWc7gpHpByVBj9HTRpFNNQyENh11xjq", + }, + initialStakingCollators: [ + "6gUmMnikYxEkk4H7RdnsLRrzNRuDrGAh8JgSiCghG39qenX9", + "6cgKZANaeUJ42VC7iAXrTzX8NC2gdn4WmYAHRo1RBjBfVvnk", + "6bh2t6KMJ9BKgCs1B6qcrp5BjMyv2azmgBC6ySwZ3wrTeW5s", + "6bBH94XAkscX5Q1oswuPSenUzjb9f2iPcfhTKdu1XCK1uwVS", + "6emSrvAgGZXGBu255njQg3pBxDyQN47T7H2XDZuS5V5epHaX", + "6fciE2ek1AMFUaFm4nizaHEZtXBy6eRxEcoygr3SFKfddBBK", + "6ftBtHvYrThAv1xHYDnYrm2qQLFcj2rhkaU5GqNuqvKp57v6", + "6feqfoP5htFpSriTd9oomDa1dZDmcM4XpjKEq8dfdcADCfGt", + ], + ss58Prefix: 56, + paraId: 2094, + otherParaIds: { + statemint: 1000, + moonbeam: 2004, + bifrost: 2030, + equilibrium: 2011, + polkadex: 2040, + }, +}; + +exports.getDefinitions = function (network) { + switch (network) { + case "local": + return localDefinition; + + case "foucoco": + return foucocoDefinition; + + case "amplitude": + return amplitudeDefinition; + + case "pendulum": + return pendulumDefinition; + } +}; diff --git a/.github/workflows/scripts/js/package.json b/.github/workflows/scripts/js/package.json new file mode 100644 index 000000000..c447e1a1e --- /dev/null +++ b/.github/workflows/scripts/js/package.json @@ -0,0 +1,13 @@ +{ + "name": "scripts", + "version": "1.0.0", + "main": "parachain_authorize_upgrade.js", + "license": "ISC", + "dependencies": { + "@polkadot/api": "^9.3.3", + "@polkadot/util-crypto": "^10.4.2" + }, + "keywords": [], + "author": "", + "description": "calls for an authorize upgrade using democracy" +} diff --git a/.github/workflows/scripts/js/parachain_authorize_upgrade.js b/.github/workflows/scripts/js/parachain_authorize_upgrade.js new file mode 100644 index 000000000..4a016d20e --- /dev/null +++ b/.github/workflows/scripts/js/parachain_authorize_upgrade.js @@ -0,0 +1,38 @@ +const { ApiPromise, WsProvider, Keyring } = require("@polkadot/api"); +const { blake2AsHex } = require("@polkadot/util-crypto"); +const fs = require('fs'); + +const { submitTransaction } = require("./common"); + +const { getDefinitions } = require("./constants"); + +const GOVERNANCE_MODE = "democracy"; // "democracy" | "sudo" | "multisig" +const DRY_RUN = true; + + +async function main() { + const args = process.argv; + + if (args.length < 4 ) { + console.error('Expecting two arguments!'); + process.exit(1); + } + + const definitions = getDefinitions(args[2]); + const { websocketUrl, distributionAccounts, otherParaIds, unit } = definitions; + + const wsProvider = new WsProvider(websocketUrl); + const api = await ApiPromise.create({ provider: wsProvider }); + + const wasmFileBytes = fs.readFileSync(args[3]); + const wasmFileHash = blake2AsHex(wasmFileBytes, 256); + console.log('wasmfile: ', wasmFileHash); + + const authorizeUpgrade = api.tx.parachainSystem.authorizeUpgrade(wasmFileHash, true); + + await submitTransaction(authorizeUpgrade, GOVERNANCE_MODE, { definitions, api, dryRun: DRY_RUN }); + + process.exit(); +} + +main(); diff --git a/.github/workflows/scripts/js/signatories.json b/.github/workflows/scripts/js/signatories.json new file mode 100644 index 000000000..11c78a943 --- /dev/null +++ b/.github/workflows/scripts/js/signatories.json @@ -0,0 +1,30 @@ +{ + "amplitudeSignatories": { + "fixed": [ + "6nJwMD3gk36fe6pMRL2UpbwAEjDdjjxdngQGShe753pyAvCT", + "6n62KZWvmZHgeyEXTvQFmoHRMqjKfFWvQVsApkePekuNfek5", + "6kwxQBRKMadrY9Lq3K8gZXkw1UkjacpqYhcqvX3AqmN9DofF", + "6kKHwcpCVC18KepwvdMSME8Q7ZTNr1RoRUrFDH9AdAmhL3Pt" + ], + "genesis": "6i4xDEE1Q2Bv8tnJtgD4jse4YTAzzCwCJVUehRQ93hCqKp8f", + "crowdloanReserve": "6jvbGGCA8MwSQdkxJQuooR2FqJhfwNvd35Y5eQ3qpYwQiggf", + "ecosystemDevelopment": "6kQzZK6Lsb4ysNQbtjZXFvpWGWCeUvYKwWtYwrnTQebgTJ8Q", + "liquidityIncentives": "6iTwTVTy2s55PQmEmMUHFapHkieUFMXafeUbM1drBNRG2RUb", + "protocolInitiatives": "6mwUAJj2zxiN8uyTSGKaznjogWCaRo89yfGwvEWngPs3wVny", + "marketing": "6iC6fbayHN3E1wwuxWDpxwmtgcu5WjRR2VQiTasFiYt5ss1H" + }, + "foucocoSignatories": { + "fixed": [ + "6mSy3qQKgAez9zpqY1JSnYW7d1njMNX93P4mkkQvsmPXmehB", + "6mrdgs7NsHwceSPQRcXCagYzZiB4hoMBGmpMPLA4rS4BGyo7", + "6jBUR27UemaZBF2aYrEbMuN3u76aANEpA3uxLrQcWP8jNDtf", + "6hcDDb1nV6zrqfiB7dgQ5DbzuLkPmxkvSZ5LSA9kcE3gxNs8" + ], + "genesis": "6k4NQX2KepBkeexrWVNabnWG9GZxvQTYi4ytHHCNwPhLZMnE", + "crowdloanReserve": "6hWu9uZCbWzQDYCYwecvu4TxhUXQzsVxtrPCmUzp4qELTHUS", + "ecosystemDevelopment": "6jbFvLwHANbrwohteoZcMfQVQbeWYD7GjXFibje486am6nvu", + "liquidityIncentives": "6n17bbDiW4Up1PBVUujcXqMhbeyXtiR6VoNg3M9RrjVtfwTP", + "protocolInitiatives": "6jWjXWovuJ1yj29uwntwLdM6Jaf3vDhfjHJ44SUUpqJ1zTF6", + "marketing": "6mYPy2m6Br29odXjLHuuzfEaRhoQJtYxGLWjPMfQz1htyF77" + } +} \ No newline at end of file From 778e2b4e378322cfb19664e012a32a735d01606f Mon Sep 17 00:00:00 2001 From: b-yap <2826165+b-yap@users.noreply.github.com> Date: Wed, 20 Mar 2024 17:20:31 +0800 Subject: [PATCH 06/27] add comments and rename job names --- .github/workflows/release.yml | 4 ++-- ...t_commit_of_runtime_since_last_tag.sh => get_commits.sh} | 6 ++++++ .github/workflows/scripts/js/parachain_authorize_upgrade.js | 6 ++++++ 3 files changed, 14 insertions(+), 2 deletions(-) rename .github/workflows/scripts/{get_relevant_commit_of_runtime_since_last_tag.sh => get_commits.sh} (86%) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2f7365f40..f66cdcd29 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,4 @@ -name: Release and Upgrade Preparation +name: Release and Propose an Upgrade env: SUBWASM_VERSION: 0.20.0 @@ -92,7 +92,7 @@ jobs: ${{ matrix.chain }}-metadata.json ${{ matrix.chain }}-diff.txt - upgrade_prep: + propose_upgrade: if: ${{ success() }} needs: srtool name: Perform runtime upgrade on ${{ matrix.chain }} ${{ github.event.inputs.ref }} diff --git a/.github/workflows/scripts/get_relevant_commit_of_runtime_since_last_tag.sh b/.github/workflows/scripts/get_commits.sh similarity index 86% rename from .github/workflows/scripts/get_relevant_commit_of_runtime_since_last_tag.sh rename to .github/workflows/scripts/get_commits.sh index a65529440..ea8dca13b 100755 --- a/.github/workflows/scripts/get_relevant_commit_of_runtime_since_last_tag.sh +++ b/.github/workflows/scripts/get_commits.sh @@ -1,5 +1,11 @@ #!/bin/bash +# It saves into a filename: commits_for__release-release- +# all the commits relevant to the given runtime, from the last release up to +# the latest commit of the main branch of Pendulum repo/ +# scripts$ ./get_commits.sh + + chosenRuntime="$1" ## forcefully set to lowercase chosenRuntime=$( echo "$chosenRuntime" | tr -s '[:upper:]' '[:lower:]') diff --git a/.github/workflows/scripts/js/parachain_authorize_upgrade.js b/.github/workflows/scripts/js/parachain_authorize_upgrade.js index 4a016d20e..9b5273628 100644 --- a/.github/workflows/scripts/js/parachain_authorize_upgrade.js +++ b/.github/workflows/scripts/js/parachain_authorize_upgrade.js @@ -1,3 +1,9 @@ +// This code will submit a transaction to propose an `authorizeUpgrade` +// steps: +// 1. npm init -y +// 2. npm install +// 3. node parachain_authorize_upgrade.js + const { ApiPromise, WsProvider, Keyring } = require("@polkadot/api"); const { blake2AsHex } = require("@polkadot/util-crypto"); const fs = require('fs'); From 86499dc9e34253aa41be9f325153199901404f22 Mon Sep 17 00:00:00 2001 From: b-yap <2826165+b-yap@users.noreply.github.com> Date: Mon, 1 Apr 2024 17:58:47 +0800 Subject: [PATCH 07/27] remove unnecessary loc in the js code --- .github/workflows/scripts/js/common.js | 346 ------------------ .github/workflows/scripts/js/constants.js | 154 -------- .../scripts/js/parachain_authorize_upgrade.js | 100 ++++- .github/workflows/scripts/js/signatories.json | 30 -- 4 files changed, 87 insertions(+), 543 deletions(-) delete mode 100644 .github/workflows/scripts/js/common.js delete mode 100644 .github/workflows/scripts/js/constants.js delete mode 100644 .github/workflows/scripts/js/signatories.json diff --git a/.github/workflows/scripts/js/common.js b/.github/workflows/scripts/js/common.js deleted file mode 100644 index 990484147..000000000 --- a/.github/workflows/scripts/js/common.js +++ /dev/null @@ -1,346 +0,0 @@ -const { ApiPromise, WsProvider } = require("@polkadot/api"); -const { Keyring } = require("@polkadot/api"); -const readline = require("node:readline/promises"); -const { stdin, stdout } = require("node:process"); - -const rl = readline.createInterface({ input: stdin, output: stdout }); - -// if keypair is undefined, then dryRun must be true -async function submitExtrinsic(transaction, keypair, dryRun) { - console.log("Submit transaction"); - if (dryRun) { - console.log("Dry run"); - console.log("Transaction size\n", (transaction.inner.toHex().length - 2) / 2); - console.log("Transaction data:"); - console.log(transaction.inner.toHex()); - - if (!dryRun) await multisigTransaction.signAndSend(initiatingSignatory); - - console.log("\n\nTransaction hash:", `0x${Buffer.from(transaction.inner.hash).toString("hex")}`); - - return; - } - - await new Promise((resolve, reject) => { - transaction.signAndSend(keypair, ({ status, dispatchError }) => { - // status would still be set, but in the case of error we can shortcut - // to just check it (so an error would indicate InBlock or Finalized) - if (dispatchError) { - if (dispatchError.isModule) { - // for module errors, we have the section indexed, lookup - const decoded = api.registry.findMetaError(dispatchError.asModule); - const { docs, name, section } = decoded; - - console.log(`${section}.${name}: ${docs.join(" ")}`); - } else { - // Other, CannotLookup, BadOrigin, no extra info - console.log(dispatchError.toString()); - } - reject(); - } - - if (status.isInBlock) { - console.log("Success: transaction in block"); - resolve(); - } - - if (status.isFinalized) { - console.log("Transaction finalized"); - } - }); - }); -} - -async function democracyProposal(call, type, deposit, submitPreimage, { api, submitterKeypair, dryRun }) { - console.log("Preimage data", call.inner.toHex()); - console.log("Preimage hash", `0x${Buffer.from(call.inner.hash).toString("hex")}`); - - if (submitPreimage) { - const submitPreimageTransaction = api.tx.preimage.notePreimage(call.inner.toHex()); - // await submitExtrinsic(submitPreimageTransaction, submitterKeypair, dryRun); - } - - switch (type) { - case "public": - const submitProposalTransaction = api.tx.democracy.propose(call.inner.hash, deposit); - // await submitExtrinsic(submitProposalTransaction, submitterKeypair, dryRun); - break; - - case "external": - case "externalMajority": - case "externalDefault": - let externalProposeTransaction; - let threshold; - - const callLength = (call.inner.toHex().length - 2) / 2; - - switch (type) { - case "external": - externalProposeTransaction = api.tx.democracy.externalPropose({ - Lookup: { hash: call.inner.hash, len: callLength }, - }); - threshold = 3; - break; - case "externalMajority": - externalProposeTransaction = api.tx.democracy.externalProposeMajority({ - Lookup: { hash: call.inner.hash, len: callLength }, - }); - threshold = 3; - break; - case "externalDefault": - externalProposeTransaction = api.tx.democracy.externalProposeDefault({ - Lookup: { hash: call.inner.hash, len: callLength }, - }); - threshold = 5; - break; - } - - const councilTransaction = api.tx.council.propose( - threshold, - externalProposeTransaction, - (externalProposeTransaction.toHex().length - 2) / 2 - ); - // await submitExtrinsic(councilTransaction, submitterKeypair, dryRun); - break; - } -} - -function rawKeyString(rawKey) { - return Array.from(rawKey) - .map((entry) => entry.toString(16).padStart(2, "0")) - .join(""); -} - -// if dryRun is true, then initiatingSignatory is the account address of the first signatory to submit the transaction -// if dryRun is false, then initiatingSignatory is the key pair of the first signatory to submit the transaction -async function multisig(transaction, signatories, initiatingSignatory, threshold, { api, keyring, dryRun }) { - const submitterAddress = dryRun ? initiatingSignatory : initiatingSignatory.addressRaw; - - const otherSignatories = signatories - .map((signer) => keyring.decodeAddress(signer)) - .filter((addressRaw) => rawKeyString(addressRaw) !== rawKeyString(submitterAddress)) - .sort((a, b) => (rawKeyString(a) < rawKeyString(b) ? -1 : 1)); - - const multisigTransaction = api.tx.multisig.asMulti(threshold, otherSignatories, undefined, transaction, { - ref_time: 1e9, - proof_size: 1e5, - }); - - console.log("Transaction size\n", (transaction.inner.toHex().length - 2) / 2); - console.log("Transaction data:"); - console.log(transaction.inner.toHex()); - - if (!dryRun) { - const result = await multisigTransaction.signAndSend(initiatingSignatory); - console.log("\nResult of submission", JSON.stringify(result, null, 2)); - } - - console.log("\n\nTransaction hash:", `0x${Buffer.from(transaction.inner.hash).toString("hex")}`); -} - -// if dryRun is true, then initiatingSignatory is the account address of the first signatory to submit the transaction -// if dryRun is false, then initiatingSignatory is the key pair of the first signatory to submit the transaction -async function simpleSudo(transaction, submitterKeypair, { api, keyring, dryRun }) { - console.log("Transaction size\n", (transaction.inner.toHex().length - 2) / 2); - console.log("Transaction data:"); - console.log(transaction.inner.toHex()); - - if (!dryRun) { - const result = await transaction.signAndSend(submitterKeypair); - console.log("\nResult of submission", JSON.stringify(result, null, 2)); - } - - console.log("\n\nTransaction hash:", `0x${Buffer.from(transaction.inner.hash).toString("hex")}`); -} - -function sudo(transaction, { api }) { - return api.tx.sudo.sudoUncheckedWeight(transaction, 0); -} - -exports.submitTransaction = async function (call, governanceMode, { api, definitions, unit, dryRun }) { - if (governanceMode === "direct") { - console.log("Transaction size\n", (call.inner.toHex().length - 2) / 2); - console.log("Transaction data:"); - console.log(call.inner.toHex()); - console.log("\n\nTransaction hash:", `0x${Buffer.from(call.inner.hash).toString("hex")}`); - return; - } - - const keyring = new Keyring({ type: "sr25519" }); - - const { signatoryAddresses, multisigThreshold } = definitions; - - let secretQuery; - switch (governanceMode) { - case "democracy": - secretQuery = dryRun ? undefined : "Enter the secret mnemonic seed of the council member: "; - break; - - case "sudo": - case "simpleSudo": - secretQuery = dryRun - ? "Enter the address of the sudo signatory: " - : "Enter the secret mnemonic seed of the sudo signatory: "; - break; - - case "multisig": - secretQuery = dryRun - ? "Enter the address of the initiating signatory: " - : "Enter the secret mnemonic seed of the multisig account signatory: "; - break; - } - - let submitterKeypair; - - if (secretQuery) { - const submitterSecret = await rl.question(secretQuery); - submitterKeypair = dryRun ? submitterSecret.trim() : keyring.addFromUri(submitterSecret.trim()); - } - - switch (governanceMode) { - case "democracy": - await democracyProposal(call, "externalMajority", unit, true, { - api, - submitterKeypair, - dryRun, - }); - break; - - case "sudo": - { - const sudoTransaction = sudo(call, { api }); - await multisig(sudoTransaction, signatoryAddresses.fixed, submitterKeypair, multisigThreshold, { - api, - keyring, - dryRun, - }); - } - break; - - case "simpleSudo": - { - const sudoTransaction = sudo(call, { api }); - await simpleSudo(sudoTransaction, submitterKeypair, { - api, - keyring, - dryRun, - }); - } - break; - - case "multisig": - { - await multisig(call, signatoryAddresses.fixed, submitterKeypair, multisigThreshold, { - api, - keyring, - dryRun, - }); - } - break; - } -}; - -exports.submitTransactionFor = async function (call, address, ss58Prefix, dryRun) { - const keyring = new Keyring({ type: "sr25519", ss58Format: ss58Prefix }); - - secretKey = await rl.question(`Enter the secret mnemonic seed of address "${address}": `); - const keypair = keyring.addFromUri(secretKey.trim()); - if (keypair.address !== address) { - throw new Error(`Incorrect private key for address: expected ${address}, got: ${keypair.address}`); - } - - await submitExtrinsic(call, keypair, dryRun); -}; - - -async function createRelayChainXcmTransaction( - createInnerTransaction, - maximumFeePaidOnRelayChain, - { api, definitions: { paraId, relayChainWebsocketUrl } } -) { - if (paraId === undefined) return undefined; - if (relayChainWebsocketUrl === undefined) return undefined; - - const relayChainWsProvider = new WsProvider(relayChainWebsocketUrl); - const relayChainApi = await ApiPromise.create({ - provider: relayChainWsProvider, - }); - - const innerTransaction = createInnerTransaction(relayChainApi); - - const innerCallEncoded = innerTransaction.inner.toU8a(); - const innerCallInfo = await relayChainApi.call.transactionPaymentCallApi.queryCallInfo( - innerCallEncoded, - innerCallEncoded.length - ); - - const destination = { - v2: { parents: 1, interior: "Here" }, - }; - - const transaction = api.tx.polkadotXcm.send(destination, { - v2: [ - { - WithdrawAsset: [ - { - id: { - Concrete: { - parents: 0, - interior: "Here", - }, - }, - fun: { - Fungible: maximumFeePaidOnRelayChain, - }, - }, - ], - }, - { - BuyExecution: { - fees: { - id: { - Concrete: { - parents: 0, - interior: "Here", - }, - }, - fun: { - Fungible: maximumFeePaidOnRelayChain, - }, - }, - weightLimit: "Unlimited", - }, - }, - { - Transact: { - originType: "Native", - requireWeightAtMost: innerCallInfo.weight.refTime, - call: { - encoded: innerTransaction.inner.toHex(), - }, - }, - }, - { RefundSurplus: {} }, - { - DepositAsset: { - assets: { - Wild: "All", - }, - maxAssets: 1, - beneficiary: { - parents: 0, - interior: { - X1: { - Parachain: paraId, - }, - }, - }, - }, - }, - ], - }); - - return transaction; -} - - diff --git a/.github/workflows/scripts/js/constants.js b/.github/workflows/scripts/js/constants.js deleted file mode 100644 index 3705a8bcb..000000000 --- a/.github/workflows/scripts/js/constants.js +++ /dev/null @@ -1,154 +0,0 @@ -const { - foucocoSignatories, - amplitudeSignatories, - pendulumSignatories, -} = require("./signatories.json"); - -const localDefinition = { - websocketUrl: "ws://127.0.0.1:9944", - relayChainWebsocketUrl: undefined, - genesisAccount: "6hESxBrhZ9ThDDsB1kGWpzj1jc3RMeb6QTGuHx6cb3F4YH2S", - secondsPerBlock: 6, - multisigThreshold: 3, - signatoryAddresses: foucocoSignatories, - existentialDeposit: 500n, - unit: 10n ** 12n, - distributionAccounts: { - crowdloanReserve: "6nHM6jraY47FQqKvCY6yHGDiB2U1JMhhKbKeDv2DCc68A5Gh", - ecosystemDevelopment: "6hZFMaTFbRkqwuZ7B4zEDWUQe11UvAE4KbPNsTjZEu13w9vz", - liquidityIncentives: "6nAgoYasDAzqYZVN67zwWUgNdTcTV4bKDhYmqs1iaDXcKeLZ", - protocolInitiatives: "6hpW4pn1pMoaPwKGwzbDNuv6v7tD8fnWqpMzkYaiUNNZdA23", - marketing: "6kYPzPsBbNun6LXrTbq9UwZPh7sn6zQkX1p8BezX54BqEGqH", - }, - sudo: "6ftBYTotU4mmCuvUqJvk6qEP7uCzzz771pTMoxcbHFb9rcPv", - initialStakingCollators: [], - ss58Prefix: 42, - paraId: undefined, - otherParaIds: undefined, -}; - -const foucocoDefinition = { - websocketUrl: "wss://rpc-foucoco.pendulumchain.tech", - relayChainWebsocketUrl: "wss://rococo-rpc.polkadot.io", - // Moonbase Alpha urls - // websocketUrl: "wss://moonbeam-00.pendulumchain.tech", - // relayChainWebsocketUrl: "wss://frag-moonbase-relay-rpc-ws.g.moonbase.moonbeam.network", - genesisAccount: "6hESxBrhZ9ThDDsB1kGWpzj1jc3RMeb6QTGuHx6cb3F4YH2S", - secondsPerBlock: 12, - multisigThreshold: 3, - signatoryAddresses: foucocoSignatories, - existentialDeposit: 1_000_000_000n, - unit: 10n ** 12n, - relaychainUnit: 10n ** 12n, - distributionAccounts: { - crowdloanReserve: "6nHM6jraY47FQqKvCY6yHGDiB2U1JMhhKbKeDv2DCc68A5Gh", - ecosystemDevelopment: "6hZFMaTFbRkqwuZ7B4zEDWUQe11UvAE4KbPNsTjZEu13w9vz", - liquidityIncentives: "6nAgoYasDAzqYZVN67zwWUgNdTcTV4bKDhYmqs1iaDXcKeLZ", - protocolInitiatives: "6hpW4pn1pMoaPwKGwzbDNuv6v7tD8fnWqpMzkYaiUNNZdA23", - marketing: "6kYPzPsBbNun6LXrTbq9UwZPh7sn6zQkX1p8BezX54BqEGqH", - }, - initialStakingCollators: [ - "6ihktBwyFJYjE1LKdqoAWzo5VDPJJGso9D5iASZyhuN5JvGH", - "6mbXa9Qca6B6cX51cbtfWWLhup84rMoMFCxNHjso15GBFyGh", - "6mMdv2wmb4Cp8PAtDLF1WTh1wLPwPbETwtcjqgJLskdB8EYo", - "6kL1dzcBJiLgMdAT1qDFD79CLupX1gCCF8RSg5Dh5qRgQeCx", - ], - ss58Prefix: 57, - paraId: 2124, - otherParaIds: { - statemine: 1000, - moonbase: 1000, - bifrost: 2030, - }, -}; - -const amplitudeDefinition = { - websocketUrl: "wss://rpc-amplitude.pendulumchain.tech", - relayChainWebsocketUrl: "wss://kusama-rpc.dwellir.com", - genesisAccount: "6nCzN2oTHkm5VV5CW2q9StXtd3J4CpuRHtQaYiBssCLxq6Dv", - secondsPerBlock: 12, - multisigThreshold: 3, - signatoryAddresses: amplitudeSignatories, - existentialDeposit: 1_000_000_000n, - unit: 10n ** 12n, - relaychainUnit: 10n ** 12n, - distributionAccounts: { - crowdloanReserve: "6kkrogmET4ULqTYXWa8UVqhaYgZMTEf2C7MgQtpFH3CXB783", - ecosystemDevelopment: "6kw7NZVJMWh6fgwUSzzSUhf9pQSxBXCzJPrm7cRrN3ZzWuJS", - liquidityIncentives: "6i6pdBXuzNH9m2bM4ipdiMGWSpfz3uDMriHCBdAVXTtzBNPA", - protocolInitiatives: "6hj43L8TpPqFTLuyUTVqfQJPow57oi1ArNTJs5spVYAkFVqJ", - marketing: "6kToZCN5iATwXSR3CKQeHDMcR543FMDUtp1fr5AA9RK6mygn", - }, - initialStakingCollators: [ - "6mTATq7Ug9RPk4s8aMv5H7WVZ7RvwrJ1JitbYMXWPhanzqiv", - "6n8WiWqjEB8nCNRo5mxXc89FqhuMd2dgXNSrzuPxoZSnatnL", - "6ic56zZmjqo746yifWzcNxxzxLe3pRo8WNitotniUQvgKnyU", - "6gvFApEyYj4EavJP26mwbVu7YxFBYZ9gaJFB7gv5gA6vNfze", - "6mz3ymVAsfHotEhHphVRvLLBhMZ2frnwbuvW5QZiMRwJghxE", - "6mpD3zcHcUBkxCjTsGg2tMTfmQZdXLVYZnk4UkN2XAUTLkRe", - "6mGcZntk59RK2JfxfdmprgDJeByVUgaffMQYkp1ZeoEKeBJA", - "6jq7obxC7AxhWeJNzopwYidKNNe48cLrbGSgB2zs2SuRTWGA", - ], - ss58Prefix: 57, - paraId: 2124, - otherParaIds: { - statemine: 1000, - bifrost: 2001, - picasso: 2087, - }, -}; - -const pendulumDefinition = { - websocketUrl: "wss://rpc-pendulum.prd.pendulumchain.tech", - relayChainWebsocketUrl: "wss://polkadot-rpc.dwellir.com", - genesisAccount: "6cY3Zrb2gr1xt3BczzJ3xoMpF7UyrcGNfR3cjkjcF7auq2Y9", - secondsPerBlock: 12, - multisigThreshold: 4, - signatoryAddresses: pendulumSignatories, - existentialDeposit: 1_000_000_000n, - unit: 10n ** 12n, - relaychainUnit: 10n ** 10n, // strange but that's how it is - distributionAccounts: { - genesis: "6cY3Zrb2gr1xt3BczzJ3xoMpF7UyrcGNfR3cjkjcF7auq2Y9", - team: "6gfLdZvfW2w6fDaPpVfUs53W8Aay17s1bjwcFaqDaBVt7Muo", - crowdloanReserve: "6biLQnLREwRd9aSPiN9xxR2UDCPa1XL3ZSwqNUxNEr3QvGDk", - liquidityIncentives: "6eiGivQB9dtQUMs1VpxATipDYrewWSr4kGsvgjELgqnvRYyx", - marketing: "6gKuTtzLBtgYyW3SP6jh7DnXbNU8fDVFG2AxHCLbGYqaspe7", - treasury: "6dZRnXfN7nnrAUDWykWc7gpHpByVBj9HTRpFNNQyENh11xjq", - }, - initialStakingCollators: [ - "6gUmMnikYxEkk4H7RdnsLRrzNRuDrGAh8JgSiCghG39qenX9", - "6cgKZANaeUJ42VC7iAXrTzX8NC2gdn4WmYAHRo1RBjBfVvnk", - "6bh2t6KMJ9BKgCs1B6qcrp5BjMyv2azmgBC6ySwZ3wrTeW5s", - "6bBH94XAkscX5Q1oswuPSenUzjb9f2iPcfhTKdu1XCK1uwVS", - "6emSrvAgGZXGBu255njQg3pBxDyQN47T7H2XDZuS5V5epHaX", - "6fciE2ek1AMFUaFm4nizaHEZtXBy6eRxEcoygr3SFKfddBBK", - "6ftBtHvYrThAv1xHYDnYrm2qQLFcj2rhkaU5GqNuqvKp57v6", - "6feqfoP5htFpSriTd9oomDa1dZDmcM4XpjKEq8dfdcADCfGt", - ], - ss58Prefix: 56, - paraId: 2094, - otherParaIds: { - statemint: 1000, - moonbeam: 2004, - bifrost: 2030, - equilibrium: 2011, - polkadex: 2040, - }, -}; - -exports.getDefinitions = function (network) { - switch (network) { - case "local": - return localDefinition; - - case "foucoco": - return foucocoDefinition; - - case "amplitude": - return amplitudeDefinition; - - case "pendulum": - return pendulumDefinition; - } -}; diff --git a/.github/workflows/scripts/js/parachain_authorize_upgrade.js b/.github/workflows/scripts/js/parachain_authorize_upgrade.js index 9b5273628..5302108a6 100644 --- a/.github/workflows/scripts/js/parachain_authorize_upgrade.js +++ b/.github/workflows/scripts/js/parachain_authorize_upgrade.js @@ -1,19 +1,90 @@ -// This code will submit a transaction to propose an `authorizeUpgrade` -// steps: -// 1. npm init -y -// 2. npm install -// 3. node parachain_authorize_upgrade.js - const { ApiPromise, WsProvider, Keyring } = require("@polkadot/api"); const { blake2AsHex } = require("@polkadot/util-crypto"); +const readline = require("node:readline/promises"); +const { stdin, stdout } = require("node:process"); const fs = require('fs'); -const { submitTransaction } = require("./common"); +const rl = readline.createInterface({ input: stdin, output: stdout }); + +// if keypair is undefined, then dryRun must be true +async function submitExtrinsic(transaction, keypair) { + console.log("Submit transaction: ", transaction); + + // await new Promise((resolve, reject) => { + // transaction.signAndSend(keypair, ({ status, dispatchError }) => { + // // status would still be set, but in the case of error we can shortcut + // // to just check it (so an error would indicate InBlock or Finalized) + // if (dispatchError) { + // if (dispatchError.isModule) { + // // for module errors, we have the section indexed, lookup + // const decoded = api.registry.findMetaError(dispatchError.asModule); + // const { docs, name, section } = decoded; + // + // console.log(`${section}.${name}: ${docs.join(" ")}`); + // } else { + // // Other, CannotLookup, BadOrigin, no extra info + // console.log(dispatchError.toString()); + // } + // reject(); + // } + // + // if (status.isInBlock) { + // console.log("Success: transaction in block"); + // resolve(); + // } + // + // if (status.isFinalized) { + // console.log("Transaction finalized"); + // } + // }); + // }); +} + +async function democracyProposal(call, { api, submitterKeypair }) { + console.log("Preimage data", call.inner.toHex()); + console.log("Preimage hash", `0x${Buffer.from(call.inner.hash).toString("hex")}`); + + const submitPreimageTransaction = api.tx.preimage.notePreimage(call.inner.toHex()); + await submitExtrinsic(submitPreimageTransaction, submitterKeypair); + + const callLength = (call.inner.toHex().length - 2) / 2; + const externalProposeTransaction = api.tx.democracy.externalProposeMajority({ + Lookup: { hash: call.inner.hash, len: callLength }, + }); + const threshold = 3; + + const councilTransaction = api.tx.council.propose( + threshold, + externalProposeTransaction, + (externalProposeTransaction.toHex().length - 2) / 2 + ); + await submitExtrinsic(councilTransaction, submitterKeypair); +} + +async function submitTransaction(call, api) { + const keyring = new Keyring({ type: "sr25519" }); + + // todo: need an account + let secretQuery = "Enter the secret mnemonic seed of the council member: "; + + const submitterSecret = await rl.question(secretQuery); + let submitterKeypair = keyring.addFromUri(submitterSecret.trim()); -const { getDefinitions } = require("./constants"); + await democracyProposal(call, { + api, + submitterKeypair + }); +}; -const GOVERNANCE_MODE = "democracy"; // "democracy" | "sudo" | "multisig" -const DRY_RUN = true; +function getUrl (network) { + switch (network) { + case "amplitude": + return "wss://rpc-amplitude.pendulumchain.tech"; + + case "pendulum": + return "wss://rpc-pendulum.prd.pendulumchain.tech"; + } +}; async function main() { @@ -24,10 +95,13 @@ async function main() { process.exit(1); } - const definitions = getDefinitions(args[2]); - const { websocketUrl, distributionAccounts, otherParaIds, unit } = definitions; + console.log("the argument: ", args[2]); + const websocketUrl = getUrl(args[2]); + + console.log("the url: ", websocketUrl); const wsProvider = new WsProvider(websocketUrl); + const api = await ApiPromise.create({ provider: wsProvider }); const wasmFileBytes = fs.readFileSync(args[3]); @@ -36,7 +110,7 @@ async function main() { const authorizeUpgrade = api.tx.parachainSystem.authorizeUpgrade(wasmFileHash, true); - await submitTransaction(authorizeUpgrade, GOVERNANCE_MODE, { definitions, api, dryRun: DRY_RUN }); + await submitTransaction(authorizeUpgrade, api); process.exit(); } diff --git a/.github/workflows/scripts/js/signatories.json b/.github/workflows/scripts/js/signatories.json deleted file mode 100644 index 11c78a943..000000000 --- a/.github/workflows/scripts/js/signatories.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "amplitudeSignatories": { - "fixed": [ - "6nJwMD3gk36fe6pMRL2UpbwAEjDdjjxdngQGShe753pyAvCT", - "6n62KZWvmZHgeyEXTvQFmoHRMqjKfFWvQVsApkePekuNfek5", - "6kwxQBRKMadrY9Lq3K8gZXkw1UkjacpqYhcqvX3AqmN9DofF", - "6kKHwcpCVC18KepwvdMSME8Q7ZTNr1RoRUrFDH9AdAmhL3Pt" - ], - "genesis": "6i4xDEE1Q2Bv8tnJtgD4jse4YTAzzCwCJVUehRQ93hCqKp8f", - "crowdloanReserve": "6jvbGGCA8MwSQdkxJQuooR2FqJhfwNvd35Y5eQ3qpYwQiggf", - "ecosystemDevelopment": "6kQzZK6Lsb4ysNQbtjZXFvpWGWCeUvYKwWtYwrnTQebgTJ8Q", - "liquidityIncentives": "6iTwTVTy2s55PQmEmMUHFapHkieUFMXafeUbM1drBNRG2RUb", - "protocolInitiatives": "6mwUAJj2zxiN8uyTSGKaznjogWCaRo89yfGwvEWngPs3wVny", - "marketing": "6iC6fbayHN3E1wwuxWDpxwmtgcu5WjRR2VQiTasFiYt5ss1H" - }, - "foucocoSignatories": { - "fixed": [ - "6mSy3qQKgAez9zpqY1JSnYW7d1njMNX93P4mkkQvsmPXmehB", - "6mrdgs7NsHwceSPQRcXCagYzZiB4hoMBGmpMPLA4rS4BGyo7", - "6jBUR27UemaZBF2aYrEbMuN3u76aANEpA3uxLrQcWP8jNDtf", - "6hcDDb1nV6zrqfiB7dgQ5DbzuLkPmxkvSZ5LSA9kcE3gxNs8" - ], - "genesis": "6k4NQX2KepBkeexrWVNabnWG9GZxvQTYi4ytHHCNwPhLZMnE", - "crowdloanReserve": "6hWu9uZCbWzQDYCYwecvu4TxhUXQzsVxtrPCmUzp4qELTHUS", - "ecosystemDevelopment": "6jbFvLwHANbrwohteoZcMfQVQbeWYD7GjXFibje486am6nvu", - "liquidityIncentives": "6n17bbDiW4Up1PBVUujcXqMhbeyXtiR6VoNg3M9RrjVtfwTP", - "protocolInitiatives": "6jWjXWovuJ1yj29uwntwLdM6Jaf3vDhfjHJ44SUUpqJ1zTF6", - "marketing": "6mYPy2m6Br29odXjLHuuzfEaRhoQJtYxGLWjPMfQz1htyF77" - } -} \ No newline at end of file From 1a10416987024e0b323f754dc5e09abeb97a71d5 Mon Sep 17 00:00:00 2001 From: b-yap <2826165+b-yap@users.noreply.github.com> Date: Tue, 2 Apr 2024 16:09:57 +0800 Subject: [PATCH 08/27] update js code --- .../scripts/js/parachain_authorize_upgrade.js | 95 ++++++++----------- 1 file changed, 39 insertions(+), 56 deletions(-) diff --git a/.github/workflows/scripts/js/parachain_authorize_upgrade.js b/.github/workflows/scripts/js/parachain_authorize_upgrade.js index 5302108a6..1f08216b3 100644 --- a/.github/workflows/scripts/js/parachain_authorize_upgrade.js +++ b/.github/workflows/scripts/js/parachain_authorize_upgrade.js @@ -1,3 +1,9 @@ +// This code will submit a transaction to propose an `authorizeUpgrade` +// steps: +// 1. npm init -y +// 2. npm install +// 3. node parachain_authorize_upgrade.js + const { ApiPromise, WsProvider, Keyring } = require("@polkadot/api"); const { blake2AsHex } = require("@polkadot/util-crypto"); const readline = require("node:readline/promises"); @@ -10,70 +16,47 @@ const rl = readline.createInterface({ input: stdin, output: stdout }); async function submitExtrinsic(transaction, keypair) { console.log("Submit transaction: ", transaction); - // await new Promise((resolve, reject) => { - // transaction.signAndSend(keypair, ({ status, dispatchError }) => { - // // status would still be set, but in the case of error we can shortcut - // // to just check it (so an error would indicate InBlock or Finalized) - // if (dispatchError) { - // if (dispatchError.isModule) { - // // for module errors, we have the section indexed, lookup - // const decoded = api.registry.findMetaError(dispatchError.asModule); - // const { docs, name, section } = decoded; - // - // console.log(`${section}.${name}: ${docs.join(" ")}`); - // } else { - // // Other, CannotLookup, BadOrigin, no extra info - // console.log(dispatchError.toString()); - // } - // reject(); - // } - // - // if (status.isInBlock) { - // console.log("Success: transaction in block"); - // resolve(); - // } - // - // if (status.isFinalized) { - // console.log("Transaction finalized"); - // } - // }); - // }); -} - -async function democracyProposal(call, { api, submitterKeypair }) { - console.log("Preimage data", call.inner.toHex()); - console.log("Preimage hash", `0x${Buffer.from(call.inner.hash).toString("hex")}`); - - const submitPreimageTransaction = api.tx.preimage.notePreimage(call.inner.toHex()); - await submitExtrinsic(submitPreimageTransaction, submitterKeypair); - - const callLength = (call.inner.toHex().length - 2) / 2; - const externalProposeTransaction = api.tx.democracy.externalProposeMajority({ - Lookup: { hash: call.inner.hash, len: callLength }, + await new Promise((resolve, reject) => { + transaction.signAndSend(keypair, ({ status, dispatchError }) => { + // status would still be set, but in the case of error we can shortcut + // to just check it (so an error would indicate InBlock or Finalized) + if (dispatchError) { + if (dispatchError.isModule) { + // for module errors, we have the section indexed, lookup + const decoded = api.registry.findMetaError(dispatchError.asModule); + const { docs, name, section } = decoded; + + console.log(`${section}.${name}: ${docs.join(" ")}`); + } else { + // Other, CannotLookup, BadOrigin, no extra info + console.log(dispatchError.toString()); + } + reject(); + } + + if (status.isInBlock) { + console.log("Success: transaction in block"); + resolve(); + } + + if (status.isFinalized) { + console.log("Transaction finalized"); + } + }); }); - const threshold = 3; - - const councilTransaction = api.tx.council.propose( - threshold, - externalProposeTransaction, - (externalProposeTransaction.toHex().length - 2) / 2 - ); - await submitExtrinsic(councilTransaction, submitterKeypair); } async function submitTransaction(call, api) { const keyring = new Keyring({ type: "sr25519" }); - // todo: need an account - let secretQuery = "Enter the secret mnemonic seed of the council member: "; + let submitterKeypair = keyring.addFromUri("//Alice"); - const submitterSecret = await rl.question(secretQuery); - let submitterKeypair = keyring.addFromUri(submitterSecret.trim()); + console.log("Preimage data", call.inner.toHex()); + console.log("Preimage hash", `0x${Buffer.from(call.inner.hash).toString("hex")}`); - await democracyProposal(call, { - api, - submitterKeypair - }); + const submitPreimageTransaction = api.tx.preimage.notePreimage(call.inner.toHex()); + // todo: uncomment if ready + // await submitExtrinsic(submitPreimageTransaction, submitterKeypair); }; function getUrl (network) { From 4d61a1ab245ed335f6b7fe2634a949f4cead8f80 Mon Sep 17 00:00:00 2001 From: b-yap <2826165+b-yap@users.noreply.github.com> Date: Thu, 4 Apr 2024 15:45:05 +0800 Subject: [PATCH 09/27] update js code --- .../scripts/js/parachain_authorize_upgrade.js | 61 ++++++++++++------- 1 file changed, 40 insertions(+), 21 deletions(-) diff --git a/.github/workflows/scripts/js/parachain_authorize_upgrade.js b/.github/workflows/scripts/js/parachain_authorize_upgrade.js index 1f08216b3..852e91ff2 100644 --- a/.github/workflows/scripts/js/parachain_authorize_upgrade.js +++ b/.github/workflows/scripts/js/parachain_authorize_upgrade.js @@ -1,4 +1,12 @@ // This code will submit a transaction to propose an `authorizeUpgrade` +// for Pendulum: +// * save to env var PENDULUM_SEED the account seed of Pendulum +// * save to env var PENDULUM_WASM_FILE the compressed wasm file of Pendulum +// +// for Amplitude: +// * save to env var AMPLITUDE_SEED the account seed of Amplitude +// * save to env var AMPLITUDE_WASM_FILE the compressed wasm file of Amplitude +// // steps: // 1. npm init -y // 2. npm install @@ -6,11 +14,19 @@ const { ApiPromise, WsProvider, Keyring } = require("@polkadot/api"); const { blake2AsHex } = require("@polkadot/util-crypto"); -const readline = require("node:readline/promises"); -const { stdin, stdout } = require("node:process"); const fs = require('fs'); -const rl = readline.createInterface({ input: stdin, output: stdout }); +const amplitudeDefinition = { + websocketUrl: "wss://rpc-amplitude.pendulumchain.tech", + accountSeed: process.env.AMPLITUDE_SEED, + wasmFile: process.env.AMPLITUDE_WASM_FILE +} + +const pendulumDefinition = { + websocketUrl: "wss://rpc-pendulum.prd.pendulumchain.tech", + accountSeed: process.env.PENDULUM_SEED, + wasmFile: process.env.PENDULUM_WASM_FILE +} // if keypair is undefined, then dryRun must be true async function submitExtrinsic(transaction, keypair) { @@ -46,54 +62,57 @@ async function submitExtrinsic(transaction, keypair) { }); } -async function submitTransaction(call, api) { - const keyring = new Keyring({ type: "sr25519" }); - // todo: need an account - let submitterKeypair = keyring.addFromUri("//Alice"); - +async function democracyProposal(call, { api, submitterKeypair }) { console.log("Preimage data", call.inner.toHex()); console.log("Preimage hash", `0x${Buffer.from(call.inner.hash).toString("hex")}`); const submitPreimageTransaction = api.tx.preimage.notePreimage(call.inner.toHex()); - // todo: uncomment if ready + // uncomment if ready // await submitExtrinsic(submitPreimageTransaction, submitterKeypair); +} + +async function submitTransaction(accountSeed, call, api) { + const keyring = new Keyring({ type: "sr25519" }); + let submitterKeypair = keyring.addFromUri(accountSeed); + console.log("account: ", submitterKeypair.address); + + await democracyProposal(call, { + api, + submitterKeypair + }); }; -function getUrl (network) { +function getDefinitions (network) { switch (network) { case "amplitude": - return "wss://rpc-amplitude.pendulumchain.tech"; - + return amplitudeDefinition; case "pendulum": - return "wss://rpc-pendulum.prd.pendulumchain.tech"; + return pendulumDefinition; } }; - async function main() { const args = process.argv; - if (args.length < 4 ) { - console.error('Expecting two arguments!'); + if (args.length < 3 ) { + console.error('Please provide the chain to upgrade'); process.exit(1); } - console.log("the argument: ", args[2]); - const websocketUrl = getUrl(args[2]); - + let { accountSeed, websocketUrl, wasmFile } = getDefinitions(args[2]); console.log("the url: ", websocketUrl); const wsProvider = new WsProvider(websocketUrl); const api = await ApiPromise.create({ provider: wsProvider }); - const wasmFileBytes = fs.readFileSync(args[3]); + const wasmFileBytes = fs.readFileSync(wasmFile); const wasmFileHash = blake2AsHex(wasmFileBytes, 256); console.log('wasmfile: ', wasmFileHash); const authorizeUpgrade = api.tx.parachainSystem.authorizeUpgrade(wasmFileHash, true); - await submitTransaction(authorizeUpgrade, api); + await submitTransaction(accountSeed,authorizeUpgrade, api); process.exit(); } From 1582ef7a597482b7b8cd9b64d04002cccf770ea5 Mon Sep 17 00:00:00 2001 From: b-yap <2826165+b-yap@users.noreply.github.com> Date: Thu, 16 May 2024 19:05:47 +0800 Subject: [PATCH 10/27] new release yml file --- .github/workflows/release-old.yml | 136 ++++++++++++++++++++++++++++++ .github/workflows/release.yml | 132 +++++------------------------ 2 files changed, 157 insertions(+), 111 deletions(-) create mode 100644 .github/workflows/release-old.yml diff --git a/.github/workflows/release-old.yml b/.github/workflows/release-old.yml new file mode 100644 index 000000000..f66cdcd29 --- /dev/null +++ b/.github/workflows/release-old.yml @@ -0,0 +1,136 @@ +name: Release and Propose an Upgrade + +env: + SUBWASM_VERSION: 0.20.0 + +on: + pull_request: + types: + - closed + branches: + - 'main' + +jobs: + srtool: + if: ${{ github.event.pull_request.merged == true && contains(github.event.pull_request.title, 'release:') }} + name: SrTool check on ${{ matrix.chain }} ${{ github.event.inputs.ref }} + strategy: + fail-fast: false + matrix: + chain: ["amplitude", "pendulum", "foucoco"] + shouldReleaseAmp: + - ${{ contains(github.event.pull_request.title, 'amplitude') }} + shouldReleasePen: + - ${{ contains(github.event.pull_request.title, 'pendulum') }} + shouldReleaseFou: + - ${{ contains(github.event.pull_request.title, 'foucoco') }} + exclude: + - shouldReleaseAmp: false + chain: "amplitude" + - shouldReleasePen: false + chain: "pendulum" + - shouldReleaseFou: false + chain: "foucoco" + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.inputs.ref }} + fetch-depth: 0 + + - name: Srtool build + id: srtool_build + uses: chevdor/srtool-actions@v0.9.2 + with: + chain: ${{ matrix.chain }} + runtime_dir: runtime/${{ matrix.chain }} + # this is important to avoid build fail. See https://github.com/paritytech/srtool/issues/62 + tag: 1.66.1 + - name: Summary + run: | + echo '${{ steps.srtool_build.outputs.json }}' | jq > ${{ matrix.chain }}-srtool-digest.json + cat ${{ matrix.chain }}-srtool-digest.json + echo "Runtime location: ${{ steps.srtool_build.outputs.wasm }}" + echo '${{ steps.srtool_build.outputs.json }}' + cp ${{ steps.srtool_build.outputs.wasm }} ${{ matrix.chain }}_runtime.compact.wasm + cp ${{ steps.srtool_build.outputs.wasm_compressed }} ${{ matrix.chain }}_runtime.compact.compressed.wasm + + # it takes a while to build the runtime, so let's save the artifact as soon as we have it + - name: Archive Artifacts for ${{ matrix.chain }} + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.chain }}-runtime + path: | + ${{ matrix.chain }}_runtime.compact.wasm + ${{ matrix.chain }}_runtime.compact.compressed.wasm + ${{ matrix.chain }}-srtool-digest.json + + # We now get extra information thanks to subwasm, + - name: Install subwasm ${{ env.SUBWASM_VERSION }} + run: | + wget https://github.com/chevdor/subwasm/releases/download/v${{ env.SUBWASM_VERSION }}/subwasm_linux_amd64_v${{ env.SUBWASM_VERSION }}.deb + sudo dpkg -i subwasm_linux_amd64_v${{ env.SUBWASM_VERSION }}.deb + subwasm --version + - name: Show Runtime information + run: | + subwasm info ${{ steps.srtool_build.outputs.wasm_compressed }} + subwasm --json info ${{ steps.srtool_build.outputs.wasm }} > ${{ matrix.chain }}-info.json + subwasm --json info ${{ steps.srtool_build.outputs.wasm_compressed }} > ${{ matrix.chain }}-info_compressed.json + - name: Extract the metadata + run: | + subwasm meta ${{ steps.srtool_build.outputs.wasm }} + subwasm --json meta ${{ steps.srtool_build.outputs.wasm }} > ${{ matrix.chain }}-metadata.json + + - name: Archive Subwasm results + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.chain }}-runtime-${{ github.sha }} + path: | + ${{ matrix.chain }}-info.json + ${{ matrix.chain }}-info_compressed.json + ${{ matrix.chain }}-metadata.json + ${{ matrix.chain }}-diff.txt + + propose_upgrade: + if: ${{ success() }} + needs: srtool + name: Perform runtime upgrade on ${{ matrix.chain }} ${{ github.event.inputs.ref }} + runs-on: ubuntu-latest + strategy: + matrix: + chain: ["amplitude", "pendulum"] + shouldReleaseAmp: + - ${{ contains(github.event.pull_request.title, 'amplitude') }} + shouldReleasePen: + - ${{ contains(github.event.pull_request.title, 'pendulum') }} + exclude: + - shouldReleaseAmp: false + chain: "amplitude" + - shouldReleasePen: false + chain: "pendulum" + + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.inputs.ref }} + fetch-depth: 0 + + - name: download artifact + uses: actions/download-artifact@v4 + with: + name: ${{ matrix.chain }}-runtime + + - name: prepare Node + uses: actions/setup-node@v4 + with: + node-version: '21.x' + - name: Install dependencies + run: | + cd .github/scripts/js + npm init -y + npm install + - name: run script for parachain upgrade + run: | + node --version + node .github/scripts/js/parachain_authorize_upgrade.js ${{ matrix.chain }} ${{ matrix.chain }}_runtime.compact.compressed.wasm \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f66cdcd29..e220f4ce1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,8 +1,10 @@ +# This action triggers a GitLab CI job that performs the following: +# * Srtool Check +# * Subwasm info of the compressed wasm file +# * Generate Release Notes +# * Propose a Parachain Upgrade name: Release and Propose an Upgrade -env: - SUBWASM_VERSION: 0.20.0 - on: pull_request: types: @@ -11,93 +13,14 @@ on: - 'main' jobs: - srtool: + release_check: +# This job will only run if: +# * the pull request is closed and merged to main branch; +# * the pull request has the "release:" in its title if: ${{ github.event.pull_request.merged == true && contains(github.event.pull_request.title, 'release:') }} - name: SrTool check on ${{ matrix.chain }} ${{ github.event.inputs.ref }} - strategy: - fail-fast: false - matrix: - chain: ["amplitude", "pendulum", "foucoco"] - shouldReleaseAmp: - - ${{ contains(github.event.pull_request.title, 'amplitude') }} - shouldReleasePen: - - ${{ contains(github.event.pull_request.title, 'pendulum') }} - shouldReleaseFou: - - ${{ contains(github.event.pull_request.title, 'foucoco') }} - exclude: - - shouldReleaseAmp: false - chain: "amplitude" - - shouldReleasePen: false - chain: "pendulum" - - shouldReleaseFou: false - chain: "foucoco" - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - with: - ref: ${{ github.event.inputs.ref }} - fetch-depth: 0 - - - name: Srtool build - id: srtool_build - uses: chevdor/srtool-actions@v0.9.2 - with: - chain: ${{ matrix.chain }} - runtime_dir: runtime/${{ matrix.chain }} - # this is important to avoid build fail. See https://github.com/paritytech/srtool/issues/62 - tag: 1.66.1 - - name: Summary - run: | - echo '${{ steps.srtool_build.outputs.json }}' | jq > ${{ matrix.chain }}-srtool-digest.json - cat ${{ matrix.chain }}-srtool-digest.json - echo "Runtime location: ${{ steps.srtool_build.outputs.wasm }}" - echo '${{ steps.srtool_build.outputs.json }}' - cp ${{ steps.srtool_build.outputs.wasm }} ${{ matrix.chain }}_runtime.compact.wasm - cp ${{ steps.srtool_build.outputs.wasm_compressed }} ${{ matrix.chain }}_runtime.compact.compressed.wasm - - # it takes a while to build the runtime, so let's save the artifact as soon as we have it - - name: Archive Artifacts for ${{ matrix.chain }} - uses: actions/upload-artifact@v4 - with: - name: ${{ matrix.chain }}-runtime - path: | - ${{ matrix.chain }}_runtime.compact.wasm - ${{ matrix.chain }}_runtime.compact.compressed.wasm - ${{ matrix.chain }}-srtool-digest.json - - # We now get extra information thanks to subwasm, - - name: Install subwasm ${{ env.SUBWASM_VERSION }} - run: | - wget https://github.com/chevdor/subwasm/releases/download/v${{ env.SUBWASM_VERSION }}/subwasm_linux_amd64_v${{ env.SUBWASM_VERSION }}.deb - sudo dpkg -i subwasm_linux_amd64_v${{ env.SUBWASM_VERSION }}.deb - subwasm --version - - name: Show Runtime information - run: | - subwasm info ${{ steps.srtool_build.outputs.wasm_compressed }} - subwasm --json info ${{ steps.srtool_build.outputs.wasm }} > ${{ matrix.chain }}-info.json - subwasm --json info ${{ steps.srtool_build.outputs.wasm_compressed }} > ${{ matrix.chain }}-info_compressed.json - - name: Extract the metadata - run: | - subwasm meta ${{ steps.srtool_build.outputs.wasm }} - subwasm --json meta ${{ steps.srtool_build.outputs.wasm }} > ${{ matrix.chain }}-metadata.json - - - name: Archive Subwasm results - uses: actions/upload-artifact@v4 - with: - name: ${{ matrix.chain }}-runtime-${{ github.sha }} - path: | - ${{ matrix.chain }}-info.json - ${{ matrix.chain }}-info_compressed.json - ${{ matrix.chain }}-metadata.json - ${{ matrix.chain }}-diff.txt - - propose_upgrade: - if: ${{ success() }} - needs: srtool - name: Perform runtime upgrade on ${{ matrix.chain }} ${{ github.event.inputs.ref }} - runs-on: ubuntu-latest + name: Is ${{ matrix.chain }} need new release ${{ github.event.inputs.ref }} strategy: + fail-fast: true matrix: chain: ["amplitude", "pendulum"] shouldReleaseAmp: @@ -109,28 +32,15 @@ jobs: chain: "amplitude" - shouldReleasePen: false chain: "pendulum" + runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - ref: ${{ github.event.inputs.ref }} - fetch-depth: 0 - - - name: download artifact - uses: actions/download-artifact@v4 - with: - name: ${{ matrix.chain }}-runtime +# steps: +# - name: trigger GitLab Ci Job +# uses: appleboy/gitlab-ci-action@master +# with: +# host: "https://gitlab.com" +# token: ${{ secrets.GITLABAPI }} +# project_id: 51267165 +# debug: true +# ref: development - - name: prepare Node - uses: actions/setup-node@v4 - with: - node-version: '21.x' - - name: Install dependencies - run: | - cd .github/scripts/js - npm init -y - npm install - - name: run script for parachain upgrade - run: | - node --version - node .github/scripts/js/parachain_authorize_upgrade.js ${{ matrix.chain }} ${{ matrix.chain }}_runtime.compact.compressed.wasm \ No newline at end of file From e00c939d8222de954654b4dfb6c9668776a874e4 Mon Sep 17 00:00:00 2001 From: b-yap <2826165+b-yap@users.noreply.github.com> Date: Thu, 16 May 2024 19:17:16 +0800 Subject: [PATCH 11/27] remove unused scripts --- .github/workflows/scripts/get_commits.sh | 62 --------- .github/workflows/scripts/js/package.json | 13 -- .../scripts/js/parachain_authorize_upgrade.js | 120 ------------------ 3 files changed, 195 deletions(-) delete mode 100755 .github/workflows/scripts/get_commits.sh delete mode 100644 .github/workflows/scripts/js/package.json delete mode 100644 .github/workflows/scripts/js/parachain_authorize_upgrade.js diff --git a/.github/workflows/scripts/get_commits.sh b/.github/workflows/scripts/get_commits.sh deleted file mode 100755 index ea8dca13b..000000000 --- a/.github/workflows/scripts/get_commits.sh +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/bash - -# It saves into a filename: commits_for__release-release- -# all the commits relevant to the given runtime, from the last release up to -# the latest commit of the main branch of Pendulum repo/ -# scripts$ ./get_commits.sh - - -chosenRuntime="$1" -## forcefully set to lowercase -chosenRuntime=$( echo "$chosenRuntime" | tr -s '[:upper:]' '[:lower:]') - - -## list of runtimes available -runtimesList=("foucoco" "amplitude" "pendulum") - -excludeRuntimes='' -## will make comparison case-insensitive -for runtime in "${runtimesList[@]}"; do - ## exclude runtimes that is NOT chosen - if [[ "$runtime" != "$chosenRuntime" ]]; then - if [ -z "${excludeRuntimes}" ]; then - excludeRuntimes=$runtime - else - excludeRuntimes="$excludeRuntimes|$runtime" - fi - fi -done - -if [ -z "${excludeRuntimes}" ]; then - echo "unsupported runtime "$chosenRuntime - exit -fi - -## get the latest tag of this runtime -lastVersionName=$(git describe --abbrev=0 --tags --always `git rev-list --tags` | grep -i "$chosenRuntime*" -m 1) -echo "last version: "$lastVersionName - -## extract the version number of the version -lastVersionNumber=$(echo $lastVersionName | sed 's/[^0-9]*//g') -newVersionName=$chosenRuntime-release-$((lastVersionNumber+1)) -echo "new version: "$newVersionName -fileName="commits_for_"$newVersionName - -## remove the file if existed -if test -f $fileName; then - rm $fileName -fi - -## get the commits since the last tag -latestCommitOfLastVersion=$(git log $lastVersionName --oneline --max-count=1 | cut -c1-7) - -if [ -z "${latestCommitOfLastVersion}" ]; then - echo "last version is up to date." - exit -fi - -## only list commits related to this runtime and the general code changes -## save to file commits_for_-release-.txt -git log $latestCommitOfLastVersion..origin --oneline | grep -i -Ev "$excludeRuntimes" |cut -c1-7 >> $fileName - - diff --git a/.github/workflows/scripts/js/package.json b/.github/workflows/scripts/js/package.json deleted file mode 100644 index c447e1a1e..000000000 --- a/.github/workflows/scripts/js/package.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "scripts", - "version": "1.0.0", - "main": "parachain_authorize_upgrade.js", - "license": "ISC", - "dependencies": { - "@polkadot/api": "^9.3.3", - "@polkadot/util-crypto": "^10.4.2" - }, - "keywords": [], - "author": "", - "description": "calls for an authorize upgrade using democracy" -} diff --git a/.github/workflows/scripts/js/parachain_authorize_upgrade.js b/.github/workflows/scripts/js/parachain_authorize_upgrade.js deleted file mode 100644 index 852e91ff2..000000000 --- a/.github/workflows/scripts/js/parachain_authorize_upgrade.js +++ /dev/null @@ -1,120 +0,0 @@ -// This code will submit a transaction to propose an `authorizeUpgrade` -// for Pendulum: -// * save to env var PENDULUM_SEED the account seed of Pendulum -// * save to env var PENDULUM_WASM_FILE the compressed wasm file of Pendulum -// -// for Amplitude: -// * save to env var AMPLITUDE_SEED the account seed of Amplitude -// * save to env var AMPLITUDE_WASM_FILE the compressed wasm file of Amplitude -// -// steps: -// 1. npm init -y -// 2. npm install -// 3. node parachain_authorize_upgrade.js - -const { ApiPromise, WsProvider, Keyring } = require("@polkadot/api"); -const { blake2AsHex } = require("@polkadot/util-crypto"); -const fs = require('fs'); - -const amplitudeDefinition = { - websocketUrl: "wss://rpc-amplitude.pendulumchain.tech", - accountSeed: process.env.AMPLITUDE_SEED, - wasmFile: process.env.AMPLITUDE_WASM_FILE -} - -const pendulumDefinition = { - websocketUrl: "wss://rpc-pendulum.prd.pendulumchain.tech", - accountSeed: process.env.PENDULUM_SEED, - wasmFile: process.env.PENDULUM_WASM_FILE -} - -// if keypair is undefined, then dryRun must be true -async function submitExtrinsic(transaction, keypair) { - console.log("Submit transaction: ", transaction); - - await new Promise((resolve, reject) => { - transaction.signAndSend(keypair, ({ status, dispatchError }) => { - // status would still be set, but in the case of error we can shortcut - // to just check it (so an error would indicate InBlock or Finalized) - if (dispatchError) { - if (dispatchError.isModule) { - // for module errors, we have the section indexed, lookup - const decoded = api.registry.findMetaError(dispatchError.asModule); - const { docs, name, section } = decoded; - - console.log(`${section}.${name}: ${docs.join(" ")}`); - } else { - // Other, CannotLookup, BadOrigin, no extra info - console.log(dispatchError.toString()); - } - reject(); - } - - if (status.isInBlock) { - console.log("Success: transaction in block"); - resolve(); - } - - if (status.isFinalized) { - console.log("Transaction finalized"); - } - }); - }); -} - -async function democracyProposal(call, { api, submitterKeypair }) { - console.log("Preimage data", call.inner.toHex()); - console.log("Preimage hash", `0x${Buffer.from(call.inner.hash).toString("hex")}`); - - const submitPreimageTransaction = api.tx.preimage.notePreimage(call.inner.toHex()); - // uncomment if ready - // await submitExtrinsic(submitPreimageTransaction, submitterKeypair); -} - -async function submitTransaction(accountSeed, call, api) { - const keyring = new Keyring({ type: "sr25519" }); - let submitterKeypair = keyring.addFromUri(accountSeed); - console.log("account: ", submitterKeypair.address); - - await democracyProposal(call, { - api, - submitterKeypair - }); -}; - -function getDefinitions (network) { - switch (network) { - case "amplitude": - return amplitudeDefinition; - case "pendulum": - return pendulumDefinition; - } -}; - -async function main() { - const args = process.argv; - - if (args.length < 3 ) { - console.error('Please provide the chain to upgrade'); - process.exit(1); - } - - let { accountSeed, websocketUrl, wasmFile } = getDefinitions(args[2]); - console.log("the url: ", websocketUrl); - - const wsProvider = new WsProvider(websocketUrl); - - const api = await ApiPromise.create({ provider: wsProvider }); - - const wasmFileBytes = fs.readFileSync(wasmFile); - const wasmFileHash = blake2AsHex(wasmFileBytes, 256); - console.log('wasmfile: ', wasmFileHash); - - const authorizeUpgrade = api.tx.parachainSystem.authorizeUpgrade(wasmFileHash, true); - - await submitTransaction(accountSeed,authorizeUpgrade, api); - - process.exit(); -} - -main(); From a4a5ee06c3477a19d1653d520623cc50bc79451e Mon Sep 17 00:00:00 2001 From: b-yap <2826165+b-yap@users.noreply.github.com> Date: Thu, 16 May 2024 19:32:15 +0800 Subject: [PATCH 12/27] add the correct gitlab id --- .github/workflows/release.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e220f4ce1..32af393a9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -34,13 +34,13 @@ jobs: chain: "pendulum" runs-on: ubuntu-latest -# steps: -# - name: trigger GitLab Ci Job -# uses: appleboy/gitlab-ci-action@master -# with: -# host: "https://gitlab.com" -# token: ${{ secrets.GITLABAPI }} -# project_id: 51267165 -# debug: true -# ref: development + steps: + - name: trigger GitLab Ci Job + uses: appleboy/gitlab-ci-action@master + with: + host: "https://gitlab.com" + token: ${{ secrets.GITLABAPI }} + project_id: 56492543 + debug: true + ref: main From b40dd711412ff4ba57a26e9deb64e32ebcc37327 Mon Sep 17 00:00:00 2001 From: b-yap <2826165+b-yap@users.noreply.github.com> Date: Fri, 17 May 2024 15:01:09 +0800 Subject: [PATCH 13/27] test gitlab id --- .github/workflows/release.yml | 47 ++++++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 14 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 32af393a9..171285764 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,42 +5,61 @@ # * Propose a Parachain Upgrade name: Release and Propose an Upgrade +#on: +# pull_request: +# types: +# - closed +# branches: +# - 'main' on: pull_request: - types: - - closed branches: - - 'main' + - main jobs: release_check: # This job will only run if: # * the pull request is closed and merged to main branch; # * the pull request has the "release:" in its title - if: ${{ github.event.pull_request.merged == true && contains(github.event.pull_request.title, 'release:') }} - name: Is ${{ matrix.chain }} need new release ${{ github.event.inputs.ref }} +# if: ${{ github.event.pull_request.merged == true && contains(github.event.pull_request.title, 'release:') }} + name: ${{ matrix.chain }} need new release strategy: fail-fast: true matrix: - chain: ["amplitude", "pendulum"] + chain: ["AMPLITUDE", "PENDULUM"] shouldReleaseAmp: - ${{ contains(github.event.pull_request.title, 'amplitude') }} shouldReleasePen: - ${{ contains(github.event.pull_request.title, 'pendulum') }} exclude: - shouldReleaseAmp: false - chain: "amplitude" + chain: "AMPLITUDE" - shouldReleasePen: false - chain: "pendulum" + chain: "PENDULUM" runs-on: ubuntu-latest steps: - - name: trigger GitLab Ci Job - uses: appleboy/gitlab-ci-action@master + - id: string + uses: ASzc/change-string-case-action@v6 with: - host: "https://gitlab.com" - token: ${{ secrets.GITLABAPI }} + string: ${{ matrix.chain }} + + - name: Set environment variable + id: set-env + run: | + echo "${{ steps.string.outputs.uppercase }}=Y" >> $GITHUB_ENV + + - name: Print environment variable + run: | + echo "${{ format('${0}', steps.string.outputs.uppercase ) }}" + + - name: trigger gitlab + uses: eic/trigger-gitlab-ci@v1 + with: + url: https://gitlab.com project_id: 56492543 - debug: true - ref: main + token: ${{ secrets.GITLABAPI }} + ref_name: main + variables: | + AMPLITUDE: Y From ea4a4328df6a783626894c5f049d66eec3d18519 Mon Sep 17 00:00:00 2001 From: b-yap <2826165+b-yap@users.noreply.github.com> Date: Fri, 17 May 2024 15:05:05 +0800 Subject: [PATCH 14/27] try to run --- .github/workflows/release.yml | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 171285764..8568f1ef6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -26,19 +26,25 @@ jobs: strategy: fail-fast: true matrix: - chain: ["AMPLITUDE", "PENDULUM"] - shouldReleaseAmp: - - ${{ contains(github.event.pull_request.title, 'amplitude') }} - shouldReleasePen: - - ${{ contains(github.event.pull_request.title, 'pendulum') }} - exclude: - - shouldReleaseAmp: false - chain: "AMPLITUDE" - - shouldReleasePen: false - chain: "PENDULUM" + chain: ["AMPLITUDE"] +# chain: ["AMPLITUDE", "PENDULUM"] +# shouldReleaseAmp: +# - ${{ contains(github.event.pull_request.title, 'amplitude') }} +# shouldReleasePen: +# - ${{ contains(github.event.pull_request.title, 'pendulum') }} +# exclude: +# - shouldReleaseAmp: false +# chain: "AMPLITUDE" +# - shouldReleasePen: false +# chain: "PENDULUM" runs-on: ubuntu-latest steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.inputs.ref }} + fetch-depth: 0 + - id: string uses: ASzc/change-string-case-action@v6 with: From 6df86852178359ef4ba0e27096db5d1d836c7853 Mon Sep 17 00:00:00 2001 From: b-yap <2826165+b-yap@users.noreply.github.com> Date: Fri, 17 May 2024 15:18:58 +0800 Subject: [PATCH 15/27] try to run --- .github/workflows/release.yml | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8568f1ef6..fc1a5717a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -40,32 +40,21 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - with: - ref: ${{ github.event.inputs.ref }} - fetch-depth: 0 - - - id: string - uses: ASzc/change-string-case-action@v6 - with: - string: ${{ matrix.chain }} - - name: Set environment variable id: set-env run: | - echo "${{ steps.string.outputs.uppercase }}=Y" >> $GITHUB_ENV + echo "${{ matrix.chain }}=Y" >> $GITHUB_ENV - name: Print environment variable run: | - echo "${{ format('${0}', steps.string.outputs.uppercase ) }}" + echo "${{ format('${0}', steps.s ) }}" - - name: trigger gitlab - uses: eic/trigger-gitlab-ci@v1 + - name: trigger GitLab Ci Job + uses: appleboy/gitlab-ci-action@master with: - url: https://gitlab.com - project_id: 56492543 + host: "https://gitlab.com" token: ${{ secrets.GITLABAPI }} - ref_name: main - variables: | - AMPLITUDE: Y + project_id: 56492543 + debug: true + ref: main From ac72f6656a75e8e2e370870abbc3b411c33d7a30 Mon Sep 17 00:00:00 2001 From: b-yap <2826165+b-yap@users.noreply.github.com> Date: Fri, 17 May 2024 18:27:28 +0800 Subject: [PATCH 16/27] use another gitlab trigger api --- .github/workflows/release.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fc1a5717a..5600c065b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -47,14 +47,14 @@ jobs: - name: Print environment variable run: | - echo "${{ format('${0}', steps.s ) }}" + echo "${{ format('${0}', ${{ matrix.chain }} ) }}" - - name: trigger GitLab Ci Job - uses: appleboy/gitlab-ci-action@master + - name: trigger gitlab + uses: eic/trigger-gitlab-ci@v1 with: - host: "https://gitlab.com" - token: ${{ secrets.GITLABAPI }} + url: https://gitlab.com project_id: 56492543 - debug: true - ref: main - + token: ${{ secrets.GITLABAPI }} + ref_name: main + variables: | + ${{ matrix.chain }}: ${{ format('${0}', steps.string.outputs.uppercase ) }} From 85a45a4aab31afc5189f6d045d25481877e80450 Mon Sep 17 00:00:00 2001 From: b-yap <2826165+b-yap@users.noreply.github.com> Date: Fri, 17 May 2024 18:30:20 +0800 Subject: [PATCH 17/27] remove useless lines --- .github/workflows/release.yml | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5600c065b..026d026ce 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -40,15 +40,6 @@ jobs: runs-on: ubuntu-latest steps: - - name: Set environment variable - id: set-env - run: | - echo "${{ matrix.chain }}=Y" >> $GITHUB_ENV - - - name: Print environment variable - run: | - echo "${{ format('${0}', ${{ matrix.chain }} ) }}" - - name: trigger gitlab uses: eic/trigger-gitlab-ci@v1 with: @@ -57,4 +48,4 @@ jobs: token: ${{ secrets.GITLABAPI }} ref_name: main variables: | - ${{ matrix.chain }}: ${{ format('${0}', steps.string.outputs.uppercase ) }} + ${{ matrix.chain }}:Y From ee97e052dbfb07ba6916c9ce318fc4b5146920a0 Mon Sep 17 00:00:00 2001 From: b-yap <2826165+b-yap@users.noreply.github.com> Date: Fri, 17 May 2024 18:36:20 +0800 Subject: [PATCH 18/27] use mb-wali/gitlab-cd-trigger@main github actions --- .github/workflows/release.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 026d026ce..77641ecac 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -41,11 +41,11 @@ jobs: steps: - name: trigger gitlab - uses: eic/trigger-gitlab-ci@v1 + uses: mb-wali/gitlab-cd-trigger@main with: - url: https://gitlab.com - project_id: 56492543 - token: ${{ secrets.GITLABAPI }} - ref_name: main - variables: | - ${{ matrix.chain }}:Y + URL: https://gitlab.com + GITLB_TRIGGER_TOKEN: ${{ secrets.GITLABAPI }} + PROJECT_ID: '56492543' + REF_NAME: 'main' + PIPELINE_VARIABLES: '{"${{ matrix.chain }}":Y}' + From e5e9ad0ef2ac9acab6b57dc6e6591c78540925dc Mon Sep 17 00:00:00 2001 From: b-yap <2826165+b-yap@users.noreply.github.com> Date: Fri, 17 May 2024 18:37:06 +0800 Subject: [PATCH 19/27] wrap with double quote --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 77641ecac..249e42a88 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -47,5 +47,5 @@ jobs: GITLB_TRIGGER_TOKEN: ${{ secrets.GITLABAPI }} PROJECT_ID: '56492543' REF_NAME: 'main' - PIPELINE_VARIABLES: '{"${{ matrix.chain }}":Y}' + PIPELINE_VARIABLES: '{"${{ matrix.chain }}":"Y"}' From 48bf5361155fa5c778337c6a8bca1ba2c0ebc9a9 Mon Sep 17 00:00:00 2001 From: b-yap <2826165+b-yap@users.noreply.github.com> Date: Fri, 17 May 2024 18:39:12 +0800 Subject: [PATCH 20/27] wrap with single quote --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 249e42a88..2fe128934 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -43,7 +43,7 @@ jobs: - name: trigger gitlab uses: mb-wali/gitlab-cd-trigger@main with: - URL: https://gitlab.com + URL: 'https://gitlab.com' GITLB_TRIGGER_TOKEN: ${{ secrets.GITLABAPI }} PROJECT_ID: '56492543' REF_NAME: 'main' From ecff16361b5bab8cff1a10b862d8fb844b3e7dcc Mon Sep 17 00:00:00 2001 From: b-yap <2826165+b-yap@users.noreply.github.com> Date: Fri, 17 May 2024 18:40:30 +0800 Subject: [PATCH 21/27] wrap with double quote --- .github/workflows/release.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2fe128934..387b70eaf 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -43,9 +43,9 @@ jobs: - name: trigger gitlab uses: mb-wali/gitlab-cd-trigger@main with: - URL: 'https://gitlab.com' + URL: "https://gitlab.com" GITLB_TRIGGER_TOKEN: ${{ secrets.GITLABAPI }} - PROJECT_ID: '56492543' - REF_NAME: 'main' + PROJECT_ID: "56492543" + REF_NAME: "main" PIPELINE_VARIABLES: '{"${{ matrix.chain }}":"Y"}' From 523ce4ca983f02cec3bc42db301721214fa656d0 Mon Sep 17 00:00:00 2001 From: b-yap <2826165+b-yap@users.noreply.github.com> Date: Fri, 17 May 2024 18:43:11 +0800 Subject: [PATCH 22/27] back with eic but wrap env result with double quote --- .github/workflows/release.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 387b70eaf..cbb9d3f0c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -41,11 +41,11 @@ jobs: steps: - name: trigger gitlab - uses: mb-wali/gitlab-cd-trigger@main + uses: eic/trigger-gitlab-ci@v1 with: - URL: "https://gitlab.com" - GITLB_TRIGGER_TOKEN: ${{ secrets.GITLABAPI }} - PROJECT_ID: "56492543" - REF_NAME: "main" - PIPELINE_VARIABLES: '{"${{ matrix.chain }}":"Y"}' - + url: https://gitlab.com + project_id: 56492543 + token: ${{ secrets.GITLABAPI }} + ref_name: main + variables: | + ${{ matrix.chain }}:"Y" From a372c1c8ad97bfe8d175ce4bd793037a89b8e0ef Mon Sep 17 00:00:00 2001 From: b-yap <2826165+b-yap@users.noreply.github.com> Date: Fri, 17 May 2024 18:45:57 +0800 Subject: [PATCH 23/27] use + sign --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cbb9d3f0c..e6dfa4a0e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -48,4 +48,4 @@ jobs: token: ${{ secrets.GITLABAPI }} ref_name: main variables: | - ${{ matrix.chain }}:"Y" + ${{ matrix.chain }}=Y From 568a01d8430e58d4b3fd571c276166004862b9e5 Mon Sep 17 00:00:00 2001 From: b-yap <2826165+b-yap@users.noreply.github.com> Date: Fri, 17 May 2024 18:48:57 +0800 Subject: [PATCH 24/27] Test pendulum --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e6dfa4a0e..ee0546c01 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -26,7 +26,7 @@ jobs: strategy: fail-fast: true matrix: - chain: ["AMPLITUDE"] + chain: ["PENDULUM"] # chain: ["AMPLITUDE", "PENDULUM"] # shouldReleaseAmp: # - ${{ contains(github.event.pull_request.title, 'amplitude') }} From ffbe62e64c133389acf845e5a18197133cdbfee3 Mon Sep 17 00:00:00 2001 From: b-yap <2826165+b-yap@users.noreply.github.com> Date: Fri, 17 May 2024 18:51:49 +0800 Subject: [PATCH 25/27] final yaml file --- .github/workflows/release.yml | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ee0546c01..467fe996e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,20 +1,16 @@ # This action triggers a GitLab CI job that performs the following: # * Srtool Check # * Subwasm info of the compressed wasm file -# * Generate Release Notes # * Propose a Parachain Upgrade +# * Generate Release Notes name: Release and Propose an Upgrade -#on: -# pull_request: -# types: -# - closed -# branches: -# - 'main' on: pull_request: + types: + - closed branches: - - main + - 'main' jobs: release_check: @@ -26,17 +22,18 @@ jobs: strategy: fail-fast: true matrix: - chain: ["PENDULUM"] -# chain: ["AMPLITUDE", "PENDULUM"] -# shouldReleaseAmp: -# - ${{ contains(github.event.pull_request.title, 'amplitude') }} -# shouldReleasePen: -# - ${{ contains(github.event.pull_request.title, 'pendulum') }} -# exclude: -# - shouldReleaseAmp: false -# chain: "AMPLITUDE" -# - shouldReleasePen: false -# chain: "PENDULUM" + chain: ["AMPLITUDE", "PENDULUM"] +# The job will run for Amplitude IF the pull request has the "amplitude" in its title + shouldReleaseAmp: + - ${{ contains(github.event.pull_request.title, 'amplitude') }} +# The job will run for Pendulum IF the pull request has the "pendulum" in its title + shouldReleasePen: + - ${{ contains(github.event.pull_request.title, 'pendulum') }} + exclude: + - shouldReleaseAmp: false + chain: "AMPLITUDE" + - shouldReleasePen: false + chain: "PENDULUM" runs-on: ubuntu-latest steps: From 76c9387d7dadb4a55536ebfd3d8541cb47d13f00 Mon Sep 17 00:00:00 2001 From: b-yap <2826165+b-yap@users.noreply.github.com> Date: Fri, 17 May 2024 18:52:25 +0800 Subject: [PATCH 26/27] remove old release yaml file --- .github/workflows/release-old.yml | 136 ------------------------------ 1 file changed, 136 deletions(-) delete mode 100644 .github/workflows/release-old.yml diff --git a/.github/workflows/release-old.yml b/.github/workflows/release-old.yml deleted file mode 100644 index f66cdcd29..000000000 --- a/.github/workflows/release-old.yml +++ /dev/null @@ -1,136 +0,0 @@ -name: Release and Propose an Upgrade - -env: - SUBWASM_VERSION: 0.20.0 - -on: - pull_request: - types: - - closed - branches: - - 'main' - -jobs: - srtool: - if: ${{ github.event.pull_request.merged == true && contains(github.event.pull_request.title, 'release:') }} - name: SrTool check on ${{ matrix.chain }} ${{ github.event.inputs.ref }} - strategy: - fail-fast: false - matrix: - chain: ["amplitude", "pendulum", "foucoco"] - shouldReleaseAmp: - - ${{ contains(github.event.pull_request.title, 'amplitude') }} - shouldReleasePen: - - ${{ contains(github.event.pull_request.title, 'pendulum') }} - shouldReleaseFou: - - ${{ contains(github.event.pull_request.title, 'foucoco') }} - exclude: - - shouldReleaseAmp: false - chain: "amplitude" - - shouldReleasePen: false - chain: "pendulum" - - shouldReleaseFou: false - chain: "foucoco" - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - with: - ref: ${{ github.event.inputs.ref }} - fetch-depth: 0 - - - name: Srtool build - id: srtool_build - uses: chevdor/srtool-actions@v0.9.2 - with: - chain: ${{ matrix.chain }} - runtime_dir: runtime/${{ matrix.chain }} - # this is important to avoid build fail. See https://github.com/paritytech/srtool/issues/62 - tag: 1.66.1 - - name: Summary - run: | - echo '${{ steps.srtool_build.outputs.json }}' | jq > ${{ matrix.chain }}-srtool-digest.json - cat ${{ matrix.chain }}-srtool-digest.json - echo "Runtime location: ${{ steps.srtool_build.outputs.wasm }}" - echo '${{ steps.srtool_build.outputs.json }}' - cp ${{ steps.srtool_build.outputs.wasm }} ${{ matrix.chain }}_runtime.compact.wasm - cp ${{ steps.srtool_build.outputs.wasm_compressed }} ${{ matrix.chain }}_runtime.compact.compressed.wasm - - # it takes a while to build the runtime, so let's save the artifact as soon as we have it - - name: Archive Artifacts for ${{ matrix.chain }} - uses: actions/upload-artifact@v4 - with: - name: ${{ matrix.chain }}-runtime - path: | - ${{ matrix.chain }}_runtime.compact.wasm - ${{ matrix.chain }}_runtime.compact.compressed.wasm - ${{ matrix.chain }}-srtool-digest.json - - # We now get extra information thanks to subwasm, - - name: Install subwasm ${{ env.SUBWASM_VERSION }} - run: | - wget https://github.com/chevdor/subwasm/releases/download/v${{ env.SUBWASM_VERSION }}/subwasm_linux_amd64_v${{ env.SUBWASM_VERSION }}.deb - sudo dpkg -i subwasm_linux_amd64_v${{ env.SUBWASM_VERSION }}.deb - subwasm --version - - name: Show Runtime information - run: | - subwasm info ${{ steps.srtool_build.outputs.wasm_compressed }} - subwasm --json info ${{ steps.srtool_build.outputs.wasm }} > ${{ matrix.chain }}-info.json - subwasm --json info ${{ steps.srtool_build.outputs.wasm_compressed }} > ${{ matrix.chain }}-info_compressed.json - - name: Extract the metadata - run: | - subwasm meta ${{ steps.srtool_build.outputs.wasm }} - subwasm --json meta ${{ steps.srtool_build.outputs.wasm }} > ${{ matrix.chain }}-metadata.json - - - name: Archive Subwasm results - uses: actions/upload-artifact@v4 - with: - name: ${{ matrix.chain }}-runtime-${{ github.sha }} - path: | - ${{ matrix.chain }}-info.json - ${{ matrix.chain }}-info_compressed.json - ${{ matrix.chain }}-metadata.json - ${{ matrix.chain }}-diff.txt - - propose_upgrade: - if: ${{ success() }} - needs: srtool - name: Perform runtime upgrade on ${{ matrix.chain }} ${{ github.event.inputs.ref }} - runs-on: ubuntu-latest - strategy: - matrix: - chain: ["amplitude", "pendulum"] - shouldReleaseAmp: - - ${{ contains(github.event.pull_request.title, 'amplitude') }} - shouldReleasePen: - - ${{ contains(github.event.pull_request.title, 'pendulum') }} - exclude: - - shouldReleaseAmp: false - chain: "amplitude" - - shouldReleasePen: false - chain: "pendulum" - - steps: - - uses: actions/checkout@v4 - with: - ref: ${{ github.event.inputs.ref }} - fetch-depth: 0 - - - name: download artifact - uses: actions/download-artifact@v4 - with: - name: ${{ matrix.chain }}-runtime - - - name: prepare Node - uses: actions/setup-node@v4 - with: - node-version: '21.x' - - name: Install dependencies - run: | - cd .github/scripts/js - npm init -y - npm install - - name: run script for parachain upgrade - run: | - node --version - node .github/scripts/js/parachain_authorize_upgrade.js ${{ matrix.chain }} ${{ matrix.chain }}_runtime.compact.compressed.wasm \ No newline at end of file From 7981d43ac8b7e13f78440819a3b24921e5801228 Mon Sep 17 00:00:00 2001 From: b-yap <2826165+b-yap@users.noreply.github.com> Date: Fri, 17 May 2024 18:59:05 +0800 Subject: [PATCH 27/27] uncomment if statement --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 467fe996e..b455b2dc1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,7 +17,7 @@ jobs: # This job will only run if: # * the pull request is closed and merged to main branch; # * the pull request has the "release:" in its title -# if: ${{ github.event.pull_request.merged == true && contains(github.event.pull_request.title, 'release:') }} + if: ${{ github.event.pull_request.merged == true && contains(github.event.pull_request.title, 'release:') }} name: ${{ matrix.chain }} need new release strategy: fail-fast: true