Skip to content

Commit b453b52

Browse files
lispcVelaciela
andauthored
rewrite build guest (#172)
* rewrite build guest * add --output to build-guest * update release scripts * support gpu! * fix build * upgrade plonky3-gpu v0.2.2 * revert * lint * fix verifier --------- Co-authored-by: Velaciela <git.rover@outlook.com>
1 parent 3057de5 commit b453b52

File tree

24 files changed

+2375
-345
lines changed

24 files changed

+2375
-345
lines changed

.dockerignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,11 @@ Dockerfile.backup
1111

1212
docs
1313

14-
releases
14+
#releases
1515

1616
*.yml
1717

1818
*.sh
19-
!build-guest-actions-entrypoint.sh
2019

2120
*.log
2221
*.md

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml.gpu

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
[patch."https://github.com/openvm-org/openvm.git"]
2+
openvm-build = { git = "ssh://git@github.com/scroll-tech/openvm-gpu.git", branch = "patch-v1.4.0-c033e18-pipe", default-features = false }
3+
openvm-circuit = { git = "ssh://git@github.com/scroll-tech/openvm-gpu.git", branch = "patch-v1.4.0-c033e18-pipe", default-features = false }
4+
openvm-continuations = { git = "ssh://git@github.com/scroll-tech/openvm-gpu.git", branch = "patch-v1.4.0-c033e18-pipe", default-features = false }
5+
openvm-instructions ={ git = "ssh://git@github.com/scroll-tech/openvm-gpu.git", branch = "patch-v1.4.0-c033e18-pipe", default-features = false }
6+
openvm-native-circuit = { git = "ssh://git@github.com/scroll-tech/openvm-gpu.git", branch = "patch-v1.4.0-c033e18-pipe", default-features = false }
7+
openvm-native-compiler = { git = "ssh://git@github.com/scroll-tech/openvm-gpu.git", branch = "patch-v1.4.0-c033e18-pipe", default-features = false }
8+
openvm-native-recursion = { git = "ssh://git@github.com/scroll-tech/openvm-gpu.git", branch = "patch-v1.4.0-c033e18-pipe", default-features = false }
9+
openvm-native-transpiler = { git = "ssh://git@github.com/scroll-tech/openvm-gpu.git", branch = "patch-v1.4.0-c033e18-pipe", default-features = false }
10+
openvm-rv32im-transpiler = { git = "ssh://git@github.com/scroll-tech/openvm-gpu.git", branch = "patch-v1.4.0-c033e18-pipe", default-features = false }
11+
openvm-sdk = { git = "ssh://git@github.com/scroll-tech/openvm-gpu.git", branch = "patch-v1.4.0-c033e18-pipe", default-features = false, features = ["parallel", "bench-metrics", "evm-prove"] }
12+
openvm-transpiler = { git = "ssh://git@github.com/scroll-tech/openvm-gpu.git", branch = "patch-v1.4.0-c033e18-pipe", default-features = false }
13+
14+
[patch."https://github.com/openvm-org/stark-backend.git"]
15+
openvm-stark-backend = { git = "ssh://git@github.com/scroll-tech/openvm-stark-gpu.git", branch = "update-p3-gpu-v0.2.2", features = ["gpu"] }
16+
openvm-stark-sdk = { git = "ssh://git@github.com/scroll-tech/openvm-stark-gpu.git", branch = "update-p3-gpu-v0.2.2", features = ["gpu"] }
17+
18+
[patch."https://github.com/Plonky3/Plonky3.git"]
19+
p3-air = { git = "ssh://git@github.com/scroll-tech/plonky3-gpu.git", tag = "v0.2.2" }
20+
p3-field = { git = "ssh://git@github.com/scroll-tech/plonky3-gpu.git", tag = "v0.2.2" }
21+
p3-commit = { git = "ssh://git@github.com/scroll-tech/plonky3-gpu.git", tag = "v0.2.2" }
22+
p3-matrix = { git = "ssh://git@github.com/scroll-tech/plonky3-gpu.git", tag = "v0.2.2" }
23+
p3-baby-bear = { git = "ssh://git@github.com/scroll-tech/plonky3-gpu.git", features = [
24+
"nightly-features",
25+
], tag = "v0.2.2" }
26+
p3-koala-bear = { git = "ssh://git@github.com/scroll-tech/plonky3-gpu.git", tag = "v0.2.2" }
27+
p3-util = { git = "ssh://git@github.com/scroll-tech/plonky3-gpu.git", tag = "v0.2.2" }
28+
p3-challenger = { git = "ssh://git@github.com/scroll-tech/plonky3-gpu.git", tag = "v0.2.2" }
29+
p3-dft = { git = "ssh://git@github.com/scroll-tech/plonky3-gpu.git", tag = "v0.2.2" }
30+
p3-fri = { git = "ssh://git@github.com/scroll-tech/plonky3-gpu.git", tag = "v0.2.2" }
31+
p3-goldilocks = { git = "ssh://git@github.com/scroll-tech/plonky3-gpu.git", tag = "v0.2.2" }
32+
p3-keccak = { git = "ssh://git@github.com/scroll-tech/plonky3-gpu.git", tag = "v0.2.2" }
33+
p3-keccak-air = { git = "ssh://git@github.com/scroll-tech/plonky3-gpu.git", tag = "v0.2.2" }
34+
p3-blake3 = { git = "ssh://git@github.com/scroll-tech/plonky3-gpu.git", tag = "v0.2.2" }
35+
p3-mds = { git = "ssh://git@github.com/scroll-tech/plonky3-gpu.git", tag = "v0.2.2" }
36+
p3-merkle-tree = { git = "ssh://git@github.com/scroll-tech/plonky3-gpu.git", tag = "v0.2.2" }
37+
p3-monty-31 = { git = "ssh://git@github.com/scroll-tech/plonky3-gpu.git", tag = "v0.2.2" }
38+
p3-poseidon = { git = "ssh://git@github.com/scroll-tech/plonky3-gpu.git", tag = "v0.2.2" }
39+
p3-poseidon2 = { git = "ssh://git@github.com/scroll-tech/plonky3-gpu.git", tag = "v0.2.2" }
40+
p3-poseidon2-air = { git = "ssh://git@github.com/scroll-tech/plonky3-gpu.git", tag = "v0.2.2" }
41+
p3-symmetric = { git = "ssh://git@github.com/scroll-tech/plonky3-gpu.git", tag = "v0.2.2" }
42+
p3-uni-stark = { git = "ssh://git@github.com/scroll-tech/plonky3-gpu.git", tag = "v0.2.2" }
43+
p3-maybe-rayon = { git = "ssh://git@github.com/scroll-tech/plonky3-gpu.git", tag = "v0.2.2" } # the "parallel" feature is NOT on by default to allow single-threaded benchmarking
44+
p3-bn254-fr = { git = "ssh://git@github.com/scroll-tech/plonky3-gpu.git", tag = "v0.2.2" }

Makefile

Lines changed: 24 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ export RUST_LOG
1010
OPENVM_RUST_TOOLCHAIN ?= nightly-2025-08-18
1111
export OPENVM_RUST_TOOLCHAIN
1212

13-
TESTDATA_PATH := crates/integration/testdata/phase2
14-
CHUNK_PROOF := 1-4
15-
16-
$(info TESTDATA_PATH set to: $(TESTDATA_PATH))
13+
# Set GPU config if GPU=1 is set
14+
ifeq ($(GPU),1)
15+
CARGO_CONFIG_FLAG = --config Cargo.toml.gpu
16+
else
17+
CARGO_CONFIG_FLAG =
18+
endif
1719

1820
download-release:
1921
sh download-release.sh
@@ -40,54 +42,47 @@ build-guest-local:
4042

4143
clean-build-guest: clean-guest build-guest
4244

43-
clean-test-cache:
44-
@rm -f $(TESTDATA_PATH)/proofs/*.json
45-
46-
$(TESTDATA_PATH)/proofs/chunk-%.json:
47-
@OUTPUT_DIR=$(realpath $(TESTDATA_PATH)/proofs) $(MAKE) test-single-chunk
48-
cp -f $(TESTDATA_PATH)/proofs/chunk/proofs/*.json $(TESTDATA_PATH)/proofs
49-
5045
profile-chunk:
51-
@GUEST_PROFILING=true cargo test --release -p scroll-zkvm-integration --test chunk_circuit guest_profiling -- --exact --nocapture
46+
@GUEST_PROFILING=true cargo test $(CARGO_CONFIG_FLAG) --release -p scroll-zkvm-integration --test chunk_circuit guest_profiling -- --exact --nocapture
5247

5348
export-onchain-verifier:
54-
@cargo test --release -p scroll-zkvm-integration --test onchain_verifier export_onchain_verifier -- --exact --nocapture
49+
@cargo test $(CARGO_CONFIG_FLAG) --release -p scroll-zkvm-integration --test onchain_verifier export_onchain_verifier -- --exact --nocapture
5550

5651
test-execute-chunk:
57-
@cargo test --release -p scroll-zkvm-integration --test chunk_circuit test_execute -- --exact --nocapture
52+
@cargo test $(CARGO_CONFIG_FLAG) --release -p scroll-zkvm-integration --test chunk_circuit test_execute -- --exact --nocapture
5853

5954
test-execute-chunk-multi:
60-
@cargo test --release -p scroll-zkvm-integration --test chunk_circuit test_execute_multi -- --exact --nocapture
55+
@cargo test $(CARGO_CONFIG_FLAG) --release -p scroll-zkvm-integration --test chunk_circuit test_execute_multi -- --exact --nocapture
6156

6257
test-cycle:
63-
@cargo test --release -p scroll-zkvm-integration --test chunk_circuit test_cycle -- --exact --nocapture
58+
@cargo test $(CARGO_CONFIG_FLAG) --release -p scroll-zkvm-integration --test chunk_circuit test_cycle -- --exact --nocapture
6459

65-
test-execute-batch: $(TESTDATA_PATH)/proofs/chunk-$(CHUNK_PROOF).json
66-
@cargo test --release -p scroll-zkvm-integration --test batch_circuit test_e2e_execute -- --exact --nocapture
60+
test-execute-batch:
61+
@cargo test $(CARGO_CONFIG_FLAG) --release -p scroll-zkvm-integration --test batch_circuit test_e2e_execute -- --exact --nocapture
6762

68-
test-execute-batch-fast: $(TESTDATA_PATH)/tasks/batch-task.json
69-
@cargo test --release -p scroll-zkvm-integration --test batch_circuit test_execute -- --exact --nocapture
63+
test-execute-batch-fast:
64+
@cargo test $(CARGO_CONFIG_FLAG) --release -p scroll-zkvm-integration --test batch_circuit test_execute -- --exact --nocapture
7065

7166
test-execute-bundle:
72-
@cargo test --release -p scroll-zkvm-integration --test bundle_circuit test_execute -- --exact --nocapture
67+
@cargo test $(CARGO_CONFIG_FLAG) --release -p scroll-zkvm-integration --test bundle_circuit test_execute -- --exact --nocapture
7368

7469
test-single-chunk:
75-
@cargo test --release -p scroll-zkvm-integration --test chunk_circuit setup_prove_verify_single -- --exact --nocapture
70+
@cargo test $(CARGO_CONFIG_FLAG) --release -p scroll-zkvm-integration --test chunk_circuit setup_prove_verify_single -- --exact --nocapture
7671

7772
test-multi-chunk:
78-
@cargo test --release -p scroll-zkvm-integration --test chunk_circuit setup_prove_verify_multi -- --exact --nocapture
73+
@cargo test $(CARGO_CONFIG_FLAG) --release -p scroll-zkvm-integration --test chunk_circuit setup_prove_verify_multi -- --exact --nocapture
7974

80-
test-single-batch: $(TESTDATA_PATH)/tasks/batch-task.json
81-
@cargo test --release -p scroll-zkvm-integration --test batch_circuit setup_prove_verify_single -- --exact --nocapture
75+
test-single-batch:
76+
@cargo test $(CARGO_CONFIG_FLAG) --release -p scroll-zkvm-integration --test batch_circuit setup_prove_verify_single -- --exact --nocapture
8277

8378
test-e2e-batch:
84-
@cargo test --release -p scroll-zkvm-integration --test batch_circuit e2e -- --exact --nocapture
79+
@cargo test $(CARGO_CONFIG_FLAG) --release -p scroll-zkvm-integration --test batch_circuit e2e -- --exact --nocapture
8580

8681
test-bundle:
87-
@cargo test --release -p scroll-zkvm-integration --test bundle_circuit setup_prove_verify -- --exact --nocapture
82+
@cargo test $(CARGO_CONFIG_FLAG) --release -p scroll-zkvm-integration --test bundle_circuit setup_prove_verify -- --exact --nocapture
8883

8984
test-bundle-local:
90-
@cargo test --release -p scroll-zkvm-integration --test bundle_circuit setup_prove_verify_local_task -- --exact --nocapture
85+
@cargo test $(CARGO_CONFIG_FLAG) --release -p scroll-zkvm-integration --test bundle_circuit setup_prove_verify_local_task -- --exact --nocapture
9186

9287
test-e2e-bundle:
93-
@cargo test --release -p scroll-zkvm-integration --test bundle_circuit e2e -- --exact --nocapture
88+
@cargo test $(CARGO_CONFIG_FLAG) --release -p scroll-zkvm-integration --test bundle_circuit e2e -- --exact --nocapture

build-guest.sh

Lines changed: 19 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,7 @@
22
set -ex
33

44
mkdir -p releases
5-
rm -rf releases/*
6-
7-
[ -f "crates/build-guest/.env" ] && . crates/build-guest/.env
8-
9-
# if BUILD_STAGES if empty, set it to stage1,stage2,stage3
10-
if [ -z "${BUILD_STAGES}" ]; then
11-
BUILD_STAGES="stage1,stage2,stage3"
12-
fi
5+
#rm -rf releases/*
136

147
# build docker image
158
docker build --platform linux/amd64 -t build-guest:local .
@@ -21,41 +14,32 @@ cleanup() {
2114
docker rm -f $(cat ./build-guest.cid) 2>/dev/null || true
2215
fi
2316
rm -f ./build-guest.cid
24-
17+
2518
}
2619

2720
# set trap to cleanup on exit
2821
trap cleanup EXIT
2922

3023
# run docker image
31-
docker run --cidfile ./build-guest.cid --platform linux/amd64\
32-
-e BUILD_STAGES=${BUILD_STAGES}\
33-
build-guest:local\
34-
make build-guest-local
24+
docker run --cidfile ./build-guest.cid --platform linux/amd64 build-guest:local make build-guest-local
3525
container_id=$(cat ./build-guest.cid)
3626

37-
if [ -n "$(echo ${BUILD_STAGES} | grep stage1)" ]; then
38-
# copy leaf commitments from container to local
39-
for f in chunk-circuit/chunk_leaf_commit.rs \
40-
batch-circuit/batch_leaf_commit.rs \
41-
bundle-circuit/bundle_leaf_commit.rs; do
42-
docker cp ${container_id}:/app/crates/circuits/${f} crates/circuits/${f}
43-
done
44-
fi
45-
46-
if [ -n "$(echo ${BUILD_STAGES} | grep stage2)" ]; then
47-
# copy root verifier
48-
docker cp ${container_id}:/app/crates/build-guest/root_verifier.asm crates/build-guest/root_verifier.asm
49-
fi
50-
51-
if [ -n "$(echo ${BUILD_STAGES} | grep stage3)" ]; then
52-
# copy exe commitments from container to local
53-
for f in chunk-circuit/chunk_exe_commit.rs \
54-
batch-circuit/batch_exe_commit.rs \
55-
bundle-circuit/bundle_exe_commit.rs; do
56-
docker cp ${container_id}:/app/crates/circuits/${f} crates/circuits/${f}
57-
done
58-
fi
27+
# copy vm commitments from container to local
28+
for f in chunk-circuit/chunk_vm_commit.rs \
29+
batch-circuit/batch_vm_commit.rs \
30+
bundle-circuit/bundle_vm_commit.rs; do
31+
docker cp ${container_id}:/app/crates/circuits/${f} crates/circuits/${f}
32+
done
33+
34+
# copy root verifier
35+
docker cp ${container_id}:/app/crates/build-guest/root_verifier.asm crates/build-guest/root_verifier.asm
36+
37+
# copy exe commitments from container to local
38+
for f in chunk-circuit/chunk_exe_commit.rs \
39+
batch-circuit/batch_exe_commit.rs \
40+
bundle-circuit/bundle_exe_commit.rs; do
41+
docker cp ${container_id}:/app/crates/circuits/${f} crates/circuits/${f}
42+
done
5943

6044
# copy release files from container to local
6145
docker cp ${container_id}:/app/releases/dev releases/dev

crates/build-guest/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ openvm-build = { workspace = true, default-features = false }
1515
openvm-circuit = { workspace = true }
1616

1717
eyre.workspace = true
18-
serde.workspace = true
1918
hex.workspace = true
2019
serde_json.workspace = true
2120
snark-verifier-sdk.workspace = true
2221
toml.workspace = true
2322

2423
cargo_metadata = "0.19.1"
2524
dotenv = "0.15.0"
25+
clap = { version = "4.0", features = ["derive"] }
2626

2727
[features]
2828
default = []

0 commit comments

Comments
 (0)