diff --git a/crates/cli/src/commands/vkey.rs b/crates/cli/src/commands/vkey.rs index 19a31c53d..e18e07357 100644 --- a/crates/cli/src/commands/vkey.rs +++ b/crates/cli/src/commands/vkey.rs @@ -52,7 +52,7 @@ impl VkeyCmd { file.read_to_end(&mut elf)?; // Get the verification key - let prover = ProverClient::new(); + let prover = ProverClient::builder().local().build(); let pk = rt.block_on(prover.setup(Arc::from(&elf[..]))); // Print the verification key hash diff --git a/crates/perf/Cargo.toml b/crates/perf/Cargo.toml index 38300783f..25b9e16fa 100644 --- a/crates/perf/Cargo.toml +++ b/crates/perf/Cargo.toml @@ -12,7 +12,7 @@ categories = { workspace = true } [dependencies] sp1-prover = { workspace = true } sp1-core-executor = { workspace = true, features = ["programs"] } -sp1-sdk = { workspace = true } +sp1-sdk = { workspace = true, features = ["blocking"] } p3-baby-bear = { workspace = true } sp1-stark = { workspace = true } sp1-cuda = { workspace = true } diff --git a/crates/perf/src/main.rs b/crates/perf/src/main.rs index 09affc6e6..499736dc1 100644 --- a/crates/perf/src/main.rs +++ b/crates/perf/src/main.rs @@ -1,5 +1,6 @@ use std::{ env, + sync::Arc, time::{Duration, Instant}, }; @@ -179,8 +180,6 @@ fn main() { let private_key = env::var("SP1_PRIVATE_KEY") .expect("SP1_PRIVATE_KEY must be set for remote proving"); let rpc_url = env::var("PROVER_NETWORK_RPC").ok(); - let skip_simulation = - env::var("SKIP_SIMULATION").map(|val| val == "true").unwrap_or_default(); let mut prover_builder = ProverClient::builder().network(); @@ -188,21 +187,22 @@ fn main() { prover_builder = prover_builder.rpc_url(rpc_url); } - if skip_simulation { - prover_builder = prover_builder.skip_simulation(); - } + let pk = Arc::new(pk); + let vk = Arc::new(vk); let prover = prover_builder.private_key(private_key).build(); - let (_, _) = time_operation(|| prover.execute(&elf, stdin.clone())); + let (_, _) = time_operation(|| prover.execute(Arc::from(&elf[..]), stdin.clone())); let (proof, _) = time_operation(|| prover.prove(&pk, stdin.clone()).groth16().run().unwrap()); + let proof = Arc::new(proof); - let (_, _) = time_operation(|| prover.verify(&proof, &vk)); + let (_, _) = time_operation(|| prover.verify(proof, vk.clone())); let (proof, _) = time_operation(|| prover.prove(&pk, stdin).plonk().run().unwrap()); + let proof = Arc::new(proof); - let (_, _) = time_operation(|| prover.verify(&proof, &vk)); + let (_, _) = time_operation(|| prover.verify(proof, vk)); } ProverMode::Mock => unreachable!(), }; diff --git a/crates/sdk/src/client.rs b/crates/sdk/src/client.rs index 27b9fe673..ef8ccaf99 100644 --- a/crates/sdk/src/client.rs +++ b/crates/sdk/src/client.rs @@ -25,6 +25,7 @@ pub struct ProverClient { inner: Box, } +#[allow(clippy::new_without_default)] impl ProverClient { pub fn builder() -> ProverClientBuilder { ProverClientBuilder::new() diff --git a/crates/sdk/src/client/request.rs b/crates/sdk/src/client/request.rs index fdb221b46..d820949e6 100644 --- a/crates/sdk/src/client/request.rs +++ b/crates/sdk/src/client/request.rs @@ -1,17 +1,13 @@ -use crate::{ - proof::SP1ProofWithPublicValues, - prover::Prover, -}; - +use crate::{proof::SP1ProofWithPublicValues, prover::Prover}; +use crate::Mode; +use crate::ProofOpts; use anyhow::Result; use sp1_core_machine::io::SP1Stdin; use sp1_prover::SP1ProvingKey; -use std::sync::Arc; -use crate::Mode; -use crate::ProofOpts; use std::future::{Future, IntoFuture}; use std::pin::Pin; +use std::sync::Arc; pub struct DynProofRequest<'a> { prover: &'a dyn Prover, @@ -74,4 +70,3 @@ impl<'a> IntoFuture for DynProofRequest<'a> { self.prover.prove_with_options(self.pk, self.stdin, self.opts) } } - diff --git a/crates/sdk/src/lib.rs b/crates/sdk/src/lib.rs index 9f5ccbba9..5691eea54 100644 --- a/crates/sdk/src/lib.rs +++ b/crates/sdk/src/lib.rs @@ -41,14 +41,14 @@ pub use crate::network_v2::NetworkProver; #[cfg(feature = "network-v2")] #[path = "network-v2/mod.rs"] -pub mod network_v2;/// The default timeout seconds for a proof request to be generated (4 hours). +pub mod network_v2; +/// The default timeout seconds for a proof request to be generated (4 hours). /// pub const DEFAULT_TIMEOUT: u64 = 14400; /// The default cycle limit for a proof request. pub const DEFAULT_CYCLE_LIMIT: u64 = 100_000_000; - pub struct ProofOpts { pub mode: Mode, pub timeout: u64, diff --git a/crates/sdk/src/local/mock.rs b/crates/sdk/src/local/mock.rs index 026403ec3..d048e1668 100644 --- a/crates/sdk/src/local/mock.rs +++ b/crates/sdk/src/local/mock.rs @@ -1,6 +1,5 @@ #![allow(unused_variables)] - // /// An implementation of [crate::ProverClient] that can generate mock proofs. // pub struct MockProver { // pub(crate) prover: SP1Prover, diff --git a/crates/sdk/src/prover.rs b/crates/sdk/src/prover.rs index beb9c80ba..553cb1000 100644 --- a/crates/sdk/src/prover.rs +++ b/crates/sdk/src/prover.rs @@ -7,7 +7,7 @@ use sp1_core_machine::io::SP1Stdin; use sp1_primitives::io::SP1PublicValues; use sp1_prover::{SP1ProvingKey, SP1VerifyingKey}; -use crate::{ProofOpts, proof::SP1ProofWithPublicValues, SP1VerificationError}; +use crate::{proof::SP1ProofWithPublicValues, ProofOpts, SP1VerificationError}; #[async_trait] pub trait Prover: Sync { diff --git a/examples/fibonacci/script/bin/network.rs b/examples/fibonacci/script/bin/network.rs index 6570bf6b3..8f02391c0 100644 --- a/examples/fibonacci/script/bin/network.rs +++ b/examples/fibonacci/script/bin/network.rs @@ -27,15 +27,9 @@ async fn main() { let private_key = std::env::var("SP1_PRIVATE_KEY").unwrap(); - // let client = ProverClient::builder().local().build(); - - // Or use old env var behavior - let client = ProverClient::builder() .from_env(); - // let client = ProverClient::new(); - // Generate the proof, using the specified network configuration. let client = ProverClient::builder() .network() @@ -50,10 +44,10 @@ async fn main() { let proof_result = client .prove(&pk, stdin) .compressed() - .timeout(10000) + .timeout(10) + .cycle_limit(20_000) .await; - // Example of handling potential errors. let mut proof = match proof_result { Ok(proof) => proof,