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
|
RPC_URL=$1
|
||||||
shift
|
shift
|
||||||
|
|
||||||
# Check for --starknet / --aztec flag
|
# Check for --starknet / --aztec / --cosmos flag
|
||||||
is_starknet=false
|
is_starknet=false
|
||||||
is_aztec=false
|
is_aztec=false
|
||||||
|
is_cosmos=false
|
||||||
if [ "$1" == "--starknet" ]; then
|
if [ "$1" == "--starknet" ]; then
|
||||||
is_starknet=true
|
is_starknet=true
|
||||||
shift
|
shift
|
||||||
elif [ "$1" == "--aztec" ]; then
|
elif [ "$1" == "--aztec" ]; then
|
||||||
is_aztec=true
|
is_aztec=true
|
||||||
shift
|
shift
|
||||||
|
elif [ "$1" == "--cosmos" ]; then
|
||||||
|
is_cosmos=true
|
||||||
|
shift
|
||||||
fi
|
fi
|
||||||
|
|
||||||
REF=""
|
REF=""
|
||||||
@@ -33,6 +37,28 @@ ref=${REF% }
|
|||||||
|
|
||||||
timeout=3 # seconds
|
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)
|
response_file=$(mktemp)
|
||||||
|
|
||||||
# Use appropriate RPC method based on chain type
|
# Use appropriate RPC method based on chain type
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ for path in $pathlist; do
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
case "$protocol" in
|
case "$protocol" in
|
||||||
eth|starknet|aztec)
|
eth|starknet|aztec|cosmos)
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
# Protocol family known from the registry but no probe support
|
# Protocol family known from the registry but no probe support
|
||||||
@@ -67,8 +67,10 @@ for path in $pathlist; do
|
|||||||
|
|
||||||
is_starknet=false
|
is_starknet=false
|
||||||
is_aztec=false
|
is_aztec=false
|
||||||
|
is_cosmos=false
|
||||||
[ "$protocol" = "starknet" ] && is_starknet=true
|
[ "$protocol" = "starknet" ] && is_starknet=true
|
||||||
[ "$protocol" = "aztec" ] && is_aztec=true
|
[ "$protocol" = "aztec" ] && is_aztec=true
|
||||||
|
[ "$protocol" = "cosmos" ] && is_cosmos=true
|
||||||
|
|
||||||
ref=''
|
ref=''
|
||||||
if [ -n "$2" ]; then
|
if [ -n "$2" ]; then
|
||||||
@@ -127,6 +129,12 @@ for path in $pathlist; do
|
|||||||
echo "error"
|
echo "error"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
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
|
else
|
||||||
# Ethereum chain ID detection
|
# 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)
|
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
|
$BASEPATH/check-health.sh "$RPC_URL" --aztec $ref
|
||||||
elif $is_starknet; then
|
elif $is_starknet; then
|
||||||
$BASEPATH/check-health.sh "$RPC_URL" --starknet $ref
|
$BASEPATH/check-health.sh "$RPC_URL" --starknet $ref
|
||||||
|
elif $is_cosmos; then
|
||||||
|
$BASEPATH/check-health.sh "$RPC_URL" --cosmos $ref
|
||||||
else
|
else
|
||||||
$BASEPATH/check-health.sh "$RPC_URL" $ref
|
$BASEPATH/check-health.sh "$RPC_URL" $ref
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user