Skip to content

Add mina-rosetta-healthcheck CLI#18796

Draft
dkijania wants to merge 8 commits intocompatiblefrom
darek/rosetta-healthcheck
Draft

Add mina-rosetta-healthcheck CLI#18796
dkijania wants to merge 8 commits intocompatiblefrom
darek/rosetta-healthcheck

Conversation

@dkijania
Copy link
Copy Markdown
Member

Summary

Adds a new lightweight CLI mina-rosetta-healthcheck for probing the health of a running Mina Rosetta server. Mirrors the shape of mina-archive-healthcheck: fast single-request probes for k8s readiness/liveness, CI smoke tests, plus an audit group that wraps rosetta-cli for deep sweeps and a show-config/export-config pair for extracting the in-tree rosetta-cli-config files.

Commits

  1. 6d44cf7a9b - CLI skeleton (quick probes + --json): network-list, network-status, network-options, block, account-balance, mempool, ready, wait.
  2. b3887e3cea - Embed rosetta-cli-config files (config.json, mina.ros, mina-no-delegation-test.ros, mina-with-return-funds.ros) + export-config / show-config.
  3. 0c3af00a1a - audit subcommands wrapping rosetta-cli (configuration-validate, check-spec, check-construction, check-data, all).
  4. cd8456a690 - Include mina-rosetta-healthcheck in the build-rosetta Makefile target and in build_rosetta_deb in scripts/debian/builder-helpers.sh.
  5. dfde294c98 - README.

Files touched

  • New: src/app/mina_rosetta_healthcheck/{dune,mina_rosetta_healthcheck.ml,README.md,gen_embedded/{dune,gen_embedded.ml}}
  • Modified: src/dune-project, Makefile (build-rosetta), scripts/debian/builder-helpers.sh (build_rosetta_deb)

Test plan

  • dune build src/app/mina_rosetta_healthcheck/mina_rosetta_healthcheck.exe
  • make build-rosetta succeeds and produces mina-rosetta-healthcheck
  • Debian Build Bullseye Devnet builds the rosetta package including the new binary
  • mina-rosetta-healthcheck network-list --online-uri http://localhost:3087 exits 0 against a running Rosetta server
  • mina-rosetta-healthcheck ready --json emits a single JSON record
  • mina-rosetta-healthcheck show-config prints embedded config.json
  • mina-rosetta-healthcheck export-config --out /tmp/cfg writes all four embedded files
  • mina-rosetta-healthcheck audit all --config /tmp/cfg/config.json runs rosetta-cli sweeps end-to-end
  • Rosetta-related CI jobs pass (Docker: Rosetta, Rosetta unit tests, Rosetta integration tests, Rosetta block race)

dkijania and others added 5 commits April 21, 2026 08:59
Lightweight tool that probes a running Mina Rosetta server with
single-request HTTP checks. Subcommands:

- network-list    — POST /network/list
- network-status  — POST /network/status (with optional --max-delay tip recency)
- network-options — POST /network/options
- block           — POST /block by --index or --hash
- account-balance — POST /account/balance for a B62q... address
- mempool         — POST /mempool
- ready           — composite of list/status/options
- wait            — poll ready until pass or --timeout

Designed for k8s exec probes, Docker HEALTHCHECK, and CI smoke tests.
Every subcommand supports --json for machine-readable output and follows
the single-JSON-record-per-invocation contract from mina-archive-healthcheck.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
Bundle the four canonical rosetta-cli configs living under
src/app/rosetta/rosetta-cli-config/ into the healthcheck binary at
compile time, so operators can extract them without hunting for
paths on disk:

- config.json
- mina.ros
- mina-no-delegation-test.ros
- mina-with-return-funds.ros

The embedding is done by a tiny generator (gen_embedded/) invoked
via a dune (rule) that emits embedded_configs.ml exposing the
contents as string constants. Using a generator dodges the
escaping/delimiter headaches of hand-embedding long JSON/DSL
blobs in OCaml string literals.

Two new subcommands consume the embedded configs:

- show-config [--file NAME] — prints one embedded config to stdout
  (default: config.json). Useful for
  `mina-rosetta-healthcheck show-config > config.json`.
- export-config --out DIR [--force] — writes all four files into
  DIR, creating it if missing and refusing to clobber a non-empty
  dir without --force.

Both obey the same JSON contract as the quick probes and flush
stderr explicitly before Stdlib.exit so environment errors are
visible under Async.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
Add an [audit] command group that shells out to an external
[rosetta-cli] binary to run the four canonical exchange-validation
sweeps described in section A of rosetta_exchange_validation.md:

- audit configuration-validate — rosetta-cli configuration:validate CFG
- audit check-spec             — rosetta-cli check:spec --all --configuration-file CFG
- audit check-construction     — rosetta-cli check:construction --configuration-file CFG
- audit check-data             — rosetta-cli check:data --configuration-file CFG
- audit all                    — run all four; [--continue-on-error] runs
                                  every step and exits with the worst code

