Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removing compile time config load logging from cli #16403

Merged
merged 9 commits into from
Jan 9, 2025

Conversation

svv232
Copy link
Member

@svv232 svv232 commented Dec 5, 2024

PR does a number of things:

  • Removes ~logger parameter from load_constants, while adding a new load_constants_with_logging function for the cases where logging is actually required
    • This ensures that all of the direct usages of load_constants appear in the diff and decision on whether to use the logging is made explicitly on a case-by-case basis within this PR
  • Removes ?logger parameter from load_compile_config
  • Replaces Logger.create () with Logger.null () in a single occasion of load_config_files being used directly for a CLI command that is expected to produce a short output with a result (mina advanced compile-time-constants)

@svv232 svv232 requested a review from a team as a code owner December 5, 2024 19:55
@svv232
Copy link
Member Author

svv232 commented Dec 5, 2024

!ci-build-me

@@ -1802,14 +1791,8 @@ module Json_loader : Json_loader_intf = struct
| Ok loaded_config ->
combine config loaded_config
| Error err ->
[%log fatal]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means that we won't see the failure reason in the node logs, and so we'll have a harder time root-causing crashes if node operators hit this :(

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for this specific log, won't node operators just see the error in the exception back trace?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It depends on how they're running the node, and whether they're collecting error messages instead of logs. Most only have logs.

@svv232
Copy link
Member Author

svv232 commented Dec 5, 2024

!ci-build-me

@svv232
Copy link
Member Author

svv232 commented Dec 5, 2024

!ci-build-me

@svv232 svv232 requested a review from mrmr1993 December 5, 2024 21:54
@svv232 svv232 requested a review from a team as a code owner December 5, 2024 22:00
@svv232
Copy link
Member Author

svv232 commented Dec 5, 2024

!ci-build-me

@svv232
Copy link
Member Author

svv232 commented Dec 5, 2024

!ci-nightly-me

@coveralls
Copy link

Coverage Status

coverage: 60.682%. first build
when pulling 5aa527c on sai/removing-logging-from-cfg-loading
into b6f5f57 on compatible.

@svv232 svv232 requested a review from georgeee December 11, 2024 20:25
@svv232
Copy link
Member Author

svv232 commented Dec 11, 2024

!ci-build-me

@svv232
Copy link
Member Author

svv232 commented Dec 11, 2024

!ci-nightly-me

@svv232
Copy link
Member Author

svv232 commented Dec 12, 2024

!ci-build-me

Copy link
Member

@georgeee georgeee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need two explicit versions of load_constants: with and without the logging.

In many contexts where logging was removed now it's actually useful to have, and violates no "contract" with users

@@ -22,10 +22,8 @@ let command =
let open Async in
let open Deferred.Let_syntax in
let%bind constraint_constants, proof_level =
let logger = Logger.create () in
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't look right to me

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed

let%map conf =
Runtime_config.Constants.load_constants ~logger config_file
in
let%map conf = Runtime_config.Constants.load_constants config_file in
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't look right to me

@@ -1567,7 +1567,7 @@ 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 config_file
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't look right to me

@@ -1599,7 +1599,7 @@ 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 config_file
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't look right to me

@@ -1656,7 +1656,7 @@ 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 config_file
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't look right to me

let%map conf =
Runtime_config.Constants.load_constants ~logger config_files
in
let%map conf = Runtime_config.Constants.load_constants config_files in
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't look right to me

let%map constants =
Runtime_config.Constants.load_constants ~logger config_file
in
let%map constants = Runtime_config.Constants.load_constants config_file in
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't look right to me

Changes to this whole file should be reverted, I think

@@ -2028,13 +2028,14 @@ 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 =
config_files =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest that we rename this function to load_constants_with_logging and have an explicit ~logger parameter: let load_constants = load_constants_with_logging ~logger:(Logger.null ())

@@ -363,7 +363,7 @@ module Make (Inputs : Intf.Inputs_intf) :
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
config_file
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't look right to me

@svv232
Copy link
Member Author

svv232 commented Dec 13, 2024

!ci-build-me

@svv232 svv232 requested a review from georgeee December 17, 2024 06:53
Copy link
Member

@georgeee georgeee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR fully addresses the issue of logging originated in load_config_files appearing in unexpected contexts.

Usages of load_config_files can be classified as follows:

  • Direct usages in long-running processes (mina, archive), tests and genesis_ledger_helper
  • Direct usage in a CLI command
  • Usages in load_constants and load_compile_config

First category functions well, so no need for a change. Latter two categories are fully addressed on a case-by-case basis.

P.S. left a thread of comments while performing this review, for bookkeeping.

@@ -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) ] ;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

@@ -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 =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment from review:

  1. For usages of load_compile_config with no ~logger provided, things remain the same
  2. For usages of load_compile_config that were supplying ~logger, compiler would mark all of the occasions and these would have appeared in the PR's diff (none appears, hence there were no such usages)

@@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No-op change

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirm that we want logging on for this component (assuming internal commands aren't used in automated scripts)

@@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No-op change

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirm that we want logging on for this component (assuming internal commands aren't used in automated scripts)

@@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No-op change

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirm that we want logging on for this component (assuming internal commands aren't used in automated scripts)

let%map conf =
Runtime_config.Constants.load_constants ~logger config_files
in
let%map conf = Runtime_config.Constants.load_constants config_files in
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirm that we don't want logging on for this component (CLI utility)

let%map conf =
Runtime_config.Constants.load_constants ~logger config_files
in
let%map conf = Runtime_config.Constants.load_constants config_files in
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirm that we don't want logging on for this component (CLI utility)

@@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirm that we don't want logging on for this component (CLI utility)

let%map conf =
Runtime_config.Constants.load_constants ~logger config_files
in
let%map conf = Runtime_config.Constants.load_constants config_files in
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirm that we don't want logging on for this component (CLI utility)

let%map conf =
Runtime_config.Constants.load_constants ~logger config_files
Runtime_config.Constants.load_constants_with_logging
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirm that we want logging for this test utility

Copy link
Member

@mrmr1993 mrmr1993 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Crypto changes LGTM

@georgeee georgeee merged commit c3c7c34 into compatible Jan 9, 2025
57 checks passed
@georgeee georgeee deleted the sai/removing-logging-from-cfg-loading branch January 9, 2025 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants