feat(xdc-zero): Chain 138 bridge runbook, config fragments, merge helper
- Add CHAIN138_XDC_ZERO_BRIDGE_RUNBOOK and 07-ccip pointer doc - Add config/xdc-zero templates, parent register fragment, README - Add merge-endpointconfig-chain138.sh (jq merge, XDC_ZERO_ENDPOINT_DIR) - Add xdc-zero-chain138-preflight.sh; trim XDC URL vars in load-project-env - Wire AGENTS.md, MASTER_INDEX, verify README, .env.master.example Made-with: Cursor
This commit is contained in:
@@ -34,6 +34,7 @@ err_exit() { echo "ERROR: $1" >&2; exit 1; }
|
||||
|
||||
# 4b. Strip trailing CR/LF from RPC URL vars (editor mistakes; breaks cast/curl)
|
||||
for _lpr_k in RPC_URL_138 RPC_URL CHAIN138_RPC CHAIN138_RPC_URL ETHEREUM_MAINNET_RPC \
|
||||
XDC_PARENTNET_URL PARENTNET_URL SUBNET_URL XDC_ZERO_PEER_RPC_URL \
|
||||
RPC_URL_138_PUBLIC GNOSIS_MAINNET_RPC GNOSIS_RPC CRONOS_RPC_URL CRONOS_RPC \
|
||||
CELO_MAINNET_RPC CELO_RPC WEMIX_RPC WEMIX_MAINNET_RPC BSC_RPC_URL \
|
||||
POLYGON_MAINNET_RPC BASE_MAINNET_RPC OPTIMISM_MAINNET_RPC ARBITRUM_MAINNET_RPC \
|
||||
|
||||
@@ -34,6 +34,8 @@ One-line install (Debian/Ubuntu): `sudo apt install -y sshpass rsync dnsutils ip
|
||||
- `check-gru-transport-preflight.sh` - Operator-focused GRU runtime preflight. Calls `/api/v1/bridge/preflight`, prints blocked pairs with `eligibilityBlockers` / `runtimeMissingRequirements`, and fails unless all active pairs are runtime-ready or `ALLOW_BLOCKED=1` is set.
|
||||
- `check-cstar-v2-transport-stack.sh` - Predeploy Forge verifier for the `c* V2` bridge stack. Runs the base V2 token suite, legacy reserve-verifier compatibility suite, V2 reserve/verifier full L1/L2 round-trip suite, and the core `CWMultiTokenBridge` round-trip suite.
|
||||
- `run-repo-green-test-path.sh` - Local deterministic green-path aggregate behind root `pnpm test`. Runs config validation, then the focused `smom-dbis-138` contract and service CI targets.
|
||||
- `xdc-zero-chain138-preflight.sh` - `eth_chainId` HTTP checks for `XDC_PARENTNET_URL`/`PARENTNET_URL` and `RPC_URL_138`; optional `ETHEREUM_MAINNET_RPC`, `BSC_RPC_URL`. See [CHAIN138_XDC_ZERO_BRIDGE_RUNBOOK](../../docs/03-deployment/CHAIN138_XDC_ZERO_BRIDGE_RUNBOOK.md).
|
||||
- `../xdc-zero/merge-endpointconfig-chain138.sh` - Merge `chain138` into XDC-Zero `endpointconfig.json` (optional `xdcparentnet.registers` append). Set `XDC_ZERO_ENDPOINT_DIR`; use `--dry-run`. See [config/xdc-zero/README.md](../../config/xdc-zero/README.md).
|
||||
- `check-completion-status.sh` - One-command summary of repo-completable checks, public report API health, and pointers to operator/external remaining work.
|
||||
- `reconcile-env-canonical.sh` - Emit recommended .env lines for Chain 138 (canonical source of truth); use to reconcile `smom-dbis-138/.env` with [CONTRACT_ADDRESSES_REFERENCE](../../docs/11-references/CONTRACT_ADDRESSES_REFERENCE.md). Usage: `./scripts/verify/reconcile-env-canonical.sh [--print]`
|
||||
- `check-deployer-balance-blockscout-vs-rpc.sh` - Compare deployer native balance from Blockscout API vs RPC (to verify index matches current chain); see [EXPLORER_AND_BLOCKSCAN_REFERENCE](../../docs/11-references/EXPLORER_AND_BLOCKSCAN_REFERENCE.md)
|
||||
|
||||
74
scripts/verify/xdc-zero-chain138-preflight.sh
Executable file
74
scripts/verify/xdc-zero-chain138-preflight.sh
Executable file
@@ -0,0 +1,74 @@
|
||||
#!/usr/bin/env bash
|
||||
# Preflight: RPC reachability and eth_chainId for XDC Zero second pair (parent ↔ Chain 138).
|
||||
# Optional: ETHEREUM_MAINNET_RPC (or other vars) for quick public mainnet access checks.
|
||||
#
|
||||
# Usage:
|
||||
# bash scripts/verify/xdc-zero-chain138-preflight.sh
|
||||
# XDC mainnet (default in .env.master.example): XDC_PARENTNET_URL=https://rpc.xinfin.network
|
||||
# Apothem: XDC_PARENTNET_URL=https://rpc.apothem.network bash scripts/verify/xdc-zero-chain138-preflight.sh
|
||||
#
|
||||
# Loads repo dotenv via scripts/lib/load-project-env.sh when sourced from repo root.
|
||||
|
||||
# Avoid nounset while sourcing dotenv (some .env lines reference optional vars).
|
||||
set -eo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
||||
# shellcheck source=/dev/null
|
||||
source "${PROJECT_ROOT}/scripts/lib/load-project-env.sh"
|
||||
|
||||
_rpc_chain_id() {
|
||||
local url="$1"
|
||||
local name="$2"
|
||||
if [[ -z "$url" || "$url" == "devnet" || "$url" == "testnet" ]]; then
|
||||
echo "SKIP $name: empty or alias URL ($url) — resolve to HTTPS RPC for this check."
|
||||
return 0
|
||||
fi
|
||||
local out
|
||||
if ! out="$(curl -sS --connect-timeout 8 --max-time 20 -X POST "$url" \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{"jsonrpc":"2.0","method":"eth_chainId","params":[],"id":1}' 2>/dev/null)"; then
|
||||
echo "FAIL $name: no HTTP response from $url"
|
||||
return 1
|
||||
fi
|
||||
local hex
|
||||
hex="$(printf '%s' "$out" | sed -n 's/.*"result":"\([^"]*\)".*/\1/p')"
|
||||
if [[ -z "$hex" ]]; then
|
||||
echo "FAIL $name: bad JSON or error from $url — $out"
|
||||
return 1
|
||||
fi
|
||||
echo "OK $name ($url) eth_chainId=$hex"
|
||||
}
|
||||
|
||||
echo "=== XDC Zero Chain 138 pair — RPC preflight ==="
|
||||
|
||||
fail=0
|
||||
PARENT="${XDC_PARENTNET_URL:-${PARENTNET_URL:-}}"
|
||||
PEER="${XDC_ZERO_PEER_RPC_URL:-${RPC_URL_138:-${CHAIN138_RPC_URL:-${CHAIN138_RPC:-}}}}"
|
||||
|
||||
if [[ -n "$PARENT" ]]; then
|
||||
_rpc_chain_id "$PARENT" "XDC_PARENTNET / PARENTNET" || fail=1
|
||||
else
|
||||
echo "WARN XDC_PARENTNET_URL and PARENTNET_URL unset — set one for parent checks."
|
||||
fi
|
||||
|
||||
if [[ -n "$PEER" ]]; then
|
||||
_rpc_chain_id "$PEER" "Chain138 RPC_URL_138" || fail=1
|
||||
else
|
||||
echo "WARN RPC_URL_138 (or CHAIN138_RPC_URL) unset — set for Chain 138 checks."
|
||||
fi
|
||||
|
||||
if [[ -n "${ETHEREUM_MAINNET_RPC:-}" ]]; then
|
||||
_rpc_chain_id "$ETHEREUM_MAINNET_RPC" "ETHEREUM_MAINNET_RPC (optional)" || fail=1
|
||||
fi
|
||||
|
||||
if [[ -n "${BSC_RPC_URL:-}" ]]; then
|
||||
_rpc_chain_id "$BSC_RPC_URL" "BSC_RPC_URL (optional)" || fail=1
|
||||
fi
|
||||
|
||||
if [[ "$fail" -ne 0 ]]; then
|
||||
echo "=== Preflight finished with failures ==="
|
||||
exit 1
|
||||
fi
|
||||
echo "=== Preflight finished ==="
|
||||
echo "Next: deploy Endpoint/CSC per docs/03-deployment/CHAIN138_XDC_ZERO_BRIDGE_RUNBOOK.md"
|
||||
80
scripts/xdc-zero/merge-endpointconfig-chain138.sh
Executable file
80
scripts/xdc-zero/merge-endpointconfig-chain138.sh
Executable file
@@ -0,0 +1,80 @@
|
||||
#!/usr/bin/env bash
|
||||
# Merge Chain 138 XDC-Zero fragments into an existing endpointconfig.json (upstream XDC-Zero layout).
|
||||
# Requires jq. Backs up the target file unless --dry-run or explicit stdout.
|
||||
#
|
||||
# Usage:
|
||||
# bash scripts/xdc-zero/merge-endpointconfig-chain138.sh path/to/endpointconfig.json
|
||||
# bash scripts/xdc-zero/merge-endpointconfig-chain138.sh path/to/endpointconfig.json path/to/out.json
|
||||
# bash scripts/xdc-zero/merge-endpointconfig-chain138.sh path/to/endpointconfig.json --dry-run
|
||||
# bash scripts/xdc-zero/merge-endpointconfig-chain138.sh --dry-run path/to/endpointconfig.json
|
||||
# Or set XDC_ZERO_ENDPOINT_DIR to an XDC-Zero/endpoint clone path (uses .../endpointconfig.json).
|
||||
#
|
||||
# Sources: config/xdc-zero/endpointconfig.fragment.chain138.example.json,
|
||||
# config/xdc-zero/xdcparentnet-register-chain138.fragment.json
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
||||
FRAG="$PROJECT_ROOT/config/xdc-zero/endpointconfig.fragment.chain138.example.json"
|
||||
REG_FRAG="$PROJECT_ROOT/config/xdc-zero/xdcparentnet-register-chain138.fragment.json"
|
||||
|
||||
DRY_RUN=false
|
||||
BASE=""
|
||||
OUT=""
|
||||
POSITIONAL=()
|
||||
for a in "$@"; do
|
||||
if [[ "$a" == "--dry-run" ]]; then
|
||||
DRY_RUN=true
|
||||
else
|
||||
POSITIONAL+=("$a")
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ ${#POSITIONAL[@]} -ge 1 ]]; then
|
||||
BASE="${POSITIONAL[0]}"
|
||||
fi
|
||||
if [[ ${#POSITIONAL[@]} -ge 2 ]]; then
|
||||
OUT="${POSITIONAL[1]}"
|
||||
fi
|
||||
|
||||
if [[ -z "$BASE" && -n "${XDC_ZERO_ENDPOINT_DIR:-}" ]]; then
|
||||
BASE="${XDC_ZERO_ENDPOINT_DIR%/}/endpointconfig.json"
|
||||
fi
|
||||
|
||||
if [[ -z "$BASE" || ! -f "$BASE" ]]; then
|
||||
echo "Usage: $0 <endpointconfig.json> [out.json] [--dry-run]" >&2
|
||||
echo " Or: XDC_ZERO_ENDPOINT_DIR=/path/to/XDC-Zero/endpoint $0 [--dry-run]" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ ! -f "$FRAG" || ! -f "$REG_FRAG" ]]; then
|
||||
echo "ERROR: missing fragment under config/xdc-zero/" >&2
|
||||
exit 1
|
||||
fi
|
||||
command -v jq >/dev/null 2>&1 || { echo "ERROR: jq required" >&2; exit 1; }
|
||||
|
||||
_step1="$(jq --slurpfile f "$FRAG" '.chain138 = $f[0].chain138' "$BASE")"
|
||||
MERGED="$(printf '%s\n' "$_step1" | jq --slurpfile r "$REG_FRAG" '
|
||||
(if .xdcparentnet == null then . + {xdcparentnet: {registers: []}} else . end)
|
||||
| .xdcparentnet.registers += $r[0]
|
||||
')"
|
||||
|
||||
_c138_count="$(printf '%s' "$MERGED" | jq '[.xdcparentnet.registers[]? | select(.chainId == 138)] | length')"
|
||||
if [[ "${_c138_count:-0}" -gt 1 ]]; then
|
||||
echo "WARN: xdcparentnet.registers has ${_c138_count} entries with chainId 138 — review manually." >&2
|
||||
fi
|
||||
|
||||
if $DRY_RUN; then
|
||||
printf '%s\n' "$MERGED"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ -n "$OUT" ]]; then
|
||||
printf '%s\n' "$MERGED" >"$OUT"
|
||||
echo "Wrote $OUT"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
cp -a "$BASE" "${BASE}.bak.$(date +%Y%m%d%H%M%S)"
|
||||
printf '%s\n' "$MERGED" >"$BASE"
|
||||
echo "Merged into $BASE (backup beside file)."
|
||||
Reference in New Issue
Block a user