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 3 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

nhtyy marked this conversation as resolved.
Show resolved Hide resolved
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
26 changes: 22 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,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/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 @@ -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() {
nhtyy marked this conversation as resolved.
Show resolved Hide resolved
println!("cargo:warning=ELF name is set but --output-directory is not used");
}

print_elf_paths_cargo_directives(&target_elf_paths);
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
nhtyy marked this conversation as resolved.
Show resolved Hide resolved
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