diff --git a/Makefile b/Makefile index 3bf871156..3f947123e 100644 --- a/Makefile +++ b/Makefile @@ -33,6 +33,9 @@ NETWORK ?= devnet VERBOSITY ?= info GIT_COMMIT := $(shell git rev-parse --short=8 HEAD) +# Circuit blobs configuration +CIRCUIT_BLOBS_TAG ?= 20251006-berkeley-devnet + # Documentation server port DOCS_PORT ?= 3000 @@ -193,9 +196,9 @@ clean: ## Clean build artifacts cargo clean .PHONY: download-circuits -download-circuits: ## Download the circuits used by Mina from GitHub +download-circuits: ## Download the circuits used by Mina from GitHub (uses CIRCUIT_BLOBS_TAG) @if [ ! -d "circuit-blobs" ]; then \ - git clone --depth 1 https://github.com/o1-labs/circuit-blobs.git; \ + git clone --depth 1 --branch $(CIRCUIT_BLOBS_TAG) https://github.com/o1-labs/circuit-blobs.git; \ ln -s "$$PWD"/circuit-blobs/3.0.0mainnet ledger/; \ ln -s "$$PWD"/circuit-blobs/3.0.1devnet ledger/; \ else \ diff --git a/ledger/src/proofs/circuit_blobs.rs b/ledger/src/proofs/circuit_blobs.rs index 7707008c0..59d07a4c1 100644 --- a/ledger/src/proofs/circuit_blobs.rs +++ b/ledger/src/proofs/circuit_blobs.rs @@ -53,9 +53,14 @@ //! If files are not found locally, the system automatically downloads them from: //! //! ```text -//! https://github.com/o1-labs/circuit-blobs/releases/download/ +//! https://github.com/o1-labs/circuit-blobs/raw/main// //! ``` //! +//! The `` corresponds to the circuit version (e.g., +//! `20251006-berkeley-devnet`) and is defined by the `TAG` constant in the +//! `git_release_url` function. To use a different version, modify the constant +//! in the source code. +//! //! Downloaded files are cached locally for future use. //! //! ## Web Environment @@ -105,6 +110,9 @@ //! export MINA_CIRCUIT_BLOBS_BASE_DIR=/path/to/your/circuit-blobs //! ``` //! +//! To use a different circuit version when downloading from GitHub, modify the +//! `TAG` constant in the `git_release_url` function in this file. +//! //! ## Related Modules //! //! - [`crate::proofs::provers`]: Prover creation using circuit data @@ -120,10 +128,16 @@ pub fn home_base_dir() -> Option { } fn git_release_url(filename: &impl AsRef) -> String { - const RELEASES_PATH: &str = "https://github.com/o1-labs/circuit-blobs/releases/download"; + const RAW_GITHUB_BASE: &str = "https://github.com/o1-labs/circuit-blobs/raw/refs/tags"; + const TAG: &str = "20251006-berkeley-devnet"; + // This only works for devnet right now. For mainnet, we need to change this + // to "mainnet" or make it configurable. It is used for now as this to + // replace the requirement of adding assets to the release. + const VERSION: &str = "berkeley-devnet"; + let filename_str = filename.as_ref().to_str().unwrap(); - format!("{RELEASES_PATH}/{filename_str}") + format!("{RAW_GITHUB_BASE}/{TAG}/{VERSION}/{filename_str}") } #[cfg(not(target_family = "wasm"))] @@ -201,3 +215,35 @@ pub fn fetch_blocking(filename: &impl AsRef) -> std::io::Result> { let url = format!("{prefix}/{}", filename.as_ref().to_str().unwrap()); mina_core::http::get_bytes_blocking(&url) } + +#[cfg(test)] +mod tests { + use super::*; + + // Run with: + // ``` + // cargo test \ + // --package mina-tree \ + // --lib \ + // -- proofs::circuit_blobs::tests::test_fetch_circuit_file --ignored + // ``` + #[test] + fn test_fetch_circuit_file() { + // NOTE: Update this filename if the TAG constant changes in git_release_url + // This file should exist in the release tagged by TAG + let filename = "step-step-proving-key-blockchain-snark-step-0-55f640777b6486a6fd3fdbc3fcffcc60_rows_rev.bin"; + + let url = git_release_url(&filename); + let response = reqwest::blocking::Client::new() + .head(&url) + .send() + .expect("Failed to send HEAD request"); + + assert!( + response.status().is_success(), + "Circuit file URL returned status {}: {}", + response.status(), + url + ); + } +}