- Update dbis_core, cross-chain-pmm-lps, explorer-monorepo, metamask-integration, pr-workspace/chains - Omit embedded publish git dirs and empty placeholders from index Made-with: Cursor
121 lines
4.2 KiB
Bash
Executable File
121 lines
4.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Verify GRU Monetary Transport Layer runtime readiness via /api/v1/bridge/preflight.
|
|
# Usage: bash scripts/verify/check-gru-transport-preflight.sh [base_url]
|
|
# base_url: Optional API base, defaults to https://explorer.d-bis.org
|
|
#
|
|
# Exit codes:
|
|
# 0 = endpoint healthy and, unless ALLOW_BLOCKED=1, no blocked pairs remain
|
|
# 1 = endpoint unreachable, wrong payload, or blocked pairs remain
|
|
#
|
|
# Env:
|
|
# SKIP_EXIT=1 Print diagnostics but always exit 0
|
|
# ALLOW_BLOCKED=1 Treat blocked pairs as warnings instead of failures
|
|
|
|
set -euo pipefail
|
|
|
|
BASE_URL="${1:-${BASE_URL:-https://explorer.d-bis.org}}"
|
|
BASE_URL="${BASE_URL%/}"
|
|
SKIP_EXIT="${SKIP_EXIT:-0}"
|
|
ALLOW_BLOCKED="${ALLOW_BLOCKED:-0}"
|
|
HAD_FAILURE=0
|
|
|
|
log() { printf '%s\n' "$*"; }
|
|
ok() { printf '[OK] %s\n' "$*"; }
|
|
warn() { printf '[WARN] %s\n' "$*"; }
|
|
fail() {
|
|
printf '[FAIL] %s\n' "$*"
|
|
HAD_FAILURE=1
|
|
if [[ "$SKIP_EXIT" != "1" ]]; then
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
tmp_body="$(mktemp)"
|
|
trap 'rm -f "$tmp_body"' EXIT
|
|
|
|
fetch_preflight() {
|
|
local prefix
|
|
for prefix in "" "/token-aggregation"; do
|
|
local url="${BASE_URL}${prefix}/api/v1/bridge/preflight"
|
|
local code
|
|
code="$(curl -sS -o "$tmp_body" -w "%{http_code}" -m 25 "$url" 2>/dev/null || echo "000")"
|
|
if [[ "$code" == "200" ]]; then
|
|
printf '%s\n' "$prefix"
|
|
return 0
|
|
fi
|
|
done
|
|
return 1
|
|
}
|
|
|
|
log "=== GRU Transport preflight ==="
|
|
log "Base URL: $BASE_URL"
|
|
log ""
|
|
|
|
if ! prefix="$(fetch_preflight)"; then
|
|
fail "Could not fetch /api/v1/bridge/preflight on either /api/v1 or /token-aggregation/api/v1."
|
|
fi
|
|
|
|
if ! jq -e '
|
|
type == "object" and
|
|
(.gruTransport | type == "object") and
|
|
(.gruTransport.summary.transportPairs | type == "number") and
|
|
(.gruTransport.blockedPairs | type == "array") and
|
|
(.gruTransport.readyPairs | type == "array")
|
|
' "$tmp_body" >/dev/null 2>&1; then
|
|
summary="$(head -c 300 "$tmp_body" | tr '\n' ' ')"
|
|
fail "Unexpected /api/v1/bridge/preflight payload shape. Sample: $summary"
|
|
fi
|
|
|
|
transport_pairs="$(jq -r '.gruTransport.summary.transportPairs // 0' "$tmp_body")"
|
|
runtime_ready_pairs="$(jq -r '.gruTransport.summary.runtimeReadyTransportPairs // 0' "$tmp_body")"
|
|
blocked_pairs="$(jq -r '.gruTransport.blockedPairs | length' "$tmp_body")"
|
|
ready_pairs="$(jq -r '.gruTransport.readyPairs | length' "$tmp_body")"
|
|
gas_transport_pairs="$(jq -r '.gruTransport.summary.gasTransportPairs // 0' "$tmp_body")"
|
|
strict_pairs="$(jq -r '.gruTransport.summary.strictEscrowTransportPairs // 0' "$tmp_body")"
|
|
hybrid_pairs="$(jq -r '.gruTransport.summary.hybridCapTransportPairs // 0' "$tmp_body")"
|
|
|
|
display_path="${prefix}/api/v1/bridge/preflight"
|
|
if [[ -z "$prefix" ]]; then
|
|
display_path="/api/v1/bridge/preflight"
|
|
fi
|
|
ok "Preflight endpoint reachable at ${display_path}"
|
|
log "Transport pairs: $transport_pairs"
|
|
log "Runtime-ready pairs: $runtime_ready_pairs"
|
|
log "Ready pairs returned: $ready_pairs"
|
|
log "Blocked pairs returned: $blocked_pairs"
|
|
log "Gas-native transport pairs: $gas_transport_pairs"
|
|
log "Strict-escrow pairs: $strict_pairs"
|
|
log "Hybrid-cap pairs: $hybrid_pairs"
|
|
|
|
if (( blocked_pairs > 0 )); then
|
|
log ""
|
|
warn "Blocked GRU transport pairs:"
|
|
jq -r '
|
|
.gruTransport.blockedPairs[]
|
|
| "- \(.key): eligibilityBlockers=\(((.eligibilityBlockers // []) | join(",")) // "") runtimeMissingRequirements=\(((.runtimeMissingRequirements // []) | join(",")) // "")"
|
|
' "$tmp_body"
|
|
|
|
gas_blocked_pairs="$(jq -r '[.gruTransport.blockedPairs[] | select(.assetClass == "gas_native")] | length' "$tmp_body")"
|
|
if (( gas_blocked_pairs > 0 )); then
|
|
log ""
|
|
warn "Blocked gas-native lanes:"
|
|
jq -r '
|
|
.gruTransport.blockedPairs[]
|
|
| select(.assetClass == "gas_native")
|
|
| "- \(.key): family=\(.familyKey // "n/a") backingMode=\(.backingMode // "n/a") supplyInvariantSatisfied=\(.supplyInvariantSatisfied // false) runtimeMissingRequirements=\(((.runtimeMissingRequirements // []) | join(",")) // "")"
|
|
' "$tmp_body"
|
|
fi
|
|
|
|
if [[ "$ALLOW_BLOCKED" != "1" ]]; then
|
|
fail "GRU transport preflight has blocked pairs. Set ALLOW_BLOCKED=1 for diagnostic-only mode."
|
|
else
|
|
warn "ALLOW_BLOCKED=1 set: blocked pairs reported without failing."
|
|
fi
|
|
else
|
|
ok "All active GRU transport pairs are runtime-ready."
|
|
fi
|
|
|
|
if [[ "$SKIP_EXIT" == "1" ]]; then
|
|
warn "SKIP_EXIT=1 set: diagnostic mode."
|
|
fi
|