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

Add l1_batch_commit_data_generator as parameter to the DataSizeCriterion structure #151

Merged
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
15 changes: 2 additions & 13 deletions core/lib/zksync_core/src/eth_sender/aggregator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ impl Aggregator {
Box::from(DataSizeCriterion {
op: AggregatedActionType::Commit,
data_limit: config.max_eth_tx_data_size,
l1_batch_commit_data_generator: l1_batch_commit_data_generator.clone(),
}),
Box::from(TimestampDeadlineCriterion {
op: AggregatedActionType::Commit,
Expand Down Expand Up @@ -165,7 +166,6 @@ impl Aggregator {
&mut self.execute_criteria,
ready_for_execute_batches,
last_sealed_l1_batch,
self.l1_batch_commit_data_generator.clone(),
)
.await;

Expand Down Expand Up @@ -224,7 +224,6 @@ impl Aggregator {
&mut self.commit_criteria,
ready_for_commit_l1_batches,
last_sealed_batch,
self.l1_batch_commit_data_generator.clone(),
)
.await;

Expand Down Expand Up @@ -321,14 +320,12 @@ impl Aggregator {
storage: &mut StorageProcessor<'_>,
ready_for_proof_l1_batches: Vec<L1BatchWithMetadata>,
last_sealed_l1_batch: L1BatchNumber,
l1_batch_commit_data_generator: Arc<dyn L1BatchCommitDataGenerator>,
) -> Option<ProveBatches> {
let batches = extract_ready_subrange(
storage,
&mut self.proof_criteria,
ready_for_proof_l1_batches,
last_sealed_l1_batch,
l1_batch_commit_data_generator.clone(),
)
.await?;

Expand Down Expand Up @@ -375,7 +372,6 @@ impl Aggregator {
storage,
ready_for_proof_l1_batches,
last_sealed_l1_batch,
self.l1_batch_commit_data_generator.clone(),
)
.await
}
Expand All @@ -401,7 +397,6 @@ impl Aggregator {
storage,
ready_for_proof_batches,
last_sealed_l1_batch,
self.l1_batch_commit_data_generator.clone(),
)
.await
}
Expand All @@ -415,17 +410,11 @@ async fn extract_ready_subrange(
publish_criteria: &mut [Box<dyn L1BatchPublishCriterion>],
unpublished_l1_batches: Vec<L1BatchWithMetadata>,
last_sealed_l1_batch: L1BatchNumber,
l1_batch_commit_data_generator: Arc<dyn L1BatchCommitDataGenerator>,
) -> Option<Vec<L1BatchWithMetadata>> {
let mut last_l1_batch: Option<L1BatchNumber> = None;
for criterion in publish_criteria {
let l1_batch_by_criterion = criterion
.last_l1_batch_to_publish(
storage,
&unpublished_l1_batches,
last_sealed_l1_batch,
l1_batch_commit_data_generator.clone(),
)
.last_l1_batch_to_publish(storage, &unpublished_l1_batches, last_sealed_l1_batch)
.await;
if let Some(l1_batch) = l1_batch_by_criterion {
last_l1_batch = Some(last_l1_batch.map_or(l1_batch, |number| number.min(l1_batch)));
Expand Down
8 changes: 2 additions & 6 deletions core/lib/zksync_core/src/eth_sender/publish_criterion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ pub trait L1BatchPublishCriterion: fmt::Debug + Send + Sync {
storage: &mut StorageProcessor<'_>,
consecutive_l1_batches: &[L1BatchWithMetadata],
last_sealed_l1_batch: L1BatchNumber,
_l1_batch_commit_data_generator: Arc<dyn L1BatchCommitDataGenerator>,
) -> Option<L1BatchNumber>;
}

Expand All @@ -46,7 +45,6 @@ impl L1BatchPublishCriterion for NumberCriterion {
_storage: &mut StorageProcessor<'_>,
consecutive_l1_batches: &[L1BatchWithMetadata],
_last_sealed_l1_batch: L1BatchNumber,
_l1_batch_commit_data_generator: Arc<dyn L1BatchCommitDataGenerator>,
) -> Option<L1BatchNumber> {
let mut batch_numbers = consecutive_l1_batches
.iter()
Expand Down Expand Up @@ -93,7 +91,6 @@ impl L1BatchPublishCriterion for TimestampDeadlineCriterion {
_storage: &mut StorageProcessor<'_>,
consecutive_l1_batches: &[L1BatchWithMetadata],
last_sealed_l1_batch: L1BatchNumber,
_l1_batch_commit_data_generator: Arc<dyn L1BatchCommitDataGenerator>,
) -> Option<L1BatchNumber> {
let first_l1_batch = consecutive_l1_batches.iter().next()?;
let last_l1_batch_number = consecutive_l1_batches.iter().last()?.header.number.0;
Expand Down Expand Up @@ -158,7 +155,6 @@ impl L1BatchPublishCriterion for GasCriterion {
storage: &mut StorageProcessor<'_>,
consecutive_l1_batches: &[L1BatchWithMetadata],
_last_sealed_l1_batch: L1BatchNumber,
_l1_batch_commit_data_generator: Arc<dyn L1BatchCommitDataGenerator>,
) -> Option<L1BatchNumber> {
let base_cost = agg_l1_batch_base_cost(self.op);
assert!(
Expand Down Expand Up @@ -203,6 +199,7 @@ impl L1BatchPublishCriterion for GasCriterion {
pub struct DataSizeCriterion {
pub op: AggregatedActionType,
pub data_limit: usize,
pub l1_batch_commit_data_generator: Arc<dyn L1BatchCommitDataGenerator>,
}

#[async_trait]
Expand All @@ -216,7 +213,6 @@ impl L1BatchPublishCriterion for DataSizeCriterion {
_storage: &mut StorageProcessor<'_>,
consecutive_l1_batches: &[L1BatchWithMetadata],
_last_sealed_l1_batch: L1BatchNumber,
l1_batch_commit_data_generator: Arc<dyn L1BatchCommitDataGenerator>,
) -> Option<L1BatchNumber> {
const STORED_BLOCK_INFO_SIZE: usize = 96; // size of `StoredBlockInfo` solidity struct
let mut data_size_left = self.data_limit - STORED_BLOCK_INFO_SIZE;
Expand All @@ -226,7 +222,7 @@ impl L1BatchPublishCriterion for DataSizeCriterion {
let l1_commit_data_size =
ethabi::encode(&[ethabi::Token::Array(vec![CommitBatchInfo::new(
l1_batch,
l1_batch_commit_data_generator.clone(),
self.l1_batch_commit_data_generator.clone(),
)
.into_token()])])
.len();
Expand Down
Loading