- Add scripts/forge/scope.sh at proxmox root delegating to smom-dbis-138 so load_deployment_env + forge-scope resolve the correct Forge repo. - Step 4 of run-all-next-steps-chain138.sh: call load_deployment_env after sourcing smom/.env so PRIVATE_KEY matches deploy scripts (fixes forge decode errors when key is indirected via repo root .env). Co-authored-by: Cursor <cursoragent@cursor.com>
201 lines
8.4 KiB
Bash
Executable File
201 lines
8.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Run all deployment next steps for Chain 138 in order:
|
|
# preflight → (optional mirror+seed pool) → PMM mesh (default) → register c* as GRU → verify.
|
|
#
|
|
# Usage: ./scripts/deployment/run-all-next-steps-chain138.sh [--dry-run] [--skip-mirror] [--skip-mesh] [--legacy-pools-only] [--mesh-only] [--skip-register-gru] [--skip-verify]
|
|
# --dry-run Print steps only; do not run deploy/scripts.
|
|
# --skip-mirror Do not deploy TransactionMirror + seed pool step.
|
|
# --skip-mesh Do not run full PMM mesh creation script.
|
|
# --legacy-pools-only Equivalent to --skip-mesh (keeps legacy mirror+seed behavior only).
|
|
# --mesh-only Skip mirror+seed step and run mesh creation only.
|
|
# --skip-register-gru Skip RegisterGRUCompliantTokens. Use when c* are already GRU-registered and you only
|
|
# want preflight + mesh sync + on-chain verify (no second forge script / compile for GRU).
|
|
# --skip-verify Skip final on-chain verification.
|
|
#
|
|
# Keeping forge artifacts warm (avoids a long cold compile on the first forge script in this ladder, usually Step 4):
|
|
# cd smom-dbis-138 && forge build
|
|
# Paris-only bytecode for live Besu: FOUNDRY_PROFILE=chain138 forge build (see smom-dbis-138/foundry.toml)
|
|
#
|
|
# Requires: repo root; smom-dbis-138/.env with PRIVATE_KEY, RPC_URL_138; for register-gru: UNIVERSAL_ASSET_REGISTRY, CUSDT_ADDRESS_138, CUSDC_ADDRESS_138 (and optional c* vars).
|
|
# See: docs/03-deployment/DEPLOYMENT_ORDER_OF_OPERATIONS.md
|
|
|
|
set -euo pipefail
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
|
SMOM="$PROJECT_ROOT/smom-dbis-138"
|
|
|
|
# shellcheck source=./scripts/lib/run-summary.sh
|
|
source "$PROJECT_ROOT/scripts/lib/run-summary.sh"
|
|
|
|
RUN_STARTED_AT="$(date -u +"%Y-%m-%dT%H:%M:%SZ")"
|
|
SECONDS=0
|
|
|
|
format_duration() {
|
|
local total="$1"
|
|
printf '%02dm:%02ds' "$((total / 60))" "$((total % 60))"
|
|
}
|
|
|
|
DRY_RUN=""
|
|
SKIP_MIRROR=""
|
|
SKIP_MESH=""
|
|
MESH_ONLY=""
|
|
SKIP_REGISTER_GRU=""
|
|
SKIP_VERIFY=""
|
|
JSON_OUT=""
|
|
for a in "$@"; do
|
|
case "$a" in
|
|
--dry-run) DRY_RUN=1 ;;
|
|
--skip-mirror) SKIP_MIRROR=1 ;;
|
|
--skip-mesh|--legacy-pools-only) SKIP_MESH=1 ;;
|
|
--mesh-only) MESH_ONLY=1; SKIP_MIRROR=1 ;;
|
|
--skip-register-gru) SKIP_REGISTER_GRU=1 ;;
|
|
--skip-verify) SKIP_VERIFY=1 ;;
|
|
--json-out)
|
|
JSON_OUT_NEXT=1
|
|
;;
|
|
-h|--help)
|
|
sed -n '1,20p' "$0"
|
|
echo " --json-out PATH Write a machine-readable run summary JSON."
|
|
exit 0
|
|
;;
|
|
*)
|
|
if [[ -n "${JSON_OUT_NEXT:-}" ]]; then
|
|
JSON_OUT="$a"
|
|
unset JSON_OUT_NEXT
|
|
else
|
|
echo "Unknown argument: $a" >&2
|
|
exit 1
|
|
fi
|
|
;;
|
|
esac
|
|
done
|
|
|
|
if [[ -n "${JSON_OUT_NEXT:-}" ]]; then
|
|
echo "Missing value for --json-out" >&2
|
|
exit 1
|
|
fi
|
|
|
|
RUN_STATUS="failed"
|
|
run_summary_init "run-all-next-steps-chain138.sh" "$RUN_STARTED_AT" "$JSON_OUT"
|
|
trap 'run_summary_write "$RUN_STATUS" "$SECONDS" "$([[ -n "$DRY_RUN" ]] && echo dry-run || echo run)"; run_summary_cleanup' EXIT
|
|
|
|
echo "=== Chain 138 — run all next steps ==="
|
|
echo " started: $RUN_STARTED_AT"
|
|
echo " dry-run: $DRY_RUN skip-mirror: $SKIP_MIRROR skip-mesh: $SKIP_MESH mesh-only: $MESH_ONLY skip-register-gru: $SKIP_REGISTER_GRU skip-verify: $SKIP_VERIFY"
|
|
echo ""
|
|
|
|
# 1) Preflight
|
|
echo "--- Step 1: Preflight ---"
|
|
STEP_STARTED=$SECONDS
|
|
if [[ -n "$DRY_RUN" ]]; then
|
|
echo "[DRY-RUN] $PROJECT_ROOT/scripts/deployment/preflight-chain138-deploy.sh"
|
|
else
|
|
"$SCRIPT_DIR/preflight-chain138-deploy.sh" || { echo "Preflight failed." >&2; exit 1; }
|
|
fi
|
|
run_summary_record_step "1" "Preflight" "$([[ -n "$DRY_RUN" ]] && echo planned || echo success)" "$((SECONDS - STEP_STARTED))"
|
|
echo " Completed in $(format_duration "$((SECONDS - STEP_STARTED))")"
|
|
echo ""
|
|
|
|
# 2) TransactionMirror + seed pool (legacy step; optional)
|
|
if [[ -z "$SKIP_MIRROR" ]]; then
|
|
echo "--- Step 2: TransactionMirror + seed pool ---"
|
|
STEP_STARTED=$SECONDS
|
|
if [[ -n "$DRY_RUN" ]]; then
|
|
echo "[DRY-RUN] $PROJECT_ROOT/scripts/deployment/deploy-transaction-mirror-and-pmm-pool-after-txpool-clear.sh"
|
|
else
|
|
"$PROJECT_ROOT/scripts/deployment/deploy-transaction-mirror-and-pmm-pool-after-txpool-clear.sh" || { echo "Deploy failed." >&2; exit 1; }
|
|
fi
|
|
run_summary_record_step "2" "TransactionMirror + seed pool" "$([[ -n "$DRY_RUN" ]] && echo planned || echo success)" "$((SECONDS - STEP_STARTED))"
|
|
echo " Completed in $(format_duration "$((SECONDS - STEP_STARTED))")"
|
|
echo ""
|
|
else
|
|
run_summary_record_step "2" "TransactionMirror + seed pool" "skipped" "0"
|
|
echo "--- Step 2: TransactionMirror + seed pool (skipped) ---"
|
|
echo ""
|
|
fi
|
|
|
|
# 3) PMM full mesh (default on Chain 138)
|
|
if [[ -z "$SKIP_MESH" ]]; then
|
|
echo "--- Step 3: PMM full mesh (Chain 138) ---"
|
|
STEP_STARTED=$SECONDS
|
|
if [[ -n "$DRY_RUN" ]]; then
|
|
echo "[DRY-RUN] $PROJECT_ROOT/scripts/create-pmm-full-mesh-chain138.sh"
|
|
else
|
|
"$PROJECT_ROOT/scripts/create-pmm-full-mesh-chain138.sh" || { echo "PMM full mesh failed." >&2; exit 1; }
|
|
fi
|
|
run_summary_record_step "3" "PMM full mesh (Chain 138)" "$([[ -n "$DRY_RUN" ]] && echo planned || echo success)" "$((SECONDS - STEP_STARTED))"
|
|
echo " Completed in $(format_duration "$((SECONDS - STEP_STARTED))")"
|
|
echo ""
|
|
else
|
|
run_summary_record_step "3" "PMM full mesh (Chain 138)" "skipped" "0"
|
|
echo "--- Step 3: PMM full mesh (skipped; legacy-only mode) ---"
|
|
echo ""
|
|
fi
|
|
|
|
# 4) Register c* as GRU (optional)
|
|
if [[ -z "$SKIP_REGISTER_GRU" ]]; then
|
|
echo "--- Step 4: Register c* as GRU (UniversalAssetRegistry) ---"
|
|
STEP_STARTED=$SECONDS
|
|
if [[ -n "$DRY_RUN" ]]; then
|
|
echo "[DRY-RUN] cd $SMOM && forge script script/deploy/RegisterGRUCompliantTokens.s.sol --rpc-url \$RPC_URL_138 --broadcast --private-key \$PRIVATE_KEY --with-gas-price 1000000000"
|
|
else
|
|
if [[ -f "$SMOM/.env" ]]; then
|
|
set -a
|
|
# shellcheck source=/dev/null
|
|
source "$SMOM/.env"
|
|
set +a
|
|
# Match deploy scripts: merge repo-root .env / secure keys so PRIVATE_KEY is not a bare indirection.
|
|
if [[ -f "$SMOM/scripts/lib/deployment/dotenv.sh" ]]; then
|
|
# shellcheck disable=SC1090
|
|
source "$SMOM/scripts/lib/deployment/dotenv.sh"
|
|
load_deployment_env --repo-root "$PROJECT_ROOT"
|
|
fi
|
|
# Fallback: Register script expects CUSDT_ADDRESS_138/CUSDC_ADDRESS_138; use COMPLIANT_USDT/COMPLIANT_USDC if set
|
|
[[ -z "${CUSDT_ADDRESS_138:-}" && -n "${COMPLIANT_USDT:-}" ]] && export CUSDT_ADDRESS_138="$COMPLIANT_USDT"
|
|
[[ -z "${CUSDC_ADDRESS_138:-}" && -n "${COMPLIANT_USDC:-}" ]] && export CUSDC_ADDRESS_138="$COMPLIANT_USDC"
|
|
if [[ -n "${UNIVERSAL_ASSET_REGISTRY:-}" && ( -n "${CUSDT_ADDRESS_138:-}" || -n "${CUSDC_ADDRESS_138:-}" ) ]]; then
|
|
(cd "$SMOM" && forge script script/deploy/RegisterGRUCompliantTokens.s.sol --rpc-url "${RPC_URL_138:-http://192.168.11.211:8545}" --broadcast --private-key "$PRIVATE_KEY" --with-gas-price 1000000000) || echo "RegisterGRUCompliantTokens failed or skipped (check UNIVERSAL_ASSET_REGISTRY and CUSDT_ADDRESS_138/CUSDC_ADDRESS_138)."
|
|
else
|
|
echo "Skip: set UNIVERSAL_ASSET_REGISTRY and CUSDT_ADDRESS_138 (and optional c* vars) in $SMOM/.env to register c* as GRU."
|
|
fi
|
|
else
|
|
echo "Skip: $SMOM/.env not found."
|
|
fi
|
|
fi
|
|
run_summary_record_step "4" "Register c* as GRU (UniversalAssetRegistry)" "$([[ -n "$DRY_RUN" ]] && echo planned || echo success)" "$((SECONDS - STEP_STARTED))"
|
|
echo " Completed in $(format_duration "$((SECONDS - STEP_STARTED))")"
|
|
echo ""
|
|
else
|
|
run_summary_record_step "4" "Register c* as GRU (UniversalAssetRegistry)" "skipped" "0"
|
|
echo "--- Step 4: Register c* as GRU (skipped) ---"
|
|
echo ""
|
|
fi
|
|
|
|
# 5) Verify
|
|
if [[ -z "$SKIP_VERIFY" ]]; then
|
|
echo "--- Step 5: On-chain verification ---"
|
|
STEP_STARTED=$SECONDS
|
|
if [[ -n "$DRY_RUN" ]]; then
|
|
echo "[DRY-RUN] $PROJECT_ROOT/scripts/verify/check-contracts-on-chain-138.sh"
|
|
else
|
|
if [[ -f "$SMOM/.env" ]]; then
|
|
set -a
|
|
# shellcheck source=/dev/null
|
|
source "$SMOM/.env"
|
|
set +a
|
|
fi
|
|
"$PROJECT_ROOT/scripts/verify/check-contracts-on-chain-138.sh" "${RPC_URL_138:-}" || true
|
|
fi
|
|
run_summary_record_step "5" "On-chain verification" "$([[ -n "$DRY_RUN" ]] && echo planned || echo success)" "$((SECONDS - STEP_STARTED))"
|
|
echo " Completed in $(format_duration "$((SECONDS - STEP_STARTED))")"
|
|
echo ""
|
|
else
|
|
run_summary_record_step "5" "On-chain verification" "skipped" "0"
|
|
echo "--- Step 5: Verify (skipped) ---"
|
|
echo ""
|
|
fi
|
|
|
|
echo "=== Next steps run complete. ==="
|
|
echo "Total elapsed: $(format_duration "$SECONDS")"
|
|
RUN_STATUS="success"
|