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

feat: v4.0.1 #1941

Merged
merged 14 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
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
6 changes: 3 additions & 3 deletions .github/workflows/book.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ name: book

on:
push:
branches: [main]
branches: [dev]
pull_request:
branches: [main]
branches: [dev]
paths:
- "book/**"
merge_group:
Expand Down Expand Up @@ -46,7 +46,7 @@ jobs:

deploy:
# Only deploy if a push to main
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: update comment

if: github.ref_name == 'main' && github.event_name == 'push'
if: github.ref_name == 'dev' && github.event_name == 'push'
runs-on: ubuntu-latest
needs: [build]

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/docker-gnark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
[
runs-on,
runner=64cpu-linux-arm64,
disk=large,
spot=false,
"run-id=${{ github.run_id }}",
]
Expand Down
19 changes: 18 additions & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -371,4 +371,21 @@ jobs:
- name: "Build examples without lock files"
run: |
cd examples
cargo build --all --all-targets
cargo build --all --all-targets

build-in-host:
name: "Build patches and zkvm in host"
runs-on: [runs-on, runner=16cpu-linux-x64, disk=large, "run-id=${{ github.run_id }}"]
steps:
- name: "Checkout sources"
uses: "actions/checkout@v4"

- name: "Setup CI"
uses: ./.github/actions/setup
with:
pull_token: ${{ secrets.PRIVATE_PULL_TOKEN }}

- name: "Build programs in host"
run: |
cd ./patch-testing/build-host
cargo build
26 changes: 22 additions & 4 deletions book/docs/developers/common-issues.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
If you are using a library that has an MSRV specified, you may encounter an error like this when building your program.

```txt
package `alloy cannot be built because it requires rustc 1.83 or newer, while the currently active rustc version is 1.81.0`
package `alloy cannot be built because it requires rustc 1.83 or newer, while the currently active rustc version is 1.82.0`
```

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.

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).
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.82**. You can update to the latest version by running [`sp1up`](../getting-started/install.md).

```shell
% sp1up
% cargo +succinct --version
cargo 1.81.0-dev (2dbb1af80 2024-08-20)
cargo 1.82.0-dev (8f40fc59f 2024-08-21)
```

A Succinct Rust toolchain with version **1.82** should work for all crates that have an MSRV of **1.82** or lower.
Expand Down Expand Up @@ -120,4 +120,22 @@ 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"] }
```
```

## Failed to run LLVM passes: unknown pass name 'loweratomic'

The Rust compiler had breaking changes to its names of available options between 1.81 and 1.82.

```bash
[sp1] Compiling proc-macro2 v1.0.93
[sp1] Compiling unicode-ident v1.0.14
[sp1] Compiling quote v1.0.38
[sp1] Compiling syn v2.0.96
[sp1] Compiling serde_derive v1.0.217
[sp1] Compiling serde v1.0.217
[sp1] error: failed to run LLVM passes: unknown pass name 'loweratomic'
```

This message indicates that you're trying to use `sp1-build` < `4.0.0` with the 1.82 toolchain,
`sp1-build` versions >= 4.0.0 have support for the 1.82 and 1.81 toolchains.

2 changes: 2 additions & 0 deletions book/docs/developers/usage-in-ci.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ Try setting a github actions secret to your PAT, and then passing it into the `s
~/.sp1/bin/cargo-prove prove --version
```

