fix: ENVIRONMENT.md describes Anvil as Base Sepolia but backtesting scripts use Base mainnet addresses (#729)

- Clarify that the dev Anvil defaults to Base Sepolia but can be overridden
  with FORK_URL (confirmed from containers/anvil-entrypoint.sh)
- Add "Network Contexts" section distinguishing three distinct Anvil usages:
  1. Dev stack Anvil (docker-compose): Base Sepolia by default
  2. red-team.sh: requires FORK_URL=mainnet because it uses Base mainnet
     periphery addresses (V3_FACTORY, SwapRouter02, NPM)
  3. FitnessEvaluator.t.sol: independent mainnet fork via BASE_RPC_URL,
     unrelated to the docker-compose stack

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
openhands 2026-03-14 07:28:27 +00:00
parent 319632e7ae
commit f55eaae230

View file

@ -8,7 +8,7 @@ Docker Compose services (in startup order):
| Service | Purpose | Port | Health Check | | Service | Purpose | Port | Health Check |
|---------|---------|------|-------------| |---------|---------|------|-------------|
| **anvil** | Local Ethereum fork (Base Sepolia) | 8545 | JSON-RPC response | | **anvil** | Local Ethereum fork (Base Sepolia by default; override with `FORK_URL`) | 8545 | JSON-RPC response |
| **postgres** | Ponder database | 5432 | pg_isready | | **postgres** | Ponder database | 5432 | pg_isready |
| **bootstrap** | Deploys contracts to anvil | — | One-shot, exits 0 | | **bootstrap** | Deploys contracts to anvil | — | One-shot, exits 0 |
| **ponder** | On-chain indexer + GraphQL API | 42069 | HTTP /ready or GraphQL | | **ponder** | On-chain indexer + GraphQL API | 42069 | HTTP /ready or GraphQL |
@ -18,6 +18,44 @@ Docker Compose services (in startup order):
| **caddy** | Reverse proxy / TLS | 80/443 | — | | **caddy** | Reverse proxy / TLS | 80/443 | — |
| **otterscan** | Block explorer | 5100 | — | | **otterscan** | Block explorer | 5100 | — |
## Network Contexts
Two distinct Anvil contexts are in use; they target different networks.
### Dev stack Anvil (docker-compose)
The `anvil` service in `docker-compose.yml` runs `containers/anvil-entrypoint.sh`, which forks:
```
${FORK_URL:-https://sepolia.base.org}
```
**Default: Base Sepolia.** Uniswap V3 contracts are re-deployed fresh by the `bootstrap` service at start-up, so the fork target only affects block history and chain-id context. The bootstrap deploys all protocol contracts (Kraiken, Stake, LiquidityManager, OptimizerProxy) at addresses written to `tmp/containers/contracts.env`.
To fork Base mainnet instead (required for red-team / backtesting — see below):
```bash
FORK_URL=https://mainnet.base.org docker compose up -d
```
### Backtesting / red-team Anvil (`scripts/harb-evaluator/red-team.sh`)
`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. Before running red-team.sh, set:
```bash
export FORK_URL=https://mainnet.base.org
```
### FitnessEvaluator (`onchain/test/FitnessEvaluator.t.sol`)
`FitnessEvaluator.t.sol` is completely independent of the dev Anvil. It forks Base mainnet once per `forge test` run using the `BASE_RPC_URL` environment variable and has no relationship to the docker-compose stack:
```bash
BASE_RPC_URL=https://mainnet.base.org \
FITNESS_MANIFEST_DIR=/tmp/manifest \
forge test --match-contract FitnessEvaluator -vv
```
## Quick Start ## Quick Start
```bash ```bash