Skip to content

refactor(demo): run native demo without Docker#4708

Merged
sveitser merged 7 commits into
mainfrom
ma/native-demo-no-docker
Jul 20, 2026
Merged

refactor(demo): run native demo without Docker#4708
sveitser merged 7 commits into
mainfrom
ma/native-demo-no-docker

Conversation

@sveitser

Copy link
Copy Markdown
Collaborator

Replace the five Docker-backed process-compose services with native processes so just demo-native needs no Docker daemon:

  • demo-l1-network: custom geth-l1 image -> native anvil (from foundry)
  • espresso-node-db-0/1: docker postgres -> scripts/run-postgres
  • keydb: docker keydb -> native redis-server
  • telemetry-collector (vector) and block-explorer: dropped

flake.nix adds redis and bumps postgresql_16 -> postgresql_18. cleanup-process-compose drops the docker compose teardown and reaps anvil/postgres/redis-server.

Replace the five Docker-backed process-compose services with native
processes so `just demo-native` needs no Docker daemon:

- demo-l1-network: custom geth-l1 image -> native anvil (from foundry)
- espresso-node-db-0/1: docker postgres -> scripts/run-postgres
- keydb: docker keydb -> native redis-server
- telemetry-collector (vector) and block-explorer: dropped

flake.nix adds redis and bumps postgresql_16 -> postgresql_18.
cleanup-process-compose drops the docker compose teardown and reaps
anvil/postgres/redis-server.
@gemini-code-assist

Copy link
Copy Markdown
Contributor
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

@sveitser
sveitser requested a review from twittner July 17, 2026 07:02
@claude

claude Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Claude finished @sveitser's task in 3m 22s —— View job


Review: run native demo without Docker

