Skip to content

Commit

Permalink
add
Browse files Browse the repository at this point in the history
  • Loading branch information
ratankaliani committed Jan 15, 2025
2 parents 029fc4e + 43b82ce commit 6a1543c
Show file tree
Hide file tree
Showing 21 changed files with 40 additions and 106 deletions.
8 changes: 0 additions & 8 deletions book/docs/developers/building-circuit-artifacts.md

This file was deleted.

26 changes: 1 addition & 25 deletions book/docs/developers/common-issues.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,28 +120,4 @@ To resolve this, ensure that you're importing both `sp1-lib` and `sp1-zkvm` with
[dependencies]
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.
```
10 changes: 1 addition & 9 deletions book/docs/generating-proofs/advanced.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Compressed from "@site/static/examples_fibonacci_script_bin_compressed.rs.mdx";
import Execute from "@site/static/examples_fibonacci_script_bin_execute.rs.mdx";

# Advanced Usage
# Advanced

## Execution Only

Expand All @@ -12,14 +12,6 @@ Instead, you should have your script only execute the program with the RISC-V ru

If the execution of your program succeeds, then proof generation should succeed as well! (Unless there is a bug in our zkVM implementation.)

## Compressed Proofs

With the `ProverClient`, the default `prove` function generates a proof that is succinct, but can have size that scales with the number of cycles of the program. To generate a compressed proof of constant size, you can use the `prove_compressed` function instead. This will use STARK recursion to generate a proof that is constant size (around 7Kb), but will be slower than just calling `prove`, as it will use recursion to combine the core SP1 proof into a single constant-sized proof.

<Compressed />

You can run the above script with `RUST_LOG=info cargo run --bin compressed --release` from `examples/fibonacci/script`.

## Logging and Tracing Information

You can use `utils::setup_logger()` to enable logging information respectively. You should only use one or the other of these functions.
Expand Down
9 changes: 1 addition & 8 deletions book/docs/generating-proofs/basics.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,4 @@ To make this more concrete, let's walk through a simple example of generating a

<Example />

You can run the above script in the `script` directory with `RUST_LOG=info cargo run --release`. Note that running the above script will generate a proof locally.

<div class="warning">
WARNING: Local proving often is much slower than the prover network and for certain proof types (e.g. Groth16, PLONK) require a
significant amount of RAM. You might only be able to generate proofs for small inputs locally.
</div>

We recommend using the [prover network](./prover-network.md) to generate proofs. Read more about the [recommended workflow](./recommended-workflow) for developing with SP1.
You can run the above script in the `script` directory with `RUST_LOG=info cargo run --release`. Note that running the above script will generate a proof locally.
8 changes: 6 additions & 2 deletions book/docs/generating-proofs/hardware-acceleration/cuda.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,9 @@ Please make sure you have the following installed before using the CUDA prover:

## Usage

To use the CUDA prover, you can compile the `sp1-sdk` crate with the `cuda` feature enabled. You
can use the normal methods on the `ProverClient` to generate proofs.
To use the CUDA prover, you have two options:

1. Use `ProverClient::from_env` to build the client and set `SP1_PROVER` environment variable to `cuda`.
2. Use `ProverClient::builder().cuda().build()` to build the client.

Then, use your standard methods on the `ProverClient` to generate proofs.
8 changes: 4 additions & 4 deletions book/docs/generating-proofs/proof-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ For a full list of options, see the following [docs](https://docs.rs/sp1-sdk/lat
The default prover mode generates a list of STARK proofs that in aggregate have size proportional to
the size of the execution. Use this in settings where you don't care about **verification cost / proof size**.

```rust,noplayground
```rust
let client = ProverClient::from_env();
client.prove(&pk, &stdin).run().unwrap();
```
Expand All @@ -21,7 +21,7 @@ client.prove(&pk, &stdin).run().unwrap();
The compressed prover mode generates STARK proofs that have constant size. Use this in settings where you
care about **verification cost / proof size**, but not onchain verification. Compressed proofs are also useful because they can be cheaply recursively verified within SP1 itself (see the [proof aggregation](../writing-programs/proof-aggregation.md) section).

