@@ -91,7 +91,7 @@ impl SlotsProcessor<ReqwestTransport> {
91
91
{
92
92
info ! (
93
93
new_head_slot = block_header. slot,
94
- old__head_slot = prev_block_header. slot,
94
+ old_head_slot = prev_block_header. slot,
95
95
new_head_block_root = ?block_header. root,
96
96
old_head_block_root = ?prev_block_header. root,
97
97
"Reorg detected!" ,
@@ -270,65 +270,58 @@ impl SlotsProcessor<ReqwestTransport> {
270
270
let mut rewinded_blocks: Vec < B256 > = vec ! [ ] ;
271
271
272
272
while reorg_depth <= MAX_ALLOWED_REORG_DEPTH && current_old_slot > 0 {
273
- reorg_depth += 1 ;
274
-
275
273
// We iterate over blocks by slot and not block root as blobscan blocks don't
276
274
// have parent root we can use to traverse the chain
277
- let old_blobscan_block = match self
275
+ if let Some ( old_blobscan_block) = self
278
276
. context
279
277
. blobscan_client ( )
280
278
. get_block ( current_old_slot)
281
279
. await ?
282
280
{
283
- Some ( block) => block,
284
- None => {
285
- current_old_slot -= 1 ;
286
-
287
- continue ;
288
- }
289
- } ;
281
+ let canonical_block_path = self
282
+ . get_canonical_block_path ( & old_blobscan_block, new_head_header. root )
283
+ . await ?;
290
284
291
- let canonical_block_path = self
292
- . get_canonical_block_path ( & old_blobscan_block, new_head_header. root )
293
- . await ?;
294
-
295
- // If a path exists, we've found the common ancient block
296
- // and can proceed with handling the reorg.
297
- if !canonical_block_path. is_empty ( ) {
298
- let canonical_block_path =
299
- canonical_block_path. into_iter ( ) . rev ( ) . collect :: < Vec < _ > > ( ) ;
300
-
301
- let canonical_block_headers: Vec < BlockHeader > = canonical_block_path
302
- . iter ( )
303
- . map ( |block| block. into ( ) )
304
- . collect :: < Vec < _ > > ( ) ;
305
-
306
- // If the new canonical block path includes blocks beyond the new head block,
307
- // they were skipped and must be processed.
308
- for block in canonical_block_headers. iter ( ) {
309
- if block. slot != new_head_header. slot {
310
- self . process_block ( block)
311
- . await
312
- . with_context ( || format ! ( "Failed to sync forwarded block" ) ) ?;
285
+ // If a path exists, we've found the common ancient block
286
+ if !canonical_block_path. is_empty ( ) {
287
+ let canonical_block_path =
288
+ canonical_block_path. into_iter ( ) . rev ( ) . collect :: < Vec < _ > > ( ) ;
289
+
290
+ let canonical_block_headers: Vec < BlockHeader > = canonical_block_path
291
+ . iter ( )
292
+ . map ( |block| block. into ( ) )
293
+ . collect :: < Vec < _ > > ( ) ;
294
+
295
+ // If the new canonical block path includes blocks beyond the new head block,
296
+ // they were skipped and must be processed.
297
+ for block in canonical_block_headers. iter ( ) {
298
+ if block. slot != new_head_header. slot {
299
+ self . process_block ( block)
300
+ . await
301
+ . with_context ( || format ! ( "Failed to sync forwarded block" ) ) ?;
302
+ }
313
303
}
314
- }
315
304
316
- let forwarded_blocks = canonical_block_path
317
- . iter ( )
318
- . map ( |block| block. execution_block_hash )
319
- . collect :: < Vec < _ > > ( ) ;
305
+ let forwarded_blocks = canonical_block_path
306
+ . iter ( )
307
+ . map ( |block| block. execution_block_hash )
308
+ . collect :: < Vec < _ > > ( ) ;
320
309
321
- self . context
322
- . blobscan_client ( )
323
- . handle_reorg ( rewinded_blocks. clone ( ) , forwarded_blocks. clone ( ) )
324
- . await ?;
310
+ self . context
311
+ . blobscan_client ( )
312
+ . handle_reorg ( rewinded_blocks. clone ( ) , forwarded_blocks. clone ( ) )
313
+ . await ?;
325
314
326
- info ! ( rewinded_blocks = ?rewinded_blocks, forwarded_blocks = ?forwarded_blocks, "Reorg handled!" , ) ;
315
+ info ! ( rewinded_blocks = ?rewinded_blocks, forwarded_blocks = ?forwarded_blocks, "Reorg handled!" ) ;
327
316
328
- return Ok ( ( ) ) ;
317
+ return Ok ( ( ) ) ;
318
+ }
319
+
320
+ rewinded_blocks. push ( old_blobscan_block. hash ) ;
329
321
}
330
322
331
- rewinded_blocks. push ( old_blobscan_block. hash ) ;
323
+ current_old_slot -= 1 ;
324
+ reorg_depth += 1 ;
332
325
}
333
326
334
327
Err ( anyhow ! ( "No common block found" ) . into ( ) )
0 commit comments