-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
feat: add more metrics for the tee_prover #3276
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
-- Add down migration script here | ||
ALTER TABLE l1_batches DROP COLUMN IF EXISTS sealed_at; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
-- add a sealed_at column for metrics | ||
ALTER TABLE l1_batches ADD COLUMN sealed_at TIMESTAMP; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ use std::{ | |
|
||
use anyhow::Context as _; | ||
use bigdecimal::{BigDecimal, FromPrimitive, ToPrimitive}; | ||
use chrono::NaiveDateTime; | ||
use zksync_db_connection::{ | ||
connection::Connection, | ||
error::{DalResult, SqlxContext}, | ||
|
@@ -742,6 +743,7 @@ impl BlocksDal<'_, '_> { | |
pubdata_input = $19, | ||
predicted_circuits_by_type = $20, | ||
updated_at = NOW(), | ||
sealed_at = NOW(), | ||
is_sealed = TRUE | ||
WHERE | ||
number = $1 | ||
|
@@ -2394,6 +2396,29 @@ impl BlocksDal<'_, '_> { | |
.flatten()) | ||
} | ||
|
||
pub async fn get_sealed_at( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bikeshedding: Despite the argument making it clear what this method is about, I'd still name it more specifically, like |
||
&mut self, | ||
l1_batch_number: L1BatchNumber, | ||
) -> DalResult<Option<NaiveDateTime>> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bikeshedding: Most existing DAL methods convert time to |
||
Ok(sqlx::query!( | ||
r#" | ||
SELECT | ||
sealed_at | ||
FROM | ||
l1_batches | ||
WHERE | ||
is_sealed | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't this condition redundant? If |
||
AND number = $1 | ||
"#, | ||
i64::from(l1_batch_number.0) | ||
) | ||
.instrument("get_sealed_at") | ||
.with_arg("l1_batch_number", &l1_batch_number) | ||
.fetch_optional(self.storage) | ||
.await? | ||
.and_then(|row| row.sealed_at)) | ||
} | ||
|
||
pub async fn set_protocol_version_for_pending_l2_blocks( | ||
&mut self, | ||
id: ProtocolVersionId, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
use std::sync::Arc; | ||
|
||
use axum::{extract::Path, Json}; | ||
use chrono::Utc; | ||
use zksync_config::configs::ProofDataHandlerConfig; | ||
use zksync_dal::{ConnectionPool, Core, CoreDal}; | ||
use zksync_object_store::{ObjectStore, ObjectStoreError}; | ||
|
@@ -16,7 +17,7 @@ use zksync_prover_interface::{ | |
use zksync_types::{tee_types::TeeType, L1BatchNumber, L2ChainId}; | ||
use zksync_vm_executor::storage::L1BatchParamsProvider; | ||
|
||
use crate::errors::RequestProcessorError; | ||
use crate::{errors::RequestProcessorError, metrics::METRICS}; | ||
|
||
#[derive(Clone)] | ||
pub(crate) struct TeeRequestProcessor { | ||
|
@@ -194,11 +195,6 @@ impl TeeRequestProcessor { | |
let mut connection = self.pool.connection_tagged("tee_request_processor").await?; | ||
let mut dal = connection.tee_proof_generation_dal(); | ||
|
||
tracing::info!( | ||
"Received proof {:?} for batch number: {:?}", | ||
proof, | ||
l1_batch_number | ||
); | ||
dal.save_proof_artifacts_metadata( | ||
l1_batch_number, | ||
proof.0.tee_type, | ||
|
@@ -208,6 +204,28 @@ impl TeeRequestProcessor { | |
) | ||
.await?; | ||
|
||
let sealed_at = connection | ||
.blocks_dal() | ||
.get_sealed_at(l1_batch_number) | ||
.await?; | ||
|
||
let duration = | ||
sealed_at.and_then(|sealed_at| (Utc::now() - sealed_at.and_utc()).to_std().ok()); | ||
|
||
let duration_secs_f64 = if let Some(duration) = duration { | ||
METRICS.tee_proof_roundtrip_time[&proof.0.tee_type.into()].observe(duration); | ||
duration.as_secs_f64() | ||
} else { | ||
f64::NAN | ||
}; | ||
|
||
tracing::info!( | ||
l1_batch_number = %l1_batch_number, | ||
sealed_to_proven_in_secs = %duration_secs_f64, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: |
||
"Received proof {:?}", | ||
proof | ||
); | ||
|
||
Ok(Json(SubmitProofResponse::Success)) | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To record the full hash, use
?
(=Debug
) specifier. AFAIU, theDisplay
impl forH256
doesn't display all hex digits, but rather only starting / ending ones.