Note: Installing via `sp1up` always installs the latest version, its recommended to [use a release commit](https://github.com/succinctlabs/sp1/releases) via `sp1up -C <commit>`.

## Speeding up your CI workflow

### Caching
Expand Down
13 changes: 13 additions & 0 deletions book/docs/writing-programs/patched-crates.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,19 @@ Apply the following patches based on what crates are in your dependencies.

While `secp256k1` doesnt usually rely on `ecdsa-core` the patched version does, so you must patch it as well.

## Secp256r1 Acceleration

- `p256`

```toml
ecdsa-core = { git = "https://github.com/sp1-patches/signatures", package = "ecdsa", tag = "patch-0.16.9-sp1-4.0.0" }
```

### Notes

- The curve operations for `p256` are inside of the `ecdsa-core` crate, so you don't need to patch `p256` itself, and just patching `ecdsa-core` is enough.
- The current patch only accelerates the `ecrecover` function. In a future release, we will accelerate the `verify` function used in `P256Verify` (RIP-7212 precompile).

## BN254 Acceleration

To accelerate BN254 (Also known as BN128 and Alt-BN128), you will need to patch the `substrate-bn` crate.
Expand Down
3 changes: 1 addition & 2 deletions book/docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ const config: Config = {
"classic",
({
docs: {
routeBasePath: "docs",
sidebarPath: require.resolve("./sidebars.ts"),
onlyIncludeVersions: ["4.0.0", "3.4.0"],
},
blog: false,
pages: {},
Expand Down
39 changes: 35 additions & 4 deletions book/versioned_docs/version-4.0.0/developers/common-issues.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
If you are using a library that has an MSRV specified, you may encounter an error like this when building your program.

```txt
package `alloy cannot be built because it requires rustc 1.83 or newer, while the currently active rustc version is 1.81.0`
package `alloy cannot be built because it requires rustc 1.83 or newer, while the currently active rustc version is 1.82.0`
```

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.

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).
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.82**. You can update to the latest version by running [`sp1up`](../getting-started/install.md).

```shell
% sp1up
% cargo +succinct --version
cargo 1.81.0-dev (2dbb1af80 2024-08-20)
cargo 1.82.0-dev (8f40fc59f 2024-08-21)
```

A Succinct Rust toolchain with version **1.82** should work for all crates that have an MSRV of **1.82** or lower.
Expand Down Expand Up @@ -120,4 +120,35 @@ 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"] }
```
```

## Failed to run LLVM passes: unknown pass name 'loweratomic'

The Rust compiler had breaking changes to its names of available options between 1.81 and 1.82.

```bash
[sp1] Compiling proc-macro2 v1.0.93
[sp1] Compiling unicode-ident v1.0.14
[sp1] Compiling quote v1.0.38
[sp1] Compiling syn v2.0.96
[sp1] Compiling serde_derive v1.0.217
[sp1] Compiling serde v1.0.217
[sp1] error: failed to run LLVM passes: unknown pass name 'loweratomic'
```

This message indicates that you're trying to use `sp1-build` < `4.0.0` with the 1.82 toolchain,
`sp1-build` versions >= 4.0.0 have support for the 1.82 and 1.81 toolchains.

If you're using `cargo prove build` an `sp1up` should fix this.

## Ubuntu 20.04 (ARM)

The Succinct Rust toolchain is built on Ubuntu 22.04 for ARM machines,
which links a newer version of libc than available on Ubuntu 20.04.

This error may manifest as:
```bash
/lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found
```
This most commonly happens in CI runners. To solve this, bump the runner OS to 22.04.
This issue also applies all older Linux distributions that don't have support for the same version of libc used to build it.
2 changes: 2 additions & 0 deletions book/versioned_docs/version-4.0.0/developers/usage-in-ci.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ Try setting a github actions secret to your PAT, and then passing it into the `s
~/.sp1/bin/cargo-prove prove --version
```

Note: Installing via `sp1up` always installs the latest version, its recommended to [use a release commit](https://github.com/succinctlabs/sp1/releases) via `sp1up -C <commit>`.

## Speeding up your CI workflow

### Caching
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ let mut proof = client.prove(&pk, &stdin).run().unwrap();
SP1_PROVER=network NETWORK_PRIVATE_KEY=... RUST_LOG=info cargo run --release
```

- `SP1_PROVER` should be set to `network` rather than the default `cpu` when using the prover network. This variable allows you to switch between the CPU and network provers.
- Set `SP1_PROVER` to `network` (default is `cpu`). Configuring this variable to `network` will use the prover network.

- `NETWORK_PRIVATE_KEY` should be set to your [private key](./key-setup.md). You will need
to be using a [whitelisted](../prover-network) key to use the network.

- `NETWORK_RPC_URL`: Defaults to `https://rpc.production.succinct.xyz`. This is the RPC URL of the prover network.

When you call any of the prove functions in ProverClient now, it will first simulate your program, then wait for it to be proven through the network and finally return the proof.

## View the status of your proof
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ The prover network currently only supports specific versions of SP1:
| Version | Description |
| ------- | ---------------------------------------------------------------- |
| v4.X.X | V4 Release. Latest performant & production ready version. |
| v3.X.X | V3 Release. Previous circuit version deprecated in January 2025. |

`X` denotes that any minor and patch version is supported (e.g. `v2.1.0`, `v2.1.1`).
`X` denotes that any minor and patch version is supported (e.g. `v4.0.1`, `v4.1.0`).

If you submit a proof request to the prover network and you are not using a supported version, you will receive an error message.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,19 @@ Apply the following patches based on what crates are in your dependencies.

While `secp256k1` doesnt usually rely on `ecdsa-core` the patched version does, so you must patch it as well.

## Secp256r1 Acceleration

- `p256`

```toml
ecdsa-core = { git = "https://github.com/sp1-patches/signatures", package = "ecdsa", tag = "patch-0.16.9-sp1-4.0.0" }
```

### Notes

- The curve operations for `p256` are inside of the `ecdsa-core` crate, so you don't need to patch `p256` itself, and just patching `ecdsa-core` is enough.
- The current patch only accelerates the `ecrecover` function. In a future release, we will accelerate the `verify` function used in `P256Verify` (RIP-7212 precompile).

## BN254 Acceleration

To accelerate BN254 (Also known as BN128 and Alt-BN128), you will need to patch the `substrate-bn` crate.
Expand Down
2 changes: 2 additions & 0 deletions crates/build/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ pub fn execute_build_program(

std::fs::copy(&elf_path, &output_path)?;
}
} else if args.elf_name.is_some() {
println!("cargo:warning=ELF name is set but --output-directory is not used, the ELF will be place in the `target/` directory");
}

print_elf_paths_cargo_directives(&target_elf_paths);
Expand Down
19 changes: 13 additions & 6 deletions crates/core/machine/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ mod sys {
let mut dir = out_dir.clone();
loop {
if dir.ends_with("target") {
break dir;
break Some(dir);
}
if !dir.pop() {
panic!("OUT_DIR does not have parent called \"target\": {:?}", out_dir);
break None;
}
}
};
Expand All @@ -61,7 +61,7 @@ mod sys {
let target_include_dir = out_dir.join(INCLUDE_DIRNAME);

// The directory to place symlinks to headers into. Has the fixed path "target/include".
let target_include_dir_fixed = target_dir.join(INCLUDE_DIRNAME);
let target_include_dir_fixed = target_dir.map(|dir| dir.join(INCLUDE_DIRNAME));

// The directory to read source files from.
let source_dir = crate_dir.join(SOURCE_DIRNAME);
Expand Down Expand Up @@ -127,8 +127,10 @@ mod sys {
// Write the bindings to the target include directory.
let header_path = target_include_dir.join(cbindgen_hpp);
if bindings.write_to_file(&header_path) {
// Symlink the header to the fixed include directory.
rel_symlink_file(header_path, target_include_dir_fixed.join(cbindgen_hpp));
if let Some(ref target_include_dir_fixed) = target_include_dir_fixed {
// Symlink the header to the fixed include directory.
rel_symlink_file(header_path, target_include_dir_fixed.join(cbindgen_hpp));
}
}
}
Err(cbindgen::Error::ParseSyntaxError { error, crate_name, src_path }) => {
Expand All @@ -150,7 +152,12 @@ mod sys {
fs::create_dir_all(parent).unwrap();
}
fs::copy(header, &dst).unwrap();
rel_symlink_file(dst, target_include_dir_fixed.join(relpath));

// We only need to symlink if we have a target.
if let Some(ref target_include_dir_fixed) = target_include_dir_fixed {
// Symlink the header to the fixed include directory.
rel_symlink_file(dst, target_include_dir_fixed.join(relpath));
}
}

// Use the `cc` crate to build the library and statically link it to the crate.
Expand Down
6 changes: 2 additions & 4 deletions crates/sdk/src/network/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
//!
//! This module provides a builder for the [`NetworkProver`].

use crate::network::DEFAULT_NETWORK_RPC_URL;
use crate::NetworkProver;

/// A builder for the [`NetworkProver`].
Expand Down Expand Up @@ -83,10 +84,7 @@ impl NetworkProverBuilder {

let rpc_url = match self.rpc_url {
Some(rpc_url) => rpc_url,
None => std::env::var("NETWORK_RPC_URL").expect(
"NETWORK_RPC_URL environment variable is not set. \
Please set it to your rpc url or use the .rpc_url() method.",
),
None => std::env::var("NETWORK_RPC_URL").unwrap_or(DEFAULT_NETWORK_RPC_URL.to_string()),
};

NetworkProver::new(&private_key, &rpc_url)
Expand Down
5 changes: 2 additions & 3 deletions crates/zkvm/entrypoint/src/allocators/bump.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
use core::alloc::{GlobalAlloc, Layout};

use crate::syscalls::sys_alloc_aligned;
use core::alloc::{GlobalAlloc, Layout};

/// A simple heap allocator.
///
/// Allocates memory from left to right, without any deallocation.
pub struct SimpleAlloc;
struct SimpleAlloc;

unsafe impl GlobalAlloc for SimpleAlloc {
unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
Expand Down
6 changes: 3 additions & 3 deletions crates/zkvm/entrypoint/src/allocators/embedded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ use critical_section::RawRestoreState;
use embedded_alloc::LlffHeap as Heap;

#[global_allocator]
pub static HEAP: EmbeddedAlloc = EmbeddedAlloc;
static HEAP: EmbeddedAlloc = EmbeddedAlloc;

pub static INNER_HEAP: Heap = Heap::empty();
static INNER_HEAP: Heap = Heap::empty();

struct CriticalSection;
critical_section::set_impl!(CriticalSection);
Expand Down Expand Up @@ -39,7 +39,7 @@ pub fn free() -> usize {
critical_section::with(|cs| INNER_HEAP.free())
}

pub struct EmbeddedAlloc;
struct EmbeddedAlloc;

unsafe impl GlobalAlloc for EmbeddedAlloc {
unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
Expand Down
5 changes: 4 additions & 1 deletion crates/zkvm/entrypoint/src/allocators/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@
mod bump;

#[cfg(feature = "embedded")]
pub mod embedded;
mod embedded;

#[cfg(feature = "embedded")]
pub use embedded::{free, init, used};
Loading
Loading