Skip to content

[Feat] Staff for running zkvm prover #1666

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions zkvm-prover/.work/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.vmexe
34 changes: 34 additions & 0 deletions zkvm-prover/.work/batch/openvm.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[app_fri_params.fri_params]
log_blowup = 1
log_final_poly_len = 0
num_queries = 100
proof_of_work_bits = 16

[app_vm_config.rv32i]

[app_vm_config.rv32m]

[app_vm_config.io]

[app_vm_config.keccak]

[app_vm_config.castf]

[app_vm_config.modular]
supported_modulus = [
"4002409555221667393417789825735904156556882819939007885332058136124031650490837864442687629129015664037894272559787",
"52435875175126190479447740508185965837690552500527637822603658699938581184513",
]
[app_vm_config.native]
[app_vm_config.pairing]
supported_curves = ["Bls12_381"]
[app_vm_config.sha256]
[app_vm_config.fp2]
supported_modulus = [
"4002409555221667393417789825735904156556882819939007885332058136124031650490837864442687629129015664037894272559787",
]
[[app_vm_config.ecc.supported_curves]]
modulus = "4002409555221667393417789825735904156556882819939007885332058136124031650490837864442687629129015664037894272559787"
scalar = "52435875175126190479447740508185965837690552500527637822603658699938581184513"
a = "0"
b = "4"
17 changes: 17 additions & 0 deletions zkvm-prover/.work/bundle/openvm.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[app_fri_params.fri_params]
log_blowup = 1
log_final_poly_len = 0
num_queries = 100
proof_of_work_bits = 16

[app_vm_config.rv32i]

[app_vm_config.rv32m]

[app_vm_config.io]

[app_vm_config.keccak]

[app_vm_config.castf]

[app_vm_config.native]
53 changes: 53 additions & 0 deletions zkvm-prover/.work/chunk/openvm.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
[app_fri_params.fri_params]
log_blowup = 1
log_final_poly_len = 0
num_queries = 100
proof_of_work_bits = 16

[app_vm_config.rv32i]

[app_vm_config.io]

[app_vm_config.keccak]

[app_vm_config.rv32m]
range_tuple_checker_sizes = [256, 8192]

[app_vm_config.bigint]
range_tuple_checker_sizes = [256, 8192]

[app_vm_config.modular]
supported_modulus = [
"21888242871839275222246405745257275088696311157297823662689037894645226208583",
"21888242871839275222246405745257275088548364400416034343698204186575808495617",
"115792089237316195423570985008687907853269984665640564039457584007908834671663",
"115792089237316195423570985008687907852837564279074904382605163141518161494337",
"115792089210356248762697446949407573530086143415290314195533631308867097853951",
"115792089210356248762697446949407573529996955224135760342422259061068512044369"
]

[app_vm_config.fp2]
supported_modulus = ["21888242871839275222246405745257275088696311157297823662689037894645226208583"]

[app_vm_config.pairing]
supported_curves = ["Bn254"]

[app_vm_config.sha256]

[[app_vm_config.ecc.supported_curves]]
modulus = "115792089237316195423570985008687907853269984665640564039457584007908834671663"
scalar = "115792089237316195423570985008687907852837564279074904382605163141518161494337"
a = "0"
b = "7"

[[app_vm_config.ecc.supported_curves]]
modulus = "115792089210356248762697446949407573530086143415290314195533631308867097853951"
scalar = "115792089210356248762697446949407573529996955224135760342422259061068512044369"
a = "115792089210356248762697446949407573530086143415290314195533631308867097853948"
b = "41058363725152142129326129780047268409114441015993725554835256314039467401291"

[[app_vm_config.ecc.supported_curves]]
modulus = "21888242871839275222246405745257275088696311157297823662689037894645226208583"
scalar = "21888242871839275222246405745257275088548364400416034343698204186575808495617"
a = "0"
b = "3"
20 changes: 20 additions & 0 deletions zkvm-prover/.work/download-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add strict mode to the script

Enable robust error handling by adding:

+ set -euo pipefail

immediately after the shebang.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
#!/bin/bash
#!/bin/bash
set -euo pipefail
🤖 Prompt for AI Agents
In zkvm-prover/.work/download-release.sh at line 1, add strict mode settings
immediately after the shebang line by including 'set -euo pipefail' to enable
robust error handling and make the script exit on errors, unset variables, or
failed pipes.


# release version
if [ -z "${SCROLL_ZKVM_VERSION}" ]; then
SCROLL_ZKVM_VERSION=$($SHELL ./print_high_zkvm_version.sh | cut -d' ' -f1|cut -c2-)
fi
Comment on lines +4 to +6
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Simplify and harden version detection

Avoid using $SHELL and handle errors if the version script fails. For example:

