@@ -34,6 +34,7 @@ struct DbPathConfig {
3434 state_kv_db_path : Option < ShardedDbPathConfig > ,
3535 state_merkle_db_path : Option < ShardedDbPathConfig > ,
3636 hot_state_kv_db_path : Option < ShardedDbPathConfig > ,
37+ hot_state_merkle_db_path : Option < ShardedDbPathConfig > ,
3738}
3839
3940#[ derive( Clone , Debug , Deserialize , PartialEq , Eq , Serialize ) ]
@@ -242,12 +243,15 @@ impl Default for RocksdbConfigs {
242243pub struct HotStateConfig {
243244 /// Max number of items in each shard.
244245 pub max_items_per_shard : usize ,
246+ /// Whether to delete persisted data on disk on restart. Used during development.
247+ pub delete_on_restart : bool ,
245248}
246249
247250impl Default for HotStateConfig {
248251 fn default ( ) -> Self {
249252 Self {
250253 max_items_per_shard : 250_000 ,
254+ delete_on_restart : true ,
251255 }
252256 }
253257}
@@ -458,6 +462,7 @@ impl StorageConfig {
458462 let mut state_kv_db_paths = ShardedDbPaths :: default ( ) ;
459463 let mut state_merkle_db_paths = ShardedDbPaths :: default ( ) ;
460464 let mut hot_state_kv_db_paths = ShardedDbPaths :: default ( ) ;
465+ let mut hot_state_merkle_db_paths = ShardedDbPaths :: default ( ) ;
461466
462467 if let Some ( db_path_overrides) = self . db_path_overrides . as_ref ( ) {
463468 db_path_overrides
@@ -475,6 +480,12 @@ impl StorageConfig {
475480 if let Some ( hot_state_kv_db_path) = db_path_overrides. hot_state_kv_db_path . as_ref ( ) {
476481 hot_state_kv_db_paths = ShardedDbPaths :: new ( hot_state_kv_db_path) ;
477482 }
483+
484+ if let Some ( hot_state_merkle_db_path) =
485+ db_path_overrides. hot_state_merkle_db_path . as_ref ( )
486+ {
487+ hot_state_merkle_db_paths = ShardedDbPaths :: new ( hot_state_merkle_db_path) ;
488+ }
478489 }
479490
480491 StorageDirPaths :: new (
@@ -483,6 +494,7 @@ impl StorageConfig {
483494 state_kv_db_paths,
484495 state_merkle_db_paths,
485496 hot_state_kv_db_paths,
497+ hot_state_merkle_db_paths,
486498 )
487499 }
488500
@@ -503,6 +515,7 @@ pub struct StorageDirPaths {
503515 state_kv_db_paths : ShardedDbPaths ,
504516 state_merkle_db_paths : ShardedDbPaths ,
505517 hot_state_kv_db_paths : ShardedDbPaths ,
518+ hot_state_merkle_db_paths : ShardedDbPaths ,
506519}
507520
508521impl StorageDirPaths {
@@ -548,13 +561,26 @@ impl StorageDirPaths {
548561 . unwrap_or ( & self . default_path )
549562 }
550563
564+ pub fn hot_state_merkle_db_metadata_root_path ( & self ) -> & PathBuf {
565+ self . hot_state_merkle_db_paths
566+ . metadata_path ( )
567+ . unwrap_or ( & self . default_path )
568+ }
569+
570+ pub fn hot_state_merkle_db_shard_root_path ( & self , shard_id : usize ) -> & PathBuf {
571+ self . hot_state_merkle_db_paths
572+ . shard_path ( shard_id)
573+ . unwrap_or ( & self . default_path )
574+ }
575+
551576 pub fn from_path < P : AsRef < Path > > ( path : P ) -> Self {
552577 Self {
553578 default_path : path. as_ref ( ) . to_path_buf ( ) ,
554579 ledger_db_path : None ,
555580 state_kv_db_paths : Default :: default ( ) ,
556581 state_merkle_db_paths : Default :: default ( ) ,
557582 hot_state_kv_db_paths : Default :: default ( ) ,
583+ hot_state_merkle_db_paths : Default :: default ( ) ,
558584 }
559585 }
560586
@@ -564,13 +590,15 @@ impl StorageDirPaths {
564590 state_kv_db_paths : ShardedDbPaths ,
565591 state_merkle_db_paths : ShardedDbPaths ,
566592 hot_state_kv_db_paths : ShardedDbPaths ,
593+ hot_state_merkle_db_paths : ShardedDbPaths ,
567594 ) -> Self {
568595 Self {
569596 default_path,
570597 ledger_db_path,
571598 state_kv_db_paths,
572599 state_merkle_db_paths,
573600 hot_state_kv_db_paths,
601+ hot_state_merkle_db_paths,
574602 }
575603 }
576604}
@@ -732,6 +760,23 @@ impl ConfigSanitizer for StorageConfig {
732760 return Err ( Error :: ConfigSanitizerFailed ( sanitizer_name, e. to_string ( ) ) ) ;
733761 }
734762 }
763+
764+ if let Some ( hot_state_merkle_db_path) =
765+ db_path_overrides. hot_state_merkle_db_path . as_ref ( )
766+ {
767+ if let Some ( metadata_path) = hot_state_merkle_db_path. metadata_path . as_ref ( ) {
768+ if !metadata_path. is_absolute ( ) {
769+ return Err ( Error :: ConfigSanitizerFailed (
770+ sanitizer_name,
771+ format ! ( "Path {metadata_path:?} in db_path_overrides is not an absolute path." ) ,
772+ ) ) ;
773+ }
774+ }
775+
776+ if let Err ( e) = hot_state_merkle_db_path. get_shard_paths ( ) {
777+ return Err ( Error :: ConfigSanitizerFailed ( sanitizer_name, e. to_string ( ) ) ) ;
778+ }
779+ }
735780 }
736781
737782 Ok ( ( ) )
0 commit comments