Add Chain 138 RPC capability verification

This commit is contained in:
defiQUG
2026-03-28 15:56:42 -07:00
parent 56fd41b7bc
commit d65baa02f2

View File

@@ -1,9 +1,11 @@
#!/usr/bin/env bash
# Chain 138 — RPC health: parallel head check + per-node peer count.
# Exit 0 if all HTTP RPCs respond, head spread <= max_blocks_spread, each peer count >= min_peers.
# Chain 138 — RPC health: parallel head check + per-node peer count + public RPC capability probe.
# Exit 0 if all HTTP RPCs respond, head spread <= max_blocks_spread, each peer count >= min_peers,
# and the public RPC capability probe matches the currently documented support matrix.
#
# Usage: ./scripts/verify/check-chain138-rpc-health.sh
# Env: RPC_MAX_HEAD_SPREAD (default 12), RPC_MIN_PEERS (default 10), RPC_TIMEOUT_SEC (default 20)
# Env: RPC_MAX_HEAD_SPREAD (default 12), RPC_MIN_PEERS (default 10), RPC_TIMEOUT_SEC (default 20),
# CHAIN138_PUBLIC_RPC_URL (default https://rpc-http-pub.d-bis.org)
set -euo pipefail
@@ -15,6 +17,7 @@ source "${PROJECT_ROOT}/config/ip-addresses.conf" 2>/dev/null || true
MAX_SPREAD="${RPC_MAX_HEAD_SPREAD:-12}"
MIN_PEERS="${RPC_MIN_PEERS:-10}"
TO="${RPC_TIMEOUT_SEC:-20}"
PUBLIC_RPC_URL="${CHAIN138_PUBLIC_RPC_URL:-https://rpc-http-pub.d-bis.org}"
# VMID|IP (HTTP :8545)
RPC_ROWS=(
@@ -89,6 +92,61 @@ fi
if [[ "$fail" -eq 0 ]]; then
echo "OK: all RPCs responded, peers >= $MIN_PEERS, spread <= $MAX_SPREAD"
else
echo "FAIL: $fail check(s) failed"
fi
echo
echo "Chain 138 public RPC capability probe ($PUBLIC_RPC_URL)"
rpc_request() {
local method="$1"
local params="${2:-[]}"
curl -sS -m "$TO" -X POST "$PUBLIC_RPC_URL" \
-H "Content-Type: application/json" \
-d "{\"jsonrpc\":\"2.0\",\"method\":\"${method}\",\"params\":${params},\"id\":1}"
}
check_supported_method() {
local method="$1"
local params="${2:-[]}"
local response result
response="$(rpc_request "$method" "$params" || printf '%s' '{"error":"curl"}')"
result="$(printf '%s' "$response" | jq -r '.result // empty' 2>/dev/null || true)"
if [[ -n "$result" ]]; then
printf ' %-32s %s\n' "$method" "OK"
return 0
fi
printf ' %-32s %s\n' "$method" "FAIL"
((fail++)) || true
return 1
}
check_expected_missing_method() {
local method="$1"
local params="${2:-[]}"
local response code message
response="$(rpc_request "$method" "$params" || printf '%s' '{"error":"curl"}')"
code="$(printf '%s' "$response" | jq -r '.error.code // empty' 2>/dev/null || true)"
message="$(printf '%s' "$response" | jq -r '.error.message // empty' 2>/dev/null || true)"
if [[ "$code" == "-32601" || "$message" == "Method not found" ]]; then
printf ' %-32s %s\n' "$method" "EXPECTED_MISSING"
return 0
fi
printf ' %-32s %s\n' "$method" "UNEXPECTED"
((fail++)) || true
return 1
}
check_supported_method "eth_chainId"
check_supported_method "eth_gasPrice"
check_supported_method "eth_feeHistory" "[\"0x1\", \"latest\", []]"
check_supported_method "trace_block" "[\"0x1\"]"
check_supported_method "trace_replayBlockTransactions" "[\"0x1\", [\"trace\"]]"
check_expected_missing_method "eth_maxPriorityFeePerGas"
if [[ "$fail" -eq 0 ]]; then
echo "OK: node health and public RPC capability checks passed"
exit 0
fi
echo "FAIL: $fail check(s) failed"