@@ -29,25 +29,26 @@ pub const BUFFERED_STATE_TARGET_ITEMS_FOR_TEST: usize = 10;
2929
3030#[ derive( Clone , Debug , Default , Deserialize , PartialEq , Eq , Serialize ) ]
3131#[ serde( default , deny_unknown_fields) ]
32- pub struct DbPathConfig {
33- pub ledger_db_path : Option < PathBuf > ,
34- pub state_kv_db_path : Option < ShardedDbPathConfig > ,
35- pub state_merkle_db_path : Option < ShardedDbPathConfig > ,
36- pub hot_state_kv_db_path : Option < ShardedDbPathConfig > ,
32+ struct DbPathConfig {
33+ ledger_db_path : Option < PathBuf > ,
34+ state_kv_db_path : Option < ShardedDbPathConfig > ,
35+ state_merkle_db_path : Option < ShardedDbPathConfig > ,
36+ 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 ) ]
4041#[ serde( deny_unknown_fields) ]
41- pub struct ShardedDbPathConfig {
42- pub metadata_path : Option < PathBuf > ,
43- pub shard_paths : Vec < ShardPathConfig > ,
42+ struct ShardedDbPathConfig {
43+ metadata_path : Option < PathBuf > ,
44+ shard_paths : Vec < ShardPathConfig > ,
4445}
4546
4647#[ derive( Clone , Debug , Deserialize , PartialEq , Eq , Serialize ) ]
4748#[ serde( deny_unknown_fields) ]
48- pub struct ShardPathConfig {
49- pub shards : String ,
50- pub path : PathBuf ,
49+ struct ShardPathConfig {
50+ shards : String ,
51+ path : PathBuf ,
5152}
5253
5354impl ShardedDbPathConfig {
@@ -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}
@@ -284,7 +288,7 @@ pub struct StorageConfig {
284288 /// Fine grained control for db paths of individal databases/shards.
285289 /// If not specificed, will use `dir` as default.
286290 /// Only allowed when sharding is enabled.
287- pub db_path_overrides : Option < DbPathConfig > ,
291+ db_path_overrides : Option < DbPathConfig > ,
288292 /// ensure `ulimit -n`, set to 0 to not ensure.
289293 pub ensure_rlimit_nofile : u64 ,
290294 /// panic if failed to ensure `ulimit -n`
@@ -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}
@@ -741,10 +769,8 @@ impl ConfigSanitizer for StorageConfig {
741769
742770#[ cfg( test) ]
743771mod test {
744- use crate :: config:: {
745- config_optimizer:: ConfigOptimizer , NodeConfig , NodeType , PrunerConfig , ShardPathConfig ,
746- ShardedDbPathConfig , StorageConfig ,
747- } ;
772+ use super :: { ShardPathConfig , ShardedDbPathConfig , StorageConfig } ;
773+ use crate :: config:: { config_optimizer:: ConfigOptimizer , NodeConfig , NodeType , PrunerConfig } ;
748774 use aptos_types:: chain_id:: ChainId ;
749775
750776 #[ test]
0 commit comments