From d65baa02f2250607d3f4120a42c34bcdd2206dfd Mon Sep 17 00:00:00 2001 From: defiQUG Date: Sat, 28 Mar 2026 15:56:42 -0700 Subject: [PATCH] Add Chain 138 RPC capability verification --- scripts/verify/check-chain138-rpc-health.sh | 64 ++++++++++++++++++++- 1 file changed, 61 insertions(+), 3 deletions(-) diff --git a/scripts/verify/check-chain138-rpc-health.sh b/scripts/verify/check-chain138-rpc-health.sh index 4fd4b26..846cb41 100755 --- a/scripts/verify/check-chain138-rpc-health.sh +++ b/scripts/verify/check-chain138-rpc-health.sh @@ -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"