Skip to content

Commit

Permalink
Merge pull request #16403 from MinaProtocol/sai/removing-logging-from…
Browse files Browse the repository at this point in the history
…-cfg-loading

removing compile time config load logging from cli
  • Loading branch information
georgeee authored Jan 9, 2025
2 parents 40c86e2 + 2f8fa03 commit c3c7c34
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 45 deletions.
3 changes: 2 additions & 1 deletion src/app/batch_txn_tool/batch_txn_tool.ml
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,8 @@ let output_there_and_back_cmds =
let logger = Logger.create () in
let%bind minimum_user_command_fee =
let%map conf =
Runtime_config.Constants.load_constants ~logger config_file
Runtime_config.Constants.load_constants_with_logging ~logger
config_file
in
Option.value
~default:
Expand Down
9 changes: 6 additions & 3 deletions src/app/cli/src/cli_entrypoint/mina_cli_entrypoint.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1567,7 +1567,8 @@ let internal_commands ~itn_features logger =
let open Deferred.Let_syntax in
let%bind constraint_constants, proof_level, compile_config =
let%map conf =
Runtime_config.Constants.load_constants ~logger config_file
Runtime_config.Constants.load_constants_with_logging ~logger
config_file
in
Runtime_config.Constants.
(constraint_constants conf, proof_level conf, compile_config conf)
Expand Down Expand Up @@ -1599,7 +1600,8 @@ let internal_commands ~itn_features logger =
let open Deferred.Let_syntax in
let%bind constraint_constants, proof_level, compile_config =
let%map conf =
Runtime_config.Constants.load_constants ~logger config_file
Runtime_config.Constants.load_constants_with_logging ~logger
config_file
in
Runtime_config.Constants.
(constraint_constants conf, proof_level conf, compile_config conf)
Expand Down Expand Up @@ -1656,7 +1658,8 @@ let internal_commands ~itn_features logger =
let open Async in
let%bind constraint_constants, proof_level, compile_config =
let%map conf =
Runtime_config.Constants.load_constants ~logger config_file
Runtime_config.Constants.load_constants_with_logging ~logger
config_file
in
Runtime_config.Constants.
(constraint_constants conf, proof_level conf, compile_config conf)
Expand Down
25 changes: 8 additions & 17 deletions src/app/cli/src/init/client.ml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ let or_error_str ~f_ok ~error = function
| Error e ->
sprintf "%s\n%s\n" error (Error.to_string_hum e)

let load_compile_config ?(logger = Logger.null ()) config_files =
let%map conf = Runtime_config.Constants.load_constants ~logger config_files in
let load_compile_config config_files =
let%map conf = Runtime_config.Constants.load_constants config_files in
Runtime_config.Constants.compile_config conf

