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

PR #16186, split for re-review #16502

Open
wants to merge 25 commits into
base: georgeee/redo-16186-for-better-review-base
Choose a base branch
from

Conversation

georgeee
Copy link
Member

@georgeee georgeee commented Jan 22, 2025

This is not intended to be merged into any of major branches.

Created for the sole purpose of visibility.

This PR has the same code changes as #16186, but organized in a granular fashion.

To test against merge commit e130ac7: git diff e130ac77a50149ebb0ff3840e4ac5dae32afe201 (returns zero code and no output).

Rename: init_from_config_file -> Config_loader.init_from_config_file_legacy
Accept config file parameter in `ledger hash`, 'ledger test apply' and
'advanced itn-create-accounts' commands.
@georgeee georgeee force-pushed the georgeee/redo-16186-for-better-review branch from cf46526 to 60b5ab3 Compare January 22, 2025 14:21
@georgeee georgeee marked this pull request as ready for review January 22, 2025 14:24
@georgeee georgeee requested review from a team as code owners January 22, 2025 14:24
@georgeee georgeee changed the title PR #16186, split for re-review, commit 1/N PR #16186, split for re-review Jan 22, 2025
@@ -390,23 +387,32 @@ let output_there_and_back_cmds =
transactions, if this is not present then we use the env var \
MINA_PRIVKEY_PASS"
(optional string)
and config_file = Cli_lib.Flag.config_files
Copy link
Member Author

Choose a reason for hiding this comment

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

Clarification: commit f070475 (Remove default_transaction_fee from node_config) also adds --config-file to the batch_txn_tool app

@@ -85,6 +86,7 @@ module T = struct
; constraint_constants : Genesis_constants.Constraint_constants.t
; genesis_constants : Genesis_constants.t
; proof_level : Genesis_constants.Proof_level.t
; compile_config : Mina_compile_config.t
Copy link
Member Author

@georgeee georgeee Jan 23, 2025

Choose a reason for hiding this comment

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

RE commit 788ab19

This field is added to Genesis_proof.t so that it later appears in Precomputed_values.t and in all of the places that get it.

I don't like this solution. I tried to revert it on compatible, but there turned out to be many places which need to be updated.

I suggest to leave it "as is" and later find a better solution for passing Mina_compile_config.t to various structures. BTW, the name will soon be completely pointless, as this config is configured in runtime now as much as in runtime. I suggest after refactoring to get rid of any compile-time configuration whatsoever we reconsider use of both Mina_compile_config.t and Precomputed_values.t. And skip spending time on partial solutions now

Copy link
Member

Choose a reason for hiding this comment

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

I agree that this is terrible. The original PR should not have landed in this state.

Copy link
Member Author

Choose a reason for hiding this comment

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

Are you against it so much as to ask us to rework this immediately?

Or are you okay with this change to live in the codebase for a bit longer? Until we have more progress on dismantling the compile-time config and then we plan to remove Mina_compile_config.t, so it will naturally disappear from Inputs.t as well.

@georgeee
Copy link
Member Author

A NIT: reversion of commit 60b5ab3 would be good to have in compatible

; proof = None
; proof =
Some
{ Runtime_config.Proof_keys.default with level = Some No_check }
Copy link
Member Author

Choose a reason for hiding this comment

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

Comment about the change: we set the proof level used in mina_lib test to be No_check through runtime config and not through constants (which would be a 1:1 rewrite from previous code).

It'd be somewhat more straightforward to use the following code in the call below:

~constants:({(Runtime_config.Constants.magic_for_unit_tests runtime_config) with proof_level = No_check})

But it would work just the same as what is implemented now.

Genesis_constants.Compiled.constraint_constants
let open Deferred.Let_syntax in
let%bind constraint_constants, proof_level =
let logger = Logger.create () in
Copy link
Member Author

Choose a reason for hiding this comment

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

This is a correct usage of logger, as it's a daemon-like runner rather than a CLI command.

Copy link
Member

Choose a reason for hiding this comment

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

This is inaccurate, this really is a CLI command. That said, I added it for my own debugging purposes, so if you want to pollute the output then go for it.

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 a command used for debugging some log output should be helpful

let range_checks =
List.map ~f:QCheck_alcotest.to_alcotest [ RangeCircuits.test_range_gates ]
in
let logger = Logger.create () in
Copy link
Member Author

Choose a reason for hiding this comment

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

Unnecessary use of logging, removed in compatible.

Genesis_constants.Compiled.constraint_constants
let open Deferred.Let_syntax in
let%bind constraint_constants =
let logger = Logger.create () in
Copy link
Member Author

Choose a reason for hiding this comment

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

Unnecessary use of logging, removed in compatible.

let%bind constraint_constants =
let logger = Logger.create () in
let%map conf =
Runtime_config.Constants.load_constants ~logger config_file
Copy link
Member Author

Choose a reason for hiding this comment

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

Unnecessary use of logging, removed in compatible.

Genesis_constants.Compiled.constraint_constants
let%bind constraint_constants, proof_level =
let%map conf =
Runtime_config.Constants.load_constants ~logger config_file
Copy link
Member Author

Choose a reason for hiding this comment

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

Logger usage is retained from pre-existing code, the same in compatible

let%bind precomputed_values, _ =
Genesis_ledger_helper.Config_loader.load_config_files ~logger
~conf_dir ~genesis_dir ~genesis_constants ~constraint_constants
~proof_level config_files ~cli_proof_level:None
~conf_dir ?genesis_dir ~cli_proof_level:Full ~itn_features
Copy link
Member Author

