From 3ffeabfb94d383743bc05498f4c32a22fc512caf Mon Sep 17 00:00:00 2001 From: Ermal Kaleci Date: Thu, 27 Jun 2024 14:16:07 +0200 Subject: [PATCH 1/6] zombienet smoke test --- .devcontainer/devcontainer.json | 5 ++ .github/workflows/release.yml | 31 +++++++++++- scripts/{sync.sh => sync-smoke.sh} | 11 ++-- third-party/zombienet/smoke.sh | 81 ++++++++++++++++++++++++++++++ third-party/zombienet/smoke.toml | 39 ++++++++++++++ 5 files changed, 160 insertions(+), 7 deletions(-) create mode 100644 .devcontainer/devcontainer.json rename scripts/{sync.sh => sync-smoke.sh} (79%) create mode 100755 third-party/zombienet/smoke.sh create mode 100644 third-party/zombienet/smoke.toml diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000000..53638e2fce --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,5 @@ +{ + "name": "Rust", + "image": "mcr.microsoft.com/devcontainers/rust:latest", + "runArgs": ["--platform=linux/amd64"] +} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c931ef74e5..a2790bbce0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -536,7 +536,7 @@ jobs: asset_name: evm-tracing-artifacts-${{ github.ref_name }}.tar.gz asset_content_type: application/gzip - chain-sync: + chain-sync-smoke: needs: native-linux runs-on: ubuntu-latest strategy: @@ -556,4 +556,31 @@ jobs: - name: Sync chain ${{ matrix.chain }} run: | chmod +x target/release/astar-collator - ./scripts/sync.sh ${{ matrix.chain }} + ./scripts/sync-smoke.sh ${{ matrix.chain }} + + zombienet-smoke: + needs: native-linux + runs-on: ubuntu-latest + strategy: + matrix: + chain: [ "astar-dev", "shiden-dev", "shibuya-dev" ] + + steps: + - name: Checkout the source code + uses: actions/checkout@v4 + + - name: Download pre-built collator binary + uses: actions/download-artifact@v3 + with: + name: astar-ubuntu-latest-x86_64 + path: target/release + + - name: Setup + run: | + chmod +x target/release/astar-collator + mv target/release/astar-collator third-party/zombienet + + - name: Sync chain ${{ matrix.chain }} + env: + - CHAIN: ${{ matrix.chain }} + run: ./third-party/zombienet/smoke.sh diff --git a/scripts/sync.sh b/scripts/sync-smoke.sh similarity index 79% rename from scripts/sync.sh rename to scripts/sync-smoke.sh index ba315895e3..e00ff52a4a 100755 --- a/scripts/sync.sh +++ b/scripts/sync-smoke.sh @@ -8,7 +8,9 @@ chain="$@" # run node ./target/release/astar-collator --chain $chain --no-telemetry --no-prometheus --tmp -- --no-telemetry --no-prometheus & CHAIN_PID=$! -printf "Waiting for RPC to be ready" +trap "kill $CHAIN_PID" EXIT + +echo "Waiting for RPC to be ready" attempts=12 # 1 minutes until nc -z localhost 9944; do attempts=$((attempts - 1)) @@ -19,10 +21,11 @@ until nc -z localhost 9944; do sleep 5 done -printf "Waiting for 30 seconds to sync at least 1000 blocks" +echo "Waiting for 30 seconds to sync at least 1000 blocks" sleep 30 -number=$(curl --location http://localhost:9944 \ +number=$(curl --silent \ + --location http://localhost:9944 \ --header 'Content-Type: application/json' \ --data '{ "jsonrpc": "2.0", @@ -35,5 +38,3 @@ if [ "$number" -lt 1000 ]; then echo "ERROR: Chain failed to sync 1000 blocks in 30 seconds" exit 1 fi - -kill $CHAIN_PID diff --git a/third-party/zombienet/smoke.sh b/third-party/zombienet/smoke.sh new file mode 100755 index 0000000000..036f7b50fd --- /dev/null +++ b/third-party/zombienet/smoke.sh @@ -0,0 +1,81 @@ +#!/bin/bash + +set -e + +if [ $(arch) != "x86_64" ] +then + echo "Runs only on x86_64 architecture" + exit 1 +fi + +if ! command -v ./astar-collator &> /dev/null +then + echo "No executable astar-collator binary in zombienet directory" + exit 1 +fi + +if ! command -v zombienet &> /dev/null +then + mkdir -p $HOME/.local/bin + wget -O $HOME/.local/bin/zombienet https://github.com/paritytech/zombienet/releases/download/v1.3.106/zombienet-linux-x64 + chmod a+x $HOME/.local/bin/zombienet + PATH=$HOME/.local/bin:$PATH + zombienet version +fi + +echo "Pull polkadot binaries" +zombienet setup polkadot -y & SETUP_PID=$! +while ps $SETUP_PID > /dev/null ; do + sleep 1 +done +chmod +x polkadot polkadot-execute-worker polkadot-prepare-worker + +# default to shibuya-dev +if [[ ! -v CHAIN ]]; then + export CHAIN="shibuya-dev" +fi + +echo "Start zombienet for $CHAIN" +echo "NOTE: Select chain using environmental variable CHAIN= to change it." +nohup zombienet -p native spawn smoke.toml & ZOMBIENET_PID=$! + +# kill zombienet before exit +trap "kill $ZOMBIENET_PID" EXIT + +echo "Waiting for RPC to be ready" +attempts=12 # 2 minutes +until nc -z localhost 9944; do + attempts=$((attempts - 1)) + if [ $attempts -eq 0 ]; then + echo "ERROR: Chain RPC failed to start" + exit 1 + fi + printf "." + sleep 10 +done + +echo "RPC is ready" + +number=0 +attempts=20 # 200s +while [ $number -lt 5 ]; do + attempts=$((attempts - 1)) + if [ $attempts -eq 0 ]; then + echo "ERROR: Parachain failed to build 5 blocks in 200s" + exit 1 + fi + + sleep 10 + + number=$(curl --silent \ + --location http://localhost:9944 \ + --header 'Content-Type: application/json' \ + --data '{ + "jsonrpc": "2.0", + "method": "chain_getHeader", + "params": [], + "id": 1 + }' | jq '.result.number' | xargs printf "%d") + + echo "Parachain block number $number" +done diff --git a/third-party/zombienet/smoke.toml b/third-party/zombienet/smoke.toml new file mode 100644 index 0000000000..40ddb4228a --- /dev/null +++ b/third-party/zombienet/smoke.toml @@ -0,0 +1,39 @@ +[settings] +timeout = 1000 + +# Used to start 4 validator nodes and 2 collator nodes for a single parachain. + +[relaychain] +default_command = "./polkadot" +chain = "rococo-local" + + [[relaychain.nodes]] + name = "alice" + validator = true + + [[relaychain.nodes]] + name = "bob" + validator = true + + [[relaychain.nodes]] + name = "charlie" + validator = true + + [[relaychain.nodes]] + name = "dave" + validator = true + +[[parachains]] +# Right now this has to be 2000 but soon we might be able to use arbitrary para-id +id = 2000 +chain = "{{CHAIN}}" +cumulus_based = true + + [[parachains.collators]] + name = "collator1" + command = "./astar-collator" + ws_port=9944 + + [[parachains.collators]] + name = "collator2" + command = "./astar-collator" From 28b54a65b0821acabffa6e6cd071b691cdbd7399 Mon Sep 17 00:00:00 2001 From: Ermal Kaleci Date: Thu, 27 Jun 2024 14:26:06 +0200 Subject: [PATCH 2/6] update gha --- .github/workflows/release.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a2790bbce0..d107f09935 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -581,6 +581,7 @@ jobs: mv target/release/astar-collator third-party/zombienet - name: Sync chain ${{ matrix.chain }} + working-directory: third-party/zombienet env: - CHAIN: ${{ matrix.chain }} - run: ./third-party/zombienet/smoke.sh + run: ./smoke.sh From c262afa26e2910d936dec090cb2c2361bc817902 Mon Sep 17 00:00:00 2001 From: Ermal Kaleci Date: Thu, 27 Jun 2024 14:41:15 +0200 Subject: [PATCH 3/6] fix gha --- .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 d107f09935..f917770121 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -583,5 +583,5 @@ jobs: - name: Sync chain ${{ matrix.chain }} working-directory: third-party/zombienet env: - - CHAIN: ${{ matrix.chain }} + CHAIN: ${{ matrix.chain }} run: ./smoke.sh From e53406c6d34dd3cbcbe06f0bddcc052ecb0740f4 Mon Sep 17 00:00:00 2001 From: Ermal Kaleci Date: Thu, 27 Jun 2024 16:05:41 +0200 Subject: [PATCH 4/6] update script --- third-party/zombienet/smoke.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/third-party/zombienet/smoke.sh b/third-party/zombienet/smoke.sh index 036f7b50fd..aac3fb47f3 100755 --- a/third-party/zombienet/smoke.sh +++ b/third-party/zombienet/smoke.sh @@ -14,10 +14,13 @@ then exit 1 fi +ZOMBINET_VERSION=v1.3.106 + if ! command -v zombienet &> /dev/null then + echo "Install zombienet $ZOMBINET_VERSION" mkdir -p $HOME/.local/bin - wget -O $HOME/.local/bin/zombienet https://github.com/paritytech/zombienet/releases/download/v1.3.106/zombienet-linux-x64 + wget -q -O $HOME/.local/bin/zombienet https://github.com/paritytech/zombienet/releases/download/$ZOMBINET_VERSION/zombienet-linux-x64 chmod a+x $HOME/.local/bin/zombienet PATH=$HOME/.local/bin:$PATH zombienet version From bd07dfdcf2f8bf1a5d566f4adf9ff4ddde84c912 Mon Sep 17 00:00:00 2001 From: Ermal Kaleci Date: Thu, 27 Jun 2024 18:12:34 +0200 Subject: [PATCH 5/6] use zndsl to test block height --- third-party/zombienet/smoke.sh | 45 ++----------------------------- third-party/zombienet/smoke.zndsl | 11 ++++++++ 2 files changed, 13 insertions(+), 43 deletions(-) create mode 100644 third-party/zombienet/smoke.zndsl diff --git a/third-party/zombienet/smoke.sh b/third-party/zombienet/smoke.sh index aac3fb47f3..803389f619 100755 --- a/third-party/zombienet/smoke.sh +++ b/third-party/zombienet/smoke.sh @@ -33,52 +33,11 @@ while ps $SETUP_PID > /dev/null ; do done chmod +x polkadot polkadot-execute-worker polkadot-prepare-worker -# default to shibuya-dev +# if env.CHAIN is not set then use shibuya-dev if [[ ! -v CHAIN ]]; then export CHAIN="shibuya-dev" fi echo "Start zombienet for $CHAIN" -echo "NOTE: Select chain using environmental variable CHAIN= to change it." -nohup zombienet -p native spawn smoke.toml & ZOMBIENET_PID=$! -# kill zombienet before exit -trap "kill $ZOMBIENET_PID" EXIT - -echo "Waiting for RPC to be ready" -attempts=12 # 2 minutes -until nc -z localhost 9944; do - attempts=$((attempts - 1)) - if [ $attempts -eq 0 ]; then - echo "ERROR: Chain RPC failed to start" - exit 1 - fi - printf "." - sleep 10 -done - -echo "RPC is ready" - -number=0 -attempts=20 # 200s -while [ $number -lt 5 ]; do - attempts=$((attempts - 1)) - if [ $attempts -eq 0 ]; then - echo "ERROR: Parachain failed to build 5 blocks in 200s" - exit 1 - fi - - sleep 10 - - number=$(curl --silent \ - --location http://localhost:9944 \ - --header 'Content-Type: application/json' \ - --data '{ - "jsonrpc": "2.0", - "method": "chain_getHeader", - "params": [], - "id": 1 - }' | jq '.result.number' | xargs printf "%d") - - echo "Parachain block number $number" -done +zombienet -p native test smoke.zndsl diff --git a/third-party/zombienet/smoke.zndsl b/third-party/zombienet/smoke.zndsl new file mode 100644 index 0000000000..6f84859ca8 --- /dev/null +++ b/third-party/zombienet/smoke.zndsl @@ -0,0 +1,11 @@ +Description: Parachain build blocks +Network: ./smoke.toml +Creds: config + +alice: is up +collator1: is up +collator2: is up + +## test the block height +collator1: reports block height is greater than 5 within 200 seconds +collator2: reports block height is greater than 5 within 200 seconds From 477212b14b3ec78163c69bca91d325198fb04348 Mon Sep 17 00:00:00 2001 From: Ermal Kaleci Date: Thu, 27 Jun 2024 18:17:12 +0200 Subject: [PATCH 6/6] update --- .github/workflows/release.yml | 8 ++++++-- third-party/zombienet/{smoke.sh => setup.sh} | 9 --------- 2 files changed, 6 insertions(+), 11 deletions(-) rename third-party/zombienet/{smoke.sh => setup.sh} (82%) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f917770121..13bfe7f93b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -580,8 +580,12 @@ jobs: chmod +x target/release/astar-collator mv target/release/astar-collator third-party/zombienet - - name: Sync chain ${{ matrix.chain }} + - name: Setup zombienet + working-directory: third-party/zombienet + run: ./setup.sh + + - name: ${{ matrix.chain }} build blocks working-directory: third-party/zombienet env: CHAIN: ${{ matrix.chain }} - run: ./smoke.sh + run: zombienet -p native test smoke.zndsl diff --git a/third-party/zombienet/smoke.sh b/third-party/zombienet/setup.sh similarity index 82% rename from third-party/zombienet/smoke.sh rename to third-party/zombienet/setup.sh index 803389f619..0f3a813209 100755 --- a/third-party/zombienet/smoke.sh +++ b/third-party/zombienet/setup.sh @@ -32,12 +32,3 @@ while ps $SETUP_PID > /dev/null ; do sleep 1 done chmod +x polkadot polkadot-execute-worker polkadot-prepare-worker - -# if env.CHAIN is not set then use shibuya-dev -if [[ ! -v CHAIN ]]; then - export CHAIN="shibuya-dev" -fi - -echo "Start zombienet for $CHAIN" - -zombienet -p native test smoke.zndsl