cosmos: fix CometBFT RPC .result wrapping in statesync + sync-status helpers
ct_configure_statesync read .block.header.height (null — CometBFT wraps in .result) so statesync silently skipped -> gaiad fell back to genesis replay (panic). Use '.result.X // .X' (robust to wrapped/unwrapped). Same fallback in check-health --cosmos. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -43,14 +43,14 @@ timeout=3 # seconds
|
||||
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)
|
||||
catching_up=$(echo "$status" | jq -r '.result.sync_info.catching_up // .sync_info.catching_up' 2>/dev/null)
|
||||
node_height=$(echo "$status" | jq -r '.result.sync_info.latest_block_height // .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)
|
||||
ref_height=$(echo "$ref_status" | jq -r '.result.sync_info.latest_block_height // .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
|
||||
|
||||
Reference in New Issue
Block a user