@@ -2484,6 +2484,45 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
2484
2484
Ok ( ( ) )
2485
2485
}
2486
2486
2487
+ /// Run a compaction pass on the freezer DB to free up space used by deleted states.
2488
+ pub fn compact_freezer ( & self ) -> Result < ( ) , Error > {
2489
+ let current_schema_columns = vec ! [
2490
+ DBColumn :: BeaconColdStateSummary ,
2491
+ DBColumn :: BeaconStateSnapshot ,
2492
+ DBColumn :: BeaconStateDiff ,
2493
+ DBColumn :: BeaconStateRoots ,
2494
+ ] ;
2495
+
2496
+ // We can remove this once schema V21 has been gone for a while.
2497
+ let previous_schema_columns = vec ! [
2498
+ DBColumn :: BeaconState ,
2499
+ DBColumn :: BeaconStateSummary ,
2500
+ DBColumn :: BeaconBlockRootsChunked ,
2501
+ DBColumn :: BeaconStateRootsChunked ,
2502
+ DBColumn :: BeaconRestorePoint ,
2503
+ DBColumn :: BeaconHistoricalRoots ,
2504
+ DBColumn :: BeaconRandaoMixes ,
2505
+ DBColumn :: BeaconHistoricalSummaries ,
2506
+ ] ;
2507
+ let mut columns = current_schema_columns;
2508
+ columns. extend ( previous_schema_columns) ;
2509
+
2510
+ for column in columns {
2511
+ info ! (
2512
+ self . log,
2513
+ "Starting compaction" ;
2514
+ "column" => ?column
2515
+ ) ;
2516
+ self . cold_db . compact_column ( column) ?;
2517
+ info ! (
2518
+ self . log,
2519
+ "Finishing compaction" ;
2520
+ "column" => ?column
2521
+ ) ;
2522
+ }
2523
+ Ok ( ( ) )
2524
+ }
2525
+
2487
2526
/// Return `true` if compaction on finalization/pruning is enabled.
2488
2527
pub fn compact_on_prune ( & self ) -> bool {
2489
2528
self . config . compact_on_prune
@@ -2875,6 +2914,7 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
2875
2914
//
2876
2915
// We can remove this once schema V21 has been gone for a while.
2877
2916
let previous_schema_columns = vec ! [
2917
+ DBColumn :: BeaconState ,
2878
2918
DBColumn :: BeaconStateSummary ,
2879
2919
DBColumn :: BeaconBlockRootsChunked ,
2880
2920
DBColumn :: BeaconStateRootsChunked ,
@@ -2916,7 +2956,7 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
2916
2956
self . cold_db . do_atomically ( cold_ops) ?;
2917
2957
2918
2958
// In order to reclaim space, we need to compact the freezer DB as well.
2919
- self . cold_db . compact ( ) ?;
2959
+ self . compact_freezer ( ) ?;
2920
2960
2921
2961
Ok ( ( ) )
2922
2962
}
0 commit comments