@@ -124,14 +124,22 @@ pub enum Notification {
124
124
Finalization ( FinalizationNotification ) ,
125
125
Reconstruction ,
126
126
PruneBlobs ( Epoch ) ,
127
+ ManualFinalization ( ManualFinalizationNotification ) ,
128
+ }
129
+
130
+ pub struct ManualFinalizationNotification {
131
+ pub state_root : BeaconStateHash ,
132
+ pub checkpoint : Checkpoint ,
133
+ pub head_tracker : Arc < HeadTracker > ,
134
+ pub genesis_block_root : Hash256 ,
127
135
}
128
136
129
137
pub struct FinalizationNotification {
130
- finalized_state_root : BeaconStateHash ,
131
- finalized_checkpoint : Checkpoint ,
132
- head_tracker : Arc < HeadTracker > ,
133
- prev_migration : Arc < Mutex < PrevMigration > > ,
134
- genesis_block_root : Hash256 ,
138
+ pub finalized_state_root : BeaconStateHash ,
139
+ pub finalized_checkpoint : Checkpoint ,
140
+ pub head_tracker : Arc < HeadTracker > ,
141
+ pub prev_migration : Arc < Mutex < PrevMigration > > ,
142
+ pub genesis_block_root : Hash256 ,
135
143
}
136
144
137
145
impl < E : EthSpec , Hot : ItemStore < E > , Cold : ItemStore < E > > BackgroundMigrator < E , Hot , Cold > {
@@ -190,6 +198,14 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> BackgroundMigrator<E, Ho
190
198
Ok ( ( ) )
191
199
}
192
200
201
+ pub fn process_manual_finalization ( & self , notif : ManualFinalizationNotification ) {
202
+ if let Some ( Notification :: ManualFinalization ( notif) ) =
203
+ self . send_background_notification ( Notification :: ManualFinalization ( notif) )
204
+ {
205
+ Self :: run_manual_migration ( self . db . clone ( ) , notif, & self . log ) ;
206
+ }
207
+ }
208
+
193
209
pub fn process_reconstruction ( & self ) {
194
210
if let Some ( Notification :: Reconstruction ) =
195
211
self . send_background_notification ( Notification :: Reconstruction )
@@ -289,6 +305,26 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> BackgroundMigrator<E, Ho
289
305
}
290
306
}
291
307
308
+ fn run_manual_migration (
309
+ db : Arc < HotColdDB < E , Hot , Cold > > ,
310
+ notif : ManualFinalizationNotification ,
311
+ log : & Logger ,
312
+ ) {
313
+ // We create a "dummy" prev migration
314
+ let prev_migration = PrevMigration {
315
+ epoch : Epoch :: new ( 1 ) ,
316
+ epochs_per_migration : 2 ,
317
+ } ;
318
+ let notif = FinalizationNotification {
319
+ finalized_state_root : notif. state_root ,
320
+ finalized_checkpoint : notif. checkpoint ,
321
+ head_tracker : notif. head_tracker ,
322
+ prev_migration : Arc :: new ( prev_migration. into ( ) ) ,
323
+ genesis_block_root : notif. genesis_block_root ,
324
+ } ;
325
+ Self :: run_migration ( db, notif, log) ;
326
+ }
327
+
292
328
/// Perform the actual work of `process_finalization`.
293
329
fn run_migration (
294
330
db : Arc < HotColdDB < E , Hot , Cold > > ,
@@ -423,16 +459,27 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> BackgroundMigrator<E, Ho
423
459
while let Ok ( notif) = rx. recv ( ) {
424
460
let mut reconstruction_notif = None ;
425
461
let mut finalization_notif = None ;
462
+ let mut manual_finalization_notif = None ;
426
463
let mut prune_blobs_notif = None ;
427
464
match notif {
428
465
Notification :: Reconstruction => reconstruction_notif = Some ( notif) ,
429
466
Notification :: Finalization ( fin) => finalization_notif = Some ( fin) ,
467
+ Notification :: ManualFinalization ( fin) => manual_finalization_notif = Some ( fin) ,
430
468
Notification :: PruneBlobs ( dab) => prune_blobs_notif = Some ( dab) ,
431
469
}
432
470
// Read the rest of the messages in the channel, taking the best of each type.
433
471
for notif in rx. try_iter ( ) {
434
472
match notif {
435
473
Notification :: Reconstruction => reconstruction_notif = Some ( notif) ,
474
+ Notification :: ManualFinalization ( fin) => {
475
+ if let Some ( current) = manual_finalization_notif. as_mut ( ) {
476
+ if fin. checkpoint . epoch > current. checkpoint . epoch {
477
+ * current = fin;
478
+ }
479
+ } else {
480
+ manual_finalization_notif = Some ( fin) ;
481
+ }
482
+ }
436
483
Notification :: Finalization ( fin) => {
437
484
if let Some ( current) = finalization_notif. as_mut ( ) {
438
485
if fin. finalized_checkpoint . epoch
@@ -455,6 +502,9 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> BackgroundMigrator<E, Ho
455
502
if let Some ( fin) = finalization_notif {
456
503
Self :: run_migration ( db. clone ( ) , fin, & log) ;
457
504
}
505
+ if let Some ( fin) = manual_finalization_notif {
506
+ Self :: run_manual_migration ( db. clone ( ) , fin, & log) ;
507
+ }
458
508
if let Some ( dab) = prune_blobs_notif {
459
509
Self :: run_prune_blobs ( db. clone ( ) , dab, & log) ;
460
510
}
0 commit comments