From 1c8bdce50c4c6440a0eaefca72ec4b86283c2a88 Mon Sep 17 00:00:00 2001 From: aitbc Date: Wed, 29 Apr 2026 17:08:43 +0200 Subject: [PATCH] fix: Use proper JSON parsing for chain ID in sync-verification - Replace grep-based parsing with python3 JSON parsing - Increase timeout from 5 to 10 seconds for RPC calls - Fixes Not Found error when querying chain ID from aitbc1 - Same fix pattern as blockchain-health-check.sh --- scripts/multi-node/sync-verification.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/scripts/multi-node/sync-verification.sh b/scripts/multi-node/sync-verification.sh index 966e3bee..e33490df 100755 --- a/scripts/multi-node/sync-verification.sh +++ b/scripts/multi-node/sync-verification.sh @@ -72,12 +72,15 @@ get_block_height() { get_chain_id() { local node_ip="$1" - # Get chain ID from /health endpoint - chain_id=$(curl -s --max-time 5 "http://${node_ip}:${RPC_PORT}/health" 2>/dev/null | grep -o '"supported_chains":\["[^"]*"\]' | grep -o '\["[^"]*"\]' | grep -o '[^"\[\]]*' || echo "") + # Get chain ID from /health endpoint using proper JSON parsing + local health_response=$(curl -s --max-time 10 "http://${node_ip}:${RPC_PORT}/health" 2>/dev/null) - if [ -z "$chain_id" ]; then + # Check if response is valid JSON and contains supported_chains + if echo "$health_response" | python3 -c "import sys, json; data = json.load(sys.stdin); print(','.join(data.get('supported_chains', [])))" 2>/dev/null; then + chain_id=$(echo "$health_response" | python3 -c "import sys, json; data = json.load(sys.stdin); print(','.join(data.get('supported_chains', [])))" 2>/dev/null) + else # Try alternative endpoint - chain_id=$(curl -s --max-time 5 "http://${node_ip}:${RPC_PORT}/chain-id" 2>/dev/null || echo "") + chain_id=$(curl -s --max-time 10 "http://${node_ip}:${RPC_PORT}/chain-id" 2>/dev/null || echo "") fi echo "$chain_id"