Skip to content

Commit d66d75d

Browse files
authored
Merge pull request #321 from 0xPolygonHermez/pre-develop-0.7.0-imp-witness
Pre develop 0.7.0 + imp witness
2 parents b60aa34 + 96a8ec1 commit d66d75d

File tree

81 files changed

+482923
-1708609
lines changed

Some content is hidden

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

81 files changed

+482923
-1708609
lines changed
+137
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
name: Test ZisK Installation (binaries)
2+
3+
on:
4+
release:
5+
types:
6+
- published
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: write
11+
pull-requests: read
12+
13+
jobs:
14+
check-latest-release:
15+
name: Check if release published
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Check if the release is latest
19+
env:
20+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21+
if: github.event_name == 'release'
22+
run: |
23+
sudo apt update
24+
sudo apt install -y gh
25+
26+
LATEST_TAG=$(gh release list --limit 1 --json tagName --jq '.[0].tagName')
27+
CURRENT_TAG="${{ github.event.release.tag_name }}"
28+
29+
echo "Latest release tag: $LATEST_TAG"
30+
echo "Current release tag: $CURRENT_TAG"
31+
32+
if [[ "$CURRENT_TAG" == "$LATEST_TAG" ]]; then
33+
echo "This is the latest release!"
34+
else
35+
echo "This is NOT the latest release. Exiting..."
36+
exit 0
37+
fi
38+
39+
install-from-binaries:
40+
name: Install ZisK from binaries
41+
needs: check-latest-release
42+
runs-on: self-hosted
43+
container:
44+
image: ubuntu:22.04
45+
options: --memory=56g --cpus=16
46+
timeout-minutes: 60
47+
steps:
48+
- name: Clean home directory
49+
run: |
50+
find $HOME -mindepth 1 -delete || true
51+
ls -la $HOME
52+
rm -rf refs/heads/feature/gha-test-install-bin
53+
54+
- name: Check resources
55+
run: |
56+
echo "CPUs: $(nproc)"
57+
free -h
58+
59+
- name: Install tools
60+
run: apt-get update && apt-get install -y curl && apt-get install -y git
61+
62+
- name: Install Rust toolchain
63+
id: rustc-toolchain
64+
uses: actions-rs/toolchain@v1
65+
with:
66+
toolchain: stable
67+
profile: default
68+
override: true
69+
target: x86_64-unknown-linux-gnu
70+
71+
- name: Install ZisK dependencies
72+
shell: bash
73+
run: |
74+
apt-get install -y xz-utils jq curl build-essential qemu-system libomp-dev \
75+
libgmp-dev nlohmann-json3-dev protobuf-compiler uuid-dev libgrpc++-dev \
76+
libsecp256k1-dev libsodium-dev libpqxx-dev nasm libopenmpi-dev openmpi-bin openmpi-common
77+
78+
- name: Install and run ziskup
79+
run: |
80+
curl -s -o install.sh https://raw.githubusercontent.com/0xPolygonHermez/zisk/main/ziskup/install.sh
81+
chmod +x install.sh
82+
export GH_RUNNER=1
83+
./install.sh
84+
85+
- name: Add ZisK bin directory to PATH
86+
run: echo "$HOME/.zisk/bin" >> $GITHUB_PATH
87+
88+
- name: Create program
89+
shell: bash
90+
run: |
91+
cargo-zisk sdk new $HOME/sha_hasher
92+
93+
- name: Build program
94+
shell: bash
95+
run: |
96+
cd $HOME/sha_hasher
97+
cargo-zisk build --release
98+
99+
- name: Run program
100+
shell: bash
101+
run: |
102+
cd $HOME/sha_hasher
103+
cargo-zisk run --release -i build/input.bin | tee run_output.log
104+
if ! grep -qE "98211882|bd13089b|6ccf1fca|81f7f0e4|abf6352a|0c39c9b1|1f142cac|233f1280" run_output.log; then
105+
echo "❌ Run program failed"
106+
exit 1
107+
fi
108+
109+
- name: Program setup
110+
shell: bash
111+
run: |
112+
cd $HOME/sha_hasher
113+
cargo-zisk rom-setup -e target/riscv64ima-polygon-ziskos-elf/release/sha_hasher 2>&1 | tee romsetup_output.log
114+
if ! grep -F "ROM setup successfully completed" romsetup_output.log; then
115+
echo "❌ Program setup failed"
116+
exit 1
117+
fi
118+
119+
- name: Prove program
120+
shell: bash
121+
run: |
122+
cd $HOME/sha_hasher
123+
cargo-zisk prove -e target/riscv64ima-polygon-ziskos-elf/release/sha_hasher -i build/input.bin -o proof -a -y 2>&1 | tee prove_output.log
124+
if ! grep -F "Vadcop Final proof was verified" prove_output.log; then
125+
echo "❌ Prove program failed"
126+
exit 1
127+
fi
128+
129+
- name: Verify proof
130+
shell: bash
131+
run: |
132+
cd $HOME/sha_hasher
133+
cargo-zisk verify -p ./proof/proofs/vadcop_final_proof.json -u ./proof/publics.json 2>&1 | tee verify_output.log
134+
if ! grep -F "Stark proof was verified" verify_output.log; then
135+
echo "❌ Verify proof failed"
136+
exit 1
137+
fi

