Module circuit_blobs

Source
Expand description

§Circuit Constraint Extraction

This module handles circuit constraint extraction for the Mina Rust node. Circuit constraints are sourced from the circuit-blobs repository, which contains pre-compiled circuit data generated by the OCaml implementation.

§Overview

The Mina Rust node automatically handles downloading and caching circuit files, making the process transparent to users. When you run the node or generate proofs, the system will automatically fetch the required circuit data if it’s not already available locally.

§Circuit Data Files

The circuit-blobs repository contains three types of files for each circuit:

§Gates Definition (*_gates.json)

  • JSON files containing the list of gates for each circuit
  • Define the circuit structure and operations
  • Used for generating proving and verification keys

§Internal Variables (*_internal_vars.bin)

  • Binary files containing internal variable mappings
  • Store relationships between field elements and variable indices
  • Essential for witness generation

§Row Reversal Data (*_rows_rev.bin)

  • Binary files containing constraint system data
  • Used for efficient constraint evaluation
  • Required for proof generation

§Extraction Process

The Mina Rust node automatically handles circuit constraint extraction through this module’s fetch_blocking function.

§Local Resolution

The system searches for circuit files in these locations (in order):

  1. Environment Variable: MINA_CIRCUIT_BLOBS_BASE_DIR
  2. Cargo Manifest Directory: Current project directory
  3. Home Directory: ~/.mina/circuit-blobs/
  4. System Directory: /usr/local/lib/mina/circuit-blobs

§Remote Fetching

If files are not found locally, the system automatically downloads them from:

https://github.com/o1-labs/circuit-blobs/releases/download/<filename>

Downloaded files are cached locally for future use.

§Web Environment

For web deployments, circuit files are served statically:

  • Frontend Path: /assets/webnode/circuit-blobs/<version>/
  • Download Script: frontend/docker/startup.sh handles automatic downloading
  • Version: Specified by CIRCUITS_VERSION environment variable

§How It Works for Users

§First Run Experience

When you first run the Mina Rust node or generate proofs:

  1. Automatic Detection: The system checks for required circuit files
  2. Local Search: Searches in these locations (in order):
    • $MINA_CIRCUIT_BLOBS_BASE_DIR (if set)
    • Current project directory
    • ~/.mina/circuit-blobs/
    • /usr/local/lib/mina/circuit-blobs
  3. Automatic Download: If files aren’t found locally, downloads from GitHub
  4. Local Caching: Saves downloaded files to ~/.mina/circuit-blobs/
  5. Ready to Use: Circuit data is loaded and ready for proof generation

§Subsequent Runs

  • Uses cached files from ~/.mina/circuit-blobs/
  • No network requests needed
  • Fast startup times

§Development Guidelines

§Adding New Circuit Types

  1. Generate circuit data using OCaml implementation
  2. Add files to circuit-blobs repository
  3. Update circuit configuration in mina_core::network
  4. Add prover creation logic in crate::proofs::provers

§Local Development

Set MINA_CIRCUIT_BLOBS_BASE_DIR environment variable to point to your local circuit-blobs repository clone:

export MINA_CIRCUIT_BLOBS_BASE_DIR=/path/to/your/circuit-blobs

Functions§

fetch_blocking
git_release_url 🔒
home_base_dir