diff --git a/docs/ENVIRONMENT.md b/docs/ENVIRONMENT.md index 11bd220..cee577a 100644 --- a/docs/ENVIRONMENT.md +++ b/docs/ENVIRONMENT.md @@ -8,7 +8,7 @@ Docker Compose services (in startup order): | 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 | | **bootstrap** | Deploys contracts to anvil | — | One-shot, exits 0 | | **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 | — | | **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 ```bash