Cargo.lock

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

book/getting_started/installation.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Ubuntu 22.04 or higher is required.
2222

2323
Install all required dependencies with:
2424
```bash
25-
sudo apt-get install -y xz-utils jq curl build-essential qemu-system libomp-dev libgmp-dev nlohmann-json3-dev protobuf-compiler uuid-dev libgrpc++-dev libsecp256k1-dev libsodium-dev libpqxx-dev nasm libopenmpi-dev openmpi-bin openmpi-common
25+
sudo apt-get install -y xz-utils jq curl build-essential qemu-system libomp-dev libgmp-dev nlohmann-json3-dev protobuf-compiler uuid-dev libgrpc++-dev libsecp256k1-dev libsodium-dev libpqxx-dev nasm libopenmpi-dev openmpi-bin openmpi-common libclang-dev clang
2626
```
2727

2828
## Installing ZisK

book/getting_started/quickstart.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ This will create a project with the following structure:
3535
```
3636
.
3737
├── build.rs
38-
├── Cargo.lock
3938
├── Cargo.toml
4039
├── .gitignore
4140
└── src
@@ -123,7 +122,7 @@ This command generates the proof in the `./proof` directory. If everything goes
123122
[INFO ] ProofMan: Proofs generated successfully
124123
```
125124

126-
**Note**: You can use concurrent proof generation to reduce proving time. For more details, refer to the [Writing Programs](./writing_programs.md) guide.
125+
**Note**: You can use concurrent proof generation and GPU support to reduce proving time. For more details, refer to the [Writing Programs](./writing_programs.md) guide.
127126

128127
## Verify Proof
129128

book/getting_started/writing_programs.md

+24
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,30 @@ Running a Zisk proof with multiple processes enables efficient workload distribu
305305

306306
The total memory requirement increases proportionally with the number of processes. If each process requires approximately 25GB of memory, running P processes will require roughly (25 * P)GB of memory. Ensure that the system has sufficient available memory to accommodate all running processes.
307307

308+
### GPU proof generation
309+
310+
Zisk proofs can also be generated using GPUs to significantly improve performance and scalability.
311+
Follow these steps to enable GPU support:
312+
313+
1. GPU support is only available for NVIDIA GPUs.
314+
315+
2. Build Zisk with GPU support enabled.
316+
GPU support must be enabled at compile time. Follow the instructions in the **Build ZisK** section under **Option 2: Building from source** in the [Installation](./installation.md) guide, but replace the build command with:
317+
```bash
318+
cargo build --release --features gpu
319+
```
320+
321+
3. Build Zisk on the target GPU server.
322+
It is recommended to compile Zisk directly on the server where it will be executed. The binary will be optimized for the local GPU architecture, which can lead to better runtime performance.
323+
324+
You can combine GPU-based execution with concurrent proof generation using multiple processes, as described in the **Concurrent Proof Generation** section. For better performance in this setup, it is recommended to enable [NVIDIA’s Multi-Process Service (MPS)](https://docs.nvidia.com/deploy/mps/index.html). You can activate it by running:
325+
```bash
326+
nvidia-cuda-mps-control -d
327+
```
328+
329+
> **Note:** GPU memory is typically more limited than CPU memory. When combining GPU execution with concurrent proof generation, ensure that each process has sufficient memory available on the GPU to avoid out-of-memory errors.
330+
331+
308332
### Verify Proof
309333

310334
To verify a generated proof, use the following command:

cli/src/bin/cargo-zisk.rs

+20-16
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use anyhow::{anyhow, Context, Result};
22
use cargo_zisk::{
33
commands::{
4-
ZiskBuild, ZiskCheckSetup, ZiskProve, ZiskRomSetup, ZiskRun, ZiskSdk, ZiskVerify,
5-
ZiskVerifyConstraints,
4+
ZiskBuild, ZiskCheckSetup, ZiskClean, ZiskProve, ZiskRomSetup, ZiskRun, ZiskSdk,
5+
ZiskVerify, ZiskVerifyConstraints,
66
},
77
ZISK_VERSION_MESSAGE,
88
};
@@ -18,45 +18,49 @@ use clap::Parser;
1818
long_about = "Cargo Zisk is a command-line tool to manage Zisk projects."
1919
)]
2020
pub enum Cargo {
21-
Sdk(ZiskSdk),
22-
Run(ZiskRun),
2321
Build(ZiskBuild),
24-
Prove(ZiskProve),
2522
CheckSetup(ZiskCheckSetup),
23+
Clean(ZiskClean),
24+
Prove(ZiskProve),
2625
RomSetup(ZiskRomSetup),
27-
VerifyConstraints(ZiskVerifyConstraints),
26+
Run(ZiskRun),
27+
Sdk(ZiskSdk),
2828
Verify(ZiskVerify),
29+
VerifyConstraints(ZiskVerifyConstraints),
2930
}
3031