Choose a reason for hiding this comment

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

cli_proof_level is used here so that whatever is provided in compile-time config and initialized via load_config_files is overridden with Full.

let%bind config =
Runtime_config.Json_loader.load_config_files ~conf_dir ~logger
Runtime_config.Json_loader.load_config_files ?conf_dir ~logger
Copy link
Member Author

Choose a reason for hiding this comment

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

Logging behavior doesn't change comparing to previous version, which was present in mina_cli_entrypoint

Option.value ~default:(conf_dir ^/ "genesis") genesis_dir
in
let%bind.Deferred constants =
Runtime_config.Constants.load_constants ?conf_dir ?cli_proof_level
Copy link
Member Author

Choose a reason for hiding this comment

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

Note Json_loader.load_config_files is called twice: within load_constants and via a direct call below.

This results in Reading configuration files being printed twice when the node starts. Worth fixing in compatible.

Copy link
Member

Choose a reason for hiding this comment

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

Not only did this changeset break commands, but it also added output at the start of the program that has embarrassing duplication? Fantastic.

Copy link
Member

Choose a reason for hiding this comment

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

I would like this to be fixed before the release.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is already fixed in compatible

; ("client", Client.client)
; ("advanced", Client.advanced ~itn_features)
; ("ledger", Client.ledger)
; ("libp2p", Client.libp2p)
; ( "internal"
, Command.group ~summary:"Internal commands" (internal_commands logger) )
, Command.group ~summary:"Internal commands"
Copy link
Member Author

Choose a reason for hiding this comment

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

Commit cb395b2 also propagates ~itn_features down daemon and internal_commands -> replay_blocks so that it's read from compile time config in the only place in mina_cli_entrypoint

@georgeee
Copy link
Member Author

georgeee commented Jan 23, 2025

Created a PR to address minor "issues" spotted while reviewing this PR

unit tests pass.
*)
1
+ Core_kernel.Int.ceil_log2
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Core_kernel is already open.
(But I appreciate the faithful movement of the function instead of modifying it.)

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 in 1db6920

in
{ genesis_constants; constraint_constants; proof_level; compile_config }

let load_constants' ?itn_features ?cli_proof_level runtime_config =
Copy link
Member

Choose a reason for hiding this comment

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

This function name is very misleading. It appears to be doing no loading at all.

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 in 7198098 (another PR)

@@ -85,6 +86,7 @@ module T = struct
; constraint_constants : Genesis_constants.Constraint_constants.t
; genesis_constants : Genesis_constants.t
; proof_level : Genesis_constants.Proof_level.t
; compile_config : Mina_compile_config.t
Copy link
Member

Choose a reason for hiding this comment

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

I agree that this is terrible. The original PR should not have landed in this state.

@@ -33,6 +33,15 @@ let conf_dir =
flag "--config-directory" ~aliases:[ "config-directory" ]
~doc:"DIR Configuration directory" (optional string)

let config_files =
let open Command.Param in
flag "--config-file" ~aliases:[ "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.

Does this mean that we've added the junk -config-file flag alias everywhere now, just because it was on the Mina CLI for backcompat? That's annoying.

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 in 259824f

@@ -390,23 +387,32 @@ let output_there_and_back_cmds =
transactions, if this is not present then we use the env var \
MINA_PRIVKEY_PASS"
(optional string)
and config_file = Cli_lib.Flag.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.

We're calling a list of config files here config_file? That feels confusing at the very least.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is a typo, there are a few more places like this one, fixed in 6d26821

~genesis_constants ~constraint_constants ~logger:(Logger.null ())
~proof_level ~cli_proof_level:None ~genesis_dir runtime_config
>>| Or_error.ok_exn
let%bind m_conf =
Copy link
Member

Choose a reason for hiding this comment

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

What is an m_conf?

Copy link
Member Author

Choose a reason for hiding this comment

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

Renamed this variable, see a5a39eb

Runtime_config.Constants.load_constants' runtime_config
in
Genesis_ledger_helper.Config_loader.init_from_config_file ~genesis_dir
~logger ~constants runtime_config
Copy link
Member

Choose a reason for hiding this comment

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

This change is particularly irritating, changing Logger.null to logger (non-null above).

Copy link
Member Author

Choose a reason for hiding this comment

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

In compatible we set logger to Logger.null () for the entire command

Option.value ~default:(conf_dir ^/ "genesis") genesis_dir
in
let%bind.Deferred constants =
Runtime_config.Constants.load_constants ?conf_dir ?cli_proof_level
Copy link
Member

Choose a reason for hiding this comment

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

Not only did this changeset break commands, but it also added output at the start of the program that has embarrassing duplication? Fantastic.

Option.value ~default:(conf_dir ^/ "genesis") genesis_dir
in
let%bind.Deferred constants =
Runtime_config.Constants.load_constants ?conf_dir ?cli_proof_level
Copy link
Member

Choose a reason for hiding this comment

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

I would like this to be fixed before the release.

@@ -216,8 +216,9 @@ let setup_daemon logger ~itn_features =
and snark_work_fee =
flag "--snark-worker-fee" ~aliases:[ "snark-worker-fee" ]
~doc:
"FEE Amount a worker wants to get compensated for generating a snark \
proof"
(sprintf
Copy link
Member

Choose a reason for hiding this comment

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

I love a no-op sprintf.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed in compatible

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.

2 participants