Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mattstam committed Dec 12, 2024
1 parent 2a02aff commit 9ecb9ce
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 58 deletions.
2 changes: 1 addition & 1 deletion crates/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
cargo_metadata = "0.18.1"
10 changes: 7 additions & 3 deletions crates/cli/src/commands/vkey.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.")]
Expand Down Expand Up @@ -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)?;
Expand All @@ -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());
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/perf/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
15 changes: 11 additions & 4 deletions crates/sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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};
Expand Down
25 changes: 5 additions & 20 deletions crates/sdk/src/local/mock.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
14 changes: 2 additions & 12 deletions crates/sdk/src/local/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
1 change: 0 additions & 1 deletion crates/sdk/src/mode.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use crate::proof::SP1ProofKind;

use crate::network_v2::ProofMode;

Expand Down
1 change: 1 addition & 0 deletions crates/sdk/src/network-v2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ mod prover;
mod retry;
mod types;
#[rustfmt::skip]
#[allow(clippy::all)]
mod proto;

pub use client::*;
Expand Down
13 changes: 3 additions & 10 deletions crates/sdk/src/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 8 additions & 6 deletions examples/fibonacci/script/bin/network.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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;
Expand All @@ -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,
Expand Down

0 comments on commit 9ecb9ce

Please sign in to comment.