This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Mina Protocol is a lightweight blockchain that maintains constant size by using recursive zk-SNARKs. The codebase is primarily written in OCaml (4.14.2) with additional components in Go (libp2p helper) and Rust (cryptographic implementations via proof-systems submodule).
make build- Build the Mina daemon and core executables (requires 10GB+ RAM)make build-archive- Build the archive nodemake build-rosetta- Build Rosetta API componentsmake libp2p_helper- Build the Go libp2p helper (required for networking)make build-intgtest- Build integration test toolsmake build-mainnet-sigs- Build mainnet signature variantsmake build-devnet-sigs- Build devnet signature variantsmake build-daemon-utils- Build daemon utilitiesmake build-archive-utils- Build archive node and related utilitiesmake build-test-utils- Build test utilitiesmake build-replayer- Build the replayer toolmake build-logproc- Build log processor
dune build @check- Quick type-check without full buildmake check- Check that all OCaml packages build
make install- Install binaries to OPAM switchmake uninstall- Uninstall binaries
MINA_PROFILE=dev dune runtest src/lib/<library>- Run tests for a specific libraryMINA_PROFILE=dev dune runtest src/lib --profile=dev- Run all tests under src/libMINA_PROFILE=dev dune exec src/lib/<library>/test/main.exe- Run tests using explicit executableMINA_PROFILE=dev ./scripts/testone.sh <test-file> [test-name]- Run a single test file
./buildkite/scripts/unit-test.sh <profile> <path>- Run tests as done in CI (builds first, retries failures once)
make test-coverage MINA_PROFILE=dev- Run tests with coverage instrumentationmake coverage-html- Generate HTML coverage reportsmake coverage-summary- Generate coverage summary
make test-ppx- Test PPX extensions
Note: There is no make test target. Use dune runtest directly. Binaries and tests that link node_config abort unless MINA_PROFILE (or /etc/coda/build_config/PROFILE) names a profile; there is no default.
make reformat- Auto-format all OCaml codemake reformat-diff- Format only modified files (runs automatically duringmake build)make check-format- Check formatting without changing files
make check-bash- Run shellcheck on bash scriptsmake check-docker- Run hadolint on Docker files
make ml-docs- Generate OCaml documentation with odocmake update-graphql- Update GraphQL schema
./scripts/update-opam-switch.sh- Update/create the opam switch
cli/- Mina daemon and client CLI (main entry point)archive/- Archive node for storing historical blockchain datarosetta/- Rosetta API implementationlibp2p_helper/- Go-based libp2p networking helpertest_executive/- Integration test frameworkgenerate_keypair//validate_keypair/- Keypair utilitiesbatch_txn_tool/- Transaction load testingzkapp_test_transaction/- zkApp test transaction utilityzkapps_examples/- zkApp example programsreplayer/- Blockchain replay utilitymissing_blocks_auditor/- Audit for missing blocksextract_blocks//archive_blocks/- Block extraction and archivalhardfork_test/- Hard fork testing utilitiesruntime_genesis_ledger/- Runtime genesis ledger generatorlogproc/- Log processing utilitydelegation_verify/- Delegation verification
mina_lib/- Main daemon coordinator libraryconsensus/- Proof-of-stake consensus implementationtransaction_snark/- Transaction SNARK creation and verificationpickles/- Recursive SNARK composition library (used for blockchain proofs)crypto/- Cryptographic primitives (fields, curves, hashing)network_pool/- P2P networking and gossipledger/- Merkle tree ledger implementationstaged_ledger/- Transaction processing pipeline
Profiles are defined as .mlh files in src/config/ and selected via --profile in dune:
dev- Development (default). Small ledger depth (10), proof_level=check, fast 2s blocksdevnet- Devnet. Full ledger depth (35), proof_level=full, 3min blocks, testnet signaturesmainnet- Production. Full ledger depth (35), proof_level=full, 3min blocks, mainnet signatureslightnet- Lightweight test network. Full ledger depth (35), proof_level=none, 20s blocks
- Pipeline defined in Dhall (typed configuration language) in
buildkite/src/ - Jobs organized under
buildkite/src/Jobs/{Test,Release,Lint,Bench}/ - Constants (artifacts, networks, profiles, codenames) in
buildkite/src/Constants/ - Monorepo triage system:
buildkite/scripts/monorepo.shdetermines which jobs to run based on changed files - Monorepo tests:
cd buildkite && make test_monorepo
build.sh- Main build orchestrator, builds all or specific packagesbuilder-helpers.sh- Core library with package building functionstests/test_builder_helpers.sh- Unit tests for the builder helpers- Key env vars:
MINA_DEB_CODENAME,MINA_DEB_VERSION,DUNE_PROFILE,MINA_DEB_RELEASE - Supported codenames: bullseye, focal, noble, jammy, bookworm
- Package naming is profile-aware (lightnet suffix) and instrumentation-aware
build.sh- Docker image builder with service/network/platform optionshelper.sh- Tag generation and base image selection helpers- Dockerfiles in
dockerfiles/directory - Supports multiarch builds (amd64, arm64) via
docker buildx
release-manager(MinaProtocol/mina-release-toolkit, installed in the toolchain image) - Main tool for publishing, promoting, and verifying releases- Workflow: Build -> Unstable -> Alpha -> Beta -> Stable
- Supports Debian repos, GCR, and docker.io
- Uses
deb-s3for Debian repository operations
- Daemon Layer (
mina_lib/) - Coordinates all subsystems - Consensus Layer - Handles proof-of-stake consensus and chain selection
- SNARK Layer - Creates and verifies recursive proofs
- Network Layer - P2P communication via libp2p
- Ledger Layer - Maintains account balances and state
- Staged Ledger: Pipeline for processing transactions in parallel
- Scan State: Tree structure tracking pending SNARK work
- Transition Frontier: Recent blocks kept in memory
- Protocol State: Consensus-critical blockchain state
- Transaction Pool: Mempool for pending transactions
- OCaml 4.14.2 is required (not compatible with OCaml 5)
- Dune 3.1+ required
- System ulimits need adjustment for builds:
ulimit -s 65532; ulimit -n 10240 - Builds require significant RAM (10GB+)
- Git submodules must be initialized:
git submodule update --init --recursive
- Set up the opam switch:
make switch - Initialize git submodules:
git submodule update --init --recursive - Build libp2p helper:
make libp2p_helper
# Run tests for a specific library
MINA_PROFILE=dev dune runtest src/lib/mina_lib
# Run tests with proper limits
(ulimit -s 65532 || true) && (ulimit -n 10240 || true) && MINA_PROFILE=dev dune runtest src/lib
# Run a single test
MINA_PROFILE=dev ./scripts/testone.sh src/lib/mina_lib/test.ml- Add to relevant
.opamfile insrc/ - Run
make switchto update the opam switch - Commit both changes together
Always format code before committing:
make reformat-diff # Format only changed files
# or
make reformat # Format all files# Build specific target
dune build src/app/cli/src/mina.exe
# Watch mode for development
dune build -w @check
# Build and run inline tests
MINA_PROFILE=dev dune runtest src/lib/mina_libnightly.apt.packages.minaprotocol.com- Signed, for nightly packagesunstable.apt.packages.minaprotocol.com- Signed, for alpha/beta packagesstable.apt.packages.minaprotocol.com- Signed, for releasespackages.o1test.net- Unsigned, legacy multichannel repo
- CI is triggered by a PR comment, never by a label: comment
!ci-build-mefor standard CI,!ci-nightly-mefor the nightly/end-to-end pipeline - Most commands are matched against the whole comment body, so post the command alone with no extra prose
- The comment author must be a public member of the MinaProtocol org
- Code must be formatted with
make reformatbefore commits - CI uses Docker images from
europe-west3-docker.pkg.dev/o1labs-192920/euro-docker-repo/