Skip to content

Commit

Permalink
fix(derive): Sequence window expiry (#532)
Browse files Browse the repository at this point in the history
* fix(derive): Sequence window expiry

* use stage error
  • Loading branch information
clabby committed Sep 17, 2024
1 parent a5d37b0 commit 2f57beb
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions crates/derive/src/stages/batch_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,9 @@ where
// If the current epoch is too old compared to the L1 block we are at,
// i.e. if the sequence window expired, we create empty batches for the current epoch
let expiry_epoch = epoch.number + self.cfg.seq_window_size;
let force_empty_batches = (expiry_epoch == parent.l1_origin.number && empty) ||
expiry_epoch < parent.l1_origin.number;
let bq_origin = self.origin.ok_or(StageError::MissingOrigin)?;
let force_empty_batches =
(expiry_epoch == bq_origin.number && empty) || expiry_epoch < bq_origin.number;
let first_of_epoch = epoch.number == parent.l1_origin.number + 1;

// If the sequencer window did not expire,
Expand Down Expand Up @@ -235,7 +236,7 @@ where
error!(target: "batch-queue", "Cannot add batch without an origin");
panic!("Cannot add batch without an origin");
}
let origin = self.origin.ok_or_else(|| anyhow!("cannot add batch with missing origin"))?;
let origin = self.origin.ok_or(StageError::MissingOrigin)?;
let data = BatchWithInclusionBlock { inclusion_block: origin, batch };
// If we drop the batch, validation logs the drop reason with WARN level.
if data.check_batch(&self.cfg, &self.l1_blocks, parent, &mut self.fetcher).await.is_drop() {
Expand Down

0 comments on commit 2f57beb

Please sign in to comment.