Skip to content

Commit

Permalink
fix(state-keeper): Add L2ToL1LogsCriterion (#195)
Browse files Browse the repository at this point in the history
# What ❔

Added L1 batch seal criterion for number of L2 to L1 logs

## Why ❔

Number of logs must be <= 512 per batch.

## Checklist

<!-- Check your PR fulfills the following items. -->
<!-- For draft PRs check the boxes as you complete them. -->

- [x] PR title corresponds to the body of PR (we generate changelog
entries from PRs).
- [x] Tests for the changes have been added / updated.
- [x] Documentation comments have been added / updated.
- [x] Code has been formatted via `zk fmt` and `zk lint`.
  • Loading branch information
perekopskiy authored Oct 11, 2023
1 parent ea960f2 commit 64459b2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ impl ConditionalSealer {
Box::new(criteria::MaxCyclesCriterion),
Box::new(criteria::ComputationalGasCriterion),
Box::new(criteria::TxEncodingSizeCriterion),
Box::new(criteria::L2ToL1LogsCriterion),
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ pub struct InitialWritesCriterion;
pub struct MaxCyclesCriterion;
#[derive(Debug, Default)]
pub struct ComputationalGasCriterion;
#[derive(Debug, Default)]
pub struct L2ToL1LogsCriterion;

trait MetricExtractor {
const PROM_METRIC_CRITERION_NAME: &'static str;
Expand Down Expand Up @@ -119,6 +121,18 @@ impl MetricExtractor for ComputationalGasCriterion {
}
}

impl MetricExtractor for L2ToL1LogsCriterion {
const PROM_METRIC_CRITERION_NAME: &'static str = "l2_to_l1_logs";

fn limit_per_block() -> usize {
GEOMETRY_CONFIG.limit_for_l1_messages_merklizer as usize
}

fn extract(metrics: &ExecutionMetrics, _writes: &DeduplicatedWritesMetrics) -> usize {
metrics.l2_l1_logs
}
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down Expand Up @@ -322,4 +336,9 @@ mod tests {
fn computational_gas_seal_criterion() {
test_scenario_execution_metrics!(ComputationalGasCriterion, computational_gas_used, u32);
}

#[test]
fn l2_to_l1_logs_seal_criterion() {
test_scenario_execution_metrics!(L2ToL1LogsCriterion, l2_l1_logs, usize);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ mod tx_encoding_size;
pub(in crate::state_keeper) use self::{
gas::GasCriterion,
geometry_seal_criteria::{
ComputationalGasCriterion, InitialWritesCriterion, MaxCyclesCriterion,
ComputationalGasCriterion, InitialWritesCriterion, L2ToL1LogsCriterion, MaxCyclesCriterion,
RepeatedWritesCriterion,
},
pubdata_bytes::PubDataBytesCriterion,
Expand Down

0 comments on commit 64459b2

Please sign in to comment.