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

consolidate ppx-optcomp usage to single module #15837

Merged
merged 26 commits into from
Jul 24, 2024

Conversation

martyall
Copy link
Member

@martyall martyall commented Jul 17, 2024

High level

I consolidated all uses of ppx_optcomp to a single module Node_config and removed the dependency on ppx_optcomp and config.mlh from every other library.

This will allow us to easily replace the compile time configuration with loading a configuration file -- simply replace the implementation of Node_config to do this.

related to #15538

Changes

The vast majority of changes are due to

  • remove [%%import "/src/config.mlh"] wherever possible
  • remove use of ppx_optcomp wherever possible
  • remove preprocessor_deps <path_to_config.mlh> wherever possible

I tried to keep other changes minimal, just to recover from what happens when you do the above. This manifests mostly as:

  1. Rather than use the %%inject directive, use the Node_config module values
  2. Whenever %%ifdef is used, just use simple if-then-else statements in the code.
  3. remove all dead code if I detected it

@martyall
Copy link
Member Author

!ci-build-me

@martyall martyall changed the title Martin/further consolidate mlh files consolidate ppx-optcomp usage to single module Jul 17, 2024
@martyall
Copy link
Member Author

!ci-build-me

@martyall
Copy link
Member Author

!ci-build-me

Copy link
Member Author

@martyall martyall left a comment

Choose a reason for hiding this comment

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

Some comments to help the reviewers

@@ -18,7 +18,6 @@ let commands =
[ Cmd.run "./scripts/lint_codeowners.sh"
, Cmd.run "./scripts/lint_rfcs.sh"
, Cmd.run "make check-snarky-submodule"
, Cmd.run "./scripts/lint_preprocessor_deps.sh"
Copy link
Member Author

Choose a reason for hiding this comment

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

The only library which uses ppx_optcomp is now mina_node_config. It turns out that this script doesn't work when there is only one lib to check, and it also doesn't seem relevant anymore.

@@ -20,13 +20,6 @@ inputs: pkgs: {
touch $out
'';
# todo: ./scripts/check-snarky-submodule.sh # submodule issue
lint-preprocessor-deps = pkgs.runCommand "lint-preprocessor-deps" {
Copy link
Member Author

Choose a reason for hiding this comment

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

see note above about lint check script

@@ -1662,79 +1653,11 @@ let audit_type_shapes : Command.t =
Core.printf "good shapes:\n\t%d\nbad shapes:\n\t%d\n%!" !good !bad ;
if !bad > 0 then Core.exit 1 ) )

[%%if force_updates]
Copy link
Member Author

Choose a reason for hiding this comment

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

force_updates is set to false in every profile, so this code is dead. It no longer compiled, rather than update it I just deleted it.

@@ -39,8 +37,6 @@ module Make_str (_ : Wire_types.Concrete) = struct
let zero = UInt64.zero

module Controller = struct
[%%if time_offsets]
Copy link
Member Author

Choose a reason for hiding this comment

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

time_offsets is set to true for every profile

@@ -1621,25 +1619,6 @@ module Make_str (A : Wire_types.Concrete) = struct
end )
end

[%%else]
Copy link
Member Author

Choose a reason for hiding this comment

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

dead code

[%%endif]

[%%inject "supercharged_coinbase_factor", supercharged_coinbase_factor]
match
Copy link
Member Author

Choose a reason for hiding this comment

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

implicitly in the config it seems like you have one of two disjoint cases:

scan_state_with_tps_goal && 
  is_some scan_state_tps_goal_x10 && 
  is_none scan_state_transaction_capacity_log_2 

or

not scan_state_with_tps_goal && 
  is_none scan_state_tps_goal_x10 && 
  is_some scan_state_transaction_capacity_log_2 

Copy link
Member

Choose a reason for hiding this comment

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

what if we remove scan_state_with_tps_goal, scan_state_tps_goal_x10 and retain only scan_state_transaction_capacity_log_2 ?

Copy link
Member Author

Choose a reason for hiding this comment

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

you probably could, but my goal here was to do the smallest transformation and keep any config values code paths that were being used. IMO it would be easier to simplify the config which is being used in a follow up -- i.e. taking a look at what is in node config and seeing if we still care about each field.

For example, there are some fields which only act as a flag to log a simple statement, and other kind of "do nothing" fields we can likely remove.


let fork = None

[%%else]
Copy link
Member Author

Choose a reason for hiding this comment

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

dead code

@@ -67,44 +55,14 @@ let max_event_elements = 100

let max_action_elements = 100

[%%inject "network_id", network]

[%%ifndef zkapp_cmd_limit]
Copy link
Member Author

Choose a reason for hiding this comment

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

These kinds of conditional assignments are all pushed into the Node_config module

@@ -0,0 +1,49 @@
val curve_size : int
Copy link
Member Author

Choose a reason for hiding this comment

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

I felt it was better to explicitly give the Mina_compile_config interface because there are several values in here which are hard coded and seem like they should be considered as configuration


let directory = `Ephemeral

let depth = Genesis_constants.Constraint_constants.compiled.ledger_depth
end)

[%%else]
Copy link
Member Author

Choose a reason for hiding this comment

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

dead code

@martyall
Copy link
Member Author

!ci-build-me

@martyall
Copy link
Member Author

!ci-build-me

@martyall martyall marked this pull request as ready for review July 17, 2024 19:19
@martyall martyall requested review from a team, bkase, psteckler and mrmr1993 as code owners July 17, 2024 19:19
This was referenced Jul 23, 2024
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.

Approving this PR with acknowledgment that in follow-up PRs we'll get rid of a few unused options completely.


[%%else]

(*NOTE A previous version of this function included compile time ppx that didn't compile, and was never
Copy link
Member

Choose a reason for hiding this comment

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

Let's remove ensure_testnet_id_still_good function and its only callsite

@SanabriaRusso
Copy link
Collaborator

Great job!

@mrmr1993 mrmr1993 merged commit 4f31693 into compatible Jul 24, 2024
48 checks passed
@mrmr1993 mrmr1993 deleted the martin/further-consolidate-mlh-files branch July 24, 2024 16:30
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