Skip to content
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(state-keeper): More state keeper metrics #2224

Merged
merged 1 commit into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion core/node/state_keeper/src/keeper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,8 @@ impl ZkSyncStateKeeper {
}

while !self.is_canceled() {
let full_latency = KEEPER_METRICS.process_l1_batch_loop_iteration.start();

if self
.io
.should_seal_l1_batch_unconditionally(updates_manager)
Expand All @@ -516,7 +518,7 @@ impl ZkSyncStateKeeper {
.map_err(|e| e.context("wait_for_new_l2_block_params"))?;
tracing::debug!(
"Initialized new L2 block #{} (L1 batch #{}) with timestamp {}",
updates_manager.l2_block.number,
updates_manager.l2_block.number + 1,
updates_manager.l1_batch.number,
display_timestamp(new_l2_block_params.timestamp)
);
Expand Down Expand Up @@ -596,8 +598,10 @@ impl ZkSyncStateKeeper {
transaction {tx_hash}",
updates_manager.l1_batch.number
);
full_latency.observe();
return Ok(());
}
full_latency.observe();
}
Err(Error::Canceled)
}
Expand Down Expand Up @@ -674,10 +678,12 @@ impl ZkSyncStateKeeper {
updates_manager: &mut UpdatesManager,
tx: Transaction,
) -> anyhow::Result<(SealResolution, TxExecutionResult)> {
let latency = KEEPER_METRICS.execute_tx_outer_time.start();
let exec_result = batch_executor
.execute_tx(tx.clone())
.await
.with_context(|| format!("failed executing transaction {:?}", tx.hash()))?;
latency.observe();

let latency = KEEPER_METRICS.determine_seal_resolution.start();
// All of `TxExecutionResult::BootloaderOutOfGasForTx`,
Expand Down
6 changes: 6 additions & 0 deletions core/node/state_keeper/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ pub struct StateKeeperMetrics {
/// The time it takes to determine seal resolution for each tx.
#[metrics(buckets = Buckets::LATENCIES)]
pub determine_seal_resolution: Histogram<Duration>,
/// The time it takes for state keeper to wait for tx execution result from batch executor.
#[metrics(buckets = Buckets::LATENCIES)]
pub execute_tx_outer_time: Histogram<Duration>,
/// The time it takes for one iteration of the main loop in `process_l1_batch`.
#[metrics(buckets = Buckets::LATENCIES)]
pub process_l1_batch_loop_iteration: Histogram<Duration>,
}

fn vm_revert_reason_as_metric_label(reason: &VmRevertReason) -> &'static str {
Expand Down
Loading