3132
fn main() -> Result<()> {
3233
// Parse command-line arguments and handle errors if they occur.
3334
let cargo_args = Cargo::parse();
3435

3536
match cargo_args {
36-
Cargo::Sdk(cmd) => {
37-
cmd.command.run().context("Error executing SDK command")?;
38-
}
39-
Cargo::Run(cmd) => {
40-
cmd.run().context("Error executing Run command")?;
41-
}
4237
Cargo::Build(cmd) => {
4338
cmd.run().context("Error executing Build command")?;
4439
}
4540
Cargo::CheckSetup(cmd) => {
4641
cmd.run().context("Error executing CheckSetup command")?;
4742
}
48-
Cargo::Prove(args) => {
49-
args.run().context("Error executing Prove command")?;
43+
Cargo::Clean(cmd) => {
44+
cmd.run().context("Error executing Clean command")?;
45+
}
46+
Cargo::Prove(mut cmd) => {
47+
cmd.run().context("Error executing Prove command")?;
5048
}
5149
Cargo::RomSetup(cmd) => {
5250
cmd.run().context("Error executing RomSetup command")?;
5351
}
54-
Cargo::VerifyConstraints(cmd) => {
55-
cmd.run().context("Error executing VerifyConstraints command")?;
52+
Cargo::Run(cmd) => {
53+
cmd.run().context("Error executing Run command")?;
54+
}
55+
Cargo::Sdk(cmd) => {
56+
cmd.command.run().context("Error executing SDK command")?;
5657
}
5758
Cargo::Verify(cmd) => {
5859
cmd.run().map_err(|e| anyhow!("Error executing Verify command: {}", e))?;
5960
}
61+
Cargo::VerifyConstraints(mut cmd) => {
62+
cmd.run().context("Error executing VerifyConstraints command")?;
63+
}
6064
}
6165

6266
Ok(())

cli/src/commands/clean.rs

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
use std::fs;
2+
3+
use clap::Parser;
4+
use colored::Colorize;
5+
6+
use anyhow::{Context, Result};
7+
use log::info;
8+
use proofman_common::initialize_logger;
9+
10+
use crate::{commands::get_home_zisk_path, ux::print_banner};
11+
12+
/// Deletes the default zisk setup folder
13+
#[derive(Parser, Debug)]
14+
#[command(version, about = "Remove the cache directory", long_about = None)]
15+
pub struct ZiskClean;
16+
17+
impl ZiskClean {
18+
pub fn run(&self) -> Result<()> {
19+
initialize_logger(proofman_common::VerboseMode::Info);
20+
21+
print_banner();
22+
println!("{} Clean", format!("{: >12}", "Command").bright_green().bold());
23+
24+
println!();
25+
26+
let home_zisk_path = get_home_zisk_path();
27+
let cache_zisk_path = home_zisk_path.join("cache");
28+
29+
if home_zisk_path.exists() {
30+
info!("Removing default zisk path at: {}", cache_zisk_path.display());
31+
32+
fs::remove_dir_all(&cache_zisk_path).with_context(|| {
33+
format!("Failed to remove directory {}", cache_zisk_path.display())
34+
})?;
35+
36+
info!("{} Successfully removed {}", "[OK]".green().bold(), cache_zisk_path.display());
37+
} else {
38+
info!(
39+
"{} No zisk setup directory found at {}",
40+
"[WARN]".yellow(),
41+
cache_zisk_path.display()
42+
);
43+
}
44+
45+
Ok(())
46+
}
47+
}

cli/src/commands/common.rs

+6
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ pub fn get_default_proving_key() -> PathBuf {
4949
PathBuf::from(proving_key)
5050
}
5151

52+
/// Gets the default zisk folder location in the home installation directory.
53+
pub fn get_home_zisk_path() -> PathBuf {
54+
let zisk_path = format!("{}/.zisk", get_home_dir());
55+
PathBuf::from(zisk_path)
56+
}
57+
5258
/// Gets the default zisk folder location in the home installation directory.
5359
pub fn get_default_zisk_path() -> PathBuf {
5460
let zisk_path = format!("{}/.zisk/zisk", get_home_dir());

0 commit comments

Comments
 (0)