Akagi201 / zkvm-benchmark

Benchmarks between zkWasm and zkVM

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

zkvm-benchmark

Benchmarks between zkWasm and zkVM

Dependencies

Before running, make sure your have installed the following tools:

  • just: a command runner
  • hyperfine: a benchmarking tool
  • wasm-opt: from binaryen, for wasm to wasm optimization.
  • wasm-pack: Rust → Wasm workflow tool
  • delphinus-cli: from zkWasm, to run zkWasm program, built from the latest main branch.
  • risczero toolchain: from risc0, to build zkVM program, built from v0.19.1 tag.
  • lgo: an alias of the go binary built from zkgo, for build go program to wasm, built from the latest zkGo branch.
#just
mkdir -p ~/bin
curl --proto '=https' --tlsv1.2 -sSf https://just.systems/install.sh | bash -s -- --to ~/bin
export PATH="$PATH:$HOME/bin"
# hyperfine
wget https://github.com/sharkdp/hyperfine/releases/download/v1.16.1/hyperfine_1.16.1_amd64.deb
sudo dpkg -i hyperfine_1.16.1_amd64.deb
# wasm-opt
curl -L -O https://github.com/WebAssembly/binaryen/releases/download/version_116/binaryen-version_116-x86_64-linux.tar.gz
tar -xzf binaryen-version_116-x86_64-linux.tar.gz
mv binaryen-version_116-x86_64-linux/bin/wasm-opt ~/bin
# wasm-pack
rustc install stable
rustc default stable 
cargo install wasm-pack
export PATH="$PATH:$HOME/.cargo/bin"

Install risczero toolchain

git clone https://github.com/risc0/risc0.git
cd risc0
git checkout v0.19.1 # checkout to the latest release
cargo install --path risc0/cargo-risczero
cargo risczero install # installs the latest RISC Zero toolchain
cargo risczero -V
rustup toolchain list --verbose | grep risc0

Install zkGo compiler

git clone -b zkGo https://github.com/ethstorage/go.git
cd src
./all.bash
# output src/bin
cd ../bin
mv go lgo
export GOROOT="$PATH:your ethstorage go repo path"
# set the bin/ directory to your $PATH env or just copy lgo to your PATH

Install delphinus-cli

git clone https://github.com/DelphinusLab/zkWasm.git
cd zkWasm
cargo build --release
# copy ./target/release/delphinus-cli to one of your $PATH directories

Benchmark

Run Benchmarks with hyperfine.

just clean # optional
just build
just dry-run
just prove

Tested on my Mac Studio M1 Max

macos_profile zkvm_bench zkvm_prove

Test manually

Build rust version fibonacci wasm program, and copy to zkVM/zkWasm folder.

cd rust/fib-wasm
just build
just opt
just copy

dry-run Rust and zkGo version fibonacci wasm program on zkVM.

cd zkvm/wasm
just build
just opt
just dry-run-rust
just dry-run-go
just full-prove-rust

dry-run Rust and zkGo version fibonacci wasm program on zkWasm.

cd zkwasm/fib
just build
just opt
just dry-run-rust
just dry-run-go

About

Benchmarks between zkWasm and zkVM

License:Apache License 2.0


Languages

Language:Rust 54.1%Language:Just 21.7%Language:Go 17.3%Language:JavaScript 6.4%Language:Python 0.5%