Skip to content

Commit 478f7e9

Browse files
authored
fix optimistic sync fork choice update (#465)
1 parent 84fcc8c commit 478f7e9

2 files changed

Lines changed: 11 additions & 8 deletions

File tree

crates/chain-orchestrator/src/lib.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,14 +1166,12 @@ impl<
11661166
}
11671167

11681168
// Update the FCS to the new head.
1169-
let result = self
1170-
.engine
1171-
.update_fcs(
1172-
Some(BlockInfo { number: chain_head_number, hash: chain_head_hash }),
1173-
None,
1174-
None,
1175-
)
1176-
.await?;
1169+
let head = BlockInfo { number: chain_head_number, hash: chain_head_hash };
1170+
let result = if self.sync_state.l2().is_syncing() {
1171+
self.engine.optimistic_sync(head).await?
1172+
} else {
1173+
self.engine.update_fcs(Some(head), None, None).await?
1174+
};
11771175

11781176
// If the FCS update resulted in an invalid state, we return an error.
11791177
if result.is_invalid() {

crates/chain-orchestrator/src/sync.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ impl SyncState {
3939
pub const fn is_synced(&self) -> bool {
4040
self.l1.is_synced() && self.l2.is_synced()
4141
}
42+
43+
/// Returns true if either L1 or L2 is syncing.
44+
pub const fn is_syncing(&self) -> bool {
45+
self.l1.is_syncing() || self.l2.is_syncing()
46+
}
4247
}
4348

4449
/// The sync mode of the chain orchestrator.

0 commit comments

Comments
 (0)