Skip to content

feat: run L1 anvil as a Docker compose service#13

Merged
douglance merged 1 commit into
testnode-workspace-migrationfrom
feat/l1-in-docker
Jun 16, 2026
Merged

feat: run L1 anvil as a Docker compose service#13
douglance merged 1 commit into
testnode-workspace-migrationfrom
feat/l1-in-docker

Conversation

@douglance

@douglance douglance commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

What

Moves the L1 anvil chain from a detached host process (plus a 100ms evm_mine heartbeat process) into an l1 Docker compose service.

Why

With anvil on the host, docker compose down couldn't tear it down, so the CLI relied on pkill anvil / pkill <heartbeat> in stop/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 — new l1 service (stock foundry image, no custom entrypoint script). Publishes 8545 so both host tooling (127.0.0.1:8545) and Nitro containers (host.docker.internal:8545) reach the same anvil. State bind-mounted to config/anvil-state so snapshot capture/restore keep working; anvil's on-SIGTERM dump persists it on down.
  • packages/core/src/runtime.tsstartAnvilWithState() (host spawn + heartbeat) → startL1Container() (composeUp(["l1"])).
  • stop / clean / resetRuntime — drop pkill anvil / pkill heartbeat; docker compose down handles teardown.
  • status — L1 check now uses the compose service state instead of pgrep 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:run140/140 pass

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
@douglance douglance force-pushed the feat/l1-in-docker branch from a37f65c to 89d27fc Compare June 16, 2026 13:42
@douglance douglance merged commit 34e3e77 into testnode-workspace-migration Jun 16, 2026
2 checks passed
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant