From d15dd21da6e089027fa1d4ee1d66189623544763 Mon Sep 17 00:00:00 2001 From: Ermal Kaleci Date: Fri, 7 Jun 2024 15:26:04 +0200 Subject: [PATCH 1/3] chain sync test --- .github/workflows/chain-sync.yml | 44 ++++++++++++++++++++++++++++++++ scripts/sync.sh | 39 ++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+) create mode 100644 .github/workflows/chain-sync.yml create mode 100755 scripts/sync.sh diff --git a/.github/workflows/chain-sync.yml b/.github/workflows/chain-sync.yml new file mode 100644 index 000000000..e3ef7e042 --- /dev/null +++ b/.github/workflows/chain-sync.yml @@ -0,0 +1,44 @@ +name: Chain Sync + +on: + push: + branches: ["master"] + tags: + - v[0-9]+.[0-9]+.[0-9]+* + pull_request: + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + chain-sync: + continue-on-error: true + timeout-minutes: 60 + runs-on: ubuntu-latest + + steps: + - name: Checkout sources + uses: actions/checkout@v4 + + - name: Install deps + run: sudo apt -y install protobuf-compiler + + - name: Install & display rust toolchain + run: rustup show + + - name: Check targets are installed correctly + run: rustup target list --installed + + - name: Build + run: cargo build --release --locked + + - name: Test astar sync + run: ./scripts/sync.sh astar + + - name: Test shiden sync + run: ./scripts/sync.sh shiden + + - name: Test shibuya sync + run: ./scripts/sync.sh shibuya diff --git a/scripts/sync.sh b/scripts/sync.sh new file mode 100755 index 000000000..8bd998843 --- /dev/null +++ b/scripts/sync.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +set -e + +# first argument is chain +chain="$@" + +# run node +./target/release/astar-collator --chain $chain --no-telemetry --no-prometheus --tmp & CHAIN_PID=$! + +printf "Waiting for RPC to be ready" +attempts=12 # 1 minutes +until nc -z localhost 9944; do + attempts=$((attempts - 1)) + if [ $attempts -eq 0 ]; then + echo "Chain RPC failed to start" + exit 1 + fi + sleep 5 +done + +printf "Waiting for 30 seconds to sync at least 1000 blocks" +sleep 30 + +number=$(curl --location http://localhost:9944 \ + --header 'Content-Type: application/json' \ + --data '{ + "jsonrpc": "2.0", + "method": "chain_getHeader", + "params": [], + "id": 1 + }' | jq '.result.number' | xargs | { read hex_number; printf "%d\n" $hex_number; }) + +if [ "$number" -lt 1000 ]; then + echo "Chain failed to sync 1000 blocks in 30 seconds" + exit 1 +fi + +kill $CHAIN_PID From 897d4e4671ca29468c97c72e1c6305c5c4fcce68 Mon Sep 17 00:00:00 2001 From: Ermal Kaleci Date: Fri, 7 Jun 2024 16:22:18 +0200 Subject: [PATCH 2/3] finish --- .github/workflows/chain-sync.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/chain-sync.yml b/.github/workflows/chain-sync.yml index e3ef7e042..5615b9246 100644 --- a/.github/workflows/chain-sync.yml +++ b/.github/workflows/chain-sync.yml @@ -2,10 +2,8 @@ name: Chain Sync on: push: - branches: ["master"] tags: - v[0-9]+.[0-9]+.[0-9]+* - pull_request: workflow_dispatch: concurrency: From 9082fb0c33a6186869371e17fcea62a9ca79dd6a Mon Sep 17 00:00:00 2001 From: Ermal Kaleci Date: Mon, 10 Jun 2024 23:02:08 +0200 Subject: [PATCH 3/3] move to release gha --- .github/workflows/chain-sync.yml | 42 ------------------- .github/workflows/release.yml | 72 +++++++++++++++++++++----------- scripts/sync.sh | 8 ++-- 3 files changed, 51 insertions(+), 71 deletions(-) delete mode 100644 .github/workflows/chain-sync.yml diff --git a/.github/workflows/chain-sync.yml b/.github/workflows/chain-sync.yml deleted file mode 100644 index 5615b9246..000000000 --- a/.github/workflows/chain-sync.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: Chain Sync - -on: - push: - tags: - - v[0-9]+.[0-9]+.[0-9]+* - workflow_dispatch: - -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - -jobs: - chain-sync: - continue-on-error: true - timeout-minutes: 60 - runs-on: ubuntu-latest - - steps: - - name: Checkout sources - uses: actions/checkout@v4 - - - name: Install deps - run: sudo apt -y install protobuf-compiler - - - name: Install & display rust toolchain - run: rustup show - - - name: Check targets are installed correctly - run: rustup target list --installed - - - name: Build - run: cargo build --release --locked - - - name: Test astar sync - run: ./scripts/sync.sh astar - - - name: Test shiden sync - run: ./scripts/sync.sh shiden - - - name: Test shibuya sync - run: ./scripts/sync.sh shibuya diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ff8120ab3..ad7327056 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,7 +20,7 @@ jobs: df -h - name: Checkout the source code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: true @@ -53,7 +53,7 @@ jobs: steps: - name: Checkout the source code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: true @@ -98,7 +98,7 @@ jobs: id: artifact-name run: echo "::set-output name=name::astar-ubuntu-latest-${TARGET%%-*}" - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: ${{ steps.artifact-name.outputs.name }} path: target/${{ matrix.target }}/release/astar-collator @@ -109,7 +109,7 @@ jobs: steps: - name: Checkout the source code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: true @@ -131,7 +131,7 @@ jobs: - name: Build optimized binary with evm tracing run: CARGO_PROFILE_RELEASE_LTO=true RUSTFLAGS="-C codegen-units=1" cargo build --release --target x86_64-unknown-linux-gnu --features evm-tracing --verbose --locked - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: astar-evm-tracing-ubuntu-latest-x86_64-unknown-linux-gnu path: target/x86_64-unknown-linux-gnu/release/astar-collator @@ -142,17 +142,17 @@ jobs: mv target/x86_64-unknown-linux-gnu/release/wbuild/shiden-runtime/shiden_runtime.compact.compressed.wasm target/x86_64-unknown-linux-gnu/release/wbuild/shiden-runtime/shiden_evm_tracing_runtime.compact.compressed.wasm mv target/x86_64-unknown-linux-gnu/release/wbuild/shibuya-runtime/shibuya_runtime.compact.compressed.wasm target/x86_64-unknown-linux-gnu/release/wbuild/shibuya-runtime/shibuya_evm_tracing_runtime.compact.compressed.wasm - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: astar-evm-tracing-runtime path: target/x86_64-unknown-linux-gnu/release/wbuild/astar-runtime/astar_evm_tracing_runtime.compact.compressed.wasm - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: shiden-evm-tracing-runtime path: target/x86_64-unknown-linux-gnu/release/wbuild/shiden-runtime/shiden_evm_tracing_runtime.compact.compressed.wasm - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: shibuya-evm-tracing-runtime path: target/x86_64-unknown-linux-gnu/release/wbuild/shibuya-runtime/shibuya_evm_tracing_runtime.compact.compressed.wasm @@ -170,7 +170,7 @@ jobs: contents: read steps: - name: Checkout the source code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: true @@ -196,7 +196,7 @@ jobs: - name: Show sccache stats run: sccache --show-stats - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: astar-macOS-latest-x86_64 path: target/release/astar-collator @@ -206,7 +206,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout the source code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: true @@ -228,7 +228,7 @@ jobs: tag-sha: true # add git short SHA as Docker tag - name: Download pre-built linux collator binary - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: astar-ubuntu-latest-x86_64 @@ -251,7 +251,7 @@ jobs: matrix: chain: ["astar", "shiden", "shibuya"] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 @@ -273,7 +273,7 @@ jobs: # 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@v3 + uses: actions/upload-artifact@v4 with: name: ${{ matrix.chain }}-runtime path: | @@ -311,7 +311,7 @@ jobs: tee ${{ matrix.chain }}-diff.txt - name: Archive Subwasm results - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: ${{ matrix.chain }}-runtime path: | @@ -327,24 +327,24 @@ jobs: release_url: ${{ steps.create-release.outputs.html_url }} upload_url: ${{ steps.create-release.outputs.upload_url }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 - name: Download astar runtime - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: astar-runtime path: runtime-artifacts - name: Download shiden runtime - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: shiden-runtime path: runtime-artifacts - name: Download shibuya runtime - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: shibuya-runtime path: runtime-artifacts @@ -398,7 +398,7 @@ jobs: mkdir -p ubuntu-tracing-bin - name: Download pre-built collator binary - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: astar-${{ matrix.os }}-latest-${{ matrix.arch }} path: ${{ matrix.os }}-${{ matrix.arch }}-bin @@ -427,7 +427,7 @@ jobs: chain: ["astar", "shiden", "shibuya"] steps: - name: Download runtime - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: ${{ matrix.chain }}-runtime @@ -491,25 +491,25 @@ jobs: runs-on: ubuntu-latest steps: - name: Download pre-built collator binary for evm tracing - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: astar-evm-tracing-ubuntu-latest-x86_64-unknown-linux-gnu path: evm-tracing-artifacts - name: Download evm tracing runtime - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: astar-evm-tracing-runtime path: evm-tracing-artifacts - name: Download evm tracing runtime - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: shiden-evm-tracing-runtime path: evm-tracing-artifacts - name: Download evm tracing runtime - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: shibuya-evm-tracing-runtime path: evm-tracing-artifacts @@ -535,3 +535,25 @@ jobs: asset_path: evm-tracing-artifacts.tar.gz asset_name: evm-tracing-artifacts-${{ github.ref_name }}.tar.gz asset_content_type: application/gzip + + chain-sync: + needs: native-linux + runs-on: ubuntu-latest + strategy: + matrix: + chain: [ "astar", "shiden", "shibuya" ] + + steps: + - name: Checkout the source code + uses: actions/checkout@v4 + + - name: Download pre-built collator binary + uses: actions/download-artifact@v4 + with: + name: astar-ubuntu-latest-x86_64 + path: target/release + + - name: Sync chain ${{ matrix.chain }} + run: | + chmod +x target/release/astar-collator + ./scripts/sync.sh ${{ matrix.chain }} diff --git a/scripts/sync.sh b/scripts/sync.sh index 8bd998843..ba315895e 100755 --- a/scripts/sync.sh +++ b/scripts/sync.sh @@ -6,14 +6,14 @@ set -e chain="$@" # run node -./target/release/astar-collator --chain $chain --no-telemetry --no-prometheus --tmp & CHAIN_PID=$! +./target/release/astar-collator --chain $chain --no-telemetry --no-prometheus --tmp -- --no-telemetry --no-prometheus & CHAIN_PID=$! printf "Waiting for RPC to be ready" attempts=12 # 1 minutes until nc -z localhost 9944; do attempts=$((attempts - 1)) if [ $attempts -eq 0 ]; then - echo "Chain RPC failed to start" + echo "ERROR: Chain RPC failed to start" exit 1 fi sleep 5 @@ -29,10 +29,10 @@ number=$(curl --location http://localhost:9944 \ "method": "chain_getHeader", "params": [], "id": 1 - }' | jq '.result.number' | xargs | { read hex_number; printf "%d\n" $hex_number; }) + }' | jq '.result.number' | xargs printf "%d") if [ "$number" -lt 1000 ]; then - echo "Chain failed to sync 1000 blocks in 30 seconds" + echo "ERROR: Chain failed to sync 1000 blocks in 30 seconds" exit 1 fi