@@ -35,7 +35,7 @@ use state_processing::{
3535use std:: cmp:: min;
3636use std:: convert:: TryInto ;
3737use std:: marker:: PhantomData ;
38- use std:: path:: { Path , PathBuf } ;
38+ use std:: path:: Path ;
3939use std:: sync:: Arc ;
4040use std:: time:: Duration ;
4141use types:: blob_sidecar:: BlobSidecarList ;
@@ -61,7 +61,7 @@ pub struct HotColdDB<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> {
6161 /// Cold database containing compact historical data.
6262 pub cold_db : Cold ,
6363 /// Database containing blobs. If None, store falls back to use `cold_db`.
64- pub blobs_db : Option < Cold > ,
64+ pub blobs_db : Cold ,
6565 /// Hot database containing duplicated but quick-to-access recent data.
6666 ///
6767 /// The hot database also contains all blocks.
@@ -138,7 +138,6 @@ pub enum HotColdDBError {
138138 MissingExecutionPayload ( Hash256 ) ,
139139 MissingFullBlockExecutionPayloadPruned ( Hash256 , Slot ) ,
140140 MissingAnchorInfo ,
141- MissingPathToBlobsDatabase ,
142141 BlobsPreviouslyInDefaultStore ,
143142 HotStateSummaryError ( BeaconStateError ) ,
144143 RestorePointDecodeError ( ssz:: DecodeError ) ,
@@ -178,7 +177,7 @@ impl<E: EthSpec> HotColdDB<E, MemoryStore<E>, MemoryStore<E>> {
178177 anchor_info : RwLock :: new ( None ) ,
179178 blob_info : RwLock :: new ( BlobInfo :: default ( ) ) ,
180179 cold_db : MemoryStore :: open ( ) ,
181- blobs_db : Some ( MemoryStore :: open ( ) ) ,
180+ blobs_db : MemoryStore :: open ( ) ,
182181 hot_db : MemoryStore :: open ( ) ,
183182 block_cache : Mutex :: new ( BlockCache :: new ( config. block_cache_size ) ) ,
184183 state_cache : Mutex :: new ( LruCache :: new ( config. historic_state_cache_size ) ) ,
@@ -202,7 +201,7 @@ impl<E: EthSpec> HotColdDB<E, LevelDB<E>, LevelDB<E>> {
202201 pub fn open (
203202 hot_path : & Path ,
204203 cold_path : & Path ,
205- blobs_db_path : Option < PathBuf > ,
204+ blobs_db_path : & Path ,
206205 migrate_schema : impl FnOnce ( Arc < Self > , SchemaVersion , SchemaVersion ) -> Result < ( ) , Error > ,
207206 config : StoreConfig ,
208207 spec : ChainSpec ,
@@ -215,7 +214,7 @@ impl<E: EthSpec> HotColdDB<E, LevelDB<E>, LevelDB<E>> {
215214 anchor_info : RwLock :: new ( None ) ,
216215 blob_info : RwLock :: new ( BlobInfo :: default ( ) ) ,
217216 cold_db : LevelDB :: open ( cold_path) ?,
218- blobs_db : None ,
217+ blobs_db : LevelDB :: open ( blobs_db_path ) ? ,
219218 hot_db : LevelDB :: open ( hot_path) ?,
220219 block_cache : Mutex :: new ( BlockCache :: new ( config. block_cache_size ) ) ,
221220 state_cache : Mutex :: new ( LruCache :: new ( config. historic_state_cache_size ) ) ,
@@ -271,37 +270,29 @@ impl<E: EthSpec> HotColdDB<E, LevelDB<E>, LevelDB<E>> {
271270 Some ( blob_info) => {
272271 // If the oldest block slot is already set do not allow the blob DB path to be
273272 // changed (require manual migration).
274- if blob_info. oldest_blob_slot . is_some ( ) {
275- if blobs_db_path. is_some ( ) && !blob_info. blobs_db {
276- return Err ( HotColdDBError :: BlobsPreviouslyInDefaultStore . into ( ) ) ;
277- } else if blobs_db_path. is_none ( ) && blob_info. blobs_db {
278- return Err ( HotColdDBError :: MissingPathToBlobsDatabase . into ( ) ) ;
279- }
273+ if blob_info. oldest_blob_slot . is_some ( ) && !blob_info. blobs_db {
274+ return Err ( HotColdDBError :: BlobsPreviouslyInDefaultStore . into ( ) ) ;
280275 }
281276 // Set the oldest blob slot to the Deneb fork slot if it is not yet set.
277+ // Always initialize `blobs_db` to true, we no longer support storing the blobs
278+ // in the freezer DB, because the UX is strictly worse for relocating the DB.
282279 let oldest_blob_slot = blob_info. oldest_blob_slot . or ( deneb_fork_slot) ;
283280 BlobInfo {
284281 oldest_blob_slot,
285- blobs_db : blobs_db_path . is_some ( ) ,
282+ blobs_db : true ,
286283 }
287284 }
288285 // First start.
289286 None => BlobInfo {
290287 // Set the oldest blob slot to the Deneb fork slot if it is not yet set.
291288 oldest_blob_slot : deneb_fork_slot,
292- blobs_db : blobs_db_path . is_some ( ) ,
289+ blobs_db : true ,
293290 } ,
294291 } ;
295- if new_blob_info. blobs_db {
296- if let Some ( path) = & blobs_db_path {
297- db. blobs_db = Some ( LevelDB :: open ( path. as_path ( ) ) ?) ;
298- }
299- }
300292 db. compare_and_set_blob_info_with_write ( <_ >:: default ( ) , new_blob_info. clone ( ) ) ?;
301293 info ! (
302294 db. log,
303295 "Blob DB initialized" ;
304- "separate_db" => new_blob_info. blobs_db,
305296 "path" => ?blobs_db_path,
306297 "oldest_blob_slot" => ?new_blob_info. oldest_blob_slot,
307298 ) ;
@@ -575,8 +566,8 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
575566
576567 /// Check if the blobs for a block exists on disk.
577568 pub fn blobs_exist ( & self , block_root : & Hash256 ) -> Result < bool , Error > {
578- let blobs_db = self . blobs_db . as_ref ( ) . unwrap_or ( & self . cold_db ) ;
579- blobs_db . key_exists ( DBColumn :: BeaconBlob . into ( ) , block_root. as_bytes ( ) )
569+ self . blobs_db
570+ . key_exists ( DBColumn :: BeaconBlob . into ( ) , block_root. as_bytes ( ) )
580571 }
581572
582573 /// Determine whether a block exists in the database.
@@ -592,13 +583,12 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
592583 . key_delete ( DBColumn :: BeaconBlock . into ( ) , block_root. as_bytes ( ) ) ?;
593584 self . hot_db
594585 . key_delete ( DBColumn :: ExecPayload . into ( ) , block_root. as_bytes ( ) ) ?;
595- let blobs_db = self . blobs_db . as_ref ( ) . unwrap_or ( & self . cold_db ) ;
596- blobs_db . key_delete ( DBColumn :: BeaconBlob . into ( ) , block_root. as_bytes ( ) )
586+ self . blobs_db
587+ . key_delete ( DBColumn :: BeaconBlob . into ( ) , block_root. as_bytes ( ) )
597588 }
598589
599590 pub fn put_blobs ( & self , block_root : & Hash256 , blobs : BlobSidecarList < E > ) -> Result < ( ) , Error > {
600- let blobs_db = self . blobs_db . as_ref ( ) . unwrap_or ( & self . cold_db ) ;
601- blobs_db. put_bytes (
591+ self . blobs_db . put_bytes (
602592 DBColumn :: BeaconBlob . into ( ) ,
603593 block_root. as_bytes ( ) ,
604594 & blobs. as_ssz_bytes ( ) ,
@@ -988,9 +978,9 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
988978 let mut guard = self . block_cache . lock ( ) ;
989979
990980 let blob_cache_ops = blobs_ops. clone ( ) ;
991- let blobs_db = self . blobs_db . as_ref ( ) . unwrap_or ( & self . cold_db ) ;
992981 // Try to execute blobs store ops.
993- blobs_db. do_atomically ( self . convert_to_kv_batch ( blobs_ops) ?) ?;
982+ self . blobs_db
983+ . do_atomically ( self . convert_to_kv_batch ( blobs_ops) ?) ?;
994984
995985 let hot_db_cache_ops = hot_db_ops. clone ( ) ;
996986 // Try to execute hot db store ops.
@@ -1018,7 +1008,8 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
10181008 } ;
10191009 * op = reverse_op;
10201010 }
1021- blobs_db. do_atomically ( self . convert_to_kv_batch ( blob_cache_ops) ?) ?;
1011+ self . blobs_db
1012+ . do_atomically ( self . convert_to_kv_batch ( blob_cache_ops) ?) ?;
10221013 return Err ( e) ;
10231014 }
10241015
@@ -1436,15 +1427,16 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
14361427
14371428 /// Fetch blobs for a given block from the store.
14381429 pub fn get_blobs ( & self , block_root : & Hash256 ) -> Result < Option < BlobSidecarList < E > > , Error > {
1439- let blobs_db = self . blobs_db . as_ref ( ) . unwrap_or ( & self . cold_db ) ;
1440-
14411430 // Check the cache.
14421431 if let Some ( blobs) = self . block_cache . lock ( ) . get_blobs ( block_root) {
14431432 metrics:: inc_counter ( & metrics:: BEACON_BLOBS_CACHE_HIT_COUNT ) ;
14441433 return Ok ( Some ( blobs. clone ( ) ) ) ;
14451434 }
14461435
1447- match blobs_db. get_bytes ( DBColumn :: BeaconBlob . into ( ) , block_root. as_bytes ( ) ) ? {
1436+ match self
1437+ . blobs_db
1438+ . get_bytes ( DBColumn :: BeaconBlob . into ( ) , block_root. as_bytes ( ) ) ?
1439+ {
14481440 Some ( ref blobs_bytes) => {
14491441 let blobs = BlobSidecarList :: from_ssz_bytes ( blobs_bytes) ?;
14501442 self . block_cache
@@ -1640,7 +1632,7 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
16401632 } ) ;
16411633 let blob_info = BlobInfo {
16421634 oldest_blob_slot,
1643- blobs_db : self . blobs_db . is_some ( ) ,
1635+ blobs_db : true ,
16441636 } ;
16451637 self . compare_and_set_blob_info ( self . get_blob_info ( ) , blob_info)
16461638 }
0 commit comments