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

fix(sp1-build): default docker tag #1693

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
719 changes: 31 additions & 688 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions SP1_VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v3.0.0
99 changes: 62 additions & 37 deletions book/developers/common-issues.md
Original file line number Diff line number Diff line change
@@ -1,46 +1,28 @@
# Common Issues

## Bus Error

If you are running a executable that uses the `sp1-sdk` crate, you may encounter a bus error like this:

```txt
zsh: bus error
```

This is fixed by running with the `--release` flag, as the `sp1-sdk` crate only supports release builds as of right now.

## Alloy Errors
## Rust Version Errors

If you are using a library that depends on `alloy_sol_types`, and encounter an error like this:
If you are using a library that has an MSRV specified, you may encounter an error like this when building your program.

```txt
perhaps two different versions of crate `alloy_sol_types` are being used?
```

This is likely due to two different versions of `alloy_sol_types` being used. To fix this, you can set `default-features` to `false` for the `sp1-sdk` dependency in your `Cargo.toml`.

```toml
[dependencies]
sp1-sdk = { version = "2.0.0", default-features = false }
package `alloy v0.1.1 cannot be built because it requires rustc 1.76 or newer, while the currently active rustc version is 1.75.0-nightly`
```

This will configure out the `network` feature which will remove the dependency on `alloy_sol_types` and configure out the `NetworkProver`.

## Rust Version Errors
This is due to the fact that your current Succinct Rust toolchain has been built with a lower version than the MSRV of the crates you are using.

If you are using a library that has an MSRV (minimum supported rust version) of 1.76.0
or higher, you may encounter an error like this when building your program.
You can check the version of your local Succinct Rust toolchain by running `cargo +succinct --version`. The latest release of the Succinct Rust toolchain is **1.81**. You can update to the latest version by running [`sp1up`](../getting-started/install.md).

```txt
package `alloy v0.1.1 cannot be built because it requires rustc 1.76 or newer, while the currently active rustc version is 1.75.0-nightly`
```shell
% sp1up
% cargo +succinct --version
cargo 1.81.0-dev (2dbb1af80 2024-08-20)
```

This is due to the fact that the Succinct Rust toolchain might be built with a lower version than the MSRV of the crates you are using. You can check the version of the Succinct Rust toolchain by running `cargo +succinct --version`. The Succinct Rust toolchain's latest version is 1.79, and you can update to the latest version by running [`sp1up`](../getting-started/install.md).
A Succinct Rust toolchain with version **1.81** should work for all crates that have an MSRV of **1.81** or lower.

If that doesn't work (i.e. the MSRV of the crates you are using is still higher than the version of the Succinct Rust toolchain), you can try the following:
If the MSRV of your crate is higher than **1.81**, try the following:

- If you're using `cargo prove build` directly, pass the `--ignore-rust-version` flag:
- If using `cargo prove build` directly, pass the `--ignore-rust-version` flag:

```bash
cargo prove build --ignore-rust-version
Expand All @@ -57,22 +39,41 @@ If that doesn't work (i.e. the MSRV of the crates you are using is still higher
build_program_with_args("path/to/program", args);
```

## Stack Overflow Errors
## `alloy_sol_types` Errors

If you encounter the following in a script using `sp1-sdk`:
If you are using a library that depends on `alloy_sol_types`, and encounter an error like this:

```txt
perhaps two different versions of crate `alloy_sol_types` are being used?
```

This is likely due to two different versions of `alloy_sol_types` being used. To fix this, you can set `default-features` to `false` for the `sp1-sdk` dependency in your `Cargo.toml`.

```toml
[dependencies]
sp1-sdk = { version = "3.0.0", default-features = false }
```

This will configure out the `network` feature which will remove the dependency on `alloy_sol_types` and configure out the `NetworkProver`.

## Stack Overflow Errors + Bus Errors

If you encounter any of the following errors in a script using `sp1-sdk`:

```shell
# Stack Overflow Error
thread 'main' has overflowed its stack
fatal runtime error: stack overflow
```

```txt
# Bus Error
zsh: bus error

