Skip to content

Commit

Permalink
chore(driver): advance with optional target (#848)
Browse files Browse the repository at this point in the history
  • Loading branch information
refcell authored Nov 27, 2024
1 parent 443dad9 commit f4cb803
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion bin/client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ where
// Run the derivation pipeline until we are able to produce the output root of the claimed
// L2 block.
let (number, output_root) =
driver.advance_to_target(&boot.rollup_config, boot.claimed_l2_block_number).await?;
driver.advance_to_target(&boot.rollup_config, Some(boot.claimed_l2_block_number)).await?;

////////////////////////////////////////////////////////////////
// EPILOGUE //
Expand Down
20 changes: 12 additions & 8 deletions crates/driver/src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,18 @@ where
pub async fn advance_to_target(
&mut self,
cfg: &RollupConfig,
mut target: u64,
mut target: Option<u64>,
) -> DriverResult<(u64, B256), E::Error> {
loop {
// Check if we have reached the target block number.
if self.cursor.l2_safe_head().block_info.number >= target {
info!(target: "client", "Derivation complete, reached L2 safe head.");
return Ok((
self.cursor.l2_safe_head().block_info.number,
*self.cursor.l2_safe_head_output_root(),
));
if let Some(tb) = target {
if self.cursor.l2_safe_head().block_info.number >= tb {
info!(target: "client", "Derivation complete, reached L2 safe head.");
return Ok((
self.cursor.l2_safe_head().block_info.number,
*self.cursor.l2_safe_head_output_root(),
));
}
}

let OpAttributesWithParent { mut attributes, .. } = match self
Expand All @@ -95,7 +97,9 @@ where

// Adjust the target block number to the current safe head, as no more blocks
// can be produced.
target = self.cursor.l2_safe_head().block_info.number;
if target.is_some() {
target = Some(self.cursor.l2_safe_head().block_info.number);
};
continue;
}
Err(e) => {
Expand Down

0 comments on commit f4cb803

Please sign in to comment.