@@ -1207,18 +1207,18 @@ where
12071207 debug ! ( target: "engine::tree" , "received backfill sync finished event" ) ;
12081208 self . backfill_sync_state = BackfillSyncState :: Idle ;
12091209
1210- // backfill height is the block number that the backfill finished at
1211- let mut backfill_height = ctrl. block_number ( ) ;
1212-
12131210 // Pipeline unwound, memorize the invalid block and wait for CL for next sync target.
1214- if let ControlFlow :: Unwind { bad_block, target } = & ctrl {
1211+ let backfill_height = if let ControlFlow :: Unwind { bad_block, target } = & ctrl {
12151212 warn ! ( target: "engine::tree" , invalid_block=?bad_block, "Bad block detected in unwind" ) ;
12161213 // update the `invalid_headers` cache with the new invalid header
12171214 self . state . invalid_headers . insert ( * * bad_block) ;
12181215
12191216 // if this was an unwind then the target is the new height
1220- backfill_height = Some ( * target) ;
1221- }
1217+ Some ( * target)
1218+ } else {
1219+ // backfill height is the block number that the backfill finished at
1220+ ctrl. block_number ( )
1221+ } ;
12221222
12231223 // backfill height is the block number that the backfill finished at
12241224 let Some ( backfill_height) = backfill_height else { return Ok ( ( ) ) } ;
@@ -1780,20 +1780,18 @@ where
17801780 ) -> Option < B256 > {
17811781 let sync_target_state = self . state . forkchoice_state_tracker . sync_target_state ( ) ;
17821782
1783- // check if the distance exceeds the threshold for backfill sync
1784- let mut exceeds_backfill_threshold =
1785- self . exceeds_backfill_run_threshold ( canonical_tip_num, target_block_number) ;
1786-
17871783 // check if the downloaded block is the tracked finalized block
1788- if let Some ( buffered_finalized) = sync_target_state
1784+ let mut exceeds_backfill_threshold = if let Some ( buffered_finalized) = sync_target_state
17891785 . as_ref ( )
17901786 . and_then ( |state| self . state . buffer . block ( & state. finalized_block_hash ) )
17911787 {
17921788 // if we have buffered the finalized block, we should check how far
17931789 // we're off
1794- exceeds_backfill_threshold =
1795- self . exceeds_backfill_run_threshold ( canonical_tip_num, buffered_finalized. number ( ) ) ;
1796- }
1790+ self . exceeds_backfill_run_threshold ( canonical_tip_num, buffered_finalized. number ( ) )
1791+ } else {
1792+ // check if the distance exceeds the threshold for backfill sync
1793+ self . exceeds_backfill_run_threshold ( canonical_tip_num, target_block_number)
1794+ } ;
17971795
17981796 // If this is invoked after we downloaded a block we can check if this block is the
17991797 // finalized block
0 commit comments