From 78c78f5079cfe0afdb3da8f381eaae6384529eb9 Mon Sep 17 00:00:00 2001 From: Claude Agent Date: Mon, 15 Jun 2026 12:15:54 +0000 Subject: [PATCH] sync-status: add cosmos/CometBFT handler (gaiad + cosmos batch) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cosmos-hub has NO EVM RPC — eth_blockNumber checks don't apply. Add a --cosmos handler that probes the CometBFT /status method: sync_info.catching_up=false => online, else syncing; optional head-gap check vs the drpc reference. sync-status.sh dispatches protocol=cosmos -> check-health.sh --cosmos. eth/starknet/aztec untouched. Co-Authored-By: Claude Opus 4.8 (1M context) --- check-health.sh | 28 +++++++++++++++++++++++++++- sync-status.sh | 12 +++++++++++- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/check-health.sh b/check-health.sh index d2b123f3..2e9c8c37 100755 --- a/check-health.sh +++ b/check-health.sh @@ -10,15 +10,19 @@ fi RPC_URL=$1 shift -# Check for --starknet / --aztec flag +# Check for --starknet / --aztec / --cosmos flag is_starknet=false is_aztec=false +is_cosmos=false if [ "$1" == "--starknet" ]; then is_starknet=true shift elif [ "$1" == "--aztec" ]; then is_aztec=true shift +elif [ "$1" == "--cosmos" ]; then + is_cosmos=true + shift fi REF="" @@ -33,6 +37,28 @@ ref=${REF% } timeout=3 # seconds +# CometBFT / cosmos (gaiad and the cosmos batch): no EVM RPC. Use the chain's own +# sync_info from the CometBFT /status method — catching_up=false means caught up to head. +# Short-circuits here; the EVM/starknet/aztec block-comparison path below is not used. +if $is_cosmos; then + status=$(curl -L --ipv4 -m $timeout -s -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","id":1,"method":"status"}' "$RPC_URL") + if [ $? -ne 0 ] || [ -z "$status" ]; then echo "timeout"; exit 1; fi + catching_up=$(echo "$status" | jq -r '.result.sync_info.catching_up' 2>/dev/null) + node_height=$(echo "$status" | jq -r '.result.sync_info.latest_block_height' 2>/dev/null) + if [ -z "$node_height" ] || [ "$node_height" = "null" ]; then echo "error"; exit 1; fi + if [ "$catching_up" = "true" ]; then echo "syncing"; exit 1; fi + # catching_up=false => synced. If a reference endpoint is given, sanity-check head gap. + if [ -n "$ref" ]; then + ref_status=$($BASEPATH/multicurl.sh -L --ipv4 -m $timeout -s -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","id":1,"method":"status"}' $ref) + ref_height=$(echo "$ref_status" | jq -r '.result.sync_info.latest_block_height' 2>/dev/null) + if [ -n "$ref_height" ] && [ "$ref_height" != "null" ] && [ "$ref_height" -gt 0 ] 2>/dev/null; then + gap=$(( ref_height - node_height )) + if [ "$gap" -gt 100 ]; then echo "behind ($gap)"; exit 1; fi + fi + fi + echo "online"; exit 0 +fi + response_file=$(mktemp) # Use appropriate RPC method based on chain type diff --git a/sync-status.sh b/sync-status.sh index a19623b2..9ffa5d68 100755 --- a/sync-status.sh +++ b/sync-status.sh @@ -54,7 +54,7 @@ for path in $pathlist; do fi case "$protocol" in - eth|starknet|aztec) + eth|starknet|aztec|cosmos) ;; *) # Protocol family known from the registry but no probe support @@ -67,8 +67,10 @@ for path in $pathlist; do is_starknet=false is_aztec=false + is_cosmos=false [ "$protocol" = "starknet" ] && is_starknet=true [ "$protocol" = "aztec" ] && is_aztec=true + [ "$protocol" = "cosmos" ] && is_cosmos=true ref='' if [ -n "$2" ]; then @@ -127,6 +129,12 @@ for path in $pathlist; do echo "error" exit 1 fi + elif $is_cosmos; then + # Cosmos/CometBFT: no chainid. Reference by drpc slug (optional — the node's + # own sync_info.catching_up is authoritative; ref only adds a head-gap check). + if [ -n "$chain_slug" ]; then + ref=$($BASEPATH/reference-rpc-endpoint.sh --chain "$chain_slug" 2>/dev/null) || ref="" + fi else # Ethereum chain ID detection chain_id_response=$(curl -L --ipv4 -m 1 -s -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_chainId","params":[],"id":1}' $RPC_URL) @@ -155,6 +163,8 @@ for path in $pathlist; do $BASEPATH/check-health.sh "$RPC_URL" --aztec $ref elif $is_starknet; then $BASEPATH/check-health.sh "$RPC_URL" --starknet $ref + elif $is_cosmos; then + $BASEPATH/check-health.sh "$RPC_URL" --cosmos $ref else $BASEPATH/check-health.sh "$RPC_URL" $ref fi