From e683c384ab065ef0040cf51494dbd0b99cd65817 Mon Sep 17 00:00:00 2001 From: David Lehuby Date: Mon, 2 Dec 2024 16:04:00 +1000 Subject: [PATCH] Add sync check for rust webrtc nodes on devnet --- ...{sync-check.yaml => ocaml-sync-check.yaml} | 12 +-- .github/workflows/rust-sync-check.yaml | 83 +++++++++++++++++++ scripts/mina-sync-monitor.sh | 24 +++++- 3 files changed, 110 insertions(+), 9 deletions(-) rename .github/workflows/{sync-check.yaml => ocaml-sync-check.yaml} (89%) create mode 100644 .github/workflows/rust-sync-check.yaml diff --git a/.github/workflows/sync-check.yaml b/.github/workflows/ocaml-sync-check.yaml similarity index 89% rename from .github/workflows/sync-check.yaml rename to .github/workflows/ocaml-sync-check.yaml index 651d81b..5e3ad2f 100644 --- a/.github/workflows/sync-check.yaml +++ b/.github/workflows/ocaml-sync-check.yaml @@ -1,4 +1,4 @@ -name: Daily Seed Synchronization Check +name: oCaml Seed Synchronization Check on: workflow_dispatch: schedule: @@ -18,7 +18,7 @@ jobs: id: parse-mainnet-seed-list run: | echo "Parsing Mainnet Seed List" - seeds=$(cat networks/mainnet.txt | jq -R -s -c 'split("\n") | map(select(. != ""))') + seeds=$(cat networks/devnet-webrtc.txt | jq -R -s -c 'split("\n") | map(select(. != ""))') echo "seeds=$seeds" >> $GITHUB_OUTPUT test-peer: needs: parse-mainnet-seed-list @@ -36,12 +36,14 @@ jobs: echo "Starting Mina Daemon" docker run -d --restart always --name mina \ --entrypoint="" \ - minaprotocol/mina-daemon:3.0.0-93e0279-bullseye-mainnet \ + minaprotocol/mina-daemon:${{ env.MINA_TAG }} \ mina daemon \ --peer ${{ matrix.seed }} + env: + MINA_TAG: 3.0.3-d800da8-focal-mainnet - name: Wait for Daemon to Sync id: wait-for-sync - run: ./scripts/mina-sync-monitor.sh + run: ./scripts/mina-sync-monitor.sh ocaml - name: Record Failing Seed id: record-fail if: ${{ failure() }} @@ -76,7 +78,7 @@ jobs: if: ${{ success() }} uses: slackapi/slack-github-action@v1.26.0 with: - channel-id: "mf-alerts-info" + channel-id: "mf-alerts-test" payload-file-path: "./payload-slack-content.json" env: SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} diff --git a/.github/workflows/rust-sync-check.yaml b/.github/workflows/rust-sync-check.yaml new file mode 100644 index 0000000..ffd38b9 --- /dev/null +++ b/.github/workflows/rust-sync-check.yaml @@ -0,0 +1,83 @@ +name: Rust Seed Synchronization Check +on: + workflow_dispatch: + schedule: + - cron: "0 */3 * * *" # Every 3 Hours +concurrency: + group: "${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}" + cancel-in-progress: true +jobs: + parse-mainnet-seed-list: + runs-on: minafoundation-default-interruptible-runners + outputs: + seeds: ${{ steps.parse-mainnet-seed-list.outputs.seeds }} + steps: + - name: 📥 Checkout + uses: actions/checkout@v4.1.1 + - name: Parse Mainnet Seed List + id: parse-mainnet-seed-list + run: | + echo "Parsing Mainnet Seed List" + seeds=$(cat networks/devnet-webrtc.txt | jq -R -s -c 'split("\n") | map(select(. != ""))') + echo "seeds=$seeds" >> $GITHUB_OUTPUT + test-peer: + needs: parse-mainnet-seed-list + runs-on: minafoundation-xlarge-interruptible-runners + if: needs.parse-mainnet-seed-list.outputs.seeds != '[]' && needs.parse-mainnet-seed-list.outputs.seeds != '' + continue-on-error: true + strategy: + matrix: + seed: ${{ fromJson(needs.parse-mainnet-seed-list.outputs.seeds) }} + steps: + - name: 📥 Checkout + uses: actions/checkout@v4.1.1 + - name: Start Mina Daemon + run: | + echo "Starting Mina Daemon" + docker run --rm -d --name openmina \ + openmina/openmina:${{ env.MINA_TAG }} \ + node \ + --peers ${{ matrix.seed }} + env: + MINA_TAG: v0.11.4 + - name: Wait for Daemon to Sync + id: wait-for-sync + run: ./scripts/mina-sync-monitor.sh rust + - name: Record Failing Seed + id: record-fail + if: ${{ failure() }} + run: | + echo "Update Failed Seed List" + echo "${{ matrix.seed }}" > failed-seeds-${{strategy.job-index}}.txt + - name: Upload failed seeds + if: ${{ failure() }} + uses: actions/upload-artifact@v4.4.0 + with: + name: failed-seeds-${{strategy.job-index}} + path: failed-seeds-${{strategy.job-index}}.txt + retention-days: 1 + + print-failed-seeds: + needs: test-peer + runs-on: minafoundation-default-interruptible-runners + continue-on-error: true + steps: + - name: Download all artifacts + uses: actions/download-artifact@v4 + with: + pattern: "failed-seeds-*" # Use a wildcard to download all artifacts matching the pattern + - name: Echo Failed Seeds + run: | + cat failed-seeds-*/failed-seeds-*.txt > failed-seeds.txt || exit 0 + jq -n --arg message "Failed to synchronize with Mina Daemon using seed peer:" \ + --argjson seeds "$(cat failed-seeds.txt | jq -R . | jq -s .)" \ + '{text: ($message + "\n\n" + ($seeds | map("• " + .) | join("\n")))}' > payload-slack-content.json + - name: Post to a Slack channel + id: slack + if: ${{ success() }} + uses: slackapi/slack-github-action@v1.26.0 + with: + channel-id: "mf-alerts-testing" + payload-file-path: "./payload-slack-content.json" + env: + SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} diff --git a/scripts/mina-sync-monitor.sh b/scripts/mina-sync-monitor.sh index cef9087..0bd77c8 100755 --- a/scripts/mina-sync-monitor.sh +++ b/scripts/mina-sync-monitor.sh @@ -1,25 +1,41 @@ #!/usr/bin/env bash set -e + max_attempts=40 attempt=0 -sleep_duration=500 status="Null" +sleep_duration=500 +sync_check_command_ocaml="docker exec mina mina client status --json | jq -r .sync_status" +sync_check_command_rust="docker exec openmina curl -s http://localhost:3000/status | jq -r .transition_frontier.sync.status" check_sync_status() { - status=$(docker exec mina mina client status --json | jq -r .sync_status || echo "Null") + if [ "$1" == "ocaml" ]; then + status=$(eval "$sync_check_command_ocaml" || echo "Null") + elif [ "$1" == "rust" ]; then + status=$(eval "$sync_check_command_rust" || echo "Null") + else + status="Null" + fi echo "Current sync status: $status" } # Loop to check sync status while [ $attempt -lt $max_attempts ]; do - check_sync_status + if [ "$1" == "ocaml" ]; then + check_sync_status "ocaml" + elif [ "$1" == "rust" ]; then + check_sync_status "rust" + else + echo "Invalid container type. Please specify 'ocaml' or 'rust'." + exit 1 + fi + if [ "$status" == "Synced" ]; then echo "Mina client is synced." exit 0 fi attempt=$((attempt + 1)) - echo "Mina daemon is not synced. Attempt $attempt/$max_attempts." sleep $sleep_duration done