Skip to content

Commit a9c1cd2

Browse files
authored
feat: use updated SP1 (risc0#2)
1 parent f31746d commit a9c1cd2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+4131
-14830
lines changed

Diff for: Cargo.lock

+2,352-826
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: Cargo.toml

+9-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
[workspace]
2-
3-
members = ["eval/cli"]
2+
members = ["eval"]
43

54
resolver = "2"
65

@@ -11,14 +10,20 @@ opt-level = 3
1110
opt-level = 3
1211

1312
[profile.release]
14-
debug = 1
13+
opt-level = 3
1514
lto = true
1615

16+
[profile.fast]
17+
inherits = "release"
18+
debug = true
19+
debug-assertions = true
20+
1721
[profile.release.build-override]
1822
opt-level = 3
1923

20-
# Note: Need to add this patch until the Jolt repo adds an override which automatically adds this patch.
2124
[patch.crates-io]
2225
ark-ff = { git = "https://github.com/a16z/arkworks-algebra", branch = "optimize/field-from-u64" }
2326
ark-ec = { git = "https://github.com/a16z/arkworks-algebra", branch = "optimize/field-from-u64" }
2427
ark-serialize = { git = "https://github.com/a16z/arkworks-algebra", branch = "optimize/field-from-u64" }
28+
revm-interpreter = { git = "https://github.com/sp1-patches/revm-new", branch = "john/update-for-v1" }
29+
revm-primitives = { git = "https://github.com/sp1-patches/revm-new", branch = "john/update-for-v1" }

Diff for: README.md

+49-48
Original file line numberDiff line numberDiff line change
@@ -1,113 +1,106 @@
1-
# zkVM benchmarks
1+
# SP1 Benchmarks
22

3-
A benchmarking suite for zkVMs.
3+
A suite of benchmarks to evaluate SP1's performance.
44

55
## Setup
66

77
Install Rust:
8-
```
8+
9+
```sh
910
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
1011
rustup install nightly
1112
```
1213

13-
You might need to do `sudo sh` if the first command doesn't work.
14+
Install the [SP1 toolchain](https://docs.succinct.xyz/getting-started/install.html):
1415

15-
Install the Succinct toolchain which is used for building the ELF files: https://succinctlabs.github.io/sp1/getting-started/install.html.
16-
```
16+
```sh
1717
curl -L https://sp1.succinct.xyz | bash
18+
source ~/.bashrc
1819
sp1up
1920
cargo prove --version
2021
```
2122

22-
Make sure that `go` is installed on your system, to run the gnark wrapper.
23-
24-
Install the `jolt` [toolchain](https://jolt.a16zcrypto.com/usage/quickstart.html).
25-
26-
```
27-
cargo install --git https://github.com/a16z/jolt --rev 845d39af373de078ee2616cf36a255f36f38334a --force --bins jolt
28-
jolt install-toolchain
29-
```
23+
Install the [Risc0 toolchain](https://dev.risczero.com/api/zkvm/install):
3024

31-
You might have to install these libraries for JOLT:
32-
```
33-
sudo apt-get update
34-
sudo apt-get install libc6
25+
```sh
26+
curl -L https://risczero.com/install | bash
27+
source ~/.bashrc
28+
rzup
29+
cargo risczero --version
3530
```
3631

37-
Install the Risc0 toolchain:
38-
```
39-
cargo install cargo-binstall
40-
cargo binstall cargo-risczero
41-
cargo risczero install
42-
```
43-
44-
Install docker (needed for running R0's STARK -> SNARK):
32+
Install [Docker](https://docs.docker.com/engine/install/ubuntu/).
4533
* https://docs.docker.com/engine/install/ubuntu/
34+
* https://docs.docker.com/engine/install/linux-postinstall/
4635

47-
Then, make sure you can run docker not in sudo mode:
48-
https://docs.docker.com/engine/install/linux-postinstall/
36+
Install the [NVIDIA Container Toolkit](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html) if you are using NVIDIA GPUs.
37+
- https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html
4938

5039
**Note:** When benchmarking, make sure that you run 1 round of Fibonacci (or some other small program) to download the R0 docker image to make sure it doesn't contribute to benchmarking time.
5140

5241
**Note:** On Ubuntu 22.04, you might need to install libssl1.0 to use the Risc0 toolchain. You can follow these instructions (from [here](https://stackoverflow.com/questions/72133316/libssl-so-1-1-cannot-open-shared-object-file-no-such-file-or-directory/73604364#73604364)).
5342

54-
## Machine Requirements
55-
56-
We ran our benchmarks on a AWS r7i.16xlarge machine with 64 vCPUs and 512 GB of memory. Smaller programs require significantly less memory. Note that the machine has to support AVX-512 instructions, otherwise the command in `eval.sh` will not run. If your machine doesn't support AVX-512, then modify this command to remove those flags.
57-
5843
## Usage
5944

6045
You can conduct a sweep of the benchmarks by running either of the following commands:
6146

62-
```
47+
```sh
6348
python3 sweep.py
6449
```
6550

66-
or running the following command for the JOLT sweep:
67-
68-
```
69-
python3 sweep_jolt.py
70-
```
71-
7251
To run a single benchmark, you can run:
7352

74-
```
53+
```sh
7554
./eval.sh (loop|fibonacci|ssz_withdrawals|tendermint) (sp1|risc0|jolt-zkvm) (poseidon|sha256|blake3|...)
7655
```
7756

7857
Note that right now only poseidion is supported for all zkVMs, since we are interested in also profiling recursion.
7958

8059
Example SP1:
81-
```
60+
61+
```sh
8262
./eval.sh fibonacci sp1 poseidon 22 benchmark
8363
```
8464

8565
Example JOLT:
86-
```
66+
67+
```sh
8768
./eval.sh fibonacci jolt-zkvm poseidon 22 benchmark
8869
```
8970

9071
Example Risc0:
91-
```
72+
73+
```sh
9274
./eval.sh fibonacci risc0 poseidon 22 benchmark
9375
```
9476

95-
## Debugging
77+
Note for benchmarking the Reth program, you must also pass in a block number:
78+
79+
```sh
80+
./eval.sh reth sp1 poseidon 22 benchmark 19409768
81+
```
82+
83+
The inputs for these blocks have already been generated [here](./eval/cli/blocks/). You can add more
84+
blocks by using the [SP1-Reth](https://github.com/succinctlabs/sp1-reth) script.
85+
86+
## Common Issues
9687

9788
Because Risc0 uses C++ for their prover, you may need to install the C++ compiler and libraries.
9889

9990
For Ubuntu/Debian-based systems:
100-
```
91+
92+
```sh
10193
# Update system repositories and installed packages
10294
sudo apt update
10395
sudo apt upgrade
10496

10597
# Install the latest version of GCC and libraries
106-
sudo apt install build-essential
98+
sudo apt install build-essential libc6
10799
```
108100

109101
For CentOS/RHEL-based systems:
110-
```
102+
103+
```sh
111104
# Update system repositories and installed packages
112105
sudo yum update
113106

@@ -119,10 +112,18 @@ sudo yum install -y gcc-c++
119112
```
120113

121114
For Fedora:
122-
```
115+
116+
```sh
123117
# Update system repositories and installed packages
124118
sudo dnf update
125119

126120
# Install the Development Tools group which includes GCC
127121
sudo dnf groupinstall "Development Tools"
122+
```
123+
124+
Setting up NVIDIA:
125+
126+
```sh
127+
sudo nvidia-ctk runtime configure --runtime=docker
128+
sudo systemctl restart docker
128129
```

Diff for: eval.sh

+33-14
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/bin/bash
22
set -e
3-
43
echo "Running $1, $2, $3, $4, $5"
54

65
# Get program directory name as $1 and append "-$2" to it if $1 == "tendermint"
@@ -15,7 +14,7 @@ echo "Building program"
1514
# cd to program directory computed above
1615
cd "programs/$program_directory"
1716

18-
# If the prover is not jolt-zkvm, then build the program.
17+
# If the prover is sp1, then build the program.
1918
if [ "$2" == "sp1" ]; then
2019
# The reason we don't just use `cargo prove build` from the SP1 CLI is we need to pass a --features ...
2120
# flag to select between sp1 and risc0.
@@ -34,22 +33,42 @@ if [ "$2" == "risc0" ]; then
3433
cargo build --release --ignore-rust-version --features $2
3534
fi
3635

37-
38-
cd ../../eval
36+
cd ../../
3937

4038
echo "Running eval script"
4139

42-
# Runs the eval for the specified program, prover & hash function with conditional compilation based on the feature flag.
43-
44-
RUST_LOG=info RUSTFLAGS='-C target-cpu=native -C target_feature=+avx512ifma,+avx512vl' cargo run -p eval --release --no-default-features --features $2 -- --program $1 --prover $2 --hashfn $3 --shard-size $4 --filename $5
40+
# Detect whether we're on an instance with a GPU.
41+
if nvidia-smi > /dev/null 2>&1; then
42+
GPU_EXISTS=true
43+
else
44+
GPU_EXISTS=false
45+
fi
4546

46-
# TODO: conditionally run with avx flags based on the machine's architecture.
47-
#RUST_LOG=info RUSTFLAGS='-C target-cpu=native' cargo run -p eval --release --no-default-features --features $2 -- --program $1 --prover $2 --hashfn $3 --shard-size $4
47+
# Set the compilation flags.
48+
if [ "$GPU_EXISTS" = false ]; then
49+
export RUSTFLAGS='-C target-cpu=native -C target_feature=+avx512ifma,+avx512vl'
50+
fi
4851

49-
cd ../
52+
# Set the logging level.
53+
export RUST_LOG=info
5054

51-
# Get the current commit hash
52-
commit_hash=$(git rev-parse HEAD)
55+
# Determine the features based on GPU existence.
56+
if [ "$GPU_EXISTS" = true ]; then
57+
FEATURES="cuda"
58+
else
59+
FEATURES="default"
60+
fi
5361

54-
# Write the commit hash to COMMIT_HASH file
55-
echo "$commit_hash" > COMMIT_HASH
62+
# Run the benchmark.
63+
cargo run \
64+
-p sp1-benchmarks-eval \
65+
--release \
66+
--no-default-features \
67+
--features $FEATURES \
68+
-- \
69+
--program $1 \
70+
--prover $2 \
71+
--hashfn $3 \
72+
--shard-size $4 \
73+
--filename $5 \
74+
${6:+--block-number $6}

Diff for: eval/.gitignore

-1
This file was deleted.

0 commit comments

Comments
 (0)