sync-status: add cosmos/CometBFT handler (gaiad + cosmos batch)
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) <noreply@anthropic.com>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user