fix: red-team.sh sudo strips FORK_URL before docker compose sees it (#729)

red-team.sh called bare `sudo docker compose up/down` which applies
env_reset and drops FORK_URL before anvil-entrypoint.sh can read it.
Change both calls to `sudo -E` so the caller's FORK_URL override is
propagated to docker-compose and into the anvil container.

Update ENVIRONMENT.md to reflect that a plain `FORK_URL=... bash
red-team.sh` invocation now works correctly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
openhands 2026-03-14 08:30:49 +00:00
parent 5b4e867c4b
commit 52ed8ef233
2 changed files with 6 additions and 4 deletions

View file

@ -42,10 +42,10 @@ FORK_URL=https://mainnet.base.org docker compose up -d
`red-team.sh` boots the docker-compose stack and then calls protocol operations using **Base mainnet** addresses for the Uniswap V3 periphery (V3_FACTORY, SwapRouter02, NonfungiblePositionManager). These addresses are only valid on a mainnet fork.
`red-team.sh` calls `sudo docker compose up -d` internally, and `sudo` strips environment variables by default. Pass `FORK_URL` inline with `-E` to preserve it:
`red-team.sh` calls `sudo docker compose up -d` internally. The script uses `sudo -E` so that `FORK_URL` is preserved across the sudo boundary:
```bash
FORK_URL=https://mainnet.base.org sudo -E bash scripts/harb-evaluator/red-team.sh
FORK_URL=https://mainnet.base.org bash scripts/harb-evaluator/red-team.sh
```
### FitnessEvaluator (`onchain/test/FitnessEvaluator.t.sol`)

View file

@ -63,11 +63,13 @@ cd "$REPO_ROOT"
sudo sh -c 'echo 3 > /proc/sys/vm/drop_caches' 2>/dev/null || true
# Tear down completely (volumes too — clean anvil state)
sudo docker compose down -v >/dev/null 2>&1 || true
sudo -E docker compose down -v >/dev/null 2>&1 || true
sleep 3
# Bring up
sudo docker compose up -d >/dev/null 2>&1 \
# -E preserves FORK_URL (and other env vars) across the sudo boundary so that
# anvil-entrypoint.sh honours the caller's FORK_URL override.
sudo -E docker compose up -d >/dev/null 2>&1 \
|| die "docker compose up -d failed"
# Wait for bootstrap to complete (max 120s)