diff --git a/.github/workflows/node.yml b/.github/workflows/node.yml new file mode 100644 index 0000000..be38fa4 --- /dev/null +++ b/.github/workflows/node.yml @@ -0,0 +1,38 @@ +name: Testnet Deployment CI + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + testnet: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + submodules: 'recursive' + + - name: Set up Go 1.23.0 + uses: actions/setup-go@v4 + with: + go-version: '1.23.0' + + - name: Install JQ + run: sudo apt-get install jq + + - name: Build dependencies + run: ./build-dependencies.sh + + - name: Start Testnet + run: | + ./node.sh & + sleep 60 + + - name: Run Health check + run: ./healthcheck.sh \ No newline at end of file diff --git a/healthcheck.sh b/healthcheck.sh new file mode 100755 index 0000000..2f4a2a1 --- /dev/null +++ b/healthcheck.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +BEACON_CONFIG_DIR=./config/beacond +BEACOND_BINARY=./dependencies/beacon-kit/build/bin/beacond +INTERVAL=5 # Interval in seconds between checks +TRIES=5 # Number of times to check + +# Initialize the previous block height +previous_block_height=0 + +for ((i = 1; i <= TRIES; i++)); do + # Get the latest block height + latest_block_height=$($BEACOND_BINARY --home=$BEACON_CONFIG_DIR status | jq -r .sync_info.latest_block_height) + + # Validate the block height is a number + if ! [[ "$latest_block_height" =~ ^[0-9]+$ ]]; then + echo "Error: Failed to fetch latest_block_height. Received: $latest_block_height" + exit 1 + fi + + echo "Check $i: Latest Block Height = $latest_block_height" + + # Compare with the previous block height + if (( i > 1 )) && (( latest_block_height <= previous_block_height )); then + echo "Block height is not increasing (previous: $previous_block_height, current: $latest_block_height)." + exit 1 + fi + + # Update the previous block height + previous_block_height=$latest_block_height + + # Sleep before the next iteration (skip sleep after the last iteration) + if (( i < TRIES )); then + sleep $INTERVAL + fi +done + +echo "Block height is increasing consistently over $TRIES checks." +exit 0 diff --git a/node.sh b/node.sh index 8439cc4..0a9f676 100755 --- a/node.sh +++ b/node.sh @@ -58,7 +58,7 @@ MONIKER_NAME=BIG_BERA_DEFAULT_QUICKSTART_NODE_$(date +"%s") # If USE_SNAPSHOT is true, then a snapshot will be downloaded to bootstrap the state, allowing for faster sync time. # Introduces a trust assumption that the snapshot provider is trustworthy -USE_SNAPSHOT=true +USE_SNAPSHOT=false SNAPSHOTS_DIRECTORY=./snapshots # Update to use a source closer to your geography.