Skip to content

Commit 24f5349

Browse files
authored
feat: Adding reproducible builds for verifiers (#44)
## What ❔ * shell script + Docker + CI - to create reproducible verifier binaries. ## Why ❔ * to make sure that we have the same hashes for verification keys.
1 parent 1a950cd commit 24f5349

20 files changed

+157
-51
lines changed

.dockerignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ tools/verifier/target
1818
!poseidon2
1919
!prover
2020
!risc_v_simulator
21-
!risc_v_common
21+
!riscv_common
2222
!trace_holder
2323
!transcript
2424
!verifier
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Check verifiers
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
permissions:
10+
contents: read
11+
packages: read
12+
actions: read
13+
14+
jobs:
15+
check_verifiers:
16+
runs-on: [ matterlabs-ci-runner-highmem ]
17+
steps:
18+
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3
19+
20+
- name: Build fresh verifiers
21+
run: |
22+
tools/reproduce/reproduce.sh
23+
24+
- name: Fail if any files were modified
25+
run: |
26+
git status --porcelain
27+
git diff --name-only
28+
if [ -n "$(git diff --name-only)" ]; then
29+
echo "❌ The following files were modified. Did you run tools/reproduce/reproduce.sh ?:"
30+
git diff --name-only
31+
exit 1
32+
fi

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ jobs:
242242
with:
243243
rustflags: ""
244244
- name: Setup
245+
working-directory: tools/verifier
245246
run: |
246247
rustup set profile minimal
247248
rustup target add riscv32i-unknown-none-elf

tools/reproduce/Dockerfile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Use a specific version of Rust for reproducibility
2+
FROM debian:bullseye-slim as builder
3+
4+
RUN apt-get update && apt-get install -y \
5+
curl \
6+
build-essential \
7+
git \
8+
libssl-dev \
9+
pkg-config
10+
11+
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain nightly-2025-05-24
12+
ENV PATH="/root/.cargo/bin:${PATH}"
13+
14+
RUN rustup target add riscv32i-unknown-none-elf
15+
RUN cargo install cargo-binutils
16+
RUN rustup component add llvm-tools-preview
17+
18+
19+
20+
# RUN git clone --depth 1 -b mmzk_0608_reproduce https://github.com/matter-labs/zksync-airbender.git
21+
COPY . zksync-airbender
22+
23+
WORKDIR zksync-airbender/tools/verifier
24+
25+
RUN ./build.sh

tools/reproduce/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Building reproducible verifiers
2+
3+
This docker script allows building reproducible verifiers.
4+
5+
Simply run:
6+
7+
```shell
8+
./tools/reproduce/reproduce.sh
9+
```
10+
11+
12+
from the main directory.

tools/reproduce/reproduce.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
3+
# Make sure to run from the main zksync-airbender directory.
4+
5+
set -e # Exit on any error
6+
7+
# create a fresh docker
8+
docker build -t airbender-verifiers -f tools/reproduce/Dockerfile .
9+
10+
docker create --name verifiers airbender-verifiers
11+
12+
FILES=(
13+
base_layer.bin
14+
recursion_layer.bin
15+
final_recursion_layer.bin
16+
base_layer_with_output.bin
17+
recursion_layer_with_output.bin
18+
final_recursion_layer_with_output.bin
19+
universal.bin
20+
universal_no_delegation.bin
21+
universal.reduced.vk.json
22+
universal_no_delegation.final.vk.json
23+
recursion_layer.reduced.vk.json
24+
recursion_layer_no_delegation.final.vk.json
25+
final_recursion_layer.final.vk.json
26+
)
27+
28+
for FILE in "${FILES[@]}"; do
29+
docker cp verifiers:/zksync-airbender/tools/verifier/$FILE tools/verifier/
30+
md5sum tools/verifier/$FILE
31+
done
32+
33+
34+
docker rm verifiers

tools/verifier/base_layer.bin

-156 Bytes
Binary file not shown.
-180 Bytes
Binary file not shown.
-108 Bytes
Binary file not shown.
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
22
"machine_type": "ReducedFinal",
3-
"bytecode_hash_hex": "4ea94396bec858dfe173c7fd2bbfd03fd8e65aa2e850203719bb98dc8be356b5",
3+
"bytecode_hash_hex": "d0cae4b579ed5fea6432c4ce45cab94e913304796c6bbcd6455d571f28f5e6b6",
44
"params": [
5-
852930928,
6-
4147174143,
7-
2061329541,
8-
1677886472,
9-
962794339,
10-
1645607950,
11-
3092729894,
12-
22679922
5+
4029578128,
6+
1914366547,
7+
2948266123,
8+
4237709645,
9+
2465624865,
10+
4046245566,
11+
3136125741,
12+
2506099251
1313
],
14-
"params_hex": "32d6b170f730daff7add648564028408396313636215fc0eb8575026015a1172"
14+
"params_hex": "f02e7b90721aea53afbaf88bfc96514d92f67321f12ccebebaed7b2d95600a33"
1515
}

0 commit comments

Comments
 (0)