diff --git a/bin/client/src/lib.rs b/bin/client/src/lib.rs index 964f11047..1b993288b 100644 --- a/bin/client/src/lib.rs +++ b/bin/client/src/lib.rs @@ -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 // diff --git a/crates/driver/src/core.rs b/crates/driver/src/core.rs index 9340fac88..835a3fb96 100644 --- a/crates/driver/src/core.rs +++ b/crates/driver/src/core.rs @@ -72,16 +72,18 @@ where pub async fn advance_to_target( &mut self, cfg: &RollupConfig, - mut target: u64, + mut target: Option, ) -> 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 @@ -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) => {