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):
- Environment Variable:
MINA_CIRCUIT_BLOBS_BASE_DIR
- Cargo Manifest Directory: Current project directory
- Home Directory:
~/.mina/circuit-blobs/
- 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:
- Automatic Detection: The system checks for required circuit files
- 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
- Automatic Download: If files aren’t found locally, downloads from GitHub
- Local Caching: Saves downloaded files to
~/.mina/circuit-blobs/
- 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
- Generate circuit data using OCaml implementation
- Add files to circuit-blobs repository
- Update circuit configuration in
mina_core::network
- 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
§Related Modules
crate::proofs::provers
: Prover creation using circuit datacrate::proofs::constants
: Circuit type definitions