Skip to content

Commit 5b74022

Browse files
authored
feat: Update prover job ordering (#3769)
## What ❔ This is a rework of previous PR #3561 The difference is, that instead of ordering jobs by `created_at` field, we are ordering them by new `batch_created_at` column, which is assigned on saving witness inputs. ## Why ❔ <!-- Why are these changes done? What goal do they contribute to? What are the principles behind them? --> <!-- The `Why` has to be clear to non-Matter Labs entities running their own ZK Chain --> <!-- Example: PR templates ensure PR reviewers, observers, and future iterators are in context about the evolution of repos. --> ## Is this a breaking change? - [x] Yes - [ ] No ## Operational changes There is a need to run migrations on prover side ## Checklist <!-- Check your PR fulfills the following items. --> <!-- For draft PRs check the boxes as you complete them. --> - [ ] PR title corresponds to the body of PR (we generate changelog entries from PRs). - [ ] Tests for the changes have been added / updated. - [ ] Documentation comments have been added / updated. - [ ] Code has been formatted via `zkstack dev fmt` and `zkstack dev lint`.
1 parent 233a4d2 commit 5b74022

File tree

66 files changed

+555
-171
lines changed

Some content is hidden

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

66 files changed

+555
-171
lines changed

core/Cargo.lock

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

core/lib/basic_types/src/prover_dal.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use crate::{
1313
pub struct FriProverJobMetadata {
1414
pub id: u32,
1515
pub block_number: L1BatchNumber,
16+
pub batch_sealed_at: DateTime<Utc>,
1617
pub circuit_id: u8,
1718
pub aggregation_round: AggregationRound,
1819
pub sequence_number: usize,

core/lib/prover_interface/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ bellman.workspace = true
2323
serde.workspace = true
2424
serde_with = { workspace = true, features = ["base64", "hex"] }
2525
ciborium.workspace = true
26+
chrono.workspace = true
2627

2728
[dev-dependencies]
2829
tokio = { workspace = true, features = ["full"] }

core/lib/prover_interface/src/api.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ use crate::{
1919
#[derive(Debug, Clone, Serialize, Deserialize)]
2020
pub struct ProofGenerationData {
2121
pub l1_batch_number: L1BatchNumber,
22+
#[serde(default)]
23+
pub batch_sealed_at: chrono::DateTime<chrono::Utc>,
2224
pub witness_input_data: WitnessInputData,
2325
pub protocol_version: ProtocolSemanticVersion,
2426
pub l1_verifier_config: L1VerifierConfig,

core/node/external_proof_integration_api/src/processor.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,15 @@ impl Processor {
184184
},
185185
};
186186

187+
let batch_sealed_at = conn
188+
.blocks_dal()
189+
.get_batch_sealed_at(l1_batch_number)
190+
.await?
191+
.ok_or(ProcessorError::Internal)?;
192+
187193
Ok(ProofGenerationData {
188194
l1_batch_number,
195+
batch_sealed_at,
189196
witness_input_data: blob,
190197
protocol_version: protocol_version.version,
191198
l1_verifier_config: protocol_version.l1_verifier_config,

core/node/proof_data_handler/src/request_processor.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,17 @@ impl RequestProcessor {
197197

198198
METRICS.observe_blob_sizes(&blob);
199199

200+
let batch_sealed_at = conn
201+
.blocks_dal()
202+
.get_batch_sealed_at(l1_batch_number)
203+
.await?
204+
.ok_or(RequestProcessorError::GeneralError(format!(
205+
"Batch {l1_batch_number} not found in blocks_dal"
206+
)))?;
207+
200208
Ok(ProofGenerationData {
201209
l1_batch_number,
210+
batch_sealed_at,
202211
witness_input_data: blob,
203212
protocol_version: protocol_version.version,
204213
l1_verifier_config: protocol_version.l1_verifier_config,

prover/Cargo.lock

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

prover/crates/bin/gpu_checker/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ bincode.workspace = true
1818
clap = { workspace = true, features = ["derive", "string"] }
1919
once_cell.workspace = true
2020
regex.workspace = true
21+
chrono.workspace = true
2122

2223
shivini = { workspace = true, features = ["circuit_definitions", "zksync"] }
2324
zksync_circuit_prover_service.workspace = true

prover/crates/bin/gpu_checker/src/main.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use std::{
55
};
66

77
use anyhow::Context;
8+
use chrono::{DateTime, Utc};
89
use clap::Parser;
910
use once_cell::sync::Lazy;
1011
use regex::Regex;
@@ -159,6 +160,7 @@ fn get_metadata(path: &Path) -> anyhow::Result<FriProverJobMetadata> {
159160
depth: caps["depth"].parse()?,
160161
is_node_final_proof: false,
161162
pick_time: Instant::now(),
163+
batch_sealed_at: DateTime::<Utc>::default(),
162164
})
163165
}
164166

@@ -172,6 +174,7 @@ fn witness_vector_filename(metadata: FriProverJobMetadata) -> String {
172174
depth,
173175
is_node_final_proof: _,
174176
pick_time: _,
177+
batch_sealed_at: _,
175178
} = metadata;
176179
format!("{block_number}_{sequence_number}_{circuit_id}_{aggregation_round:?}_{depth}.witness_vector")
177180
}

prover/crates/bin/prover_cli/src/commands/insert_batch.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use anyhow::Context as _;
2+
use chrono::{DateTime, Utc};
23
use clap::Args as ClapArgs;
34
use zksync_basic_types::{
45
protocol_version::{ProtocolSemanticVersion, ProtocolVersionId, VersionPatch},
@@ -36,6 +37,7 @@ pub async fn run(args: Args, config: ProverCLIConfig) -> anyhow::Result<()> {
3637
args.number,
3738
&format!("witness_inputs_{}", args.number.0),
3839
ProtocolSemanticVersion::new(protocol_version, protocol_version_patch),
40+
DateTime::<Utc>::default(),
3941
)
4042
.await;
4143

0 commit comments

Comments
 (0)