Skip to content

Commit 98823f9

Browse files
authored
feat: ProverJobProcessor & circuit prover (#3287)
This is PR 2 out of 5. ## Upcoming PRs: - refactor remaining code (circuit_prover main, keystore, etc.) - add tests & example for the framework - remove witness_vector_generator & prover_fri ## How to review this PR? - I'd recommend going through the README's (first [prover_job_processor](https://github.com/matter-labs/zksync-era/pull/3287/files#diff-49a3b8fb328da83d986d678b60142b207580e36b6c39d6fe19837801b2e86bdf), then [circuit_prover_service](https://github.com/matter-labs/zksync-era/pull/3287/files#diff-ee07b5d87c31d71235b0ae764c28fb413891712a770a7751a52ef072c945d4bb)) - Compare existing circuit prover implementation with this one ## What? This PR touches 2 concepts: - Prover Job Processor - some sort of "framework" to make prover components more maintainable; it aims to make prover code more async & faster, provide more configurability, simplifies testing and makes writing new prover components easy - Circuit Prover - a complete rewrite to showcase Prover Job Processor ## Why? Check ProverJobProcessor [README.md - objectives section](https://github.com/matter-labs/zksync-era/pull/3287/files#diff-49a3b8fb328da83d986d678b60142b207580e36b6c39d6fe19837801b2e86bdfR110). ## Testing Ran on local setup, L4 & T4.
1 parent 271033f commit 98823f9

Some content is hidden

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

50 files changed

+2158
-927
lines changed

.github/workflows/ci-prover-e2e.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ jobs:
8686
ci_run zkstack prover run --component=witness-generator --round=all-rounds --docker=false &>prover_logs/witness-generator.log &
8787
- name: Run Circuit Prover
8888
run: |
89-
ci_run zkstack prover run --component=circuit-prover --witness-vector-generator-count=10 --docker=false &>prover_logs/circuit_prover.log &
89+
ci_run zkstack prover run --component=circuit-prover -l=23 -h=3 --docker=false &>prover_logs/circuit_prover.log &
9090
- name: Wait for prover jobs to finish
9191
env:
9292
DATABASE_URL: postgres://postgres:notsecurepassword@localhost:5432/zksync_prover_localhost_proving_chain

core/lib/basic_types/src/prover_dal.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//! Types exposed by the prover DAL for general-purpose use.
2-
use std::{net::IpAddr, ops::Add, str::FromStr};
2+
use std::{net::IpAddr, ops::Add, str::FromStr, time::Instant};
33

44
use chrono::{DateTime, Duration, NaiveDateTime, NaiveTime, Utc};
55
use serde::{Deserialize, Serialize};
@@ -18,6 +18,23 @@ pub struct FriProverJobMetadata {
1818
pub sequence_number: usize,
1919
pub depth: u16,
2020
pub is_node_final_proof: bool,
21+
pub pick_time: Instant,
22+
}
23+
24+
impl FriProverJobMetadata {
25+
/// Checks whether the metadata corresponds to a scheduler proof or not.
26+
pub fn is_scheduler_proof(&self) -> anyhow::Result<bool> {
27+
if self.aggregation_round == AggregationRound::Scheduler {
28+
if self.circuit_id != 1 {
29+
return Err(anyhow::anyhow!(
30+
"Invalid circuit id {} for Scheduler proof",
31+
self.circuit_id
32+
));
33+
}
34+
return Ok(true);
35+
}
36+
Ok(false)
37+
}
2138
}
2239

2340
#[derive(Debug, Clone, Copy, Default)]

prover/Cargo.lock

Lines changed: 39 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

prover/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ strum_macros = "0.26"
5858
tempfile = "3"
5959
tokio = "1"
6060
tokio-util = "0.7.11"
61+
tokio-stream = "0.1.16"
6162
toml_edit = "0.14.4"
6263
tracing = "0.1"
6364
tracing-subscriber = "0.3"
@@ -100,6 +101,8 @@ zksync_prover_fri_types = { path = "crates/lib/prover_fri_types" }
100101
zksync_prover_fri_utils = { path = "crates/lib/prover_fri_utils" }
101102
zksync_prover_keystore = { path = "crates/lib/keystore" }
102103
zksync_vk_setup_data_generator_server_fri = { path = "crates/bin/vk_setup_data_generator_server_fri" }
104+
zksync_prover_job_processor = { path = "crates/lib/prover_job_processor" }
105+
zksync_circuit_prover_service = { path = "crates/lib/circuit_prover_service" }
103106
zksync_prover_job_monitor = { path = "crates/bin/prover_job_monitor" }
104107

105108
# for `perf` profiling

prover/crates/bin/circuit_prover/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[package]
22
name = "zksync_circuit_prover"
3+
description = "ZKsync circuit prover binary implementation"
34
version.workspace = true
45
edition.workspace = true
56
authors.workspace = true
@@ -8,6 +9,7 @@ repository.workspace = true
89
license.workspace = true
910
keywords.workspace = true
1011
categories.workspace = true
12+
publish = false
1113

1214
[dependencies]
1315
tokio = { workspace = true, features = ["macros", "time"] }
@@ -29,6 +31,8 @@ zksync_prover_keystore = { workspace = true, features = ["gpu"] }
2931
zksync_env_config.workspace = true
3032
zksync_core_leftovers.workspace = true
3133
zksync_utils.workspace = true
34+
zksync_circuit_prover_service.workspace = true
35+
zksync_prover_job_processor.workspace = true
3236

3337
vise.workspace = true
3438
shivini = { workspace = true, features = [

0 commit comments

Comments
 (0)