@@ -49,6 +49,43 @@ let plugin_flag =
4949 times"
5050 else Command.Param. return []
5151
52+ module Chain_state_locations = struct
53+ (* * The locations of the chain state in a daemon. These will be computed by
54+ [chain_state_locations] based on the runtime daemon config. By default,
55+ the [chain_state] will be located in the mina config directory and the
56+ other directories will be located in the [chain_state]. *)
57+ type t =
58+ { chain_state : string (* * The top-level chain state directory *)
59+ ; mina_net : string (* * Mina networking information *)
60+ ; trust : string (* * P2P trust information *)
61+ ; root : string (* * The root snarked ledgers *)
62+ ; genesis : string (* * The genesis ledgers *)
63+ ; frontier : string (* * The transition frontier *)
64+ ; epoch_ledger : string (* * The epoch ledger snapshots *)
65+ ; proof_cache : string (* * The proof cache *)
66+ ; zkapp_vk_cache : string (* * The zkApp vk cache *)
67+ ; snark_pool : string (* * The snark pool *)
68+ }
69+
70+ (* * Determine the locations of the chain state components based on the daemon
71+ runtime config *)
72+ let of_config ~conf_dir (config : Runtime_config.t ) : t =
73+ (* TODO: post hard fork, we should not be ignoring this *)
74+ let _config = config in
75+ let chain_state = conf_dir in
76+ { chain_state
77+ ; mina_net = chain_state ^/ " mina_net2"
78+ ; trust = chain_state ^/ " trust"
79+ ; root = chain_state ^/ " root"
80+ ; genesis = chain_state ^/ " genesis"
81+ ; frontier = chain_state ^/ " frontier"
82+ ; epoch_ledger = chain_state
83+ ; proof_cache = chain_state ^/ " proof_cache"
84+ ; zkapp_vk_cache = chain_state ^/ " zkapp_vk_cache"
85+ ; snark_pool = chain_state ^/ " snark_pool"
86+ }
87+ end
88+
5289let load_config_files ~logger ~genesis_constants ~constraint_constants ~conf_dir
5390 ~genesis_dir ~cli_proof_level ~proof_level ~genesis_backing_type
5491 config_files =
@@ -98,7 +135,12 @@ let load_config_files ~logger ~genesis_constants ~constraint_constants ~conf_dir
98135 ] ;
99136 failwithf " Could not parse configuration file: %s" err () )
100137 in
101- let genesis_dir = Option. value ~default: (conf_dir ^/ " genesis" ) genesis_dir in
138+ let chain_state_locations =
139+ Chain_state_locations. of_config ~conf_dir config
140+ in
141+ let genesis_dir =
142+ Option. value ~default: chain_state_locations.genesis genesis_dir
143+ in
102144 let % bind precomputed_values =
103145 match % map
104146 Genesis_ledger_helper. init_from_config_file ~cli_proof_level ~genesis_dir
@@ -138,7 +180,7 @@ let load_config_files ~logger ~genesis_constants ~constraint_constants ~conf_dir
138180 ~metadata ;
139181 Error. raise err
140182 in
141- return (precomputed_values, config_jsons, config)
183+ return (precomputed_values, config_jsons, config, chain_state_locations )
142184
143185let setup_daemon logger ~itn_features ~default_snark_worker_fee =
144186 let open Command.Let_syntax in
@@ -793,13 +835,15 @@ let setup_daemon logger ~itn_features ~default_snark_worker_fee =
793835 let ledger_backing_type =
794836 Mina_lib.Config. ledger_backing ~hardfork_mode
795837 in
796- let % bind precomputed_values, config_jsons, config =
838+ let % bind ( precomputed_values
839+ , config_jsons
840+ , config
841+ , chain_state_locations ) =
797842 load_config_files ~logger ~conf_dir ~genesis_dir
798843 ~proof_level: Genesis_constants.Compiled. proof_level config_files
799844 ~genesis_constants ~constraint_constants ~cli_proof_level
800845 ~genesis_backing_type: ledger_backing_type
801846 in
802-
803847 constraint_constants.block_window_duration_ms |> Float. of_int
804848 |> Time.Span. of_ms |> Mina_metrics. initialize_all ;
805849
@@ -1133,7 +1177,7 @@ let setup_daemon logger ~itn_features ~default_snark_worker_fee =
11331177 Logger. trace logger ~module_: __MODULE__ " Creating %s at %s"
11341178 ~location typ
11351179 in
1136- let trust_dir = conf_dir ^/ " trust" in
1180+ let trust_dir = chain_state_locations. trust in
11371181 let % bind () = Async.Unix. mkdir ~p: () trust_dir in
11381182 let % bind trust_system = Trust_system. create trust_dir in
11391183 trace_database_initialization " trust_system" __LOC__ trust_dir ;
@@ -1151,7 +1195,9 @@ let setup_daemon logger ~itn_features ~default_snark_worker_fee =
11511195 (kp, Public_key. compress kp.Keypair. public_key) )
11521196 |> Option. to_list |> Keypair.And_compressed_pk.Set. of_list
11531197 in
1154- let epoch_ledger_location = conf_dir ^/ " epoch_ledger" in
1198+ let epoch_ledger_location =
1199+ chain_state_locations.epoch_ledger ^/ " epoch_ledger"
1200+ in
11551201 let module Context = struct
11561202 let logger = logger
11571203
@@ -1286,7 +1332,7 @@ Pass one of -peer, -peer-list-file, -seed, -peer-list-url.|} ;
12861332 Gossip_net.Libp2p.Config.
12871333 { timeout = Time.Span. of_sec 3.
12881334 ; logger
1289- ; conf_dir
1335+ ; mina_net_location = chain_state_locations.mina_net
12901336 ; chain_id
12911337 ; unsafe_no_trust_ip = false
12921338 ; seed_peer_list_url =
@@ -1408,20 +1454,23 @@ Pass one of -peer, -peer-list-file, -seed, -peer-list-url.|} ;
14081454 ; num_threads = snark_worker_parallelism_flag
14091455 }
14101456 ~snark_coordinator_key: run_snark_coordinator_flag
1411- ~snark_pool_disk_location: (conf_dir ^/ " snark_pool" )
1457+ ~snark_pool_disk_location: chain_state_locations. snark_pool
14121458 ~wallets_disk_location: (conf_dir ^/ " wallets" )
1413- ~persistent_root_location: (conf_dir ^/ " root" )
1414- ~persistent_frontier_location: (conf_dir ^/ " frontier" )
1415- ~epoch_ledger_location ~snark_work_fee: snark_work_fee_flag
1416- ~time_controller ~block_production_keypairs ~monitor
1417- ~consensus_local_state ~is_archive_rocksdb
1418- ~work_reassignment_wait ~archive_process_location
1419- ~log_block_creation ~precomputed_values ~start_time
1420- ?precomputed_blocks_path ~log_precomputed_blocks
1421- ~start_filtered_logs ~upload_blocks_to_gcloud
1422- ~block_reward_threshold ~uptime_url ~uptime_submitter_keypair
1423- ~uptime_send_node_commit ~stop_time ~node_status_url
1424- ~graphql_control_port: itn_graphql_port ~simplified_node_stats
1459+ ~persistent_root_location: chain_state_locations.root
1460+ ~persistent_frontier_location: chain_state_locations.frontier
1461+ ~epoch_ledger_location
1462+ ~proof_cache_location: chain_state_locations.proof_cache
1463+ ~zkapp_vk_cache_location: chain_state_locations.zkapp_vk_cache
1464+ ~snark_work_fee: snark_work_fee_flag ~time_controller
1465+ ~block_production_keypairs ~monitor ~consensus_local_state
1466+ ~is_archive_rocksdb ~work_reassignment_wait
1467+ ~archive_process_location ~log_block_creation
1468+ ~precomputed_values ~start_time ?precomputed_blocks_path
1469+ ~log_precomputed_blocks ~start_filtered_logs
1470+ ~upload_blocks_to_gcloud ~block_reward_threshold ~uptime_url
1471+ ~uptime_submitter_keypair ~uptime_send_node_commit ~stop_time
1472+ ~node_status_url ~graphql_control_port: itn_graphql_port
1473+ ~simplified_node_stats
14251474 ~zkapp_cmd_limit: (ref compile_config.zkapp_cmd_limit)
14261475 ~itn_features ~compile_config ~hardfork_mode () )
14271476 in
@@ -1973,7 +2022,10 @@ let internal_commands logger ~itn_features =
19732022 List. map config_files ~f: (fun config_file ->
19742023 (config_file, `Must_exist ) )
19752024 in
1976- let % bind precomputed_values, _config_jsons, _config =
2025+ let % bind ( precomputed_values
2026+ , _config_jsons
2027+ , _config
2028+ , _chain_state_locations ) =
19772029 load_config_files ~logger ~conf_dir ~genesis_dir ~genesis_constants
19782030 ~constraint_constants ~proof_level ~cli_proof_level: None
19792031 ~genesis_backing_type: Stable_db config_files
0 commit comments