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..13bfe7f93b 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,36 @@ 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: 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: zombienet -p native test smoke.zndsl 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/setup.sh b/third-party/zombienet/setup.sh new file mode 100755 index 0000000000..0f3a813209 --- /dev/null +++ b/third-party/zombienet/setup.sh @@ -0,0 +1,34 @@ +#!/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 + +ZOMBINET_VERSION=v1.3.106 + +if ! command -v zombienet &> /dev/null +then + echo "Install zombienet $ZOMBINET_VERSION" + mkdir -p $HOME/.local/bin + 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 +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 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" 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