Skip to content

Commit

Permalink
chore: E2E test for checking if Plonk parameters require regenerating (
Browse files Browse the repository at this point in the history
…#69)

* chore: Add e2e test for checking newly installed Plonk parameters

* chore: Use public address of AWS bucket
  • Loading branch information
storojs72 authored Jun 21, 2024
1 parent 9dad0a2 commit 1d9cc5b
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 15 deletions.
2 changes: 1 addition & 1 deletion prover/src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use reqwest::Client;
use crate::utils::block_on;

/// The base URL for the S3 bucket containing the plonk bn254 artifacts.
pub const PLONK_BN254_ARTIFACTS_URL_BASE: &str = "s3://sphinx-plonk-params";
pub const PLONK_BN254_ARTIFACTS_URL_BASE: &str = "https://sphinx-plonk-params.s3.amazonaws.com";

/// The current version of the plonk bn254 artifacts.
pub const PLONK_BN254_ARTIFACTS_COMMIT: &str = "4a525e9f";
Expand Down
40 changes: 29 additions & 11 deletions prover/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -713,22 +713,15 @@ mod tests {
use self::build::try_build_plonk_bn254_artifacts_dev;
use super::*;

use crate::build::try_install_plonk_bn254_artifacts;
use anyhow::Result;
use p3_field::PrimeField32;
use serial_test::serial;
use sphinx_core::io::SphinxStdin;
use sphinx_core::utils::setup_logger;
use types::HashableKey;

/// Tests an end-to-end workflow of proving a program across the entire proof generation
/// pipeline.
///
/// Add `FRI_QUERIES`=1 to your environment for faster execution. Should only take a few minutes
/// on a Mac M2. Note: This test always re-builds the plonk bn254 artifacts, so setting SP1_DEV is
/// not needed.
#[test]
#[serial]
fn test_e2e() -> Result<()> {
fn test_e2e_inner(build_artifacts: bool) -> Result<()> {
setup_logger();
let elf = include_bytes!("../../tests/fibonacci/elf/riscv32im-succinct-zkvm-elf");

Expand Down Expand Up @@ -785,8 +778,12 @@ mod tests {
assert_eq!(vk_digest_bn254, vk.hash_bn254());

tracing::info!("generate plonk bn254 proof");
let artifacts_dir =
try_build_plonk_bn254_artifacts_dev(&prover.wrap_vk, &wrapped_bn254_proof.proof);
let artifacts_dir = if build_artifacts {
try_build_plonk_bn254_artifacts_dev(&prover.wrap_vk, &wrapped_bn254_proof.proof)
} else {
try_install_plonk_bn254_artifacts(false)
};

let plonk_bn254_proof = prover.wrap_plonk_bn254(wrapped_bn254_proof, &artifacts_dir);
println!("{:?}", plonk_bn254_proof);

Expand All @@ -795,6 +792,27 @@ mod tests {
Ok(())
}

/// Tests an end-to-end workflow of proving a program across the entire proof generation
/// pipeline.
///
/// Add `FRI_QUERIES`=1 to your environment for faster execution. Should only take a few minutes
/// on a Mac M2. Note: This test always re-builds the plonk bn254 artifacts, so setting SP1_DEV is
/// not needed.
#[test]
#[serial]
fn test_e2e() -> Result<()> {
test_e2e_inner(true)
}

/// Tests an end-to-end workflow of proving a program across the entire proof generation
/// pipeline. This test tries to install plonk artifacts, so it is useful to run in in order to check if
/// newly installed parameters work
#[test]
#[ignore]
fn test_e2e_check_parameters() -> Result<()> {
test_e2e_inner(false)
}

/// Tests an end-to-end workflow of proving a program across the entire proof generation
/// pipeline in addition to verifying deferred proofs.
#[test]
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/artifacts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub fn export_solidity_plonk_bn254_verifier(output_dir: impl Into<PathBuf>) -> R
let artifacts_dir = if sphinx_prover::build::sphinx_dev_mode() {
sphinx_prover::build::plonk_bn254_artifacts_dev_dir()
} else {
try_install_plonk_bn254_artifacts(true)
try_install_plonk_bn254_artifacts(false)
};
let verifier_path = artifacts_dir.join("SphinxVerifier.sol");

Expand Down
2 changes: 1 addition & 1 deletion sdk/src/provers/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ impl Prover for LocalProver {
&outer_proof.proof,
)
} else {
sphinx_prover::build::try_install_plonk_bn254_artifacts(true)
sphinx_prover::build::try_install_plonk_bn254_artifacts(false)
};
let proof = self.prover.wrap_plonk_bn254(outer_proof, &plonk_bn254_aritfacts);
Ok(SphinxProofWithPublicValues {
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/provers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ pub trait Prover: Send + Sync {
let plonk_bn254_aritfacts = if sphinx_prover::build::sphinx_dev_mode() {
sphinx_prover::build::plonk_bn254_artifacts_dev_dir()
} else {
sphinx_prover::build::try_install_plonk_bn254_artifacts(true)
sphinx_prover::build::try_install_plonk_bn254_artifacts(false)
};
sphinx_prover.verify_plonk_bn254(
&proof.proof,
Expand Down

0 comments on commit 1d9cc5b

Please sign in to comment.