Skip to content

Commit

Permalink
Get last commitment height out of for loop
Browse files Browse the repository at this point in the history
  • Loading branch information
yaziciahmet committed Jul 17, 2024
1 parent 9798afb commit 592adb3
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions crates/sequencer/src/sequencer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -616,20 +616,22 @@ where
debug!("Pending db commitments: {:?}", pending_db_commitments);
let pending_da_commitments = self.get_pending_da_commitments().await;
debug!("Pending da commitments: {:?}", pending_da_commitments);

let mut last_commitment_l2_height = self
.ledger_db
.get_last_sequencer_commitment_l2_height()?
.unwrap_or(BatchNumber(0));
// TODO: also take mined DA blocks into account
for (l2_start, l2_end) in pending_db_commitments {
if pending_da_commitments.iter().any(|commitment| {
commitment.l2_start_block_number == l2_start.0
&& commitment.l2_end_block_number == l2_end.0
}) {
// Update last sequencer commitment l2 height
match self.ledger_db.get_last_sequencer_commitment_l2_height()? {
Some(last_commitment_l2_height) if last_commitment_l2_height >= l2_end => {}
_ => {
self.ledger_db
.set_last_sequencer_commitment_l2_height(l2_end)?;
}
};
if l2_end > last_commitment_l2_height {
last_commitment_l2_height = l2_end;
self.ledger_db
.set_last_sequencer_commitment_l2_height(l2_end)?;
}

// Delete from pending db if it is already in DA mempool
self.ledger_db
Expand Down

0 comments on commit 592adb3

Please sign in to comment.