2025-09-24 10:57:22 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
|
|
MNEMONIC_FILE=/workspace/onchain/.secret.local
|
2026-02-18 00:19:05 +01:00
|
|
|
ANVIL_STATE_DIR=/home/foundry/.foundry/anvil/tmp
|
|
|
|
|
|
|
|
|
|
# Cleanup old state snapshots (files older than 24 hours)
|
|
|
|
|
# Prevents disk bloat from accumulating JSON snapshots
|
|
|
|
|
if [[ -d "$ANVIL_STATE_DIR" ]]; then
|
|
|
|
|
echo "[anvil] Cleaning up state snapshots older than 24 hours..."
|
|
|
|
|
find "$ANVIL_STATE_DIR" -type f -name "*.json" -mtime +1 -delete 2>/dev/null || true
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
ANVIL_CMD=(anvil --fork-url "${FORK_URL:-https://sepolia.base.org}" --chain-id 31337 --block-time 1 --host 0.0.0.0 --port 8545 --threads 4 --timeout 2000 --retries 2 --fork-retry-backoff 100 --steps-tracing --no-storage-caching)
|
2025-09-24 10:57:22 +02:00
|
|
|
|
|
|
|
|
if [[ -f "$MNEMONIC_FILE" ]]; then
|
|
|
|
|
MNEMONIC="$(tr -d '\n\r' <"$MNEMONIC_FILE")"
|
|
|
|
|
if [[ -n "$MNEMONIC" ]]; then
|
|
|
|
|
ANVIL_CMD+=(--mnemonic "$MNEMONIC")
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
exec "${ANVIL_CMD[@]}"
|