Files
proxmox/scripts/verify/run-contract-verification-with-proxy.sh
defiQUG fbda1b4beb
Some checks failed
Deploy to Phoenix / deploy (push) Has been cancelled
docs: Ledger Live integration, contract deploy learnings, NEXT_STEPS updates
- ADD_CHAIN138_TO_LEDGER_LIVE: Ledger form done; public code review repo bis-innovations/LedgerLive; init/push commands
- CONTRACT_DEPLOYMENT_RUNBOOK: Chain 138 gas price 1 gwei, 36-addr check, TransactionMirror workaround
- CONTRACT_*: AddressMapper, MirrorManager deployed 2026-02-12; 36-address on-chain check
- NEXT_STEPS_FOR_YOU: Ledger done; steps completable now (no LAN); run-completable-tasks-from-anywhere
- MASTER_INDEX, OPERATOR_OPTIONAL, SMART_CONTRACTS_INVENTORY_SIMPLE: updates
- LEDGER_BLOCKCHAIN_INTEGRATION_COMPLETE: bis-innovations/LedgerLive reference

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-12 15:46:57 -08:00

85 lines
3.2 KiB
Bash
Executable File

#!/usr/bin/env bash
# Orchestrate contract verification using forge-verification-proxy and Blockscout
# Usage: source smom-dbis-138/.env 2>/dev/null; ./scripts/verify/run-contract-verification-with-proxy.sh
# Env: FORGE_VERIFY_TIMEOUT (default 900), KEEP_PROXY=1 (skip cleanup), DEBUG=1
# Version: 2026-01-31
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
source "${SCRIPT_DIR}/../lib/load-project-env.sh"
[[ "${DEBUG:-0}" = "1" ]] && set -x
# Pre-flight
command -v forge &>/dev/null || { echo "ERROR: forge not found (install Foundry)"; exit 1; }
command -v node &>/dev/null || { echo "ERROR: node not found (required for verification proxy)"; exit 1; }
SMOM="${SMOM_DIR:-${PROJECT_ROOT}/smom-dbis-138}"
[[ -d "$SMOM" ]] || { echo "ERROR: smom-dbis-138 not found at $SMOM"; exit 1; }
IP_BLOCKSCOUT="${IP_BLOCKSCOUT:-192.168.11.140}"
VERIFIER_PORT="${FORGE_VERIFIER_PROXY_PORT:-3080}"
PROXY_DIR="${PROJECT_ROOT}/forge-verification-proxy"
FORGE_VERIFY_TIMEOUT="${FORGE_VERIFY_TIMEOUT:-900}"
PROXY_PID=""
KEEP_PROXY="${KEEP_PROXY:-0}"
cleanup_proxy() {
if [[ "${KEEP_PROXY}" = "1" ]]; then return 0; fi
[[ -n "${PROXY_PID:-}" ]] && kill "$PROXY_PID" 2>/dev/null || true
}
trap cleanup_proxy EXIT
# Optional Blockscout connectivity check
if curl -s -o /dev/null -w "%{http_code}" --connect-timeout 3 "http://${IP_BLOCKSCOUT}:4000/" 2>/dev/null | grep -qE "200|404|502"; then
: Blockscout reachable
elif [[ -n "${SKIP_BLOCKSCOUT_CHECK:-}" ]]; then
: Skipping Blockscout check
else
echo "WARN: Blockscout at ${IP_BLOCKSCOUT}:4000 is not reachable from this host (private LAN)." >&2
echo " Set SKIP_BLOCKSCOUT_CHECK=1 to run anyway (verification submissions will fail until Blockscout is reachable)." >&2
echo " To verify successfully: run this script from a host on the same LAN as ${IP_BLOCKSCOUT} or via VPN." >&2
fi
proxy_listening() {
if command -v nc &>/dev/null; then
nc -z -w 2 127.0.0.1 "${VERIFIER_PORT}" 2>/dev/null
else
timeout 2 bash -c "echo >/dev/tcp/127.0.0.1/${VERIFIER_PORT}" 2>/dev/null
fi
}
start_proxy_if_needed() {
if proxy_listening; then
echo "Forge verification proxy already running on port ${VERIFIER_PORT}"
return 0
fi
[[ ! -f "${PROXY_DIR}/server.js" ]] && { echo "ERROR: forge-verification-proxy not found at ${PROXY_DIR}"; exit 1; }
echo "Starting forge-verification-proxy on port ${VERIFIER_PORT}..."
BLOCKSCOUT_URL="http://${IP_BLOCKSCOUT}:4000" PORT="${VERIFIER_PORT}" node "${PROXY_DIR}/server.js" &
PROXY_PID=$!
sleep 2
if ! kill -0 "$PROXY_PID" 2>/dev/null; then
PROXY_PID=""
echo "ERROR: Proxy failed to start"
exit 1
fi
echo "Proxy started (PID $PROXY_PID). Will run verification..."
}
export FORGE_VERIFIER_URL="http://127.0.0.1:${VERIFIER_PORT}/api"
start_proxy_if_needed
if [[ "${FORGE_VERIFY_TIMEOUT}" -gt 0 ]]; then
echo "Running verification (timeout: ${FORGE_VERIFY_TIMEOUT}s)..."
timeout "${FORGE_VERIFY_TIMEOUT}" "${SCRIPT_DIR}/../verify-contracts-blockscout.sh" "${@}" || {
code=$?
[[ $code -eq 124 ]] && echo "Verification timed out after ${FORGE_VERIFY_TIMEOUT}s. Set FORGE_VERIFY_TIMEOUT=0 for no limit." && exit 124
exit $code
}
else
"${SCRIPT_DIR}/../verify-contracts-blockscout.sh" "${@}"
fi