```rust,noplayground
```rust
let client = ProverClient::from_env();
client.prove(&pk, &stdin).compressed().run().unwrap();
```
Expand All @@ -32,7 +32,7 @@ The Groth16 prover mode generates a SNARK proof that is ~260 bytes large and can

The trusted setup for the Groth16 circuit keys uses the [Aztec Ignition ceremony](https://github.com/AztecProtocol/ignition-verification) + entropy contributions from members of the Succinct team. If you are uncomfortable with the security assumptions of the ceremony, you can use the PLONK proof type instead.

```rust,noplayground
```rust
let client = ProverClient::from_env();
client.prove(&pk, &stdin).groth16().run().unwrap();
```
Expand All @@ -43,7 +43,7 @@ The PLONK prover mode generates a SNARK proof that is ~868 bytes large and can a

PLONK does not require a trusted setup and reuses contributions from the Aztec Ignition ceremony.

```rust,noplayground
```rust
let client = ProverClient::from_env();
client.prove(&pk, &stdin).plonk().run().unwrap();
```
4 changes: 2 additions & 2 deletions book/docs/generating-proofs/prover-network/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Advanced features include:
* Async support
* Requesting a proof using a custom fulfillment strategy, such as for reserved prover network capacity

```rust,no_run
```rust
use sp1_sdk::{network::FulfillmentStrategy, Prover, ProverClient};
use std::time::Duration;

Expand All @@ -59,7 +59,7 @@ let proof = prover
.prove(&pk, &stdin)
.groth16()
.skip_simulation(true)
.fulfillment_strategy(FulfillmentStrategy::Reserved)
.strategy(FulfillmentStrategy::Reserved)
.run_async()
.await
.unwrap();
Expand Down
2 changes: 1 addition & 1 deletion book/docs/generating-proofs/recommended-workflow.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Example from "@site/static/examples_fibonacci_script_bin_execute.rs.mdx";

# Recommended Workflow for Developing with SP1
# Recommended Workflow

We recommend the following workflow for developing with SP1.

Expand Down
15 changes: 0 additions & 15 deletions book/docs/generating-proofs/sp1-sdk-faq.md

This file was deleted.

2 changes: 1 addition & 1 deletion book/docs/getting-started/hardware-requirements.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Proof Generation Requirements
# Hardware Requirements

<div class="warning">
We recommend that developers who want to use SP1 for non-trivial programs generate proofs on our prover network. The prover network generates SP1 proofs across multiple machines, reducing latency and also runs SP1 on optimized hardware instances that result in faster + cheaper proof generation times.
Expand Down
10 changes: 1 addition & 9 deletions book/docs/verification/onchain/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,4 @@ By default, the proofs generated by SP1 are not verifiable onchain, as they are

<Example/>

You can run the above script with `RUST_LOG=info cargo run --bin groth16_bn254 --release` in `examples/fibonacci/script`.

#### Using Groth16 and PLONK without Docker (Advanced)

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"] }
```
You can run the above script with `RUST_LOG=info cargo run --bin groth16_bn254 --release` in `examples/fibonacci/script`.
18 changes: 9 additions & 9 deletions book/sidebars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ const sidebars: SidebarsConfig = {
items: [
"getting-started/install",
"getting-started/quickstart",
"getting-started/hardware-requirements",
"getting-started/project-template",
"getting-started/hardware-requirements",
],
collapsed: false,
},
Expand All @@ -33,25 +33,24 @@ const sidebars: SidebarsConfig = {
label: "Writing Programs",
items: [
"writing-programs/basics",
"writing-programs/setup",
"writing-programs/compiling",
"writing-programs/cycle-tracking",
"writing-programs/inputs-and-outputs",
"writing-programs/patched-crates",
"writing-programs/precompiles",
"writing-programs/proof-aggregation",
"writing-programs/setup",
"writing-programs/cycle-tracking",
],
collapsed: true,
collapsed: false,
},
{
type: "category",
label: "Generating Proofs",
label: "Proving",
items: [
"generating-proofs/basics",
"generating-proofs/setup",
"generating-proofs/proof-types",
"generating-proofs/recommended-workflow",
"generating-proofs/sp1-sdk-faq",
{
type: "category",
label: "Hardware Acceleration",
Expand All @@ -74,7 +73,7 @@ const sidebars: SidebarsConfig = {
},
"generating-proofs/advanced",
],
collapsed: true,
collapsed: false,
},
{
type: "category",
Expand All @@ -91,15 +90,16 @@ const sidebars: SidebarsConfig = {
],
},
],
collapsed: false,
},
{
type: "category",
label: "Developers",
label: "Troubleshooting & CI",
items: [
"developers/common-issues",
"developers/usage-in-ci",
"developers/building-circuit-artifacts",
],
collapsed: false,
},
{
type: "category",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fn main() {
stdin.write(&n);

// Generate the constant-sized proof for the given program and input.
let client = ProverClient::new();
let client = ProverClient::from_env();
let (pk, vk) = client.setup(ELF);
let mut proof = client.prove(&pk, &stdin).compressed().run().unwrap();

Expand Down
2 changes: 1 addition & 1 deletion book/static/examples_fibonacci_script_bin_execute.rs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fn main() {
stdin.write(&n);

// Only execute the program and get a `SP1PublicValues` object.
let client = ProverClient::new();
let client = ProverClient::from_env();
let (mut public_values, execution_report) = client.execute(ELF, &stdin).run().unwrap();

// Print the total number of cycles executed and the full execution report with a breakdown of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fn main() {
stdin.write(&n);

// Set up the pk and vk.
let client = ProverClient::new();
let client = ProverClient::from_env();
let (pk, vk) = client.setup(ELF);
println!("vk: {:?}", vk.bytes32());

Expand Down
2 changes: 1 addition & 1 deletion book/static/examples_fibonacci_script_src_main.rs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ fn main() {
stdin.write(&n);

// Create a `ProverClient` method.
let client = ProverClient::new();
let client = ProverClient::from_env();

// Execute the program using the `ProverClient.execute` method, without generating a proof.
let (_, report) = client.execute(ELF, &stdin).run().unwrap();
Expand Down
4 changes: 2 additions & 2 deletions book/static/examples_groth16_script_src_main.rs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ fn generate_fibonacci_proof() -> (Vec<u8>, Vec<u8>, String) {
stdin.write(&n);

// Create a `ProverClient`.
let client = ProverClient::new();
let client = ProverClient::from_env();

// Generate the groth16 proof for the Fibonacci program.
let (pk, vk) = client.setup(FIBONACCI_ELF);
Expand All @@ -47,7 +47,7 @@ fn main() {
stdin.write(&vk);

// Create a `ProverClient`.
let client = ProverClient::new();
let client = ProverClient::from_env();

// Execute the program using the `ProverClient.execute` method, without generating a proof.
let (_, report) = client.execute(GROTH16_ELF, &stdin).run().unwrap();
Expand Down
2 changes: 1 addition & 1 deletion book/verification/onchain/solidity-sdk.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ fn main() {
sp1_sdk::utils::setup_logger();

// Setup the prover client.
let client = ProverClient::new();
let client = ProverClient::from_env();

// Setup the program.
let (_, vk) = client.setup(FIBONACCI_ELF);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The default prover mode generates a list of STARK proofs that in aggregate have
the size of the execution. Use this in settings where you don't care about **verification cost / proof size**.

```rust
let client = ProverClient::new();
let client = ProverClient::from_env();
client.prove(&pk, &stdin).run().unwrap();
```

Expand All @@ -22,7 +22,7 @@ The compressed prover mode generates STARK proofs that have constant size. Use t
care about **verification cost / proof size**, but not onchain verification. Compressed proofs are also useful because they can be cheaply recursively verified within SP1 itself (see the [proof aggregation](../writing-programs/proof-aggregation.md) section).

```rust
let client = ProverClient::new();
let client = ProverClient::from_env();
client.prove(&pk, &stdin).compressed().run().unwrap();
```

Expand All @@ -33,7 +33,7 @@ The Groth16 prover mode generates a SNARK proof that is ~260 bytes large and can
The trusted setup for the Groth16 circuit keys uses the [Aztec Ignition ceremony](https://github.com/AztecProtocol/ignition-verification) + entropy contributions from members of the Succinct team.

```rust
let client = ProverClient::new();
let client = ProverClient::from_env();
client.prove(&pk, &stdin).groth16().run().unwrap();
```

Expand All @@ -44,6 +44,6 @@ The PLONK prover mode generates a SNARK proof that is ~868 bytes large and can a
PLONK does not require a trusted setup.

```rust
let client = ProverClient::new();
let client = ProverClient::from_env();
client.prove(&pk, &stdin).plonk().run().unwrap();
```
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ To use the prover network to generate a proof, you can run your script that uses

```rust
// Generate the proof for the given program.
let client = ProverClient::new();
let client = ProverClient::from_env();
let (pk, vk) = client.setup(ELF);
let mut proof = client.prove(&pk, &stdin).run().unwrap();
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ fn main() {
sp1_sdk::utils::setup_logger();

// Setup the prover client.
let client = ProverClient::new();
let client = ProverClient::from_env();

// Setup the program.
let (_, vk) = client.setup(FIBONACCI_ELF);
Expand Down

0 comments on commit 6a1543c

Please sign in to comment.