@@ -484,6 +484,7 @@ pub fn downgrade_from_v24<T: BeaconChainTypes>(
484
484
let mut migrate_ops = vec ! [ ] ;
485
485
let mut states_written = 0 ;
486
486
let mut summaries_written = 0 ;
487
+ let mut summaries_skipped = 0 ;
487
488
let mut last_log_time = Instant :: now ( ) ;
488
489
489
490
// Rebuild the PruningCheckpoint from the split.
@@ -502,6 +503,18 @@ pub fn downgrade_from_v24<T: BeaconChainTypes>(
502
503
. into_iter ( )
503
504
. flat_map ( |( _, summaries) | summaries)
504
505
{
506
+ // No need to migrate any states prior to the split. The v22 schema does not need them, and
507
+ // they would generate warnings about a disjoint DAG when re-upgrading to V24.
508
+ if summary. slot < split. slot {
509
+ debug ! (
510
+ slot = %summary. slot,
511
+ ?state_root,
512
+ "Skipping migration of pre-split state"
513
+ ) ;
514
+ summaries_skipped += 1 ;
515
+ continue ;
516
+ }
517
+
505
518
// If boundary state: persist.
506
519
// Do not cache these states as they are unlikely to be relevant later.
507
520
let update_cache = false ;
@@ -538,18 +551,6 @@ pub fn downgrade_from_v24<T: BeaconChainTypes>(
538
551
) ) ;
539
552
summaries_written += 1 ;
540
553
541
- // Delete existing data
542
- for db_column in [
543
- DBColumn :: BeaconStateHotSummary ,
544
- DBColumn :: BeaconStateHotDiff ,
545
- DBColumn :: BeaconStateHotSnapshot ,
546
- ] {
547
- migrate_ops. push ( KeyValueStoreOp :: DeleteKey (
548
- db_column,
549
- state_root. as_slice ( ) . to_vec ( ) ,
550
- ) ) ;
551
- }
552
-
553
554
if last_log_time. elapsed ( ) > Duration :: from_secs ( 5 ) {
554
555
last_log_time = Instant :: now ( ) ;
555
556
info ! (
@@ -561,9 +562,27 @@ pub fn downgrade_from_v24<T: BeaconChainTypes>(
561
562
}
562
563
}
563
564
565
+ // Delete all V24 schema data. We do this outside the loop over summaries to ensure we cover
566
+ // every piece of data and to simplify logic around skipping certain summaries that do not get
567
+ // migrated.
568
+ for db_column in [
569
+ DBColumn :: BeaconStateHotSummary ,
570
+ DBColumn :: BeaconStateHotDiff ,
571
+ DBColumn :: BeaconStateHotSnapshot ,
572
+ ] {
573
+ for key in db. hot_db . iter_column_keys :: < Hash256 > ( db_column) {
574
+ let state_root = key?;
575
+ migrate_ops. push ( KeyValueStoreOp :: DeleteKey (
576
+ db_column,
577
+ state_root. as_slice ( ) . to_vec ( ) ,
578
+ ) ) ;
579
+ }
580
+ }
581
+
564
582
info ! (
565
583
states_written,
566
584
summaries_written,
585
+ summaries_skipped,
567
586
summaries_count = state_summaries_dag. summaries_count( ) ,
568
587
"DB downgrade of v24 state summaries completed"
569
588
) ;
0 commit comments