Skip to content

server: HTTP verify sidecar for a trustless indexer#2

Merged
dkijania merged 2 commits into
mainfrom
verify/http-sidecar
Jun 17, 2026
Merged

server: HTTP verify sidecar for a trustless indexer#2
dkijania merged 2 commits into
mainfrom
verify/http-sidecar

Conversation

@dkijania

Copy link
Copy Markdown
Member

What

Adds mina-verify-server — a long-lived HTTP service that answers one question: "is this precomputed block's proof honest?" Built for a trustless indexer: verify each block's SNARK proof before ingesting it, with no trusted daemon.

GET  /health  -> { "status": "ok", "network": "devnet" }
POST /verify  (precomputed-block JSON) -> { "valid": true, "height",
                "state_hash", "previous_state_hash", "staged_ledger_hash" }
              (or { "valid": false, "error": ... })

The caller ingests iff valid, keyed by the proof-backed hashes. A valid proof attests the entire chain to genesis by recursion, so trust in whoever produced the block isn't required.

Design

  • Links only the mina-verify lib (the precomputed path needs no networking) → small, stateless, CPU-bound. The expensive Verifier setup is paid once at startup; each request is just the proof check.
  • tiny_http + a worker pool — verification is blocking CPU work, so no async/tokio.
  • Lossy UTF-8 body decode. Real precomputed blocks are not strictly UTF-8: the OCaml daemon emits some byte-string fields (e.g. sok_digest in staged_ledger_diff) as mixed raw/escaped bytes. Verification ignores those fields (only protocol_state + the proof, both ASCII, are read), so the body is decoded lossily — matching how JS clients read these blocks. Verified against fresh devnet blocks that carry these bytes.
  • Config via env: BIND, MINA_VK_JSON (for mesa/mesa-mut), MINA_NETWORK, VERIFY_THREADS.
  • Docker: the image builds the bin; run as a sidecar via --entrypoint mina-verify-server.

Verified (live devnet)

  • /health → ok
  • fresh real block (with non-UTF-8 sok_digest) → valid:true, correct height/hashes, ~1–2 s
  • tampered proof → valid:false

Native release verifies in ~1–2 s/block (no wasm overhead / no num-bigint opt penalty), so an indexer can afford to verify every block, not just the tip. The README documents the docker-compose indexer topology and the --verify-block-exe curl-shim wiring (reusing the indexer's existing exe-hook pattern, so the Rust-1.94 toolchain stays bottled up in its own container).

Notes

🤖 Generated with Claude Code

dkijania and others added 2 commits June 17, 2026 21:52
Add `mina-verify-server` — a long-lived HTTP service wrapping
`Verifier::verify_precomputed_and_extract`: POST a precomputed block, get its
proof-backed facts ({valid, height, state_hash, previous_state_hash,
staged_ledger_hash}). An indexer gates ingestion on `valid` with no trusted
daemon; a valid proof attests the whole chain to genesis by recursion.

- Links only the mina-verify lib (no networking) — small, stateless, CPU-bound.
  Verifier built once at startup; each request is just the proof check.
- tiny_http (sync) with a worker pool — verification is blocking CPU work, so no
  async/tokio.
- Reads the body as bytes + lossy UTF-8: real precomputed blocks are NOT strictly
  UTF-8 (the daemon emits sok_digest in staged_ledger_diff as mixed raw/escaped
  bytes); that field is ignored by verification, so lossy decode is safe and
  necessary. Verified against fresh devnet blocks that carry these bytes.
- Config via env (BIND, MINA_VK_JSON for mesa, MINA_NETWORK, VERIFY_THREADS).
- Dockerfile builds the bin; run as the sidecar via --entrypoint mina-verify-server.

Native release verifies in ~1-2s/block, so an indexer can verify every block, not
just the tip. README documents the docker-compose indexer topology + the
--verify-block-exe curl-shim wiring.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add crates/mina-verify-server/deploy/:
- verify-block.sh — the indexer --verify-block-exe shim: curls the sidecar /verify
  and exits 0 iff {"valid":true}, non-zero => reject. Mirrors the existing
  --fetch-new-blocks-exe (mesa-pull) curl-wrapper convention.
- docker-compose.yml — runs the mina-verifier sidecar with a /health healthcheck,
  plus a commented mina-indexer stub showing the wiring + mesa MINA_VK_JSON mount.
- README.md — the trustless-indexer topology + how to demo gating on devnet.

Dockerfile: add curl to the runtime image for the sidecar healthcheck.

Verified the gating contract end-to-end against the native sidecar on live devnet:
real block -> shim exit 0 (ingest); tampered block -> exit 22 (reject).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@dkijania dkijania force-pushed the verify/http-sidecar branch 2 times, most recently from dd816ba to 4c16b05 Compare June 17, 2026 21:30
@dkijania dkijania merged commit 0b21ec0 into main Jun 17, 2026
4 checks passed
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