diff --git a/crates/chain-orchestrator/src/lib.rs b/crates/chain-orchestrator/src/lib.rs index 1ecbfd6b..33bf6a8a 100644 --- a/crates/chain-orchestrator/src/lib.rs +++ b/crates/chain-orchestrator/src/lib.rs @@ -1166,14 +1166,12 @@ impl< } // Update the FCS to the new head. - let result = self - .engine - .update_fcs( - Some(BlockInfo { number: chain_head_number, hash: chain_head_hash }), - None, - None, - ) - .await?; + let head = BlockInfo { number: chain_head_number, hash: chain_head_hash }; + let result = if self.sync_state.l2().is_syncing() { + self.engine.optimistic_sync(head).await? + } else { + self.engine.update_fcs(Some(head), None, None).await? + }; // If the FCS update resulted in an invalid state, we return an error. if result.is_invalid() { diff --git a/crates/chain-orchestrator/src/sync.rs b/crates/chain-orchestrator/src/sync.rs index be73a69c..992b9fe7 100644 --- a/crates/chain-orchestrator/src/sync.rs +++ b/crates/chain-orchestrator/src/sync.rs @@ -39,6 +39,11 @@ impl SyncState { pub const fn is_synced(&self) -> bool { self.l1.is_synced() && self.l2.is_synced() } + + /// Returns true if either L1 or L2 is syncing. + pub const fn is_syncing(&self) -> bool { + self.l1.is_syncing() || self.l2.is_syncing() + } } /// The sync mode of the chain orchestrator.