Skip to content

Commit

Permalink
fixup! feat: add more metrics for the tee_prover
Browse files Browse the repository at this point in the history
Signed-off-by: Harald Hoyer <[email protected]>
  • Loading branch information
haraldh committed Nov 18, 2024
1 parent a29529e commit e87acfe
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
4 changes: 2 additions & 2 deletions core/bin/zksync_tee_prover/src/tee_prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ impl TeeProver {
let signature = self.config.signing_key.sign_ecdsa(msg_to_sign);
let duration = observer.observe();
tracing::info!(
proof_generation_time = %duration.as_secs_f64(),
proof_generation_time = duration.as_secs_f64(),
l1_batch_number = %batch_number,
l1_root_hash = %verification_result.value_hash,
l1_root_hash = ?verification_result.value_hash,
"L1 batch verified",
);
Ok((signature, batch_number, verification_result.value_hash))
Expand Down

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

13 changes: 6 additions & 7 deletions core/lib/dal/src/blocks_dal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::{

use anyhow::Context as _;
use bigdecimal::{BigDecimal, FromPrimitive, ToPrimitive};
use chrono::NaiveDateTime;
use sqlx::types::chrono::{DateTime, Utc};
use zksync_db_connection::{
connection::Connection,
error::{DalResult, SqlxContext},
Expand Down Expand Up @@ -2396,27 +2396,26 @@ impl BlocksDal<'_, '_> {
.flatten())
}

pub async fn get_sealed_at(
pub async fn get_batch_sealed_at(
&mut self,
l1_batch_number: L1BatchNumber,
) -> DalResult<Option<NaiveDateTime>> {
) -> DalResult<Option<DateTime<Utc>>> {
Ok(sqlx::query!(
r#"
SELECT
sealed_at
FROM
l1_batches
WHERE
is_sealed
AND number = $1
number = $1
"#,
i64::from(l1_batch_number.0)
)
.instrument("get_sealed_at")
.instrument("get_batch_sealed_at")
.with_arg("l1_batch_number", &l1_batch_number)
.fetch_optional(self.storage)
.await?
.and_then(|row| row.sealed_at))
.and_then(|row| row.sealed_at.map(|d| d.and_utc())))
}

pub async fn set_protocol_version_for_pending_l2_blocks(
Expand Down
7 changes: 3 additions & 4 deletions core/node/proof_data_handler/src/tee_request_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,10 @@ impl TeeRequestProcessor {

let sealed_at = connection
.blocks_dal()
.get_sealed_at(l1_batch_number)
.get_batch_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 = sealed_at.and_then(|sealed_at| (Utc::now() - sealed_at).to_std().ok());

let duration_secs_f64 = if let Some(duration) = duration {
METRICS.tee_proof_roundtrip_time[&proof.0.tee_type.into()].observe(duration);
Expand All @@ -221,7 +220,7 @@ impl TeeRequestProcessor {

tracing::info!(
l1_batch_number = %l1_batch_number,
sealed_to_proven_in_secs = %duration_secs_f64,
sealed_to_proven_in_secs = duration_secs_f64,
"Received proof {:?}",
proof
);
Expand Down

0 comments on commit e87acfe

Please sign in to comment.