diff --git a/tools/deploy-optimizer.sh b/tools/deploy-optimizer.sh index b27350b..b6504e7 100755 --- a/tools/deploy-optimizer.sh +++ b/tools/deploy-optimizer.sh @@ -15,6 +15,11 @@ # OPTIMIZER_PROXY Address of the deployed UUPS proxy to upgrade. # RPC_URL JSON-RPC endpoint. # SECRET_FILE Path to seed-phrase file (default: onchain/.secret). +# +# Environment (dry-run mode only): +# ANVIL_FORK_URL Required when Anvil is not already running. Must point to +# a Base RPC endpoint so that forked state includes Uniswap V3 +# Factory and WETH. # ============================================================================= set -euo pipefail @@ -176,12 +181,29 @@ else fi SECRET_FILE="$ONCHAIN_DIR/.secret" - # Check if Anvil is already running + # Check if Anvil is already running. + # + # DeployLocal.sol depends on live Base infrastructure: Uniswap V3 Factory at + # 0x4752ba5DBc23f44D87826276BF6Fd6b1C372aD24 and WETH at + # 0x4200000000000000000000000000000000000006. A plain (unfork'd) Anvil has + # neither, so cold-starting without --fork-url silently breaks the pipeline. + # + # When Anvil is already running (dev stack or CI), we use it as-is. + # When it is not running we require ANVIL_FORK_URL and start a forked instance. if cast chain-id --rpc-url "$RPC_URL" >/dev/null 2>&1; then info "Anvil already running at $RPC_URL" else - info "Starting Anvil..." + ANVIL_FORK_URL="${ANVIL_FORK_URL:-}" + if [ -z "$ANVIL_FORK_URL" ]; then + fail "Anvil is not running at $RPC_URL and ANVIL_FORK_URL is not set. + DeployLocal.sol requires Base network contracts (Uniswap V3 Factory, WETH). + Either start a Base-forked Anvil externally, or set ANVIL_FORK_URL to a Base + RPC endpoint (e.g. ANVIL_FORK_URL=https://mainnet.base.org)." + fi + + info "Starting Anvil (fork: $ANVIL_FORK_URL)..." anvil --silent \ + --fork-url "$ANVIL_FORK_URL" \ --mnemonic "test test test test test test test test test test test junk" \ --port 8545 & ANVIL_PID=$! @@ -192,7 +214,7 @@ else [ $TRIES -gt 50 ] && fail "Anvil did not start within 50 attempts" sleep 0.2 done - info "Anvil started (PID $ANVIL_PID)" + info "Anvil started (PID $ANVIL_PID, fork: $ANVIL_FORK_URL)" fi # If no OPTIMIZER_PROXY set, deploy a fresh local stack