Skip to content

Commit 6811311

Browse files
committed
Update to Zisk v1.0.0-alpha via the argumentcomputer blake3-precompile fork
Sources move from upstream v0.17.0 to the argumentcomputer/zisk fork at e4057c4c (blake3-precompile), which is upstream v1.0.0-alpha plus a Blake3 compression precompile, with pil2-proofman pinned at v1.0.0-alpha and the Zisk Rust toolchain at zisk-1.0.0 (rustc 1.94.0). Build fixes for the new versions: - Vendored proofman-starks-lib-c build.rs acquires a file lock next to the pil2-stark sources; relocate it to OUT_DIR since the prebuilt pil2-stark is a read-only store path. - Vendored pil2-stark-setup embeds the proofman repo-root package.json via include_str\!("../../package.json"); copy the file into the extracted crate during vendoring. - gmp-mpfr-sys builds GMP from source and needs m4/file. - The +zisk rustup selector seds follow the CLI split (user/dev commands). Layout changes: - cargo-zisk-dev (new home of check-setup and proofman-setup) is built, wrapped, and linked into zisk-home. - libziskc.a moves to bin/ (emulator-asm links it via -L../../bin) and zisk-home ships lib-c/c/src headers, mirroring the release tarball. - install-proving-key fetches the fork-matching key (extra Blake3f AIR) from argument-zisk-setup S3 and regenerates const-trees with cargo-zisk-dev check-setup, matching ziskup's flow. - Dev shell exports ZISK_HOME, the env var the new binaries read. The sha_hasher template consumes zisk-sdk/ziskos from the fork branch. The Docker image fetches ziskup from the fork rev and gains an install-proving-key script for the fork key alongside ziskup's upstream key install (upstream binaries need the upstream key; fork-built SDK hosts need the fork key).
1 parent d7fd3b8 commit 6811311

11 files changed

Lines changed: 222 additions & 86 deletions

File tree

docker/Dockerfile

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,69 @@
11
FROM ubuntu:24.04
22

33
ENV DEBIAN_FRONTEND=noninteractive
4+
ENV SHELL=/bin/bash
45

