Sonar is a Solana-native ZK coprocessor prototype built around an Anchor program, an off-chain proving pipeline, and a thin developer surface for submitting requests and registering verifiers. The repo now contains a full request -> prove -> callback -> index loop, a real CPI SDK, a developer CLI for verifier registration, Criterion benchmarks for hot paths, and CI/security automation suitable for active development.
Sonar is not production-ready yet. The current state is best described as a hardened devnet-quality system with one end-to-end vertical slice (historical_avg) and the core primitives needed to expand toward a multi-computation coprocessor.
- On-chain program supports
register_verifier,request,callback, andrefund. - Off-chain services include a coordinator, prover, indexer, and Geyser plugin.
historical_avgruns end-to-end with an ignored integration test and CI coverage.crates/sdkprovides a real Anchor CPI helper for downstream programs.crates/cliprovidessonar-cli registerfor verifier registration.- CI runs Rust checks, Anchor build/tests, dependency/license scanning, and secret scanning.
- Benchmarks exist for coordinator and prover hot paths.
flowchart LR
A[Client or CPI caller] -->|request| B[Sonar Anchor program]
B -->|stores RequestMetadata + ResultAccount PDAs| C[(Solana state)]
B -->|emits request and inputs logs| D[Coordinator listener]
D -->|fetch account history when needed| E[Indexer HTTP API]
D -->|enqueue ProverJob| F[(Redis)]
F --> G[Prover]
G -->|proof + result| F
F --> H[Coordinator callback worker]
H -->|callback| B
B -->|verify Groth16 + write result + invoke callback| I[Consumer callback program]
B -->|fee payout| J[Prover authority]
K[Geyser plugin] --> L[(Postgres)]
L --> E
| Path | Purpose |
|---|---|
program/ |
Anchor program that owns request/result/verifier state and verifies proofs on callback |
crates/coordinator/ |
Log listener, Redis dispatcher, and callback submission worker |
crates/prover/ |
SP1 execution, Groth16 wrapping, artifact export, computation registry |
crates/indexer/ |
Geyser plugin, Postgres persistence, and Axum HTTP API |
crates/sdk/ |
Anchor CPI helper for downstream Sonar consumers |
crates/cli/ |
sonar-cli for verifier registration |
programs/historical_avg_client/ |
Example consumer program that requests the historical-average computation |
echo_callback/ |
Minimal callback target used by integration flows |
tests/ |
Rust integration/e2e coverage, including historical-average orchestration |
docs/ |
Current-state, target-state, roadmap, architecture, and contribution docs |
- Rust stable
- Node.js 20+
- Solana CLI 3.0.13
- Anchor CLI 0.32.1
- Docker (for integration and end-to-end flows)
- PostgreSQL and Redis when running the off-chain stack outside the test harness
npm install
cargo test --workspace -- --skip integration
anchor build
anchor testFor the full historical-average vertical slice:
cargo build --bins
cargo build -p sonar-indexer --lib
anchor build
cargo test --test e2e_historical_avg -- --ignored --nocapturecargo fmt --check
cargo clippy --workspace --all-targets --all-features -- -D warnings
cargo test --workspace -- --skip integrationcargo bench -p sonar-coordinator
cargo bench -p sonar-provercargo run --bin sonar-export-artifacts -- artifactscargo run -p sonar-cli -- register \
--elf-path programs/historical_avg/elf/riscv32im-succinct-zkvm-elf \
--keypair ~/.config/solana/id.json \
--rpc-url "$SOLANA_RPC_URL"sonar-cli hashes the ELF to derive the computation_id, resolves a Groth16 verifier artifact, builds register_verifier, and submits the transaction to Solana.
config/default.tomlandconfig/devnet.tomldefine runtime configuration.- The off-chain stack is environment-driven for secrets and endpoints.
- The indexer expects Postgres, the coordinator/prover expect Redis, and Solana RPC/WS endpoints are supplied via config or env vars.
- CI: format, clippy, unit/integration tests, Anchor build/tests, e2e flow, and demo verification.
- Security workflow:
cargo audit,cargo deny, andgitleaks. - Pre-commit hooks: Rust fmt/clippy,
cargo deny,cargo audit, and Prettier for Markdown/JSON/YAML.
- Production economics, fee policy, and capacity planning are still evolving.
- Verifier registration exists, but operational lifecycle management and governance are still manual.
- The repo proves one strong vertical slice today rather than a broad catalog of production computations.
- The system is still oriented around devnet/local-validator workflows, not a hardened mainnet rollout.
docs/SSOT.mdfor the current implementation truthdocs/ARCHITECTURE.mdfor component and lifecycle detaildocs/ROADMAP.mdfor what is done versus what remainsdocs/PROD_TARGET.mdfor the desired production shapedocs/CONTRIBUTING.mdfor local workflow expectationsSECURITY.mdfor disclosure and secure-development guidance