Nice cleanup — replacing the Docker-backed services with native processes makes just demo-native self-contained, and the changes are internally consistent. I verified the key wiring and it holds together:

  • anvil accounts match .env.env uses the standard foundry mnemonic (test test test … junk), which is exactly anvil's default, so --accounts 20 --balance 1000000000 funds the deployer/prover/builder accounts the deploy scripts expect.
  • redis password is consistent--requirepass 'changeme!' matches all four CDN consumers (redis://:changeme!@localhost:6379).
  • WS-on-HTTP-port change is correct — anvil serves WS and HTTP on the same port, so pointing ESPRESSO_L1_WS_PROVIDER at ESPRESSO_L1_PORT is right.
  • Removed vars left in .env/docker-compose.yaml (ESPRESSO_L1_WS_PORT, telemetry ports, block-explorer port) are still used by the untouched docker-compose.yaml path, so keeping them is correct.
  • intentionally-unreachable-telemetry-endpoint already existed for espresso-node-0 on main; extending it to nodes 1 & 3 (now that vector is dropped) is consistent with the existing convention.
  • postgres readiness probe correctly gates on the espresso DB via psql … SELECT 1 — a good fix for the "ready before createdb runs" race, which is why dropping success_threshold: 2 is safe here.
  • run-postgres shutdown — binds to 127.0.0.1 only, uses fast-shutdown (kill -INT), and the double-wait mirrors scripts/demo-native so postgres isn't orphaned. Well documented.
  • cleanup-process-composeanvil/postgres/redis-server added to NATIVE_PROCESSES and the docker teardown removed, matching the new service set.

Findings (all minor / non-blocking)

  1. run-postgres can hang if shutdown arrives during startup — if SIGTERM/SIGINT hits while still in the until pg_isready loop, the trap kills postgres but the loop then spins forever and never reaches wait. Narrow window; suggested a flag-based break inline.
  2. run-postgres usage doc — says the DATADIR must be an "existing empty" directory, but the script relies on initdb creating it. Minor wording fix suggested inline.
  3. anvil/redis bind to 0.0.0.0 — consumers all use localhost and postgres is already 127.0.0.1-only; consider --host 127.0.0.1 / --bind 127.0.0.1 for consistency. Optional.

Nothing here blocks merge. Assuming just demo-native was run end-to-end (contract deploy + nodes reaching process_healthy), this looks good to ship.

Comment thread scripts/run-postgres Outdated
Comment on lines +67 to +69
createdb -h 127.0.0.1 -p "${port}" -U root espresso

# Double wait: the first returns as soon as the trap fires; the second blocks until

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Startup-time shutdown can hang this script. The trap is installed before this readiness loop, but if SIGTERM/SIGINT arrives while we're still in the until pg_isready loop, the trap fires kill -INT on postgres and postgres starts shutting down — after which pg_isready will never succeed, so this loop spins forever and the wait lines below are never reached. process-compose then has to SIGKILL on teardown.

This is a narrow window (only during startup, before the DB is ready), so it's minor, but you can make shutdown deterministic by breaking out when a shutdown was requested, e.g. set a flag in the trap and check it:

shutting_down=0
trap 'shutting_down=1; kill -INT "${pg_pid}" 2>/dev/null' TERM INT

until pg_isready -h 127.0.0.1 -p "${port}" >/dev/null 2>&1; do
  [[ "${shutting_down}" -eq 1 ]] && break
  sleep 0.5
done

Comment thread scripts/run-postgres
Comment on lines +28 to +29
OPTIONS:
-h, --help Show this help

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor doc nit: the usage says DATADIR Existing empty data directory to initialize and use, but the script actually relies on initdb creating the directory (the caller passes ${ESPRESSO_BASE_STORAGE_PATH}/pg0, which doesn't exist yet). Only the parent needs to exist. Consider rewording to "Data directory to initialize (created if missing; must be empty if it exists)" so it's clear the dir need not pre-exist — and that re-running against a populated dir would fail initdb.

Comment thread process-compose.yaml
sveitser added 5 commits July 17, 2026 15:09
- run-postgres: break readiness loop on shutdown signal so a SIGTERM
  during startup does not spin (pg_isready never succeeds against a
  shutting-down server); skip createdb when shutting down
- run-postgres: correct DATADIR docs (initdb creates the dir)
- bind anvil and redis to 127.0.0.1 instead of all interfaces
The native demo previously ran the L1, CDN store, and node DBs as Docker
containers, so the test-integration and demo-native jobs only needed
process-compose. Now those run natively (anvil, redis-server, postgres),
which were absent on the runner and broke every native demo job with
'anvil: command not found'.

Add install-native-demo-deps: installs foundry (anvil), redis-server and
postgresql, stops the auto-started redis/postgres services so the demo can
bind its own ports, and puts the postgres server binaries on PATH.
The Push-CDN broker heartbeat uses KeyDB's EXPIREMEMBER command, which plain
redis does not implement, so brokers never registered and the CDN was dead
(the demo limped along on the libp2p secondary; the non-PoS->PoS epoch upgrade
tests stalled). The standalone cdn-broker/cdn-marshal pick their discovery
client at compile time (Redis), so SQLite/embedded discovery is not selectable.

KeyDB is not in nixpkgs and has no clean macOS build, so nix/keydb.nix
repackages prebuilt binaries: the official keydb-tools .deb relocated via
autoPatchelfHook on Linux, and the Homebrew bottle (openssl relocated + re-signed)
on macOS aarch64. CI extracts the .deb directly.
autoPatchelfHook failed on the keydb-tools .deb for libbz2.so.1.0, liblz4.so.1,
libz.so.1 and libsystemd.so.0, which broke the default nix devShell build and
every nix-develop CI job (contracts, etc.). Add the full DT_NEEDED set.
Comment thread scripts/run-postgres
@sveitser
sveitser enabled auto-merge (squash) July 18, 2026 23:43
@sveitser
sveitser disabled auto-merge July 18, 2026 23:43
@sveitser
sveitser enabled auto-merge (squash) July 18, 2026 23:43

@imabdulbasit imabdulbasit left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't looked through all of the code but since the native demo works, so I'm approving it.

@sveitser
sveitser merged commit 6755185 into main Jul 20, 2026
179 of 181 checks passed
@sveitser
sveitser deleted the ma/native-demo-no-docker branch July 20, 2026 08:57
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.

2 participants