fix: Push3 evolution: fitness scoring wrapper (transpile → deploy → attack → score) (#545)
Address round-2 review findings: - Move BASELINE_SNAP before deploy-optimizer.sh so cleanup fully reverts the deploy on a shared Anvil; fixes nonce/address collision when a second sequential evaluation reuses the same chain - Revert deploy output to capture-and-suppress on success / surface on failure; removes per-candidate stderr noise in evolution loop batch runs - Fix cast rpc anvil_mine arg order to match all other cast rpc calls in script Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
0f91234dbe
commit
4564637f85
1 changed files with 22 additions and 15 deletions
|
|
@ -138,25 +138,37 @@ fi
|
|||
# =============================================================================
|
||||
# Steps 1–3 — Transpile → compile → deploy fresh stack → UUPS upgrade
|
||||
#
|
||||
# BASELINE_SNAP is taken before deploy-optimizer.sh runs so that cleanup()
|
||||
# can fully revert the deploy on a shared Anvil (not just the bootstrap
|
||||
# mutations). Without this, a second sequential evaluation against the same
|
||||
# shared Anvil would run DeployLocal.sol again with the same deployer nonce,
|
||||
# hitting CREATE address collisions and failing with exit 1.
|
||||
#
|
||||
# deploy-optimizer.sh handles the full pipeline. With no OPTIMIZER_PROXY set
|
||||
# it also runs DeployLocal.sol to produce the initial stack.
|
||||
#
|
||||
# Output is tee'd to both a log file and stderr so progress is visible to the
|
||||
# caller while the log is preserved for post-failure diagnosis.
|
||||
# Output is captured silently on success; surfaced to stderr on failure so
|
||||
# batch / evolution-loop callers are not flooded with per-candidate progress
|
||||
# lines for every successful evaluation.
|
||||
#
|
||||
# Exit codes from deploy-optimizer.sh all map to exit 1 (invalid candidate)
|
||||
# because transpile / compile / round-trip failures are candidate issues.
|
||||
# =============================================================================
|
||||
|
||||
# Pre-deploy snapshot — reverted in cleanup to fully undo the deploy and all
|
||||
# bootstrap mutations when using a shared Anvil.
|
||||
BASELINE_SNAP=$(cast rpc anvil_snapshot --rpc-url "$RPC_URL" | tr -d '"')
|
||||
log "Pre-deploy snapshot: $BASELINE_SNAP"
|
||||
|
||||
log "Running deploy-optimizer.sh (transpile → compile → deploy → upgrade)…"
|
||||
|
||||
DEPLOY_LOG="$WORK_DIR/deploy.log"
|
||||
DEPLOY_EC=0
|
||||
"$REPO_ROOT/tools/deploy-optimizer.sh" "$PUSH3_FILE" 2>&1 \
|
||||
| tee "$DEPLOY_LOG" >&2 \
|
||||
|| DEPLOY_EC=${PIPESTATUS[0]}
|
||||
"$REPO_ROOT/tools/deploy-optimizer.sh" "$PUSH3_FILE" >"$DEPLOY_LOG" 2>&1 || DEPLOY_EC=$?
|
||||
|
||||
if [ "$DEPLOY_EC" -ne 0 ]; then
|
||||
# Surface deploy log so operators can diagnose candidate failures.
|
||||
cat "$DEPLOY_LOG" >&2
|
||||
fail1 "deploy-optimizer.sh failed (exit $DEPLOY_EC)"
|
||||
fi
|
||||
|
||||
|
|
@ -184,18 +196,13 @@ log "LiquidityManager: $LM_ADDR"
|
|||
# =============================================================================
|
||||
# Step 5 — Bootstrap LM state
|
||||
#
|
||||
# a. Snapshot pre-bootstrap state for cleanup (BASELINE_SNAP).
|
||||
# b. Grant recenterAccess to account 2 (impersonate feeDestination).
|
||||
# c. Fund LM with 1000 WETH from account 8.
|
||||
# d. Call recenter() to deploy capital into Uniswap positions.
|
||||
# a. Grant recenterAccess to account 2 (impersonate feeDestination).
|
||||
# b. Fund LM with 1000 WETH from account 8.
|
||||
# c. Call recenter() to deploy capital into Uniswap positions.
|
||||
# The LM needs TWAP history; mine blocks in batches and retry.
|
||||
# =============================================================================
|
||||
|
||||
# a. Pre-bootstrap snapshot — reverted in cleanup to undo mutations on a shared Anvil.
|
||||
BASELINE_SNAP=$(cast rpc anvil_snapshot --rpc-url "$RPC_URL" | tr -d '"')
|
||||
log "Pre-bootstrap snapshot: $BASELINE_SNAP"
|
||||
|
||||
# b. Grant recenterAccess.
|
||||
# a. Grant recenterAccess.
|
||||
RECENTER_ADDR=$(cast wallet address --private-key "$RECENTER_PK")
|
||||
|
||||
FEE_DEST=$(cast call "$LM_ADDR" "feeDestination()(address)" \
|
||||
|
|
@ -223,7 +230,7 @@ cast send "$WETH" "transfer(address,uint256)" "$LM_ADDR" 1000000000000000000000
|
|||
log "Initial recenter — deploying capital into positions"
|
||||
RECENTERED=false
|
||||
for _attempt in 1 2 3 4; do
|
||||
cast rpc anvil_mine 0x32 --rpc-url "$RPC_URL" >/dev/null 2>&1
|
||||
cast rpc --rpc-url "$RPC_URL" anvil_mine 0x32 >/dev/null 2>&1
|
||||
if cast send "$LM_ADDR" "recenter()" \
|
||||
--private-key "$RECENTER_PK" --rpc-url "$RPC_URL" >/dev/null 2>&1; then
|
||||
RECENTERED=true
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue