Skip to content

Commit 7433b51

Browse files
authored
fix(prover-gateway): Check for batch existence in DB & add tracing for axum (#4270)
## What ❔ <!-- What are the changes this PR brings about? --> <!-- Example: This PR adds a PR template to the repo. --> <!-- (For bigger PRs adding more context is appreciated) --> ## 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? - [ ] Yes - [x] No ## Operational changes <!-- Any config changes? Any new flags? Any changes to any scripts? --> <!-- Please add anything that non-Matter Labs entities running their own ZK Chain may need to know --> ## 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 8c56d5f commit 7433b51

File tree

7 files changed

+78
-3
lines changed

7 files changed

+78
-3
lines changed

prover/Cargo.lock

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

prover/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ tokio = "1"
6060
tokio-util = "0.7.11"
6161
tokio-stream = "0.1.16"
6262
toml_edit = "0.14.4"
63+
tower-http = "0.5.2"
6364
tracing = "0.1"
6465
tracing-subscriber = "0.3"
6566
tracing-test = "0.2.5"

prover/crates/bin/prover_fri_gateway/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ zksync_vlog.workspace = true
2222
axum.workspace = true
2323
anyhow.workspace = true
2424
tracing.workspace = true
25+
tower-http = { workspace = true, features = ["trace"] }
2526
reqwest = { workspace = true, features = ["blocking"] }
2627
tokio = { workspace = true, features = ["time", "macros"] }
2728
thiserror.workspace = true

prover/crates/bin/prover_fri_gateway/src/proof_data_manager.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ impl ProofDataManager {
7979
.connection()
8080
.await
8181
.unwrap()
82-
.fri_basic_witness_generator_dal()
83-
.protocol_version_for_l1_batch(batch_id)
82+
.fri_proof_compressor_dal()
83+
.protocol_version_for_successful_proof(batch_id)
8484
.await;
8585

8686
let Some(protocol_version) = protocol_version else {

prover/crates/bin/prover_fri_gateway/src/server.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use axum::{
77
Json, Router,
88
};
99
use tokio::sync::watch;
10+
use tower_http::trace::TraceLayer;
1011
use zksync_prover_interface::api::{
1112
PollGeneratedProofsRequest, PollGeneratedProofsResponse, ProofGenerationData,
1213
SubmitProofGenerationDataResponse,
@@ -27,6 +28,7 @@ impl Api {
2728
"/submit_request_for_proofs",
2829
post(Api::save_proof_generation_data),
2930
)
31+
.layer(TraceLayer::new_for_http())
3032
.layer(DefaultBodyLimit::disable())
3133
.with_state(processor);
3234

prover/crates/lib/prover_dal/.sqlx/query-a5c313104e5be0f82c4a3f0dd5680cecc68164241c54a30d88e6fb2a63ceea50.json

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

prover/crates/lib/prover_dal/src/fri_proof_compressor_dal.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,30 @@ impl FriProofCompressorDal<'_, '_> {
228228
}
229229
}
230230

231+
pub async fn protocol_version_for_successful_proof(
232+
&mut self,
233+
batch_id: L1BatchId,
234+
) -> Option<ProtocolSemanticVersion> {
235+
sqlx::query!(
236+
r#"
237+
SELECT protocol_version, protocol_version_patch
238+
FROM proof_compression_jobs_fri
239+
WHERE l1_batch_number = $1 AND chain_id = $2 AND status = 'successful'
240+
"#,
241+
batch_id.batch_number().0 as i64,
242+
batch_id.chain_id().inner() as i64,
243+
)
244+
.fetch_optional(self.storage.conn())
245+
.await
246+
.unwrap()
247+
.map(|row| {
248+
ProtocolSemanticVersion::new(
249+
ProtocolVersionId::try_from(row.protocol_version.unwrap() as u16).unwrap(),
250+
VersionPatch(row.protocol_version_patch as u32),
251+
)
252+
})
253+
}
254+
231255
pub async fn mark_proof_sent_to_server(&mut self, batch_id: L1BatchId) -> Result<(), DalError> {
232256
sqlx::query!(
233257
r#"

0 commit comments

Comments
 (0)