Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: sdk v2 #1875

Merged
merged 61 commits into from
Dec 19, 2024
Merged
Changes from 1 commit
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
2b6bd90
Merge pull request #8 from succinctlabs/tamir/merge-upstream
tamirhemo Sep 5, 2024
f17c080
Merge remote-tracking branch 'upstream/dev' into dev
tamirhemo Sep 10, 2024
4b7b72e
Merge remote-tracking branch 'upstream/dev' into tqn/merge-upstream
tqn Sep 13, 2024
7ec9cd6
Merge pull request #15 from succinctlabs/tqn/merge-upstream
tqn Sep 13, 2024
35c1ee4
Merge remote-tracking branch 'origin/dev' into kevjue/merge_upstream
kevjue Sep 20, 2024
1728714
Merge pull request #18 from succinctlabs/kevjue/merge_upstream
kevjue Sep 20, 2024
35b8d99
Merge remote-tracking branch 'upstream/dev' into tqn/merge-upstream
tqn Oct 17, 2024
544d59b
Merge pull request #30 from succinctlabs/tqn/merge-upstream
tqn Oct 17, 2024
369e1c0
Merge remote-tracking branch 'upstream/dev' into tamir/dev-10-18
tamirhemo Oct 18, 2024
e0a7dec
Merge pull request #34 from succinctlabs/tamir/dev-10-18
tamirhemo Oct 18, 2024
05fc72f
Merge remote-tracking branch 'upstream/dev' into tamir/update-10-22
tamirhemo Oct 22, 2024
a8af928
Merge pull request #36 from succinctlabs/tamir/update-10-22
tamirhemo Oct 22, 2024
f41d750
Merge remote-tracking branch 'upstream/dev' into dev
jtguibas Oct 28, 2024
4870b74
Merge remote-tracking branch 'upstream/dev' into dev
jtguibas Oct 29, 2024
4451903
fix: remove stdin from SP1ProofWithPublicValues (#1714)
jtguibas Oct 30, 2024
e6e8bce
Merge remote-tracking branch 'upstream/dev' into erabinov/merge-upstream
erabinov Nov 3, 2024
474bbe2
Merge pull request #54 from succinctlabs/erabinov/merge-upstream
erabinov Nov 4, 2024
41f7fe1
Merge remote-tracking branch 'upstream/dev' into tamir/update-nov-5
tamirhemo Nov 5, 2024
5253c03
Merge pull request #58 from succinctlabs/tamir/update-nov-5
tamirhemo Nov 5, 2024
8a696d2
Merge remote-tracking branch 'upstream/dev' into dev
tamirhemo Nov 5, 2024
6af5b1d
Merge remote-tracking branch 'upstream/dev' into dev
tamirhemo Nov 5, 2024
31147b4
perf: remove proving single proofs (#60)
erabinov Nov 7, 2024
fbceea5
Merge remote-tracking branch 'upstream/dev' into tamir/update
tamirhemo Nov 7, 2024
df14c7f
feat: verifier crate (#1765)
yuwen01 Nov 7, 2024
41532ee
feat: fix for verifier crate (#1767)
yuwen01 Nov 7, 2024
3bbf4cf
fix: ecdsa recovery failure may cause executor to panic (#1799)
nhtyy Nov 19, 2024
a2402fb
chore: bump secp256k1 patch (#1826)
nhtyy Nov 27, 2024
563ede1
fix: add hook for ed decompress (#1829)
nhtyy Nov 29, 2024
7406fb4
fix: examples patch, book clean up (#1832)
nhtyy Nov 30, 2024
3917e90
chore(docs) migrate to docusaurus
nhtyy Dec 4, 2024
f1628aa
Revert "chore(docs) migrate to docusaurus"
nhtyy Dec 4, 2024
3a776e5
ProverClient builder tweaks, compiles
ctian1 Dec 17, 2024
f51bf5e
network builders
ctian1 Dec 17, 2024
3f7acbc
SimpleProver
ctian1 Dec 17, 2024
2d8e6c1
move mock into cpu prover
ctian1 Dec 17, 2024
92e5b0c
remove ProverClient::builder
ctian1 Dec 18, 2024
7df7f1d
cleanup
ctian1 Dec 18, 2024
6bee152
clippy
ctian1 Dec 18, 2024
ddc6b59
remove
ctian1 Dec 18, 2024
163fe05
ProverClient::new -> ProverClient::env
ctian1 Dec 18, 2024
a45905b
sdk improvements
jtguibas Dec 19, 2024
e7b5dd1
more cleanup
jtguibas Dec 19, 2024
a681a83
more cleanup
jtguibas Dec 19, 2024
fa11222
fix failing test
jtguibas Dec 19, 2024
4df9b22
Merge branch 'dev' into chris/sdk-changes-3
jtguibas Dec 19, 2024
4681d4f
Merge branch 'dev' of https://github.com/succinctlabs/sp1 into dev
jtguibas Dec 19, 2024
0db7412
fix proof types
jtguibas Dec 19, 2024
780546e
merge main into dev
jtguibas Dec 19, 2024
8ed3154
prove
jtguibas Dec 19, 2024
4d4025f
cargo fmt
jtguibas Dec 19, 2024
c3ecc72
cargo
jtguibas Dec 19, 2024
7aab122
from env
jtguibas Dec 19, 2024
6b68a6b
fix examples
jtguibas Dec 19, 2024
922c592
hook
jtguibas Dec 19, 2024
e0a83b3
updated builder interface
jtguibas Dec 19, 2024
6be4185
more cleanup
jtguibas Dec 19, 2024
2da1459
fix fmt
jtguibas Dec 19, 2024
5e9d620
c++ ignore
jtguibas Dec 19, 2024
edc28ec
cargo clippy shenanigans
jtguibas Dec 19, 2024
d38a21f
doc comments
jtguibas Dec 19, 2024
5096034
stdin
jtguibas Dec 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
more cleanup
jtguibas committed Dec 19, 2024
commit a681a830347608ccb79fb0cfde5446ffc736c369
2 changes: 1 addition & 1 deletion crates/sdk/src/cpu/execute.rs
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ use sp1_prover::{components::CpuProverComponents, SP1Prover};
/// A builder for simulating the execution of a program on the CPU.
///
/// This builder providers a typed interface for configuring the SP1 RISC-V executor. The builder
/// is used for both the [crate::cpu::CpuProver] and [crate::CudaProver] client types.
/// is used for all the different variants of the [crate::ProverClient].
pub struct CpuExecuteBuilder<'a> {
pub(crate) elf: &'a [u8],
pub(crate) stdin: SP1Stdin,
1 change: 1 addition & 0 deletions crates/sdk/src/cpu/mod.rs
Original file line number Diff line number Diff line change
@@ -91,6 +91,7 @@ impl CpuProver {
context_builder: SP1ContextBuilder::default(),
core_opts: SP1CoreOpts::default(),
recursion_opts: SP1CoreOpts::recursion(),
mock: self.mock,
}
}

10 changes: 8 additions & 2 deletions crates/sdk/src/cpu/prove.rs
Original file line number Diff line number Diff line change
@@ -23,6 +23,7 @@ pub struct CpuProveBuilder<'a> {
pub(crate) stdin: SP1Stdin,
pub(crate) core_opts: SP1CoreOpts,
pub(crate) recursion_opts: SP1CoreOpts,
pub(crate) mock: bool,
}

impl<'a> CpuProveBuilder<'a> {
@@ -208,14 +209,19 @@ impl<'a> CpuProveBuilder<'a> {
/// ```
pub fn run(self) -> Result<SP1ProofWithPublicValues> {
// Get the arguments.
let Self { prover, mode, pk, stdin, mut context_builder, core_opts, recursion_opts } = self;
let Self { prover, mode, pk, stdin, mut context_builder, core_opts, recursion_opts, mock } =
self;
let opts = SP1ProverOpts { core_opts, recursion_opts };
let context = context_builder.build();

// Dump the program and stdin to files for debugging if `SP1_DUMP` is set.
crate::utils::sp1_dump(&pk.elf, &stdin);

// Run the prover.
prover.prove_impl(pk, &stdin, opts, context, mode)
if !mock {
prover.prove_impl(pk, &stdin, opts, context, mode)
} else {
prover.mock_prove_impl(pk, stdin, mode)
}
}
}
2 changes: 1 addition & 1 deletion crates/sdk/src/install.rs
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ use std::path::PathBuf;

#[cfg(any(feature = "network", feature = "network"))]
use {
crate::block_on,
crate::utils::block_on,
futures::StreamExt,
indicatif::{ProgressBar, ProgressStyle},
reqwest::Client,
4 changes: 2 additions & 2 deletions crates/sdk/src/lib.rs
Original file line number Diff line number Diff line change
@@ -34,7 +34,7 @@ pub mod install;
pub mod network;
pub mod proof;
pub mod prover;
pub(crate) mod utils;
pub mod utils;

// Re-export the client.
pub use crate::client::ProverClient;
@@ -65,7 +65,7 @@ pub use sp1_prover::{
};

// Re-export the utilities.
pub use utils::{block_on, setup_logger};
pub use utils::setup_logger;

#[cfg(test)]
mod tests {
6 changes: 3 additions & 3 deletions crates/sdk/src/network/builder.rs
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ impl NetworkProverBuilder {
///
/// # Details
/// Sets the private key that will be used sign requests sent to the network. By default, the
/// private key is read from the `SUCCINCT_PRIVATE_KEY` environment variable.
/// private key is read from the `NETWORK_PRIVATE_KEY` environment variable.
///
/// # Example
/// ```rust,no_run
@@ -34,7 +34,7 @@ impl NetworkProverBuilder {
///
/// # Details
/// The URL determintes the network that the client will connect to. By default, the URL is
/// read from the `SUCCINCT_RPC_URL` environment variable.
/// read from the `NETWORK_RPC_URL` environment variable.
///
/// # Example
/// ```rust,no_run
@@ -51,7 +51,7 @@ impl NetworkProverBuilder {
///
/// # Details
/// This method will build a [NetworkProver] with the given parameters. If the private key is
/// not provided, the method will look for the `SP1_PRIVATE_KEY` environment variable.
/// not provided, the method will look for the `NETWORK_PRIVATE_KEY` environment variable.
///
/// # Example
/// ```rust,no_run
24 changes: 21 additions & 3 deletions crates/sdk/src/network/prove.rs
Original file line number Diff line number Diff line change
@@ -8,7 +8,9 @@ use anyhow::Result;
use sp1_core_machine::io::SP1Stdin;
use sp1_prover::SP1ProvingKey;

use crate::{block_on, utils::sp1_dump, NetworkProver, SP1ProofMode, SP1ProofWithPublicValues};
use crate::{
utils::block_on, utils::sp1_dump, NetworkProver, SP1ProofMode, SP1ProofWithPublicValues,
};

use super::proto::network::FulfillmentStrategy;

@@ -184,7 +186,15 @@ impl<'a> NetworkProveBuilder<'a> {
/// .unwrap();
/// ```
pub fn run(self) -> Result<SP1ProofWithPublicValues> {
let Self { prover, mode, pk, stdin, timeout, strategy, skip_simulation } = self;
let Self { prover, mode, pk, stdin, timeout, strategy, mut skip_simulation } = self;

// Check for deprecated environment variable
if let Ok(val) = std::env::var("SKIP_SIMULATION") {
eprintln!(
"Warning: SKIP_SIMULATION environment variable is deprecated. Please use .skip_simulation() instead."
);
skip_simulation = matches!(val.to_lowercase().as_str(), "true" | "1");
}

sp1_dump(&pk.elf, &stdin);

@@ -205,7 +215,15 @@ impl<'a> NetworkProveBuilder<'a> {
/// .unwrap();
/// ```
pub async fn run_async(self) -> Result<SP1ProofWithPublicValues> {
let Self { prover, mode, pk, stdin, timeout, strategy, skip_simulation } = self;
let Self { prover, mode, pk, stdin, timeout, strategy, mut skip_simulation } = self;

// Check for deprecated environment variable
if let Ok(val) = std::env::var("SKIP_SIMULATION") {
eprintln!(
"Warning: SKIP_SIMULATION environment variable is deprecated. Please use .skip_simulation() instead."
);
skip_simulation = matches!(val.to_lowercase().as_str(), "true" | "1");
}

sp1_dump(&pk.elf, &stdin);

2 changes: 1 addition & 1 deletion crates/sdk/src/network/prover.rs
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@ use sp1_core_machine::io::SP1Stdin;
use sp1_prover::{components::CpuProverComponents, SP1Prover, SP1_CIRCUIT_VERSION};
use tonic::Code;

use {crate::block_on, tokio::time::sleep};
use {crate::utils::block_on, tokio::time::sleep};

/// An implementation of [crate::ProverClient] that can generate proofs on a remote RPC server.
pub struct NetworkProver {
4 changes: 2 additions & 2 deletions crates/sdk/src/utils.rs
Original file line number Diff line number Diff line change
@@ -18,8 +18,8 @@ pub(crate) fn sp1_dump(elf: &[u8], stdin: &SP1Stdin) {
///
/// If we're already in a tokio runtime, we'll block in place. Otherwise, we'll create a new
/// runtime.
#[cfg(any(feature = "network", feature = "network"))]
pub fn block_on<T>(fut: impl std::future::Future<Output = T>) -> T {
#[cfg(feature = "network")]
pub(crate) fn block_on<T>(fut: impl std::future::Future<Output = T>) -> T {
use tokio::task::block_in_place;

// Handle case if we're already in an tokio runtime.