feat: run L1 anvil as a Docker compose service#13
Merged
Conversation
Move the L1 anvil chain from a detached host process (plus a 100ms evm_mine heartbeat) into an `l1` Docker compose service so teardown via `docker compose down` is reliable — no orphaned anvil/heartbeat processes survive. - add `l1` compose service (foundry image) publishing 8545 so both host tooling (127.0.0.1:8545) and Nitro containers (host.docker.internal) reach it; state bind-mounted to config/anvil-state so snapshots work - replace startAnvilWithState() with startL1Container() (composeUp) - drop the pkill anvil/heartbeat calls from stop/clean/resetRuntime and the host pgrep check in status; compose down handles teardown
a37f65c to
89d27fc
Compare
douglance
added a commit
that referenced
this pull request
Jun 16, 2026
Move the L1 anvil chain from a detached host process (plus a 100ms evm_mine heartbeat) into an `l1` Docker compose service so teardown via `docker compose down` is reliable — no orphaned anvil/heartbeat processes survive. - add `l1` compose service (foundry image) publishing 8545 so both host tooling (127.0.0.1:8545) and Nitro containers (host.docker.internal) reach it; state bind-mounted to config/anvil-state so snapshots work - replace startAnvilWithState() with startL1Container() (composeUp) - drop the pkill anvil/heartbeat calls from stop/clean/resetRuntime and the host pgrep check in status; compose down handles teardown
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Moves the L1 anvil chain from a detached host process (plus a 100ms
evm_mineheartbeat process) into anl1Docker compose service.Why
With anvil on the host,
docker compose downcouldn't tear it down, so the CLI relied onpkill anvil/pkill <heartbeat>instop/clean— fragile and prone to orphaned processes. Running anvil as a compose service makes teardown reliable and resource use containerized.Changes
docker/docker-compose.yaml— newl1service (stockfoundryimage, no custom entrypoint script). Publishes8545so both host tooling (127.0.0.1:8545) and Nitro containers (host.docker.internal:8545) reach the same anvil. State bind-mounted toconfig/anvil-stateso snapshot capture/restore keep working; anvil's on-SIGTERM dump persists it ondown.packages/core/src/runtime.ts—startAnvilWithState()(hostspawn+ heartbeat) →startL1Container()(composeUp(["l1"])).stop/clean/resetRuntime— droppkill anvil/pkill heartbeat;docker compose downhandles teardown.status— L1 check now uses the compose service state instead ofpgrep anvil.Anvil's arg list (block-time, accounts, balance, mnemonic, chain-id,
--state) is unchanged from the previous host invocation, so chain behavior is identical.Verification
pnpm typecheck✅ ·pnpm build✅ ·docker compose config✅pnpm test:run→ 140/140 pass ✅