# Segmentation Fault
Segmentation fault (core dumped)
```

Re-run your script with `--release`.

Note that the core `sp1-core` library and `sp1-recursion` require being compiled with the `release` profile.
Run your script with the `--release` flag. SP1 currently only supports release builds. This is because
the `sp1-core` library and `sp1-recursion` require being compiled with the `release` profile.

## C Binding Errors

Expand Down Expand Up @@ -120,3 +121,27 @@ To resolve this, ensure that you're importing both `sp1-lib` and `sp1-zkvm` with
sp1-lib = { version = "<VERSION>", features = ["verify"] }
sp1-zkvm = { version = "<VERSION>", features = ["verify"] }
```

## `sp1-sdk` `rc` Version Semver Errors

When using release candidate (RC) versions of `sp1-sdk` (such as `3.0.0-rc1`), you might face compilation errors if you upgrade to a newer RC version (like `3.0.0-rc4`) and then try to downgrade back to an earlier RC version (such as `3.0.0-rc1`).

This issue arises because some RC releases introduce breaking changes that aren't reflected in their version numbers according to Semantic Versioning (SemVer) rules. To fix this, you need to explicitly downgrade all related crates in your `Cargo.lock` file to match the desired RC version.

To start, verify that the `sp1-sdk` version in your `Cargo.lock` file differs from the version specified in your `Cargo.toml` file:

```shell
% cargo tree -i sp1-sdk
sp1-sdk v3.0.0-rc4 (/Users/sp1/crates/sdk)
├── sp1-cli v3.0.0-rc4 (/Users/sp1/crates/cli)
├── sp1-eval v3.0.0-rc4 (/Users/sp1/crates/eval)
└── sp1-perf v3.0.0-rc4 (/Users/sp1/crates/perf)
```

After confirming the version of `sp1-sdk` in your lockfile, you can downgrade to a specific RC version using the following command. Replace `3.0.0-rc1` with the desired version number:

```shell
% cargo update -p sp1-build -p sp1-sdk -p sp1-recursion-derive -p sp1-recursion-gnark-ffi -p sp1-zkvm --precise 3.0.0-rc1
```

This command will update the `Cargo.lock` file to specify the lower RC version, resolving any version conflicts and allowing you to continue development.
2 changes: 1 addition & 1 deletion book/generating-proofs/advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ RUSTFLAGS='-C target-cpu=native' cargo run --release
Currently there is support for AVX512 and NEON SIMD instructions. For NEON, you must also enable the `sp1-sdk` feature `neon` in your script crate's `Cargo.toml` file.

```toml
sp1-sdk = { version = "2.0.0", features = ["neon"] }
sp1-sdk = { version = "3.0.0", features = ["neon"] }
```

## Performance
Expand Down
4 changes: 2 additions & 2 deletions book/generating-proofs/prover-network/versions.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ You must switch to a supported version before submitting a proof. To do so, repl

```toml
[dependencies]
sp1-zkvm = "2.0.0"
sp1-zkvm = "3.0.0"
```

replace the `sp1-sdk` version in your script's `Cargo.toml`:

```toml
[dependencies]
sp1-sdk = "2.0.0"
sp1-sdk = "3.0.0"
```

Re-build your program and script, and then try again.
2 changes: 1 addition & 1 deletion book/generating-proofs/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ name = "script"
edition = "2021"

[dependencies]
sp1-sdk = "2.0.0"
sp1-sdk = "3.0.0"
```

The `sp1-sdk` crate includes the necessary utilities to generate, save, and verify proofs.
2 changes: 1 addition & 1 deletion book/onchain-verification/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ You can run the above script with `RUST_LOG=info cargo run --bin groth16_bn254 -
If you would like to run the Groth16 or PLONK prover directly without Docker, you must have Go 1.22 installed and enable the `native-gnark` feature in `sp1-sdk`. This path is not recommended and may require additional native dependencies.

```toml
sp1-sdk = { version = "2.0.0", features = ["native-gnark"] }
sp1-sdk = { version = "3.0.0", features = ["native-gnark"] }
```
2 changes: 1 addition & 1 deletion book/writing-programs/compiling.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ The path passed in to `build_program` should point to the directory containing t

```toml
[build-dependencies]
sp1-build = "2.0.0"
sp1-build = "3.0.0"
```

You will see output like the following from the build script if the program has changed, indicating that the program was rebuilt:
Expand Down
2 changes: 1 addition & 1 deletion book/writing-programs/cycle-tracking.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Note that to use the macro, you must add the `sp1-derive` crate to your dependen

