diff --git a/Cargo.lock b/Cargo.lock index a5093d36a7cf..acbddaf554b7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9165,6 +9165,7 @@ dependencies = [ "tokio", "tower", "tracing", + "vise", "zksync_basic_types", "zksync_config", "zksync_contracts", diff --git a/core/node/proof_data_handler/Cargo.toml b/core/node/proof_data_handler/Cargo.toml index 0ab5d4bb1913..92e6b45f6fa5 100644 --- a/core/node/proof_data_handler/Cargo.toml +++ b/core/node/proof_data_handler/Cargo.toml @@ -10,6 +10,7 @@ keywords.workspace = true categories.workspace = true [dependencies] +vise.workspace = true zksync_config.workspace = true zksync_dal.workspace = true zksync_object_store.workspace = true diff --git a/core/node/proof_data_handler/src/lib.rs b/core/node/proof_data_handler/src/lib.rs index 06b88b395139..618a786ea658 100644 --- a/core/node/proof_data_handler/src/lib.rs +++ b/core/node/proof_data_handler/src/lib.rs @@ -18,6 +18,7 @@ use zksync_types::commitment::L1BatchCommitmentMode; mod tests; mod errors; +mod metrics; mod request_processor; mod tee_request_processor; diff --git a/core/node/proof_data_handler/src/metrics.rs b/core/node/proof_data_handler/src/metrics.rs new file mode 100644 index 000000000000..edccda90dc24 --- /dev/null +++ b/core/node/proof_data_handler/src/metrics.rs @@ -0,0 +1,41 @@ +use vise::{Histogram, Metrics}; +use zksync_object_store::bincode; +use zksync_prover_interface::inputs::WitnessInputData; + +const BYTES_IN_MEGABYTE: u64 = 1024 * 1024; + +#[derive(Debug, Metrics)] +pub(super) struct ProofDataHandlerMetrics { + #[metrics(buckets = vise::Buckets::exponential(1.0..=2_048.0, 2.0))] + pub vm_run_data_blob_size_in_mb: Histogram, + #[metrics(buckets = vise::Buckets::exponential(1.0..=2_048.0, 2.0))] + pub merkle_paths_blob_size_in_mb: Histogram, + #[metrics(buckets = vise::Buckets::exponential(1.0..=2_048.0, 2.0))] + pub eip_4844_blob_size_in_mb: Histogram, + #[metrics(buckets = vise::Buckets::exponential(1.0..=2_048.0, 2.0))] + pub total_blob_size_in_mb: Histogram, +} + +impl ProofDataHandlerMetrics { + pub fn observe_blob_sizes(&self, blob: &WitnessInputData) { + let vm_run_data_blob_size_in_mb = + bincode::serialize(&blob.vm_run_data).unwrap().len() as u64 / BYTES_IN_MEGABYTE; + let merkle_paths_blob_size_in_mb = + bincode::serialize(&blob.merkle_paths).unwrap().len() as u64 / BYTES_IN_MEGABYTE; + let eip_4844_blob_size_in_mb = + bincode::serialize(&blob.eip_4844_blobs).unwrap().len() as u64 / BYTES_IN_MEGABYTE; + let total_blob_size_in_mb = + bincode::serialize(blob).unwrap().len() as u64 / BYTES_IN_MEGABYTE; + + self.vm_run_data_blob_size_in_mb + .observe(vm_run_data_blob_size_in_mb); + self.merkle_paths_blob_size_in_mb + .observe(merkle_paths_blob_size_in_mb); + self.eip_4844_blob_size_in_mb + .observe(eip_4844_blob_size_in_mb); + self.total_blob_size_in_mb.observe(total_blob_size_in_mb); + } +} + +#[vise::register] +pub(super) static METRICS: vise::Global = vise::Global::new(); diff --git a/core/node/proof_data_handler/src/request_processor.rs b/core/node/proof_data_handler/src/request_processor.rs index bdb55237c4b6..a89f9b63a848 100644 --- a/core/node/proof_data_handler/src/request_processor.rs +++ b/core/node/proof_data_handler/src/request_processor.rs @@ -20,7 +20,7 @@ use zksync_types::{ L1BatchNumber, H256, }; -use crate::errors::RequestProcessorError; +use crate::{errors::RequestProcessorError, metrics::METRICS}; #[derive(Clone)] pub(crate) struct RequestProcessor { @@ -147,6 +147,8 @@ impl RequestProcessor { }, }; + METRICS.observe_blob_sizes(&blob); + let proof_gen_data = ProofGenerationData { l1_batch_number, witness_input_data: blob,