- if [ -z "${SCROLL_ZKVM_VERSION}" ]; then
-     SCROLL_ZKVM_VERSION=$($SHELL ./print_high_zkvm_version.sh | cut -d' ' -f1 | cut -c2-)
- fi
+ if [ -z "${SCROLL_ZKVM_VERSION:-}" ]; then
+   SCROLL_ZKVM_VERSION=$(./print_high_zkvm_version.sh 2>/dev/null | awk '{print substr($1,2)}') \
+     || { echo "Failed to determine SCROLL_ZKVM_VERSION"; exit 1; }
+ fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if [ -z "${SCROLL_ZKVM_VERSION}" ]; then
SCROLL_ZKVM_VERSION=$($SHELL ./print_high_zkvm_version.sh | cut -d' ' -f1|cut -c2-)
fi
if [ -z "${SCROLL_ZKVM_VERSION:-}" ]; then
SCROLL_ZKVM_VERSION=$(./print_high_zkvm_version.sh 2>/dev/null | awk '{print substr($1,2)}') \
|| { echo "Failed to determine SCROLL_ZKVM_VERSION"; exit 1; }
fi
🤖 Prompt for AI Agents
In zkvm-prover/.work/download-release.sh around lines 4 to 6, the version
detection uses $SHELL to run the script, which is unnecessary and may cause
issues. Replace the use of $SHELL with a direct script invocation, and add error
handling to check if the version script executes successfully. If it fails,
provide a clear error message and exit the script to prevent further errors.


echo $SCROLL_ZKVM_VERSION

# chunk-circuit exe
wget https://circuit-release.s3.us-west-2.amazonaws.com/scroll-zkvm/releases/$SCROLL_ZKVM_VERSION/chunk/app.vmexe -O .work/chunk/app.vmexe
Comment on lines +10 to +11
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Ensure target directories exist before download

The script writes to .work/chunk but does not create it. Add:

+ mkdir -p .work/chunk

before the wget command to prevent failures.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# chunk-circuit exe
wget https://circuit-release.s3.us-west-2.amazonaws.com/scroll-zkvm/releases/$SCROLL_ZKVM_VERSION/chunk/app.vmexe -O .work/chunk/app.vmexe
# chunk-circuit exe
mkdir -p .work/chunk
wget https://circuit-release.s3.us-west-2.amazonaws.com/scroll-zkvm/releases/$SCROLL_ZKVM_VERSION/chunk/app.vmexe -O .work/chunk/app.vmexe
🤖 Prompt for AI Agents
In zkvm-prover/.work/download-release.sh around lines 10 to 11, the script
downloads a file into the .work/chunk directory but does not ensure this
directory exists, which can cause the wget command to fail. Add a command to
create the .work/chunk directory (e.g., mkdir -p .work/chunk) before the wget
command to guarantee the target directory is present before downloading the
file.


# batch-circuit exe
wget https://circuit-release.s3.us-west-2.amazonaws.com/scroll-zkvm/releases/$SCROLL_ZKVM_VERSION/batch/app.vmexe -O .work/batch/app.vmexe

# bundle-circuit exe
wget https://circuit-release.s3.us-west-2.amazonaws.com/scroll-zkvm/releases/$SCROLL_ZKVM_VERSION/bundle/app.vmexe -O .work/bundle/app.vmexe

# bundle-circuit exe, legacy version, may not exist
wget https://circuit-release.s3.us-west-2.amazonaws.com/scroll-zkvm/releases/$SCROLL_ZKVM_VERSION/bundle/app_euclidv1.vmexe -O .work/bundle/app_euclidv1.vmexe || echo "legacy app not exist for $SCROLL_ZKVM_VERSION"
11 changes: 11 additions & 0 deletions zkvm-prover/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
.PHONY: prover lint tests_binary

RUST_MIN_STACK ?= 16777216
export RUST_MIN_STACK

CIRCUIT_STUFF = .work/chunk/app.vmexe .work/batch/app.vmexe .work/bundle/app.vmexe

ifeq (4.3,$(firstword $(sort $(MAKE_VERSION) 4.3)))
PLONKY3_VERSION=$(shell grep -m 1 "Plonky3.git" ./Cargo.lock | cut -d "#" -f2 | cut -c-7)
else
Expand Down Expand Up @@ -46,3 +51,9 @@ lint:
cargo check --all-features
cargo clippy --all-features --all-targets -- -D warnings
cargo fmt --all

$(CIRCUIT_STUFF):
bash .work/download-release.sh

test_run: $(CIRCUIT_STUFF)
GO_TAG=${GO_TAG} GIT_REV=${GIT_REV} ZK_VERSION=${ZK_VERSION} cargo run --release -- --config ./config.json
11 changes: 11 additions & 0 deletions zkvm-prover/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## Prover

A runnable zkvm prover which can communicate with coordinator, receving proving task and generate proof

## Testing

+ Get the url of the endpoint of coordinator and a rpc endpoint response to the cooresponding chain

+ Build a `config.json` file with previous knowledge from the template in current directory

+ Call `make test_run`
12 changes: 6 additions & 6 deletions zkvm-prover/config.json → zkvm-prover/config.json.template
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"sdk_config": {
"prover_name_prefix": "prover-1",
"keys_dir": "keys",
"prover_name_prefix": "test-prover",
"keys_dir": ".work",
"coordinator": {
"base_url": "http://localhost:8555",
"base_url": "<the url of coordinator>",
"retry_count": 10,
"retry_wait_time_sec": 10,
"connection_timeout_sec": 30
},
"l2geth": {
"endpoint": "http://localhost:9999"
"endpoint": "<the url of rpc endpoint>"
},
"prover": {
"circuit_type": 2,
Expand All @@ -20,12 +20,12 @@
],
"circuit_version": "v0.13.1"
},
"db_path": "unique-db-path-for-prover-1"
"db_path": ".work/db"
},
"circuits": {
"euclidV2": {
"hard_fork_name": "euclidV2",
"workspace_path": "/home/ubuntu/prover-workdir"
"workspace_path": ".work"
}
}
}