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:
2026-06-15 12:36:47 +00:00
parent 0c67fe451b
commit 55433a4822
3 changed files with 7 additions and 7 deletions

View File

@@ -169,12 +169,12 @@ ct_configure_statesync() {
[ -f "$_cfg" ] || return 0
[ -n "$_rpc" ] || { ct_log "statesync: no RPC servers given, skipping"; return 0; }
_primary=$(echo "$_rpc" | cut -d, -f1)
_latest=$(curl -s "$_primary/block" | jq -r .block.header.height 2>/dev/null || true)
_latest=$(curl -s "$_primary/block" | jq -r '.result.block.header.height // .block.header.height' 2>/dev/null || true)
if [ -z "$_latest" ] || [ "$_latest" = null ]; then
ct_log "statesync: could not read head height from $_primary, skipping"; return 0
fi
_trust_h=$((_latest - _offset))
_trust_hash=$(curl -s "$_primary/block?height=$_trust_h" | jq -r .block_id.hash 2>/dev/null || true)
_trust_hash=$(curl -s "$_primary/block?height=$_trust_h" | jq -r '.result.block_id.hash // .block_id.hash' 2>/dev/null || true)
[ -n "$_trust_hash" ] && [ "$_trust_hash" != null ] || { ct_log "statesync: no trust hash, skipping"; return 0; }
# second server defaults to the first (cometbft wants >=2 for light-client cross-check)
echo "$_rpc" | grep -q ',' || _rpc="$_rpc,$_rpc"