56
# Base Zisk dependencies
7+
# Source: https://0xpolygonhermez.github.io/zisk/getting_started/installation.html
8+
# pkg-config/libssl-dev on top of the book's list: needed to cargo-build SDK
9+
# host programs (openssl-sys) inside the container.
610
RUN apt-get update && apt-get install -y \
711
xz-utils jq curl build-essential qemu-system \
812
libomp-dev libgmp-dev nlohmann-json3-dev protobuf-compiler \
913
uuid-dev libgrpc++-dev libsecp256k1-dev libsodium-dev \
1014
libpqxx-dev nasm libopenmpi-dev openmpi-bin openmpi-common \
1115
libclang-dev clang gcc-riscv64-unknown-elf git \
16+
pkg-config libssl-dev \
1217
&& rm -rf /var/lib/apt/lists/*
1318

1419
# Install Rust
1520
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
1621
ENV PATH="/root/.cargo/bin:${PATH}"
1722

18-
# Install ZisK via ziskup
19-
# Set SETUP_KEY environment variable to bypass TTY prompt
20-
RUN curl -fsSL https://raw.githubusercontent.com/0xPolygonHermez/zisk/main/ziskup/install.sh -o /tmp/install.sh && \
21-
SETUP_KEY=proving bash /tmp/install.sh && \
22-
rm /tmp/install.sh
23+
# Install the ziskup installer, pinned to the argumentcomputer fork rev the
24+
# rest of this repo tracks (the fork's ziskup honors the ZISK_VERSION/SETUP_KEY
25+
# env vars and key modes that zisk-shell relies on). Binaries and setup keys
26+
# are not installed at build time — run `ziskup` inside the container (or
27+
# invoke zisk-shell with --gpu/--cpu/--key) to choose them. ziskup installs
28+
# the ZISK_VERSION *upstream* release binaries and its matching key from the
29+
# upstream bucket (the fork publishes no releases).
30+
ARG ZISK_FORK_REV=e4057c4cd6daaa29ea54f283ff27818acc9be8b2
31+
ARG ZISK_VERSION=1.0.0-alpha
32+
ENV ZISK_VERSION=${ZISK_VERSION}
33+
RUN mkdir -p /root/.zisk/bin && \
34+
curl -fsSL "https://raw.githubusercontent.com/argumentcomputer/zisk/${ZISK_FORK_REV}/ziskup/ziskup" \
35+
-o /root/.zisk/bin/ziskup && \
36+
chmod +x /root/.zisk/bin/ziskup
2337
ENV PATH="/root/.zisk/bin:${PATH}"
2438

39+
# Installer for the fork-matching proving key (extra Blake3f AIR), mirroring
40+
# this repo's `nix run .#install-proving-key`. Use it INSTEAD of ziskup's key
41+
# install when the prover is built from the fork sources (e.g. an SDK host
42+
# linking zisk-sdk from the blake3-precompile branch); use ziskup's upstream
43+
# key for the upstream release binaries. Both keys land in
44+
# $ZISK_DIR/provingKey — the last one installed wins.
45+
# The tarball omits the const-tree files; check-setup (from the ziskup-installed
46+
# binaries, so run `ziskup` first) regenerates them.
47+
RUN cat > /root/.zisk/bin/install-proving-key <<'EOF' && chmod +x /root/.zisk/bin/install-proving-key
48+
#!/usr/bin/env bash
49+
set -euo pipefail
50+
ZISK_DIR="${ZISK_DIR:-$HOME/.zisk}"
51+
command -v cargo-zisk-dev >/dev/null || {
52+
echo "cargo-zisk-dev not found - run 'ziskup --nokey' first" >&2
53+
exit 1
54+
}
55+
KEY_FILE="zisk-provingkey-blake3-e4057c4c-cpu.tar.gz"
56+
echo "Downloading fork proving key to $ZISK_DIR (this may take a while)..."
57+
curl -fSL --retry 3 -o "/tmp/$KEY_FILE" \
58+
"https://argument-zisk-setup.s3.amazonaws.com/$KEY_FILE"
59+
rm -rf "$ZISK_DIR/provingKey"
60+
tar -C "$ZISK_DIR" -xzf "/tmp/$KEY_FILE"
61+
rm -f "/tmp/$KEY_FILE"
62+
echo "Generating constant tree..."
63+
cargo-zisk-dev check-setup --proving-key "$ZISK_DIR/provingKey" -a
64+
echo "Proving key setup complete."
65+
EOF
66+
2567
WORKDIR /workspace
2668

2769
CMD ["/bin/bash"]

docker/build-image.nix

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{pkgs, ...}: let
22
dockerfile = ./Dockerfile;
33
in
4-
pkgs.writeShellScriptBin "zisk-build" ''
5-
echo "Building Zisk image"
6-
${pkgs.podman}/bin/podman build \
7-
-f ${dockerfile} \
8-
-t localhost/cargo-zisk:latest \
9-
"''${1:-$PWD}"
10-
''
4+
pkgs.writeShellScriptBin "zisk-build" ''
5+
echo "Building Zisk image"
6+
${pkgs.podman}/bin/podman build \
7+
-f ${dockerfile} \
8+
-t localhost/cargo-zisk:latest \
9+
"''${1:-$PWD}"
10+
''

docker/zisk-shell.nix

Lines changed: 96 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,104 @@
11
# Container will continue running on exit
22
# Remove with `podman kill zisk-dev && podman rm zisk-dev`
33
{pkgs, ...}:
4-
pkgs.writeShellScriptBin "zisk-shell" ''
5-
set -e
4+
pkgs.writeShellScriptBin "zisk-shell" ''
5+
set -e
66
7-
CONTAINER_NAME="''${ZISK_CONTAINER_NAME:-zisk-dev}"
8-
IMAGE_NAME="''${ZISK_IMAGE:-localhost/cargo-zisk:latest}"
9-
SHELL="''${ZISK_SHELL:-/bin/bash}"
7+
CONTAINER_NAME="''${ZISK_CONTAINER_NAME:-zisk-dev}"
8+
IMAGE_NAME="''${ZISK_IMAGE:-localhost/cargo-zisk:latest}"
9+
SHELL="''${ZISK_SHELL:-/bin/bash}"
1010
11-
# Check if container exists
12-
if ${pkgs.podman}/bin/podman container exists "$CONTAINER_NAME"; then
13-
# Container exists, check if it's running
14-
STATUS=$(${pkgs.podman}/bin/podman inspect -f '{{.State.Status}}' "$CONTAINER_NAME")
11+
DEVICE=
12+
KEY=
13+
SETUP=0
1514
16-
if [ "$STATUS" != "running" ]; then
17-
echo "Starting stopped container: $CONTAINER_NAME"
18-
${pkgs.podman}/bin/podman start "$CONTAINER_NAME"
15+
usage() {
16+
cat <<EOF
17+
Usage: zisk-shell [OPTIONS]
18+
19+
Enter a shell in the Zisk container. If setup options are passed, ziskup is
20+
run inside the container before the shell starts (use this to install or
21+
switch CPU/GPU binaries and setup keys).
22+
23+
Options:
24+
--gpu, --cpu Select GPU or CPU binaries
25+
--key KEY Setup key: proving | proving-no-consttree | verify | none
26+
--provingkey Shortcut for --key proving
27+
--verifykey Shortcut for --key verify
28+
--nokey Shortcut for --key none
29+
-h, --help Show this help
30+
31+
Environment:
32+
ZISK_CONTAINER_NAME (default: zisk-dev)
33+
ZISK_IMAGE (default: localhost/cargo-zisk:latest)
34+
ZISK_SHELL (default: /bin/bash)
35+
EOF
36+
}
37+
38+
while [ $# -gt 0 ]; do
39+
case "$1" in
40+
--gpu) DEVICE=gpu; SETUP=1; shift ;;
41+
--cpu) DEVICE=cpu; SETUP=1; shift ;;
42+
--key) KEY="$2"; SETUP=1; shift 2 ;;
43+
--provingkey) KEY=proving; SETUP=1; shift ;;
44+
--verifykey) KEY=verify; SETUP=1; shift ;;
45+
--nokey) KEY=none; SETUP=1; shift ;;
46+
-h|--help) usage; exit 0 ;;
47+
*)
48+
echo "zisk-shell: unknown option: $1" >&2
49+
usage >&2
50+
exit 1
51+
;;
52+
esac
53+
done
54+
55+
if [ -n "$KEY" ]; then
56+
case "$KEY" in
57+
proving|proving-no-consttree|verify|none) ;;
58+
*)
59+
echo "zisk-shell: invalid --key value: $KEY" >&2
60+
exit 1
61+
;;
62+
esac
63+
fi
64+
65+
PODMAN=${pkgs.podman}/bin/podman
66+
67+
# Check if container exists
68+
if "$PODMAN" container exists "$CONTAINER_NAME"; then
69+
STATUS=$("$PODMAN" inspect -f '{{.State.Status}}' "$CONTAINER_NAME")
70+
71+
if [ "$STATUS" != "running" ]; then
72+
echo "Starting stopped container: $CONTAINER_NAME"
73+
"$PODMAN" start "$CONTAINER_NAME"
74+
else
75+
echo "Container $CONTAINER_NAME is already running"
76+
fi
1977
else
20-
echo "Container $CONTAINER_NAME is already running"
78+
echo "Creating new container: $CONTAINER_NAME"
79+
"$PODMAN" run -dit \
80+
--name "$CONTAINER_NAME" \
81+
--privileged \
82+
--ulimit memlock=-1:-1 \
83+
--ipc=host \
84+
"$IMAGE_NAME" \
85+
"$SHELL"
2186
fi
22-
else
23-
# Container doesn't exist, create it in detached mode
24-
echo "Creating new container: $CONTAINER_NAME"
25-
${pkgs.podman}/bin/podman run -dit \
26-
--name "$CONTAINER_NAME" \
27-
--privileged \
28-
--ulimit memlock=-1:-1 \
29-
--ipc=host \
30-
"$IMAGE_NAME" \
31-
"$SHELL"
32-
fi
33-
34-
# Enter the container using exec
35-
echo "Entering container... (container will persist after exit)"
36-
${pkgs.podman}/bin/podman exec -it "$CONTAINER_NAME" "$SHELL"
37-
''
87+
88+
if [ "$SETUP" -eq 1 ]; then
89+
ZISKUP_ARGS=
90+
[ "$DEVICE" = "gpu" ] && ZISKUP_ARGS="$ZISKUP_ARGS --gpu"
91+
[ "$DEVICE" = "cpu" ] && ZISKUP_ARGS="$ZISKUP_ARGS --cpu"
92+
ENV_ARGS=
93+
if [ -n "$KEY" ]; then
94+
ENV_ARGS="-e SETUP_KEY=$KEY"
95+
fi
96+
echo "Running ziskup in container (device=''${DEVICE:-default}, key=''${KEY:-default})"
97+
# shellcheck disable=SC2086
98+
"$PODMAN" exec -it $ENV_ARGS "$CONTAINER_NAME" \
99+
/root/.zisk/bin/ziskup $ZISKUP_ARGS
100+
fi
101+
102+
echo "Entering container... (container will persist after exit)"
103+
"$PODMAN" exec -it "$CONTAINER_NAME" "$SHELL"
104+
''

flake.nix

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -52,21 +52,18 @@
5252
builtins.elem (nixpkgs.lib.getName pkg) ["mkl"];
5353
};
5454

55+
# argumentcomputer/zisk fork: upstream v1.0.0-alpha + Blake3 compression
56+
# precompile. The proving key on S3 is generated from this exact rev,
57+
# so the two must move together.
5558
ziskSrc = pkgs.fetchgit {
56-
url = "https://github.com/0xPolygonHermez/zisk";
57-
rev = "v0.17.0";
58-
sha256 = "sha256-ZVlMF3EUzk1kajzXwnW7+Tj1Ms9p6bFGGZPKx7v1nZo=";
59-
fetchSubmodules = true;
60-
};
61-
ziskSrcLite = pkgs.fetchgit {
62-
url = "https://github.com/0xPolygonHermez/zisk";
63-
rev = "v0.17.0";
64-
sha256 = "sha256-ZVlMF3EUzk1kajzXwnW7+Tj1Ms9p6bFGGZPKx7v1nZo=";
59+
url = "https://github.com/argumentcomputer/zisk";
60+
rev = "e4057c4cd6daaa29ea54f283ff27818acc9be8b2"; # blake3-precompile
61+
sha256 = "sha256-hJyomTWYCDI7sNE/YwFMUS4U1B8lXyDDy/FHEzhoKF4=";
6562
};
6663
proofmanSrc = pkgs.fetchgit {
6764
url = "https://github.com/0xPolygonHermez/pil2-proofman";
68-
rev = "v0.17.0";
69-
sha256 = "sha256-JmFlGh+q82v/p8Eg0YO6GvwQyyS/dQW0udPGizo2H+g=";
65+
rev = "v1.0.0-alpha";
66+
sha256 = "sha256-QHI3AsCZzYrgpt6vUAt8uH/dYRjw+/+H+gOJjmg2E+I=";
7067
fetchSubmodules = true;
7168
};
7269

@@ -85,21 +82,24 @@
8582
text = ''
8683
ZISK_DIR="''${ZISK_DIR:-$HOME/.zisk}"
8784
mkdir -p "$ZISK_DIR"
88-
ZISK_SETUP_FILE="zisk-provingkey-0.17.0.tar.gz"
85+
# Fork-matching key (extra Blake3f AIR): the upstream zisk-setup
86+
# bucket key does not match this circuit. The object name carries
87+
# the fork rev; the tarball omits the const-tree files, which
88+
# check-setup regenerates below.
89+
ZISK_SETUP_FILE="zisk-provingkey-blake3-e4057c4c-cpu.tar.gz"
8990
echo "Downloading proving key to $ZISK_DIR (this may take a while)..."
9091
rm -rf "$ZISK_DIR/provingKey"
91-
curl -fL -o "/tmp/$ZISK_SETUP_FILE" \
92-
"https://storage.googleapis.com/zisk-setup/$ZISK_SETUP_FILE"
92+
curl -fL --retry 3 -o "/tmp/$ZISK_SETUP_FILE" \
93+
"https://argument-zisk-setup.s3.amazonaws.com/$ZISK_SETUP_FILE"
9394
tar xf "/tmp/$ZISK_SETUP_FILE" -C "$ZISK_DIR"
9495
rm -f "/tmp/$ZISK_SETUP_FILE"
9596
echo "Generating constant tree..."
96-
cargo-zisk check-setup -a
97+
cargo-zisk-dev check-setup --proving-key "$ZISK_DIR/provingKey" -a
9798
echo "Proving key setup complete."
9899
'';
99100
};
100101
zisk-home = pkgs.callPackage ./pkgs/zisk-home.nix {
101-
inherit cargo-zisk zisk-toolchain ziskemu craneLib proofmanSrc;
102-
ziskSrc = ziskSrcLite;
102+
inherit cargo-zisk zisk-toolchain ziskemu craneLib proofmanSrc ziskSrc;
103103
};
104104
rustup-shim = pkgs.callPackage ./pkgs/rustup-shim.nix {
105105
inherit zisk-toolchain rustToolchain;
@@ -147,6 +147,8 @@
147147
secp256k1
148148
nlohmann_json
149149
nasm
150+
m4
151+
file
150152
libgit2
151153
mpi
152154
clang
@@ -177,8 +179,10 @@
177179
shellHook = ''
178180
echo "Standard Rust: $(cargo --version)"
179181
180-
# Set up ZISK_DIR in $HOME
182+
# Set up ZISK_DIR in $HOME (ZISK_HOME is what the zisk binaries
183+
# read; it defaults to $HOME/.zisk but pin it explicitly)
181184
export ZISK_DIR="$HOME/.zisk"
185+
export ZISK_HOME="$ZISK_DIR"
182186
mkdir -p "$ZISK_DIR"
183187
184188
# Always sync binaries from Nix store to ensure updates are applied

pkgs/cargo-zisk.nix

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ in
1818
cargoExtraArgs = "-p cargo-zisk -p zisk-core -p zisk-coordinator-server -p zisk-worker";
1919

2020
postPatch = ''
21-
# Remove rustup-specific +zisk arguments (we use RUSTC env var instead)
22-
sed -i 's/\["+zisk", "build"\]/["build"]/g' cli/src/commands/build.rs
23-
sed -i 's/\["+zisk", "run"\]/["run"]/g' cli/src/commands/run.rs
21+
# Remove rustup-specific +zisk toolchain selectors (we use the RUSTC
22+
# env var instead)
23+
sed -i 's/vec!\[format!("+{toolchain_name}"), "build".to_string()\]/vec!["build".to_string()]/' cli/src/commands/user/build.rs
24+
sed -i 's/vec!\["+zisk".to_string(), "build".to_string()\]/vec!["build".to_string()]/' cli/src/commands/user/run.rs
2425
sed -i 's/\["+zisk", "build"\]/["build"]/g' ziskbuild/src/command.rs
2526
'';
2627

@@ -32,9 +33,11 @@ in
3233
];
3334

3435
postInstall = ''
35-
wrapProgram $out/bin/cargo-zisk \
36-
--set RUSTC "${zisk-toolchain}/bin/rustc" \
37-
--prefix LD_LIBRARY_PATH : "${common.commonArgs.LD_LIBRARY_PATH}"
36+
for bin in cargo-zisk cargo-zisk-dev; do
37+
wrapProgram $out/bin/$bin \
38+
--set RUSTC "${zisk-toolchain}/bin/rustc" \
39+
--prefix LD_LIBRARY_PATH : "${common.commonArgs.LD_LIBRARY_PATH}"
40+
done
3841
3942
for bin in riscv2zisk zisk-coordinator zisk-worker; do
4043
if [ -f "$out/bin/$bin" ]; then

pkgs/common.nix

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
ziskSrc,
88
proofmanSrc,
99
}: rec {
10-
version = "0.17.0";
10+
version = "1.0.0-alpha";
1111

1212
# Pre-built pil2-stark with libstarks.a (build.rs sees it exists and skips make)
1313
pil2Stark = pkgs.callPackage ./pil2-stark.nix {inherit proofmanSrc;};
@@ -27,6 +27,21 @@
2727
[ -f "$f" ] || continue
2828
sed -i 's@let pil2_stark_path_raw = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../pil2-stark");@let pil2_stark_path_raw = std::env::var("PIL2_STARK_DIR").map(std::path::PathBuf::from).unwrap_or_else(|_| Path::new(env!("CARGO_MANIFEST_DIR")).join("../../pil2-stark"));@' "$f"
2929
sed -i 's@run_command("make"@run_command("true"@g' "$f"
30+
# The build lock lives next to the pil2-stark sources, which is a
31+
# read-only store path here; relocate it to OUT_DIR.
32+
sed -i 's@let lock_path = pil2_stark_path.join(".build_lock");@let lock_path = Path::new(\&env::var("OUT_DIR").unwrap()).join(".build_lock");@' "$f"
33+
done
34+
35+
# pil2-stark-setup embeds the proofman repo-root package.json via
36+
# include_str!("../../package.json"), but vendoring extracts each
37+
# crate dir in isolation. postInstall runs from the full repo
38+
# checkout, so copy the file into the crate and point the include
39+
# at it.
40+
for d in $out/pil2-stark-setup-*; do
41+
[ -d "$d" ] && [ -f package.json ] || continue
42+
cp package.json "$d/"
43+
sed -i 's@"/../../package.json"@"/package.json"@' \
44+
"$d/src/proving_key/node_deps.rs"
3045
done
3146
'';
3247
});
@@ -48,6 +63,9 @@
4863
gnumake
4964
cmake
5065
llvmPackages.openmp
66+
# gmp-mpfr-sys builds GMP from source, which needs m4 (and probes file)
67+
m4
68+
file
5169
];
5270

5371
buildInputs = with pkgs; [

pkgs/pil2-stark.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
}:
1515
stdenv.mkDerivation {
1616
pname = "pil2-stark";
17-
version = "0.17.0";
17+
version = "1.0.0-alpha";
1818

1919
src = "${proofmanSrc}/pil2-stark";
2020

0 commit comments

Comments
 (0)