diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml index cf2e8cb4b2..d291ab46ad 100644 --- a/crates/cli/Cargo.toml +++ b/crates/cli/Cargo.toml @@ -43,4 +43,4 @@ regex = "1.5.4" prettytable-rs = "0.10" textwrap = "0.16.0" ctrlc = "3.4.2" -cargo_metadata = "0.18.1" \ No newline at end of file +cargo_metadata = "0.18.1" diff --git a/crates/cli/src/commands/vkey.rs b/crates/cli/src/commands/vkey.rs index 734b470970..19a31c53d4 100644 --- a/crates/cli/src/commands/vkey.rs +++ b/crates/cli/src/commands/vkey.rs @@ -4,6 +4,8 @@ use anyhow::Result; use clap::{Args, Parser}; use sp1_build::{generate_elf_paths, BuildArgs}; use sp1_sdk::{HashableKey, ProverClient}; +use std::sync::Arc; +use tokio::runtime::Runtime; #[derive(Parser)] #[command(name = "vkey", about = "View the verification key hash for a program.")] @@ -41,6 +43,8 @@ impl VkeyCmd { unreachable!() }; + let rt = Runtime::new()?; + for (target, elf_path) in elf_paths { // Read the elf file contents let mut file = File::open(elf_path)?; @@ -49,13 +53,13 @@ impl VkeyCmd { // Get the verification key let prover = ProverClient::new(); - let (_, vk) = prover.setup(&elf); + let pk = rt.block_on(prover.setup(Arc::from(&elf[..]))); // Print the verification key hash if let Some(target) = target { - println!("Verification Key Hash for '{target}':\n{}", vk.vk.bytes32()); + println!("Verification Key Hash for '{target}':\n{}", pk.vk.bytes32()); } else { - println!("Verification Key Hash:\n{}", vk.vk.bytes32()); + println!("Verification Key Hash:\n{}", pk.vk.bytes32()); } } diff --git a/crates/perf/src/main.rs b/crates/perf/src/main.rs index 31a34c52ed..09affc6e6e 100644 --- a/crates/perf/src/main.rs +++ b/crates/perf/src/main.rs @@ -182,7 +182,7 @@ fn main() { let skip_simulation = env::var("SKIP_SIMULATION").map(|val| val == "true").unwrap_or_default(); - let mut prover_builder = ProverClient::builder().mode(ProverMode::Network); + let mut prover_builder = ProverClient::builder().network(); if let Some(rpc_url) = rpc_url { prover_builder = prover_builder.rpc_url(rpc_url); diff --git a/crates/sdk/src/lib.rs b/crates/sdk/src/lib.rs index ae594e7cd8..c0cd911bf3 100644 --- a/crates/sdk/src/lib.rs +++ b/crates/sdk/src/lib.rs @@ -5,7 +5,7 @@ //! Visit the [Getting Started](https://succinctlabs.github.io/sp1/getting-started.html) section //! in the official SP1 documentation for a quick start guide. -pub mod client; +mod client; mod mode; mod opts; mod prover; @@ -18,15 +18,22 @@ pub mod install; #[path = "network-v2/mod.rs"] pub mod network_v2; -pub mod local; +#[cfg(feature = "cuda")] +pub use crate::local::CudaProver; +#[cfg(feature = "network-v2")] +pub use crate::network_v2::NetworkProver; +pub mod local; pub mod proof; pub mod utils { pub use sp1_core_machine::utils::setup_logger; } -#[cfg(any(feature = "network", feature = "network-v2"))] -use std::future::Future; +pub use client::*; +pub use local::SP1VerificationError; +pub use proof::*; + +// pub use local::{LocalProver, MockProver, Prover}; pub use sp1_build::include_elf; pub use sp1_core_executor::{ExecutionReport, HookEnv, SP1Context, SP1ContextBuilder}; diff --git a/crates/sdk/src/local/mock.rs b/crates/sdk/src/local/mock.rs index 3cf4357df7..152eda4e7f 100644 --- a/crates/sdk/src/local/mock.rs +++ b/crates/sdk/src/local/mock.rs @@ -1,24 +1,9 @@ #![allow(unused_variables)] -use hashbrown::HashMap; -use sp1_core_executor::{SP1Context, SP1ReduceProof}; -use sp1_core_machine::io::SP1Stdin; -use sp1_stark::{ShardCommitment, ShardOpenedValues, ShardProof, StarkVerifyingKey}; - -use sp1_prover::SP1Proof; - -use anyhow::Result; -use p3_baby_bear::BabyBear; -use p3_field::{AbstractField, PrimeField}; -use p3_fri::{FriProof, TwoAdicFriPcsProof}; -use sp1_prover::{ - components::DefaultProverComponents, - verify::{verify_groth16_bn254_public_inputs, verify_plonk_bn254_public_inputs}, - Groth16Bn254Proof, HashableKey, PlonkBn254Proof, SP1Prover, SP1ProvingKey, SP1VerifyingKey, -}; - -use super::{ProofOpts, ProverType}; - -use crate::{local::SP1VerificationError, proof::SP1ProofWithPublicValues, prover::Prover}; + + +use sp1_prover::SP1Prover; + + /// An implementation of [crate::ProverClient] that can generate mock proofs. pub struct MockProver { diff --git a/crates/sdk/src/local/mod.rs b/crates/sdk/src/local/mod.rs index e7d1d900d1..27655cf429 100644 --- a/crates/sdk/src/local/mod.rs +++ b/crates/sdk/src/local/mod.rs @@ -8,24 +8,14 @@ pub use cuda::CudaProver; pub use prover::*; -use itertools::Itertools; -use p3_field::PrimeField32; -use std::borrow::Borrow; -use anyhow::Result; -use sp1_core_executor::SP1Context; -use sp1_core_machine::{io::SP1Stdin, SP1_CIRCUIT_VERSION}; use sp1_prover::{ - components::SP1ProverComponents, CoreSC, InnerSC, SP1CoreProofData, SP1Prover, SP1ProvingKey, - SP1VerifyingKey, + CoreSC, InnerSC, }; -use sp1_stark::{air::PublicValues, MachineVerificationError, Word}; +use sp1_stark::MachineVerificationError; use strum_macros::EnumString; use thiserror::Error; -use crate::install::try_install_circuit_artifacts; -use crate::opts::ProofOpts; -use crate::{proof::SP1Proof, proof::SP1ProofKind, proof::SP1ProofWithPublicValues}; /// The type of prover. #[derive(Debug, PartialEq, EnumString)] diff --git a/crates/sdk/src/mode.rs b/crates/sdk/src/mode.rs index c1f99cb688..7eb0fad5b7 100644 --- a/crates/sdk/src/mode.rs +++ b/crates/sdk/src/mode.rs @@ -1,4 +1,3 @@ -use crate::proof::SP1ProofKind; use crate::network_v2::ProofMode; diff --git a/crates/sdk/src/network-v2/mod.rs b/crates/sdk/src/network-v2/mod.rs index 8486d91090..71a1b7c068 100644 --- a/crates/sdk/src/network-v2/mod.rs +++ b/crates/sdk/src/network-v2/mod.rs @@ -4,6 +4,7 @@ mod prover; mod retry; mod types; #[rustfmt::skip] +#[allow(clippy::all)] mod proto; pub use client::*; diff --git a/crates/sdk/src/verify.rs b/crates/sdk/src/verify.rs index 8bcdbe338e..8d333bad74 100644 --- a/crates/sdk/src/verify.rs +++ b/crates/sdk/src/verify.rs @@ -4,20 +4,13 @@ use sp1_prover::components::DefaultProverComponents; use std::borrow::Borrow; use anyhow::Result; -use sp1_core_executor::SP1Context; -use sp1_core_machine::{io::SP1Stdin, SP1_CIRCUIT_VERSION}; -use sp1_prover::{ - components::SP1ProverComponents, CoreSC, InnerSC, SP1CoreProofData, SP1Prover, SP1ProvingKey, - SP1VerifyingKey, -}; -use sp1_stark::{air::PublicValues, MachineVerificationError, Word}; -use strum_macros::EnumString; -use thiserror::Error; +use sp1_prover::{SP1CoreProofData, SP1Prover, SP1VerifyingKey}; +use sp1_stark::{air::PublicValues, Word}; use crate::install::try_install_circuit_artifacts; use crate::local::SP1VerificationError; use crate::opts::ProofOpts; -use crate::{proof::SP1Proof, proof::SP1ProofKind, proof::SP1ProofWithPublicValues}; +use crate::{proof::SP1Proof, proof::SP1ProofWithPublicValues}; /// Verify that an SP1 proof is valid given its vkey and metadata. /// For Plonk proofs, verifies that the public inputs of the PlonkBn254 proof match diff --git a/examples/fibonacci/script/bin/network.rs b/examples/fibonacci/script/bin/network.rs index bc2f70446b..e018919ad0 100644 --- a/examples/fibonacci/script/bin/network.rs +++ b/examples/fibonacci/script/bin/network.rs @@ -1,5 +1,5 @@ use sp1_sdk::network_v2::{Error, FulfillmentStrategy}; -use sp1_sdk::{include_elf, utils, client::ProverClient, proof::SP1ProofWithPublicValues, SP1Stdin}; +use sp1_sdk::{include_elf, utils, ProverClient, proof::SP1ProofWithPublicValues, SP1Stdin}; use std::time::Duration; use dotenv::dotenv; @@ -37,11 +37,11 @@ async fn main() { // let client = ProverClient::new(); // Generate the proof, using the specified network configuration. - // let client = ProverClient::builder() - // .network() - // .with_rpc_url(rpc_url) - // .with_private_key(private_key) - // .build(); + let client = ProverClient::builder() + .network() + .with_rpc_url(rpc_url) + .with_private_key(private_key) + .build(); // Generate the proving key and verifying key for the given program. let pk = client.setup(Arc::from(&ELF[..])).await; @@ -52,6 +52,8 @@ async fn main() { .compressed() .await; + let prover = NetworkProver::with + // Example of handling potential errors. let mut proof = match proof_result { Ok(proof) => proof,