```toml
[dependencies]
sp1-derive = "2.0.0"
sp1-derive = "3.0.0"
```

In the script for proof generation, setup the logger with `utils::setup_logger()` and run the script with `RUST_LOG=info cargo run --release`. You should see the following output:
Expand Down
2 changes: 1 addition & 1 deletion book/writing-programs/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ name = "program"
edition = "2021"

[dependencies]
sp1-zkvm = "2.0.0"
sp1-zkvm = "3.0.0"
```

The `sp1-zkvm` crate includes necessary utilities for your program, including handling inputs and outputs,
Expand Down
6 changes: 3 additions & 3 deletions crates/build/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ pub use build::execute_build_program;

use clap::Parser;

const SP1_CIRCUIT_VERSION: &str = include_str!("../../../SP1_VERSION");
const BUILD_TARGET: &str = "riscv32im-succinct-zkvm-elf";
const DEFAULT_TAG: &str = "latest";
const DEFAULT_OUTPUT_DIR: &str = "elf";
const HELPER_TARGET_SUBDIR: &str = "elf-compilation";

Expand All @@ -27,7 +27,7 @@ pub struct BuildArgs {
#[clap(
long,
help = "The ghcr.io/succinctlabs/sp1 image tag to use when building with Docker.",
default_value = DEFAULT_TAG
default_value = SP1_CIRCUIT_VERSION
)]
pub tag: String,
#[clap(
Expand Down Expand Up @@ -75,7 +75,7 @@ impl Default for BuildArgs {
fn default() -> Self {
Self {
docker: false,
tag: DEFAULT_TAG.to_string(),
tag: SP1_CIRCUIT_VERSION.to_string(),
features: vec![],
rustflags: vec![],
ignore_rust_version: false,
Expand Down
7 changes: 0 additions & 7 deletions crates/core/machine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,6 @@ pub mod riscv;
pub mod syscall;
pub mod utils;

/// The global version for all components of SP1.
///
/// This string should be updated whenever any step in verifying an SP1 proof changes, including
/// core, recursion, and plonk-bn254. This string is used to download SP1 artifacts and the gnark
/// docker image.
pub const SP1_CIRCUIT_VERSION: &str = "v3.0.0";

// Re-export the `SP1ReduceProof` struct from sp1_core_machine.
//
// This is done to avoid a circular dependency between sp1_core_machine and sp1_core_executor, and
Expand Down
7 changes: 6 additions & 1 deletion crates/prover/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,12 @@

use components::{DefaultProverComponents, SP1ProverComponents};

pub use sp1_core_machine::SP1_CIRCUIT_VERSION;
/// The global version for all components of SP1.
///
/// This string should be updated whenever any step in verifying an SP1 proof changes, including
/// core, recursion, and plonk-bn254. This string is used to download SP1 artifacts and the gnark
/// docker image.
pub const SP1_CIRCUIT_VERSION: &str = include_str!("../../SP1_VERSION");

Check failure on line 94 in crates/prover/src/lib.rs

View workflow job for this annotation

GitHub Actions / Formatting & Clippy

couldn't read `crates/prover/src/../../SP1_VERSION`: No such file or directory (os error 2)

Check failure on line 94 in crates/prover/src/lib.rs

View workflow job for this annotation

GitHub Actions / Plonk Native

couldn't read `crates/prover/src/../../SP1_VERSION`: No such file or directory (os error 2)

Check failure on line 94 in crates/prover/src/lib.rs

View workflow job for this annotation

GitHub Actions / Plonk Docker

couldn't read `crates/prover/src/../../SP1_VERSION`: No such file or directory (os error 2)

Check failure on line 94 in crates/prover/src/lib.rs

View workflow job for this annotation

GitHub Actions / Test (ARM)

couldn't read `crates/prover/src/../../SP1_VERSION`: No such file or directory (os error 2)

/// The configuration for the core prover.
pub type CoreSC = BabyBearPoseidon2;
Expand Down
3 changes: 1 addition & 2 deletions crates/recursion/gnark-ffi/src/ffi/docker.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::ProofBn254;
use crate::{Groth16Bn254Proof, PlonkBn254Proof};
use crate::{Groth16Bn254Proof, PlonkBn254Proof, SP1_CIRCUIT_VERSION};
use anyhow::{anyhow, Result};
use sp1_core_machine::SP1_CIRCUIT_VERSION;
use std::{io::Write, process::Command};

/// Represents the proof system being used
Expand Down
3 changes: 1 addition & 2 deletions crates/recursion/gnark-ffi/src/ffi/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
//! Although we cast to *mut c_char because the Go signatures can't be immutable, the Go functions
//! should not modify the strings.

use crate::{Groth16Bn254Proof, PlonkBn254Proof};
use crate::{Groth16Bn254Proof, PlonkBn254Proof, SP1_CIRCUIT_VERSION};
use cfg_if::cfg_if;
use sp1_core_machine::SP1_CIRCUIT_VERSION;
use std::{
ffi::{c_char, CStr, CString},
mem::forget,
Expand Down
3 changes: 1 addition & 2 deletions crates/recursion/gnark-ffi/src/groth16_bn254.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ use std::{
use crate::{
ffi::{build_groth16_bn254, prove_groth16_bn254, test_groth16_bn254, verify_groth16_bn254},
witness::GnarkWitness,
Groth16Bn254Proof,
Groth16Bn254Proof, SP1_CIRCUIT_VERSION,
};

use num_bigint::BigUint;
use sha2::{Digest, Sha256};
use sp1_core_machine::SP1_CIRCUIT_VERSION;
use sp1_recursion_compiler::{
constraints::Constraint,
ir::{Config, Witness},
Expand Down
7 changes: 7 additions & 0 deletions crates/recursion/gnark-ffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,10 @@ pub use groth16_bn254::*;
pub use plonk_bn254::*;
pub use proof::*;
pub use witness::*;

/// The global version for all components of SP1.
///
/// This string should be updated whenever any step in verifying an SP1 proof changes, including
/// core, recursion, and plonk-bn254. This string is used to download SP1 artifacts and the gnark
/// docker image.
const SP1_CIRCUIT_VERSION: &str = include_str!("../../../../SP1_VERSION");
3 changes: 1 addition & 2 deletions crates/recursion/gnark-ffi/src/plonk_bn254.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ use std::{
use crate::{
ffi::{build_plonk_bn254, prove_plonk_bn254, test_plonk_bn254, verify_plonk_bn254},
witness::GnarkWitness,
PlonkBn254Proof,
PlonkBn254Proof, SP1_CIRCUIT_VERSION,
};

use num_bigint::BigUint;
use sha2::{Digest, Sha256};
use sp1_core_machine::SP1_CIRCUIT_VERSION;
use sp1_recursion_compiler::{
constraints::Constraint,
ir::{Config, Witness},
Expand Down
4 changes: 0 additions & 4 deletions crates/sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ tonic = { version = "0.12", features = ["tls", "tls-roots"], optional = true }
alloy-signer = { version = "0.3.6", optional = true }
alloy-signer-local = { version = "0.3.6", optional = true }
alloy-primitives = { version = "0.8.7", optional = true }
aws-sdk-s3 = { version = "1.53.0", optional = true }
aws-config = { version = "1.5.7", optional = true }

[features]
default = ["network"]
Expand Down Expand Up @@ -81,8 +79,6 @@ network-v2 = [
"dep:twirp",
"dep:reqwest-middleware",
"dep:tonic",
"dep:aws-sdk-s3",
"dep:aws-config",
]
cuda = ["sp1-cuda"]

Expand Down
4 changes: 2 additions & 2 deletions crates/sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ use {std::future::Future, tokio::task::block_in_place};
pub use provers::{CpuProver, MockProver, Prover};

pub use sp1_core_executor::{ExecutionReport, HookEnv, SP1Context, SP1ContextBuilder};
pub use sp1_core_machine::{io::SP1Stdin, riscv::cost::CostEstimator, SP1_CIRCUIT_VERSION};
pub use sp1_core_machine::{io::SP1Stdin, riscv::cost::CostEstimator};
pub use sp1_primitives::io::SP1PublicValues;
pub use sp1_prover::{
CoreSC, HashableKey, InnerSC, OuterSC, PlonkBn254Proof, SP1Prover, SP1ProvingKey,
SP1VerifyingKey,
SP1VerifyingKey, SP1_CIRCUIT_VERSION,
};

/// A client for interacting with SP1.
Expand Down
Loading
Loading