From fbcf8e1854d8d84475f9094102996d366d03d771 Mon Sep 17 00:00:00 2001 From: aitbc Date: Wed, 29 Apr 2026 16:24:19 +0200 Subject: [PATCH] fix: Query node's supported chains before checking RPC health - Add get_supported_chains() function to query each node's health endpoint - Modify check_node_health() to use node-specific supported chains - Prevents false failures when nodes only support specific chains - Blockchain nodes may be configured to support different chains - Health check now respects each node's actual chain configuration --- scripts/multi-node/blockchain-health-check.sh | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/scripts/multi-node/blockchain-health-check.sh b/scripts/multi-node/blockchain-health-check.sh index 51c4b027..126b1e9b 100755 --- a/scripts/multi-node/blockchain-health-check.sh +++ b/scripts/multi-node/blockchain-health-check.sh @@ -76,6 +76,20 @@ check_rpc_health() { fi } +# Get supported chains for a node +get_supported_chains() { + local node_ip="$1" + local url="http://${node_ip}:${RPC_PORT}/health" + + local supported_chains=$(curl -s "$url" | python3 -c "import sys, json; data = json.load(sys.stdin); print(','.join(data.get('supported_chains', [])))" 2>/dev/null || echo "") + + if [ -z "$supported_chains" ]; then + echo "$CHAINS" # Fallback to configured chains if health endpoint doesn't return supported chains + else + echo "$supported_chains" + fi +} + # Check systemd service status (RPC-based only, no SSH) check_service_status() { local node_name="$1" @@ -117,8 +131,12 @@ check_node_health() { local failures=0 - # Check RPC health for each chain - IFS=',' read -ra CHAIN_ARRAY <<< "$CHAINS" + # Get the chains this node actually supports + local node_chains=$(get_supported_chains "$node_ip") + log "Node ${node_name} supports chains: ${node_chains}" + + # Check RPC health for each supported chain + IFS=',' read -ra CHAIN_ARRAY <<< "$node_chains" for chain in "${CHAIN_ARRAY[@]}"; do chain=$(echo "$chain" | xargs) # Trim whitespace if ! check_rpc_health "$node_name" "$node_ip" "$chain"; then