fix: address AI review feedback on ENVIRONMENT.md Network Contexts section

- Fix factual error: bootstrap deploys KRAIKEN protocol contracts and uses
  the existing V3 Factory; it does not re-deploy Uniswap V3 infrastructure
- Fix count/characterisation: intro now says "two network contexts" (dev
  Anvil + backtesting tools) and clarifies FitnessEvaluator uses revm
  in-process, not Anvil
- Fix sudo env-stripping hazard: replace bare `export FORK_URL` instruction
  with `FORK_URL=... sudo -E bash red-team.sh` so the variable is not
  silently dropped by sudo
- Nit: add --match-test testBatchEvaluate to the FitnessEvaluator example
  to match the test file's own documented usage

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
openhands 2026-03-14 08:10:40 +00:00
parent f55eaae230
commit 5b4e867c4b

View file

@ -20,7 +20,7 @@ Docker Compose services (in startup order):
## Network Contexts
Two distinct Anvil contexts are in use; they target different networks.
Two network contexts are relevant: the dev-stack Anvil (docker-compose) and the backtesting tools that require Base mainnet.
### Dev stack Anvil (docker-compose)
@ -30,7 +30,7 @@ The `anvil` service in `docker-compose.yml` runs `containers/anvil-entrypoint.sh
${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`.
**Default: Base Sepolia.** The `bootstrap` service deploys all KRAIKEN protocol contracts (Kraiken, Stake, Optimizer, LiquidityManager) and creates a new KRK/WETH pool using the existing Uniswap V3 Factory already present on the forked network. Addresses are written to `tmp/containers/contracts.env`.
To fork Base mainnet instead (required for red-team / backtesting — see below):
@ -38,22 +38,24 @@ To fork Base mainnet instead (required for red-team / backtesting — see below)
FORK_URL=https://mainnet.base.org docker compose up -d
```
### Backtesting / red-team Anvil (`scripts/harb-evaluator/red-team.sh`)
### Backtesting / red-team (`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:
`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:
```bash
export FORK_URL=https://mainnet.base.org
FORK_URL=https://mainnet.base.org sudo -E bash scripts/harb-evaluator/red-team.sh
```
### 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:
`FitnessEvaluator.t.sol` does **not** use Anvil. It uses Foundry's native revm backend (`vm.createSelectFork`) to fork Base mainnet in-process — no docker-compose dependency:
```bash
BASE_RPC_URL=https://mainnet.base.org \
FITNESS_MANIFEST_DIR=/tmp/manifest \
forge test --match-contract FitnessEvaluator -vv
forge test --match-contract FitnessEvaluator --match-test testBatchEvaluate -vv
```
## Quick Start