From 693b845c45cb1683dcfeeb3fd3961e7e64e6e871 Mon Sep 17 00:00:00 2001 From: Felipe Knorr Kuhn Date: Sat, 23 Sep 2023 11:57:20 -0700 Subject: [PATCH 1/2] Add block height workflow --- .../workflows/get_backend_block_height.yml | 19 +++++++++++++++ scripts/get_block_tip_height.sh | 24 +++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 .github/workflows/get_backend_block_height.yml create mode 100644 scripts/get_block_tip_height.sh diff --git a/.github/workflows/get_backend_block_height.yml b/.github/workflows/get_backend_block_height.yml new file mode 100644 index 000000000..52f3b038c --- /dev/null +++ b/.github/workflows/get_backend_block_height.yml @@ -0,0 +1,19 @@ +name: 'Check if servers are in sync' + +on: [workflow_dispatch] + +jobs: + print-backend-sha: + runs-on: 'ubuntu-latest' + name: Get block height + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + path: repo + + - name: Run script + working-directory: repo + run: | + chmod +x ./scripts/get_block_tip_height.sh + sh ./scripts/get_block_tip_height.sh diff --git a/scripts/get_block_tip_height.sh b/scripts/get_block_tip_height.sh new file mode 100644 index 000000000..861be0406 --- /dev/null +++ b/scripts/get_block_tip_height.sh @@ -0,0 +1,24 @@ +BASE_HEIGHT=$(curl -sk https://node202.tk7.mempool.space/api/v1/blocks/tip/height) +IN_SYNC=true +echo "Base height (node202.tk7): $BASE_HEIGHT" + +for LOCATION in fmt va1 fra tk7 +do + for NODE in 201 202 203 204 205 206 + do + NODE_HEIGHT=$(curl -sk https://node$NODE.$LOCATION.mempool.space/api/v1/blocks/tip/height) + echo $(echo node$NODE.$LOCATION.mempool.space) - $NODE_HEIGHT + if [ "$NODE_HEIGHT" -ne "$BASE_HEIGHT" ]; then + echo $(echo node$NODE.$LOCATION.mempool.space) is not in sync + IN_SYNC=false + fi + done +done + +if [ "$IN_SYNC" = false ]; then + echo "One or more servers are out of sync. Check the logs." + exit -1 +else + echo "All servers are in sync." +fi + From 24b3ca559d89bf9665111c28c9e5e1c27e63b2c5 Mon Sep 17 00:00:00 2001 From: Felipe Knorr Kuhn Date: Sat, 23 Sep 2023 13:30:54 -0700 Subject: [PATCH 2/2] Add block delta to the logs --- scripts/get_block_tip_height.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/get_block_tip_height.sh b/scripts/get_block_tip_height.sh index 861be0406..603193bb8 100644 --- a/scripts/get_block_tip_height.sh +++ b/scripts/get_block_tip_height.sh @@ -9,7 +9,8 @@ do NODE_HEIGHT=$(curl -sk https://node$NODE.$LOCATION.mempool.space/api/v1/blocks/tip/height) echo $(echo node$NODE.$LOCATION.mempool.space) - $NODE_HEIGHT if [ "$NODE_HEIGHT" -ne "$BASE_HEIGHT" ]; then - echo $(echo node$NODE.$LOCATION.mempool.space) is not in sync + COUNT=$((BASE_HEIGHT-NODE_HEIGHT)) + echo $(echo node$NODE.$LOCATION.mempool.space) is not in sync. delta: $COUNT IN_SYNC=false fi done