Skip to content

Commit

Permalink
feat: ProverJobProcessor & circuit prover (#3287)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
EmilLuta authored Nov 15, 2024
1 parent 271033f commit 98823f9
Show file tree
Hide file tree
Showing 50 changed files with 2,158 additions and 927 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-prover-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ jobs:
ci_run zkstack prover run --component=witness-generator --round=all-rounds --docker=false &>prover_logs/witness-generator.log &
- name: Run Circuit Prover
run: |
ci_run zkstack prover run --component=circuit-prover --witness-vector-generator-count=10 --docker=false &>prover_logs/circuit_prover.log &
ci_run zkstack prover run --component=circuit-prover -l=23 -h=3 --docker=false &>prover_logs/circuit_prover.log &
- name: Wait for prover jobs to finish
env:
DATABASE_URL: postgres://postgres:notsecurepassword@localhost:5432/zksync_prover_localhost_proving_chain
Expand Down
19 changes: 18 additions & 1 deletion core/lib/basic_types/src/prover_dal.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! Types exposed by the prover DAL for general-purpose use.
use std::{net::IpAddr, ops::Add, str::FromStr};
use std::{net::IpAddr, ops::Add, str::FromStr, time::Instant};

use chrono::{DateTime, Duration, NaiveDateTime, NaiveTime, Utc};
use serde::{Deserialize, Serialize};
Expand All @@ -18,6 +18,23 @@ pub struct FriProverJobMetadata {
pub sequence_number: usize,
pub depth: u16,
pub is_node_final_proof: bool,
pub pick_time: Instant,
}

impl FriProverJobMetadata {
/// Checks whether the metadata corresponds to a scheduler proof or not.
pub fn is_scheduler_proof(&self) -> anyhow::Result<bool> {
if self.aggregation_round == AggregationRound::Scheduler {
if self.circuit_id != 1 {
return Err(anyhow::anyhow!(
"Invalid circuit id {} for Scheduler proof",
self.circuit_id
));
}
return Ok(true);
}
Ok(false)
}
}

#[derive(Debug, Clone, Copy, Default)]
Expand Down
41 changes: 39 additions & 2 deletions prover/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions prover/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ strum_macros = "0.26"
tempfile = "3"
tokio = "1"
tokio-util = "0.7.11"
tokio-stream = "0.1.16"
toml_edit = "0.14.4"
tracing = "0.1"
tracing-subscriber = "0.3"
Expand Down Expand Up @@ -100,6 +101,8 @@ zksync_prover_fri_types = { path = "crates/lib/prover_fri_types" }
zksync_prover_fri_utils = { path = "crates/lib/prover_fri_utils" }
zksync_prover_keystore = { path = "crates/lib/keystore" }
zksync_vk_setup_data_generator_server_fri = { path = "crates/bin/vk_setup_data_generator_server_fri" }
zksync_prover_job_processor = { path = "crates/lib/prover_job_processor" }
zksync_circuit_prover_service = { path = "crates/lib/circuit_prover_service" }
zksync_prover_job_monitor = { path = "crates/bin/prover_job_monitor" }

# for `perf` profiling
Expand Down
4 changes: 4 additions & 0 deletions prover/crates/bin/circuit_prover/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[package]
name = "zksync_circuit_prover"
description = "ZKsync circuit prover binary implementation"
version.workspace = true
edition.workspace = true
authors.workspace = true
Expand All @@ -8,6 +9,7 @@ repository.workspace = true
license.workspace = true
keywords.workspace = true
categories.workspace = true
publish = false

[dependencies]
tokio = { workspace = true, features = ["macros", "time"] }
Expand All @@ -29,6 +31,8 @@ zksync_prover_keystore = { workspace = true, features = ["gpu"] }
zksync_env_config.workspace = true
zksync_core_leftovers.workspace = true
zksync_utils.workspace = true
zksync_circuit_prover_service.workspace = true
zksync_prover_job_processor.workspace = true

vise.workspace = true
shivini = { workspace = true, features = [
Expand Down
Loading

0 comments on commit 98823f9

Please sign in to comment.