From e87acfec24ace2fc50cc6d3db3a96774607ed8c3 Mon Sep 17 00:00:00 2001 From: Harald Hoyer Date: Mon, 18 Nov 2024 13:01:40 +0100 Subject: [PATCH] fixup! feat: add more metrics for the tee_prover Signed-off-by: Harald Hoyer --- core/bin/zksync_tee_prover/src/tee_prover.rs | 4 ++-- ...f5ae0d087ed816920e8e75a163b87a19e39db86227.json} | 4 ++-- core/lib/dal/src/blocks_dal.rs | 13 ++++++------- .../proof_data_handler/src/tee_request_processor.rs | 7 +++---- 4 files changed, 13 insertions(+), 15 deletions(-) rename core/lib/dal/.sqlx/{query-73fb2eb75353d57898ff9810d3f5d8370dd90de4425d699446f3c9b0c77d8de5.json => query-6ec93ebdd58bdc0259d98ef5ae0d087ed816920e8e75a163b87a19e39db86227.json} (72%) diff --git a/core/bin/zksync_tee_prover/src/tee_prover.rs b/core/bin/zksync_tee_prover/src/tee_prover.rs index da431ac5b332..58f3d45969ca 100644 --- a/core/bin/zksync_tee_prover/src/tee_prover.rs +++ b/core/bin/zksync_tee_prover/src/tee_prover.rs @@ -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)) diff --git a/core/lib/dal/.sqlx/query-73fb2eb75353d57898ff9810d3f5d8370dd90de4425d699446f3c9b0c77d8de5.json b/core/lib/dal/.sqlx/query-6ec93ebdd58bdc0259d98ef5ae0d087ed816920e8e75a163b87a19e39db86227.json similarity index 72% rename from core/lib/dal/.sqlx/query-73fb2eb75353d57898ff9810d3f5d8370dd90de4425d699446f3c9b0c77d8de5.json rename to core/lib/dal/.sqlx/query-6ec93ebdd58bdc0259d98ef5ae0d087ed816920e8e75a163b87a19e39db86227.json index a95f9b04de51..bdc6b007e9df 100644 --- a/core/lib/dal/.sqlx/query-73fb2eb75353d57898ff9810d3f5d8370dd90de4425d699446f3c9b0c77d8de5.json +++ b/core/lib/dal/.sqlx/query-6ec93ebdd58bdc0259d98ef5ae0d087ed816920e8e75a163b87a19e39db86227.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n sealed_at\n FROM\n l1_batches\n WHERE\n is_sealed\n AND number = $1\n ", + "query": "\n SELECT\n sealed_at\n FROM\n l1_batches\n WHERE\n number = $1\n ", "describe": { "columns": [ { @@ -18,5 +18,5 @@ true ] }, - "hash": "73fb2eb75353d57898ff9810d3f5d8370dd90de4425d699446f3c9b0c77d8de5" + "hash": "6ec93ebdd58bdc0259d98ef5ae0d087ed816920e8e75a163b87a19e39db86227" } diff --git a/core/lib/dal/src/blocks_dal.rs b/core/lib/dal/src/blocks_dal.rs index 307d9717ad5a..0cb607a304e2 100644 --- a/core/lib/dal/src/blocks_dal.rs +++ b/core/lib/dal/src/blocks_dal.rs @@ -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}, @@ -2396,10 +2396,10 @@ impl BlocksDal<'_, '_> { .flatten()) } - pub async fn get_sealed_at( + pub async fn get_batch_sealed_at( &mut self, l1_batch_number: L1BatchNumber, - ) -> DalResult> { + ) -> DalResult>> { Ok(sqlx::query!( r#" SELECT @@ -2407,16 +2407,15 @@ impl BlocksDal<'_, '_> { 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( diff --git a/core/node/proof_data_handler/src/tee_request_processor.rs b/core/node/proof_data_handler/src/tee_request_processor.rs index becc6f1052ba..ee5be844b981 100644 --- a/core/node/proof_data_handler/src/tee_request_processor.rs +++ b/core/node/proof_data_handler/src/tee_request_processor.rs @@ -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); @@ -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 );