Binary resolution: honors ROSETTA_CLI_BIN, then falls back to
[command -v rosetta-cli]; missing binary exits 2 with a clear
message on stderr. Default config path
(/etc/mina/rosetta/rosetta-cli-config/config.json) matches the
in-tree integration-test convention.

Child stdout/stderr is streamed through to the user so long sweeps
are observable live; in --json mode we also emit one summary record
per step: { "step": "check-data", "exit_code": 0, "duration_seconds": … }.

This does NOT reimplement the Construction API round-trip in OCaml;
it delegates to rosetta-cli, which is the tool exchanges are expected
to run.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
- Makefile: add the new executable to the build-rosetta target so
  CI builds it alongside mina-rosetta and mina-ocaml-signer.
- scripts/debian/builder-helpers.sh: copy the binary into
  /usr/local/bin/mina-rosetta-healthcheck inside the rosetta
  debian package (build_rosetta_deb), so it ships next to
  mina-rosetta and can be invoked by k8s probes / Docker
  HEALTHCHECKs out of the box.

The embedded configs still live on disk at
/etc/mina/rosetta/rosetta-cli-config/ thanks to the existing
copy in build_rosetta_deb; [export-config] and [show-config]
give operators a binary-only path that does not depend on
those files being present.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
Add a usage-focused README next to the source covering:

- The command table (quick probes, audit wrappers, config export)
  and exit codes (0 pass / 1 failed check / 2 environment error).
- All flags (--online-uri, --network, --max-delay, --timeout, etc.)
  with their defaults.
- The single-JSON-record-per-invocation contract in --json mode.
- Ready-to-copy Kubernetes liveness/readiness probe snippets and
  a Docker HEALTHCHECK example.
- A "Relationship to rosetta-cli" section drawing the line between
  the fast single-request probes shipped here (for k8s / CI) and
  the long-running sweeps wrapped under [audit] (for deep audits).

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@dkijania
Copy link
Copy Markdown
Member Author

!ci-build-me

dkijania and others added 2 commits April 21, 2026 09:36
Hermetic shell-based smoke tests wired into [dune runtest
src/app/mina_rosetta_healthcheck]. Cover only the subcommands that do
NOT need a running Rosetta server, so the tests stay fast and CI-safe:

- show-config: default file matches bytes of
  src/app/rosetta/rosetta-cli-config/config.json, --file mina.ros
  matches mina.ros, --file bogus exits 2 with stderr diagnostic and
  empty stdout.
- export-config: into a fresh (non-existent, nested) dir writes all
  four files byte-matching originals; into a non-empty dir without
  --force exits 2 and leaves contents untouched; with --force
  succeeds and writes alongside.
- audit check-spec with ROSETTA_CLI_BIN=/nonexistent/rosetta-cli:
  text mode exits 2 with stderr mentioning the missing binary and
  empty stdout; --json mode emits exactly one JSON object on stdout
  with "ok": false and an "error" field, exit 2.
- --help smoke: top-level lists every subcommand (network-list,
  network-status, network-options, block, account-balance, mempool,
  ready, wait, audit, show-config, export-config); audit --help
  lists check-spec, check-construction, check-data,
  configuration-validate, all. Both exit 0.

The HTTP probe subcommands are out of scope here — they need an
HTTP fixture to be meaningful; a TODO in smoke.sh calls this out so
future work is easy to pick up.

The tests/dune rule declares the four config files as deps so dune
re-runs the suite whenever the on-disk copies change, guaranteeing
"embedded == source-tree" stays true.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
- Await child stdout/stderr copy deferreds in `run_rosetta_cli_step`
  so the tail of output written just before exit is not lost.
- Reject `export-config --out <file>` with a clean error (and a single
  JSON record in --json mode) when the path exists but is not a
  directory, instead of letting `Core.Unix.mkdir_p` raise.
- Treat a `/block` response whose `block_identifier` is present but
  missing both parseable `index` and `hash` as a failure rather than
  silently passing with `Null` values.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@dkijania
Copy link
Copy Markdown
Member Author

!ci-build-me

… in devnet/mainnet signs

- Add `ppx_version` preprocess + `bisect_ppx` instrumentation clauses
  to `src/app/mina_rosetta_healthcheck/gen_embedded/dune` to satisfy
  `scripts/require-ppxs.py` lint.
- Add `mina_rosetta_healthcheck.exe` to `build-devnet-sigs` and
  `build-mainnet-sigs` Makefile targets so the devnet Debian pipeline
  (which drives those targets via `buildkite/scripts/build-artifact.sh`)
  builds it before `build_rosetta_deb` tries to copy it.
- Assert `mina-rosetta-healthcheck` in
  `scripts/debian/tests/test_builder_helpers.sh` (and mock the exe in
  the fixture setup) to catch future regressions in the copy path.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@dkijania
Copy link
Copy Markdown
Member Author

!ci-build-me

2 similar comments
@dkijania
Copy link
Copy Markdown
Member Author

!ci-build-me

@dkijania
Copy link
Copy Markdown
Member Author

!ci-build-me

@dkijania dkijania marked this pull request as draft April 21, 2026 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: To triage

Development

Successfully merging this pull request may close these issues.

1 participant