let stop_daemon =
Expand Down Expand Up @@ -865,10 +865,7 @@ let hash_ledger =
fun () ->
let open Deferred.Let_syntax in
let%bind constraint_constants =
let logger = Logger.create () in
let%map conf =
Runtime_config.Constants.load_constants ~logger config_files
in
let%map conf = Runtime_config.Constants.load_constants config_files in
Runtime_config.Constants.constraint_constants conf
in
let process_accounts accounts =
Expand Down Expand Up @@ -976,10 +973,7 @@ let constraint_system_digests =
fun () ->
let open Deferred.Let_syntax in
let%bind constraint_constants, proof_level =
let logger = Logger.create () in
let%map conf =
Runtime_config.Constants.load_constants ~logger config_files
in
let%map conf = Runtime_config.Constants.load_constants config_files in
Runtime_config.Constants.(constraint_constants conf, proof_level conf)
in
let all =
Expand Down Expand Up @@ -1870,7 +1864,7 @@ let compile_time_constants =
let%map ({ consensus_constants; _ } as precomputed_values), _ =
(* This is kind of ugly because we are allowing for supplying a runtime_config value directly, rather than force what is read from the environment *)
(* TODO: See if we can initialize consensus_constants without also initializing the ledger *)
let logger = Logger.create () in
let logger = Logger.null () in
let%bind m_conf =
Runtime_config.Json_loader.load_config_files ~conf_dir ~logger
config_files
Expand Down Expand Up @@ -2394,9 +2388,9 @@ let test_ledger_application =
@@ fun () ->
let open Deferred.Let_syntax in
let%bind genesis_constants, constraint_constants =
let logger = Logger.create () in
let%map conf =
Runtime_config.Constants.load_constants ~logger config_files
Runtime_config.Constants.load_constants_with_logging
~logger:(Logger.create ()) config_files
in
Runtime_config.Constants.
(genesis_constants conf, constraint_constants conf)
Expand Down Expand Up @@ -2442,10 +2436,7 @@ let itn_create_accounts =
->
let open Deferred.Let_syntax in
let%bind genesis_constants, constraint_constants, compile_config =
let logger = Logger.create () in
let%map conf =
Runtime_config.Constants.load_constants ~logger config_files
in
let%map conf = Runtime_config.Constants.load_constants config_files in
Runtime_config.Constants.
( genesis_constants conf
, constraint_constants conf
Expand Down
2 changes: 1 addition & 1 deletion src/app/delegation_verify/delegation_verify.ml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ let timestamp =
let instantiate_verify_functions ~logger config_file =
let open Deferred.Let_syntax in
let%map constants =
Runtime_config.Constants.load_constants ~logger config_file
Runtime_config.Constants.load_constants_with_logging ~logger config_file
in
let constraint_constants =
Runtime_config.Constants.constraint_constants constants
Expand Down
15 changes: 3 additions & 12 deletions src/lib/cli_lib/commands.ml
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,7 @@ module Vrf = struct
let env = Secrets.Keypair.env in
let open Deferred.Let_syntax in
let%bind constraint_constants =
let logger = Logger.create () in
let%map conf =
Runtime_config.Constants.load_constants ~logger config_file
in
let%map conf = Runtime_config.Constants.load_constants config_file in
Runtime_config.Constants.constraint_constants conf
in
if Option.is_some (Sys.getenv env) then
Expand Down Expand Up @@ -310,10 +307,7 @@ module Vrf = struct
eprintf "Using password from environment variable %s\n" env ;
let open Deferred.Let_syntax in
let%bind constraint_constants =
let logger = Logger.create () in
let%map conf =
Runtime_config.Constants.load_constants ~logger config_file
in
let%map conf = Runtime_config.Constants.load_constants config_file in
Runtime_config.Constants.constraint_constants conf
in
let%bind () =
Expand Down Expand Up @@ -376,10 +370,7 @@ module Vrf = struct
@@ fun () ->
let open Deferred.Let_syntax in
let%bind constraint_constants =
let logger = Logger.create () in
let%map conf =
Runtime_config.Constants.load_constants ~logger config_file
in
let%map conf = Runtime_config.Constants.load_constants config_file in
Runtime_config.Constants.constraint_constants conf
in
let lexbuf = Lexing.from_channel In_channel.stdin in
Expand Down
4 changes: 2 additions & 2 deletions src/lib/genesis_ledger_helper/genesis_ledger_helper.ml
Original file line number Diff line number Diff line change
Expand Up @@ -848,8 +848,8 @@ module Config_loader : Config_loader_intf = struct
Option.value ~default:(conf_dir ^/ "genesis") genesis_dir
in
let%bind.Deferred constants =
Runtime_config.Constants.load_constants ?conf_dir ?cli_proof_level
~itn_features ~logger config_files
Runtime_config.Constants.load_constants_with_logging ?conf_dir
?cli_proof_level ~logger ~itn_features config_files
in
let%bind config =
Runtime_config.Json_loader.load_config_files ?conf_dir ~logger
Expand Down
3 changes: 1 addition & 2 deletions src/lib/pickles/snarky_tests/snarky_tests.ml
Original file line number Diff line number Diff line change
Expand Up @@ -650,10 +650,9 @@ let () =
let range_checks =
List.map ~f:QCheck_alcotest.to_alcotest [ RangeCircuits.test_range_gates ]
in
let logger = Logger.create () in
let%map.Async.Deferred constraint_constants =
let%map.Async.Deferred config =
Runtime_config.Constants.load_constants ~logger []
Runtime_config.Constants.load_constants []
in
Runtime_config.Constants.constraint_constants config
in
Expand Down
16 changes: 14 additions & 2 deletions src/lib/runtime_config/runtime_config.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1777,6 +1777,7 @@ module Json_loader : Json_loader_intf = struct
in
[%log info] "Reading configuration files $config_files"
~metadata:[ ("config_files", `List config_files_paths) ] ;

Deferred.Or_error.List.filter_map config_files
~f:(fun (config_file, handle_missing) ->
match%bind.Deferred load_config_file config_file with
Expand Down Expand Up @@ -1820,6 +1821,14 @@ module type Constants_intf = sig
-> ?commit_id_short:string
-> ?itn_features:bool
-> ?cli_proof_level:Genesis_constants.Proof_level.t
-> string list
-> constants Deferred.t

val load_constants_with_logging :
?conf_dir:string
-> ?commit_id_short:string
-> ?itn_features:bool
-> ?cli_proof_level:Genesis_constants.Proof_level.t
-> logger:Logger.t
-> string list
-> constants Deferred.t
Expand Down Expand Up @@ -2027,8 +2036,9 @@ module Constants : Constants_intf = struct
}

(* Use this function if you don't need/want the ledger configuration *)
let load_constants ?conf_dir ?commit_id_short ?itn_features ?cli_proof_level
~logger config_files =
let load_constants_with_logging ?conf_dir ?commit_id_short ?itn_features
?cli_proof_level ~logger config_files =
(* do not log reading compile time constants as this impacs cli command output *)
Deferred.Or_error.ok_exn
@@
let open Deferred.Or_error.Let_syntax in
Expand All @@ -2038,6 +2048,8 @@ module Constants : Constants_intf = struct
in
load_constants' ?itn_features ?cli_proof_level runtime_config

let load_constants = load_constants_with_logging ~logger:(Logger.null ())

let magic_for_unit_tests t =
let compile_constants =
{ genesis_constants = Genesis_constants.For_unit_tests.t
Expand Down
4 changes: 2 additions & 2 deletions src/lib/snark_worker/functor.ml
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,8 @@ module Make (Inputs : Intf.Inputs_intf) :
in
let%bind.Deferred constraint_constants, proof_level, compile_config =
let%map.Deferred config =
Runtime_config.Constants.load_constants ?conf_dir ?cli_proof_level
~logger config_file
Runtime_config.Constants.load_constants_with_logging ~logger
?conf_dir ?cli_proof_level config_file
in
Runtime_config.Constants.
( constraint_constants config
Expand Down
5 changes: 2 additions & 3 deletions src/lib/snark_worker/standalone/run_snark_worker.ml
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,9 @@ let command =
let open Async in
let open Deferred.Let_syntax in
let%bind constraint_constants, proof_level =
let logger = Logger.create () in
let%map conf =
Runtime_config.Constants.load_constants ~cli_proof_level ~logger
config_file
Runtime_config.Constants.load_constants_with_logging
~logger:(Logger.create ()) ~cli_proof_level config_file
in
Runtime_config.Constants.(constraint_constants conf, proof_level conf)
in
Expand Down

0 comments on commit c3c7c34

Please sign in to comment.