@@ -320,24 +320,7 @@ impl<S: StorageManager + Send + Sync + 'static, N: NetworkManager + Send + Sync
320320 base_hash : Option < BlockHash > ,
321321 ) -> SyncResult < ( ) > {
322322 let block_locator = match base_hash {
323- Some ( hash) => {
324- // When syncing from a checkpoint, we need to create a proper locator
325- // that helps the peer understand we want headers AFTER this point
326- if self . is_synced_from_checkpoint ( ) {
327- // For checkpoint sync, only include the checkpoint hash
328- // Including genesis would allow peers to fall back to sending headers from genesis
329- // if they don't recognize the checkpoint, which is exactly what we want to avoid
330- tracing:: debug!(
331- "📍 Using checkpoint-only locator for height {}: [{}]" ,
332- self . get_sync_base_height( ) ,
333- hash
334- ) ;
335- vec ! [ hash]
336- } else {
337- // Always include the hash in the locator - peer needs to know our position
338- vec ! [ hash]
339- }
340- }
323+ Some ( hash) => vec ! [ hash] ,
341324 None => {
342325 // Check if we're syncing from a checkpoint
343326 if self . is_synced_from_checkpoint ( )
@@ -461,33 +444,22 @@ impl<S: StorageManager + Send + Sync + 'static, N: NetworkManager + Send + Sync
461444 // Check if we need to initialize the compression state
462445 let state = self . headers2_state . get_state ( peer_id) ;
463446 if state. prev_header . is_none ( ) {
464- // If we're syncing from genesis (height 0), initialize with genesis header
465- if self . chain_state . read ( ) . await . tip_height ( ) == 0 {
466- // We have genesis header at index 0
467- if let Some ( genesis_header) = self . chain_state . read ( ) . await . header_at_height ( 0 )
468- {
469- tracing:: info!(
470- "Initializing headers2 compression state for peer {} with genesis header" ,
471- peer_id
472- ) ;
473- self . headers2_state . init_peer_state ( peer_id, * genesis_header) ;
474- }
475- } else if self . chain_state . read ( ) . await . tip_height ( ) > 0 {
476- // Get our current tip to use as the base for compression
477- if let Some ( tip_header) = self . chain_state . read ( ) . await . get_tip_header ( ) {
478- tracing:: info!(
479- "Initializing headers2 compression state for peer {} with tip header at height {}" ,
480- peer_id,
481- self . chain_state. read( ) . await . tip_height( )
482- ) ;
483- self . headers2_state . init_peer_state ( peer_id, tip_header) ;
484- }
447+ // Initialize with header at current tip height (works for both genesis and later)
448+ let chain_state = self . chain_state . read ( ) . await ;
449+ let tip_height = chain_state. tip_height ( ) ;
450+ if let Some ( tip_header) = chain_state. header_at_height ( tip_height) {
451+ tracing:: info!(
452+ "Initializing headers2 compression state for peer {} with header at height {}" ,
453+ peer_id,
454+ tip_height
455+ ) ;
456+ self . headers2_state . init_peer_state ( peer_id, * tip_header) ;
485457 }
486458 }
487459 }
488460
489461 // Decompress headers using the peer's compression state
490- let headers = match self . headers2_state . process_headers ( peer_id, headers2. headers . clone ( ) ) {
462+ let headers = match self . headers2_state . process_headers ( peer_id, & headers2. headers ) {
491463 Ok ( headers) => headers,
492464 Err ( e) => {
493465 tracing:: error!(
0 commit comments