diff --git a/src/app/cli/src/cli_entrypoint/mina_cli_entrypoint.ml b/src/app/cli/src/cli_entrypoint/mina_cli_entrypoint.ml index c5ee02445e7..06ddf962120 100644 --- a/src/app/cli/src/cli_entrypoint/mina_cli_entrypoint.ml +++ b/src/app/cli/src/cli_entrypoint/mina_cli_entrypoint.ml @@ -1045,13 +1045,11 @@ let setup_daemon logger ~itn_features ~default_snark_worker_fee = let module Context = struct let logger = logger - let precomputed_values = precomputed_values + let genesis_constants = precomputed_values.genesis_constants let constraint_constants = precomputed_values.constraint_constants let consensus_constants = precomputed_values.consensus_constants - - let compile_config = compile_config end in let consensus_local_state = Consensus.Data.Local_state.create diff --git a/src/lib/block_producer/block_producer.ml b/src/lib/block_producer/block_producer.ml index fc82d60271f..0a255388780 100644 --- a/src/lib/block_producer/block_producer.ml +++ b/src/lib/block_producer/block_producer.ml @@ -20,8 +20,6 @@ module type CONTEXT = sig val zkapp_cmd_limit : int option ref val vrf_poll_interval : Time.Span.t - - val compile_config : Mina_compile_config.t end type Structured_log_events.t += Block_produced @@ -664,7 +662,12 @@ let run ~context:(module Context : CONTEXT) ~vrf_evaluator ~prover ~verifier ~transition_writer ~set_next_producer_timing ~log_block_creation ~block_reward_threshold ~block_produced_bvar ~vrf_evaluation_state ~net ~zkapp_cmd_limit_hardcap = - let open Context in + let module Consensus_context = struct + include Context + + let genesis_constants = precomputed_values.genesis_constants + end in + let open Consensus_context in let constraint_constants = precomputed_values.constraint_constants in let consensus_constants = precomputed_values.consensus_constants in O1trace.sync_thread "produce_blocks" (fun () -> @@ -849,7 +852,7 @@ let run ~context:(module Context : CONTEXT) ~vrf_evaluator ~prover ~verifier Debug_assert.debug_assert (fun () -> [%test_result: [ `Take | `Keep ]] (Consensus.Hooks.select - ~context:(module Context) + ~context:(module Consensus_context) ~existing: (With_hash.map ~f:Mina_block.consensus_state previous_transition ) @@ -864,7 +867,7 @@ let run ~context:(module Context : CONTEXT) ~vrf_evaluator ~prover ~verifier in [%test_result: [ `Take | `Keep ]] (Consensus.Hooks.select - ~context:(module Context) + ~context:(module Consensus_context) ~existing:root_consensus_state_with_hashes ~candidate:consensus_state_with_hashes ) ~expect:`Take @@ -937,7 +940,7 @@ let run ~context:(module Context : CONTEXT) ~vrf_evaluator ~prover ~verifier `This_block_was_not_received_via_gossip >>= Validation.validate_frontier_dependencies ~to_header:Mina_block.header - ~context:(module Context) + ~context:(module Consensus_context) ~root_block: ( Transition_frontier.root frontier |> Breadcrumb.block_with_hash ) @@ -1412,10 +1415,15 @@ let run_precomputed ~context:(module Context : CONTEXT) ~verifier ~trust_system Header.protocol_state @@ Mina_block.header (With_hash.data previous_transition) in + let module Consensus_context = struct + include Context + + let genesis_constants = precomputed_values.genesis_constants + end in Debug_assert.debug_assert (fun () -> [%test_result: [ `Take | `Keep ]] (Consensus.Hooks.select - ~context:(module Context) + ~context:(module Consensus_context) ~existing: (With_hash.map ~f:Mina_block.consensus_state previous_transition ) @@ -1430,7 +1438,7 @@ let run_precomputed ~context:(module Context : CONTEXT) ~verifier ~trust_system in [%test_result: [ `Take | `Keep ]] (Consensus.Hooks.select - ~context:(module Context) + ~context:(module Consensus_context) ~existing:root_consensus_state_with_hashes ~candidate:consensus_state_with_hashes ) ~expect:`Take @@ -1468,7 +1476,7 @@ let run_precomputed ~context:(module Context : CONTEXT) ~verifier ~trust_system previous_protocol_state ) >>= Validation.validate_frontier_dependencies ~to_header:Mina_block.header - ~context:(module Context) + ~context:(module Consensus_context) ~root_block: ( Transition_frontier.root frontier |> Breadcrumb.block_with_hash ) diff --git a/src/lib/bootstrap_controller/bootstrap_controller.ml b/src/lib/bootstrap_controller/bootstrap_controller.ml index 70f23b0a488..5009e540988 100644 --- a/src/lib/bootstrap_controller/bootstrap_controller.ml +++ b/src/lib/bootstrap_controller/bootstrap_controller.ml @@ -18,8 +18,6 @@ module type CONTEXT = sig val constraint_constants : Genesis_constants.Constraint_constants.t val consensus_constants : Consensus.Constants.t - - val compile_config : Mina_compile_config.t end type Structured_log_events.t += Bootstrap_complete @@ -69,6 +67,8 @@ let worth_getting_root ({ context = (module Context); _ } as t) candidate = let module Context = struct include Context + let genesis_constants = precomputed_values.genesis_constants + let logger = Logger.extend logger [ ( "selection_context" @@ -153,7 +153,7 @@ let to_consensus_state h = the existing one, then reset the Sync_ledger's target by calling [start_sync_job_with_peer] function. *) let on_transition ({ context = (module Context); _ } as t) ~sender - ~root_sync_ledger ~genesis_constants candidate_header = + ~root_sync_ledger candidate_header = let open Context in let candidate_consensus_state = With_hash.map ~f:to_consensus_state candidate_header @@ -176,7 +176,7 @@ let on_transition ({ context = (module Context); _ } as t) ~sender match%bind Sync_handler.Root.verify ~context:(module Context) - ~verifier:t.verifier ~genesis_constants candidate_consensus_state + ~verifier:t.verifier candidate_consensus_state peer_root_with_proof.data with | Ok (`Root root, `Best_tip best_tip) -> @@ -190,7 +190,7 @@ let on_transition ({ context = (module Context); _ } as t) ~sender incoming transitions, add those to the transition_cache and calls [on_transition] function. *) let sync_ledger ({ context = (module Context); _ } as t) ~preferred - ~root_sync_ledger ~transition_graph ~sync_ledger_reader ~genesis_constants = + ~root_sync_ledger ~transition_graph ~sync_ledger_reader = let open Context in let query_reader = Sync_ledger.Db.query_reader root_sync_ledger in let response_writer = Sync_ledger.Db.answer_writer root_sync_ledger in @@ -233,11 +233,15 @@ let sync_ledger ({ context = (module Context); _ } as t) ~preferred ] ; Deferred.ignore_m - @@ on_transition t ~sender ~root_sync_ledger ~genesis_constants - header_with_hash ) + @@ on_transition t ~sender ~root_sync_ledger header_with_hash ) else Deferred.unit ) let external_transition_compare ~context:(module Context : CONTEXT) = + let module Consensus_context = struct + include Context + + let genesis_constants = precomputed_values.genesis_constants + end in let get_consensus_state = Fn.compose Protocol_state.consensus_state Mina_block.Header.protocol_state in @@ -251,7 +255,9 @@ let external_transition_compare ~context:(module Context : CONTEXT) = then 0 else if Consensus.Hooks.equal_select_status `Keep - @@ Consensus.Hooks.select ~context:(module Context) ~existing ~candidate + @@ Consensus.Hooks.select + ~context:(module Consensus_context) + ~existing ~candidate then -1 else 1 ) ~f:(With_hash.map ~f:get_consensus_state) @@ -274,10 +280,6 @@ let run ~context:(module Context : CONTEXT) ~trust_system ~verifier ~network ~persistent_frontier ~initial_root_transition ~catchup_mode = let open Context in O1trace.thread "bootstrap" (fun () -> - let genesis_constants = - Precomputed_values.genesis_constants precomputed_values - in - let constraint_constants = precomputed_values.constraint_constants in let rec loop previous_cycles = let sync_ledger_pipe = "sync ledger pipe" in let sync_ledger_reader, sync_ledger_writer = @@ -332,16 +334,21 @@ let run ~context:(module Context : CONTEXT) ~trust_system ~verifier ~network temp_persistent_root_instance in (* step 1. download snarked_ledger *) + let module Consensus_context = struct + include Context + + let genesis_constants = precomputed_values.genesis_constants + end in let%bind sync_ledger_time, (hash, sender, expected_staged_ledger_hash) = time_deferred (let root_sync_ledger = Sync_ledger.Db.create temp_snarked_ledger - ~context:(module Context) + ~context:(module Consensus_context) ~trust_system in don't_wait_for (sync_ledger t ~preferred:preferred_peers ~root_sync_ledger - ~transition_graph ~sync_ledger_reader ~genesis_constants ) ; + ~transition_graph ~sync_ledger_reader ) ; (* We ignore the resulting ledger returned here since it will always * be the same as the ledger we started with because we are syncing * a db ledger. *) @@ -568,7 +575,7 @@ let run ~context:(module Context : CONTEXT) ~trust_system ~verifier ~network [%log info] "Synchronizing consensus local state" ; let%map result = Consensus.Hooks.sync_local_state - ~context:(module Context) + ~context:(module Consensus_context) ~local_state:consensus_local_state ~trust_system ~glue_sync_ledger: (Mina_networking.glue_sync_ledger t.network) @@ -619,7 +626,7 @@ let run ~context:(module Context : CONTEXT) ~trust_system ~verifier ~network bootstrapping: " ^ msg ) in Transition_frontier.load - ~context:(module Context) + ~context:(module Consensus_context) ~retry_with_fresh_db:false ~verifier ~consensus_local_state ~persistent_root ~persistent_frontier ~catchup_mode () >>| function @@ -661,7 +668,7 @@ let run ~context:(module Context : CONTEXT) ~trust_system ~verifier ~network in Consensus.Hooks.equal_select_status `Take @@ Consensus.Hooks.select - ~context:(module Context) + ~context:(module Consensus_context) ~existing:root_consensus_state ~candidate: (With_hash.map @@ -730,8 +737,6 @@ let%test_module "Bootstrap_controller tests" = let constraint_constants = precomputed_values.constraint_constants - let compile_config = Mina_compile_config.For_unit_tests.t - module Context = struct let logger = Logger.create () @@ -741,8 +746,6 @@ let%test_module "Bootstrap_controller tests" = Genesis_constants.For_unit_tests.Constraint_constants.t let consensus_constants = precomputed_values.consensus_constants - - let compile_config = compile_config end let verifier = @@ -791,8 +794,7 @@ let%test_module "Bootstrap_controller tests" = let%bind fake_network = Fake_network.Generator.( gen ~precomputed_values ~verifier ~max_frontier_length - ~compile_config [ fresh_peer; fresh_peer ] - ~use_super_catchup:false) + [ fresh_peer; fresh_peer ] ~use_super_catchup:false) in let%map make_branch = Transition_frontier.Breadcrumb.For_tests.gen_seq ~precomputed_values @@ -820,17 +822,21 @@ let%test_module "Bootstrap_controller tests" = let bootstrap = make_non_running_bootstrap ~genesis_root ~network:me.network in + let module Consensus_context = struct + include Context + + let genesis_constants = precomputed_values.genesis_constants + end in let root_sync_ledger = Sync_ledger.Db.create (Transition_frontier.root_snarked_ledger me.state.frontier) - ~context:(module Context) + ~context:(module Consensus_context) ~trust_system in Async.Thread_safe.block_on_async_exn (fun () -> let sync_deferred = sync_ledger bootstrap ~root_sync_ledger ~transition_graph ~preferred:[] ~sync_ledger_reader - ~genesis_constants:Genesis_constants.For_unit_tests.t in let%bind () = Deferred.List.iter branch ~f:(fun breadcrumb -> @@ -927,7 +933,7 @@ let%test_module "Bootstrap_controller tests" = Quickcheck.test ~trials:1 Fake_network.Generator.( gen ~precomputed_values ~verifier ~max_frontier_length - ~use_super_catchup:false ~compile_config + ~use_super_catchup:false [ fresh_peer ; peer_with_branch ~frontier_branch_size:((max_frontier_length * 2) + 2) diff --git a/src/lib/bootstrap_controller/bootstrap_controller.mli b/src/lib/bootstrap_controller/bootstrap_controller.mli index df18118e515..d9730576a92 100644 --- a/src/lib/bootstrap_controller/bootstrap_controller.mli +++ b/src/lib/bootstrap_controller/bootstrap_controller.mli @@ -11,8 +11,6 @@ module type CONTEXT = sig val constraint_constants : Genesis_constants.Constraint_constants.t val consensus_constants : Consensus.Constants.t - - val compile_config : Mina_compile_config.t end type Structured_log_events.t += Bootstrap_complete [@@deriving register_event] diff --git a/src/lib/consensus/intf.ml b/src/lib/consensus/intf.ml index df4e178cac4..a00b0b62398 100644 --- a/src/lib/consensus/intf.ml +++ b/src/lib/consensus/intf.ml @@ -12,7 +12,7 @@ module type CONTEXT = sig val consensus_constants : Constants.t - val compile_config : Mina_compile_config.t + val genesis_constants : Genesis_constants.t end module type Constants = sig diff --git a/src/lib/consensus/proof_of_stake.ml b/src/lib/consensus/proof_of_stake.ml index 32abc3dd2e5..c3869c74ef9 100644 --- a/src/lib/consensus/proof_of_stake.ml +++ b/src/lib/consensus/proof_of_stake.ml @@ -31,7 +31,7 @@ module Make_str (A : Wire_types.Concrete) = struct val consensus_constants : Constants.t - val compile_config : Mina_compile_config.t + val genesis_constants : Genesis_constants.t end let make_checked t = Snark_params.Tick.Run.make_checked t @@ -3111,7 +3111,7 @@ module Make_str (A : Wire_types.Concrete) = struct let consensus_constants = Lazy.force Constants.for_unit_tests - let compile_config = Mina_compile_config.For_unit_tests.t + let genesis_constants = Genesis_constants.For_unit_tests.t end in (* Even when consensus constants are of prod sizes, candidate should still trigger a bootstrap *) should_bootstrap_len @@ -3439,7 +3439,7 @@ module Make_str (A : Wire_types.Concrete) = struct let consensus_constants = constants - let compile_config = Mina_compile_config.For_unit_tests.t + let genesis_constants = Genesis_constants.For_unit_tests.t end let test_update constraint_constants = diff --git a/src/lib/fake_network/fake_network.ml b/src/lib/fake_network/fake_network.ml index 81995f715b2..58cc462ac7b 100644 --- a/src/lib/fake_network/fake_network.ml +++ b/src/lib/fake_network/fake_network.ml @@ -14,8 +14,6 @@ module type CONTEXT = sig val constraint_constants : Genesis_constants.Constraint_constants.t val consensus_constants : Consensus.Constants.t - - val compile_config : Mina_compile_config.t end (* There must be at least 2 peers to create a network *) @@ -215,6 +213,11 @@ module Generator = struct ?get_transition_chain_proof ?get_ancestry ?get_best_tip ~context:(module Context : CONTEXT) ~verifier ~max_frontier_length ~use_super_catchup = + let module Consensus_context = struct + include Context + + let genesis_constants = precomputed_values.genesis_constants + end in let open Context in let epoch_ledger_location = Filename.temp_dir_name ^/ "epoch_ledger" @@ -223,7 +226,7 @@ module Generator = struct let genesis_ledger = Precomputed_values.genesis_ledger precomputed_values in let consensus_local_state = Consensus.Data.Local_state.create Public_key.Compressed.Set.empty - ~context:(module Context) + ~context:(module Consensus_context) ~genesis_ledger ~genesis_epoch_data:precomputed_values.genesis_epoch_data ~epoch_ledger_location @@ -257,6 +260,11 @@ module Generator = struct ?get_transition_chain_proof ?get_ancestry ?get_best_tip ~context:(module Context : CONTEXT) ~verifier ~max_frontier_length ~use_super_catchup = + let module Consensus_context = struct + include Context + + let genesis_constants = precomputed_values.genesis_constants + end in let open Context in let epoch_ledger_location = Filename.temp_dir_name ^/ "epoch_ledger" @@ -265,7 +273,7 @@ module Generator = struct let genesis_ledger = Precomputed_values.genesis_ledger precomputed_values in let consensus_local_state = Consensus.Data.Local_state.create Public_key.Compressed.Set.empty - ~context:(module Context) + ~context:(module Consensus_context) ~genesis_ledger ~genesis_epoch_data:precomputed_values.genesis_epoch_data ~epoch_ledger_location @@ -300,7 +308,7 @@ module Generator = struct let gen ?(logger = Logger.null ()) ~precomputed_values ~verifier ~max_frontier_length ~use_super_catchup - (configs : (peer_config, 'n num_peers) Gadt_lib.Vect.t) ~compile_config = + (configs : (peer_config, 'n num_peers) Gadt_lib.Vect.t) = (* TODO: Pass in *) let module Context = struct let logger = logger @@ -312,8 +320,6 @@ module Generator = struct let consensus_constants = precomputed_values.Precomputed_values.consensus_constants - - let compile_config = compile_config end in let open Quickcheck.Generator.Let_syntax in let%map states = diff --git a/src/lib/fake_network/fake_network.mli b/src/lib/fake_network/fake_network.mli index b3d041cf7f6..cee6df672f8 100644 --- a/src/lib/fake_network/fake_network.mli +++ b/src/lib/fake_network/fake_network.mli @@ -10,8 +10,6 @@ module type CONTEXT = sig val constraint_constants : Genesis_constants.Constraint_constants.t val consensus_constants : Consensus.Constants.t - - val compile_config : Mina_compile_config.t end (* There must be at least 2 peers to create a network *) @@ -100,6 +98,5 @@ module Generator : sig -> max_frontier_length:int -> use_super_catchup:bool -> (peer_config, 'n num_peers) Vect.t - -> compile_config:Mina_compile_config.t -> 'n num_peers t Generator.t end diff --git a/src/lib/genesis_constants/genesis_constants.ml b/src/lib/genesis_constants/genesis_constants.ml index 1f96fda1902..d2ba77df760 100644 --- a/src/lib/genesis_constants/genesis_constants.ml +++ b/src/lib/genesis_constants/genesis_constants.ml @@ -223,6 +223,8 @@ module T = struct ; max_action_elements : int ; zkapp_cmd_limit_hardcap : int ; minimum_user_command_fee : Currency.Fee.Stable.Latest.t + ; sync_ledger_default_subtree_depth : int + ; sync_ledger_max_subtree_depth : int } [@@deriving to_yojson, sexp_of, bin_io_unversioned] @@ -435,6 +437,9 @@ module Make (Node_config : Node_config_intf.S) : S = struct ; zkapp_cmd_limit_hardcap = Node_config.zkapp_cmd_limit_hardcap ; minimum_user_command_fee = Currency.Fee.of_mina_string_exn Node_config.minimum_user_command_fee + ; sync_ledger_max_subtree_depth = Node_config.sync_ledger_max_subtree_depth + ; sync_ledger_default_subtree_depth = + Node_config.sync_ledger_default_subtree_depth } end diff --git a/src/lib/genesis_ledger_helper/lib/genesis_ledger_helper_lib.ml b/src/lib/genesis_ledger_helper/lib/genesis_ledger_helper_lib.ml index 6ca2c3465b5..8e14b481e83 100644 --- a/src/lib/genesis_ledger_helper/lib/genesis_ledger_helper_lib.ml +++ b/src/lib/genesis_ledger_helper/lib/genesis_ledger_helper_lib.ml @@ -592,6 +592,12 @@ let make_genesis_constants ~logger ~(default : Genesis_constants.t) ; minimum_user_command_fee = Option.value ~default:default.minimum_user_command_fee (config.daemon >>= fun cfg -> cfg.minimum_user_command_fee) + ; sync_ledger_default_subtree_depth = + Option.value ~default:default.sync_ledger_default_subtree_depth + (config.daemon >>= fun cfg -> cfg.sync_ledger_default_subtree_depth) + ; sync_ledger_max_subtree_depth = + Option.value ~default:default.sync_ledger_max_subtree_depth + (config.daemon >>= fun cfg -> cfg.sync_ledger_max_subtree_depth) } let%test_module "Runtime config" = diff --git a/src/lib/ledger_catchup/ledger_catchup.ml b/src/lib/ledger_catchup/ledger_catchup.ml index 599dbcf587b..5e452ab565e 100644 --- a/src/lib/ledger_catchup/ledger_catchup.ml +++ b/src/lib/ledger_catchup/ledger_catchup.ml @@ -9,8 +9,6 @@ module type CONTEXT = sig val constraint_constants : Genesis_constants.Constraint_constants.t val consensus_constants : Consensus.Constants.t - - val compile_config : Mina_compile_config.t end let run ~context:(module Context : CONTEXT) ~trust_system ~verifier ~network diff --git a/src/lib/ledger_catchup/ledger_catchup.mli b/src/lib/ledger_catchup/ledger_catchup.mli index 03f94401b79..0a957e7e835 100644 --- a/src/lib/ledger_catchup/ledger_catchup.mli +++ b/src/lib/ledger_catchup/ledger_catchup.mli @@ -13,8 +13,6 @@ module type CONTEXT = sig val constraint_constants : Genesis_constants.Constraint_constants.t val consensus_constants : Consensus.Constants.t - - val compile_config : Mina_compile_config.t end module Catchup_jobs : sig diff --git a/src/lib/ledger_catchup/normal_catchup.ml b/src/lib/ledger_catchup/normal_catchup.ml index 99f0b38e200..bfd2607ad38 100644 --- a/src/lib/ledger_catchup/normal_catchup.ml +++ b/src/lib/ledger_catchup/normal_catchup.ml @@ -15,8 +15,6 @@ module type CONTEXT = sig val constraint_constants : Genesis_constants.Constraint_constants.t val consensus_constants : Consensus.Constants.t - - val compile_config : Mina_compile_config.t end (** [Ledger_catchup] is a procedure that connects a foreign external transition @@ -898,8 +896,6 @@ let%test_module "Ledger_catchup tests" = let constraint_constants = precomputed_values.constraint_constants - let compile_config = Mina_compile_config.For_unit_tests.t - let trust_system = Trust_system.null () let time_controller = Block_time.Controller.basic ~logger @@ -921,8 +917,6 @@ let%test_module "Ledger_catchup tests" = let constraint_constants = constraint_constants let consensus_constants = precomputed_values.consensus_constants - - let compile_config = compile_config end let downcast_transition transition = @@ -1047,7 +1041,6 @@ let%test_module "Ledger_catchup tests" = in gen ~precomputed_values ~verifier ~max_frontier_length ~use_super_catchup - ~compile_config:Mina_compile_config.For_unit_tests.t [ fresh_peer ; peer_with_branch ~frontier_branch_size:peer_branch_size ]) @@ -1069,7 +1062,6 @@ let%test_module "Ledger_catchup tests" = Fake_network.Generator.( gen ~precomputed_values ~verifier ~max_frontier_length ~use_super_catchup - ~compile_config:Mina_compile_config.For_unit_tests.t [ fresh_peer; peer_with_branch ~frontier_branch_size:1 ]) ~f:(fun network -> let open Fake_network in @@ -1085,7 +1077,6 @@ let%test_module "Ledger_catchup tests" = Fake_network.Generator.( gen ~precomputed_values ~verifier ~max_frontier_length ~use_super_catchup - ~compile_config:Mina_compile_config.For_unit_tests.t [ fresh_peer ; peer_with_branch ~frontier_branch_size:(max_frontier_length * 2) ]) diff --git a/src/lib/ledger_catchup/super_catchup.ml b/src/lib/ledger_catchup/super_catchup.ml index 4ca6305617c..507cd5eff88 100644 --- a/src/lib/ledger_catchup/super_catchup.ml +++ b/src/lib/ledger_catchup/super_catchup.ml @@ -16,8 +16,6 @@ module type CONTEXT = sig val constraint_constants : Genesis_constants.Constraint_constants.t val consensus_constants : Consensus.Constants.t - - val compile_config : Mina_compile_config.t end (** [Ledger_catchup] is a procedure that connects a foreign external transition @@ -768,6 +766,11 @@ let pick ~context:(module Context : CONTEXT) (x : Mina_state.Protocol_state.Value.t State_hash.With_state_hashes.t) (y : Mina_state.Protocol_state.Value.t State_hash.With_state_hashes.t) = let f = With_hash.map ~f:Mina_state.Protocol_state.consensus_state in + let module Context = struct + include Context + + let genesis_constants = precomputed_values.genesis_constants + end in match Consensus.Hooks.select ~context:(module Context) @@ -1449,8 +1452,6 @@ let%test_module "Ledger_catchup tests" = let use_super_catchup = true - let compile_config = Mina_compile_config.For_unit_tests.t - let verifier = Async.Thread_safe.block_on_async_exn (fun () -> Verifier.create ~logger ~proof_level ~constraint_constants @@ -1466,8 +1467,6 @@ let%test_module "Ledger_catchup tests" = let constraint_constants = constraint_constants let consensus_constants = precomputed_values.consensus_constants - - let compile_config = compile_config end (* let mock_verifier = @@ -1646,7 +1645,7 @@ let%test_module "Ledger_catchup tests" = Int.gen_incl (max_frontier_length / 2) (max_frontier_length - 1) in gen ~precomputed_values ~verifier ~max_frontier_length - ~use_super_catchup ~compile_config + ~use_super_catchup [ fresh_peer ; peer_with_branch ~frontier_branch_size:peer_branch_size ]) @@ -1666,7 +1665,7 @@ let%test_module "Ledger_catchup tests" = Quickcheck.test ~trials:1 Fake_network.Generator.( gen ~precomputed_values ~verifier ~max_frontier_length - ~use_super_catchup ~compile_config + ~use_super_catchup [ fresh_peer; peer_with_branch ~frontier_branch_size:1 ]) ~f:(fun network -> let open Fake_network in @@ -1682,7 +1681,7 @@ let%test_module "Ledger_catchup tests" = Quickcheck.test ~trials:1 Fake_network.Generator.( gen ~precomputed_values ~verifier ~max_frontier_length - ~use_super_catchup ~compile_config + ~use_super_catchup [ fresh_peer; peer_with_branch ~frontier_branch_size:1 ]) ~f:(fun network -> let open Fake_network in @@ -1699,7 +1698,7 @@ let%test_module "Ledger_catchup tests" = Quickcheck.test ~trials:1 Fake_network.Generator.( gen ~precomputed_values ~verifier ~max_frontier_length - ~use_super_catchup ~compile_config + ~use_super_catchup [ fresh_peer ; peer_with_branch ~frontier_branch_size:((max_frontier_length * 3) + 1) @@ -1777,7 +1776,7 @@ let%test_module "Ledger_catchup tests" = Quickcheck.test ~trials:1 Fake_network.Generator.( gen ~precomputed_values ~verifier ~max_frontier_length - ~use_super_catchup ~compile_config + ~use_super_catchup [ fresh_peer (* ; peer_with_branch ~frontier_branch_size:(max_frontier_length / 2) *) ; peer_with_branch_custom_rpc diff --git a/src/lib/mina_block/validation.ml b/src/lib/mina_block/validation.ml index 5254a05d2c1..d9bd83bdb73 100644 --- a/src/lib/mina_block/validation.ml +++ b/src/lib/mina_block/validation.ml @@ -19,7 +19,7 @@ module type CONTEXT = sig val consensus_constants : Consensus.Constants.t - val compile_config : Mina_compile_config.t + val genesis_constants : Genesis_constants.t end let validation (_, v) = v diff --git a/src/lib/mina_block/validation.mli b/src/lib/mina_block/validation.mli index 71881258304..97a4acb9d00 100644 --- a/src/lib/mina_block/validation.mli +++ b/src/lib/mina_block/validation.mli @@ -20,7 +20,7 @@ module type CONTEXT = sig val consensus_constants : Consensus.Constants.t - val compile_config : Mina_compile_config.t + val genesis_constants : Genesis_constants.t end val validation : diff --git a/src/lib/mina_intf/transition_frontier_components_intf.ml b/src/lib/mina_intf/transition_frontier_components_intf.ml index b9d042ba1b8..cfb4a797188 100644 --- a/src/lib/mina_intf/transition_frontier_components_intf.ml +++ b/src/lib/mina_intf/transition_frontier_components_intf.ml @@ -13,8 +13,6 @@ module type CONTEXT = sig val constraint_constants : Genesis_constants.Constraint_constants.t val consensus_constants : Consensus.Constants.t - - val compile_config : Mina_compile_config.t end module type Transition_handler_validator_intf = sig @@ -207,7 +205,6 @@ module type Consensus_best_tip_prover_intf = sig val verify : context:(module CONTEXT) -> verifier:Verifier.t - -> genesis_constants:Genesis_constants.t -> Consensus.Data.Consensus_state.Value.t State_hash.With_state_hashes.t -> ( Mina_block.t , State_body_hash.t list * Mina_block.t ) diff --git a/src/lib/mina_lib/mina_lib.ml b/src/lib/mina_lib/mina_lib.ml index a6410f96d8d..70c0fe033d6 100644 --- a/src/lib/mina_lib/mina_lib.ml +++ b/src/lib/mina_lib/mina_lib.ml @@ -1607,7 +1607,8 @@ let create ~commit_id ?wallets (config : Config.t) = ~pids:config.pids ~logger:config.logger ~conf_dir:config.conf_dir ~consensus_constants ~keypairs:config.block_production_keypairs - ~compile_config:config.compile_config ) ) + ~genesis_constants: + config.precomputed_values.genesis_constants ) ) >>| Result.ok_exn in let snark_worker = diff --git a/src/lib/mina_networking/mina_networking.ml b/src/lib/mina_networking/mina_networking.ml index 93a9522ec33..15dbc9ac89b 100644 --- a/src/lib/mina_networking/mina_networking.ml +++ b/src/lib/mina_networking/mina_networking.ml @@ -42,8 +42,6 @@ module type CONTEXT = sig val constraint_constants : Genesis_constants.Constraint_constants.t val consensus_constants : Consensus.Constants.t - - val compile_config : Mina_compile_config.t end module Node_status = Node_status diff --git a/src/lib/mina_networking/mina_networking.mli b/src/lib/mina_networking/mina_networking.mli index 1aaf511d8e2..d53ae824086 100644 --- a/src/lib/mina_networking/mina_networking.mli +++ b/src/lib/mina_networking/mina_networking.mli @@ -29,8 +29,6 @@ module type CONTEXT = sig val constraint_constants : Genesis_constants.Constraint_constants.t val consensus_constants : Consensus.Constants.t - - val compile_config : Mina_compile_config.t end module Node_status = Node_status diff --git a/src/lib/mina_networking/rpcs.ml b/src/lib/mina_networking/rpcs.ml index e6f0048531b..99882642c25 100644 --- a/src/lib/mina_networking/rpcs.ml +++ b/src/lib/mina_networking/rpcs.ml @@ -33,8 +33,6 @@ module type CONTEXT = sig val list_peers : unit -> Peer.t list Deferred.t val get_transition_frontier : unit -> Transition_frontier.t option - - val compile_config : Mina_compile_config.t end type ctx = (module CONTEXT) diff --git a/src/lib/runtime_config/runtime_config.ml b/src/lib/runtime_config/runtime_config.ml index 27cddee86de..7846e46f27e 100644 --- a/src/lib/runtime_config/runtime_config.ml +++ b/src/lib/runtime_config/runtime_config.ml @@ -514,6 +514,8 @@ module Json_layout = struct [@default None] [@key "validation-queue-size"] ; stop_time : int option [@default None] [@key "stop-time"] ; peers : string list option [@default None] [@key "peers"] + ; sync_ledger_max_subtree_depth : int option [@default None] + ; sync_ledger_default_subtree_depth : int option [@default None] } [@@deriving yojson, fields] @@ -1223,6 +1225,8 @@ module Daemon = struct ; validation_queue_size : int option [@default None] ; stop_time : int option [@default None] ; peers : string list option [@default None] + ; sync_ledger_max_subtree_depth : int option [@default None] + ; sync_ledger_default_subtree_depth : int option [@default None] } [@@deriving bin_io_unversioned, fields] @@ -1264,6 +1268,8 @@ module Daemon = struct ; validation_queue_size = None ; stop_time = None ; peers = None + ; sync_ledger_max_subtree_depth = None + ; sync_ledger_default_subtree_depth = None } let to_json_layout : t -> Json_layout.Daemon.t = Fn.id @@ -1354,6 +1360,12 @@ module Daemon = struct t2.validation_queue_size ; stop_time = opt_fallthrough ~default:t1.stop_time t2.stop_time ; peers = opt_fallthrough ~default:t1.peers t2.peers + ; sync_ledger_max_subtree_depth = + opt_fallthrough ~default:t1.sync_ledger_max_subtree_depth + t2.sync_ledger_max_subtree_depth + ; sync_ledger_default_subtree_depth = + opt_fallthrough ~default:t1.sync_ledger_default_subtree_depth + t2.sync_ledger_default_subtree_depth } end diff --git a/src/lib/sync_handler/sync_handler.ml b/src/lib/sync_handler/sync_handler.ml index 5e6ebb65b41..ef4e5d64efd 100644 --- a/src/lib/sync_handler/sync_handler.ml +++ b/src/lib/sync_handler/sync_handler.ml @@ -14,8 +14,6 @@ module type CONTEXT = sig val constraint_constants : Genesis_constants.Constraint_constants.t val consensus_constants : Consensus.Constants.t - - val compile_config : Mina_compile_config.t end module type Inputs_intf = sig @@ -99,7 +97,7 @@ module Make (Inputs : Inputs_intf) : ( module struct let logger = Context.logger - let compile_config = Context.compile_config + let genesis_constants = Context.precomputed_values.genesis_constants end ) in match get_ledger_by_hash ~frontier hash with @@ -207,6 +205,8 @@ module Make (Inputs : Inputs_intf) : let module Context = struct include Context + let genesis_constants = precomputed_values.genesis_constants + let logger = Logger.extend logger [ ("selection_context", `String "Root.prove") ] end in @@ -229,20 +229,24 @@ module Make (Inputs : Inputs_intf) : data = With_hash.data best_tip_with_witness.data } - let verify ~context:(module Context : CONTEXT) ~verifier ~genesis_constants - observed_state peer_root = + let verify ~context:(module Context : CONTEXT) ~verifier observed_state + peer_root = let module Context = struct include Context + let genesis_constants = precomputed_values.genesis_constants + let logger = Logger.extend logger [ ("selection_context", `String "Root.verify") ] end in let open Context in let open Deferred.Result.Let_syntax in + (*TODO: use precomputed_values.genesis_constants that's already passed*) let%bind ( (`Root _, `Best_tip (best_tip_transition, _)) as verified_witness ) = - Best_tip_prover.verify ~verifier ~genesis_constants ~precomputed_values - peer_root + Best_tip_prover.verify ~verifier + ~genesis_constants:precomputed_values.genesis_constants + ~precomputed_values peer_root in let is_before_best_tip candidate = Consensus.Hooks.equal_select_status diff --git a/src/lib/syncable_ledger/dune b/src/lib/syncable_ledger/dune index 5e51630c4b9..d0c99d5fd6d 100644 --- a/src/lib/syncable_ledger/dune +++ b/src/lib/syncable_ledger/dune @@ -22,7 +22,7 @@ direction error_json ppx_version.runtime - mina_compile_config + genesis_constants ) (preprocess (pps ppx_mina ppx_version ppx_jane ppx_compare ppx_deriving_yojson ppx_register_event)) diff --git a/src/lib/syncable_ledger/syncable_ledger.ml b/src/lib/syncable_ledger/syncable_ledger.ml index ac8cb70bd4a..9b9b4f50cf6 100644 --- a/src/lib/syncable_ledger/syncable_ledger.ml +++ b/src/lib/syncable_ledger/syncable_ledger.ml @@ -108,7 +108,7 @@ end module type CONTEXT = sig val logger : Logger.t - val compile_config : Mina_compile_config.t + val genesis_constants : Genesis_constants.t end module type Inputs_intf = sig @@ -403,7 +403,8 @@ end = struct match subtree_depth with | n when n >= 1 - && n <= Context.compile_config.sync_ledger_max_subtree_depth + && n + <= Context.genesis_constants.sync_ledger_max_subtree_depth -> ( let ledger_depth = MT.depth mt in let addresses = @@ -575,7 +576,7 @@ end = struct let is_more_than_two = len >= 2 in let subtree_depth = Int.ceil_log2 len in let less_than_max = - len <= Int.pow 2 Context.compile_config.sync_ledger_max_subtree_depth + len <= Int.pow 2 Context.genesis_constants.sync_ledger_max_subtree_depth in let less_than_requested = subtree_depth <= requested_depth in let valid_length = @@ -652,7 +653,8 @@ end = struct Linear_pipe.write_without_pushback_if_open t.queries ( desired_root_exn t , What_child_hashes - (addr, Context.compile_config.sync_ledger_default_subtree_depth) ) ) + (addr, Context.genesis_constants.sync_ledger_default_subtree_depth) + ) ) (** Handle the initial Num_accounts message, starting the main syncing process. *) @@ -787,7 +789,7 @@ end = struct be a power of 2 in the range 2-2^$depth" , [ ( "depth" , `Int - Context.compile_config + Context.genesis_constants .sync_ledger_max_subtree_depth ) ] ) ) in diff --git a/src/lib/syncable_ledger/test/test.ml b/src/lib/syncable_ledger/test/test.ml index aa2bf874cb8..078562e1d19 100644 --- a/src/lib/syncable_ledger/test/test.ml +++ b/src/lib/syncable_ledger/test/test.ml @@ -44,8 +44,8 @@ module Make_context (Subtree_depth : sig end) : Syncable_ledger.CONTEXT = struct let logger = Logger.null () - let compile_config = - { Mina_compile_config.For_unit_tests.t with + let genesis_constants = + { Genesis_constants.For_unit_tests.t with sync_ledger_max_subtree_depth = Subtree_depth.sync_ledger_max_subtree_depth ; sync_ledger_default_subtree_depth = diff --git a/src/lib/transition_frontier/full_frontier/full_frontier.ml b/src/lib/transition_frontier/full_frontier/full_frontier.ml index 6ed2474988e..b999f0451fa 100644 --- a/src/lib/transition_frontier/full_frontier/full_frontier.ml +++ b/src/lib/transition_frontier/full_frontier/full_frontier.ml @@ -12,8 +12,6 @@ module type CONTEXT = sig val constraint_constants : Genesis_constants.Constraint_constants.t val consensus_constants : Consensus.Constants.t - - val compile_config : Mina_compile_config.t end module Node = struct @@ -565,6 +563,11 @@ let calculate_diffs ({ context = (module Context); _ } as t) breadcrumb = ] end in let open Diff in + let module Consensus_context = struct + include Context + + let genesis_constants = precomputed_values.genesis_constants + end in O1trace.sync_thread "calculate_diff_frontier_diffs" (fun () -> let breadcrumb_hash = Breadcrumb.state_hash breadcrumb in let parent_node = @@ -585,7 +588,7 @@ let calculate_diffs ({ context = (module Context); _ } as t) breadcrumb = if Consensus.Hooks.equal_select_status (Consensus.Hooks.select - ~context:(module Context) + ~context:(module Consensus_context) ~existing: (Breadcrumb.consensus_state_with_hashes current_best_tip) ~candidate:(Breadcrumb.consensus_state_with_hashes breadcrumb) ) @@ -961,7 +964,7 @@ module For_tests = struct let consensus_constants = precomputed_values.consensus_constants - let compile_config = Mina_compile_config.For_unit_tests.t + let genesis_constants = Genesis_constants.For_unit_tests.t end let verifier () = diff --git a/src/lib/transition_frontier/full_frontier/full_frontier.mli b/src/lib/transition_frontier/full_frontier/full_frontier.mli index 2d8f04c185b..dc6614e3000 100644 --- a/src/lib/transition_frontier/full_frontier/full_frontier.mli +++ b/src/lib/transition_frontier/full_frontier/full_frontier.mli @@ -21,8 +21,6 @@ module type CONTEXT = sig val constraint_constants : Genesis_constants.Constraint_constants.t val consensus_constants : Consensus.Constants.t - - val compile_config : Mina_compile_config.t end include Frontier_intf.S diff --git a/src/lib/transition_frontier/persistent_frontier/persistent_frontier.ml b/src/lib/transition_frontier/persistent_frontier/persistent_frontier.ml index b7519acd657..51a8715f4b9 100644 --- a/src/lib/transition_frontier/persistent_frontier/persistent_frontier.ml +++ b/src/lib/transition_frontier/persistent_frontier/persistent_frontier.ml @@ -14,8 +14,6 @@ module type CONTEXT = sig val constraint_constants : Genesis_constants.Constraint_constants.t val consensus_constants : Consensus.Constants.t - - val compile_config : Mina_compile_config.t end exception Invalid_genesis_state_hash of Mina_block.Validated.t diff --git a/src/lib/transition_frontier/transition_frontier.ml b/src/lib/transition_frontier/transition_frontier.ml index f1a63f517dc..b1c6c572337 100644 --- a/src/lib/transition_frontier/transition_frontier.ml +++ b/src/lib/transition_frontier/transition_frontier.ml @@ -24,8 +24,6 @@ module type CONTEXT = sig val constraint_constants : Genesis_constants.Constraint_constants.t val consensus_constants : Consensus.Constants.t - - val compile_config : Mina_compile_config.t end let max_catchup_chunk_length = 20 @@ -722,7 +720,7 @@ module For_tests = struct let consensus_constants = precomputed_values.consensus_constants - let compile_config = Mina_compile_config.For_unit_tests.t + let genesis_constants = precomputed_values.genesis_constants end in let open Context in let open Quickcheck.Generator.Let_syntax in diff --git a/src/lib/transition_frontier/transition_frontier.mli b/src/lib/transition_frontier/transition_frontier.mli index a2071bdd5e4..0e719016fa3 100644 --- a/src/lib/transition_frontier/transition_frontier.mli +++ b/src/lib/transition_frontier/transition_frontier.mli @@ -26,8 +26,6 @@ module type CONTEXT = sig val constraint_constants : Genesis_constants.Constraint_constants.t val consensus_constants : Consensus.Constants.t - - val compile_config : Mina_compile_config.t end include Frontier_intf.S diff --git a/src/lib/transition_frontier_controller/transition_frontier_controller.ml b/src/lib/transition_frontier_controller/transition_frontier_controller.ml index 738b7c3f577..7a28592ec8a 100644 --- a/src/lib/transition_frontier_controller/transition_frontier_controller.ml +++ b/src/lib/transition_frontier_controller/transition_frontier_controller.ml @@ -11,8 +11,6 @@ module type CONTEXT = sig val constraint_constants : Genesis_constants.Constraint_constants.t val consensus_constants : Consensus.Constants.t - - val compile_config : Mina_compile_config.t end let run ~context:(module Context : CONTEXT) ~trust_system ~verifier ~network diff --git a/src/lib/transition_handler/processor.ml b/src/lib/transition_handler/processor.ml index 78655b431c7..622d6b94391 100644 --- a/src/lib/transition_handler/processor.ml +++ b/src/lib/transition_handler/processor.ml @@ -25,8 +25,6 @@ module type CONTEXT = sig val constraint_constants : Genesis_constants.Constraint_constants.t val consensus_constants : Consensus.Constants.t - - val compile_config : Mina_compile_config.t end (* TODO: calculate a sensible value from postake consensus arguments *) @@ -114,7 +112,16 @@ let process_transition ~context:(module Context : CONTEXT) ~trust_system let is_block_in_frontier = Fn.compose Option.is_some @@ Transition_frontier.find frontier in - let open Context in + let module Consensus_context = struct + include Context + + let genesis_constants = precomputed_values.genesis_constants + end in + let open Consensus_context in + let block_window_duration = + Float.of_int constraint_constants.block_window_duration_ms + |> Time.Span.of_ms + in let header, transition_hash, transition_receipt_time, sender, validation = match block_or_header with | `Block cached_env -> @@ -165,15 +172,14 @@ let process_transition ~context:(module Context : CONTEXT) ~trust_system [%log internal] "Validate_frontier_dependencies" ; match Mina_block.Validation.validate_frontier_dependencies - ~context:(module Context) + ~context:(module Consensus_context) ~root_block ~is_block_in_frontier ~to_header:ident (Envelope.Incoming.data env) with | Ok _ | Error `Parent_missing_from_frontier -> [%log internal] "Schedule_catchup" ; Catchup_scheduler.watch_header catchup_scheduler ~valid_cb - ~block_window_duration:compile_config.block_window_duration - ~header_with_hash ; + ~block_window_duration ~header_with_hash ; return () | Error `Not_selected_over_frontier_root -> handle_not_selected () @@ -197,7 +203,7 @@ let process_transition ~context:(module Context : CONTEXT) ~trust_system [%log internal] "Validate_frontier_dependencies" ; match Mina_block.Validation.validate_frontier_dependencies - ~context:(module Context) + ~context:(module Consensus_context) ~root_block ~is_block_in_frontier ~to_header:Mina_block.header initially_validated_transition with @@ -240,8 +246,7 @@ let process_transition ~context:(module Context : CONTEXT) ~trust_system in Catchup_scheduler.watch catchup_scheduler ~timeout_duration ~cached_transition:cached_initially_validated_transition - ~valid_cb - ~block_window_duration:compile_config.block_window_duration ; + ~valid_cb ~block_window_duration ; return (Error ()) ) in (* TODO: only access parent in transition frontier once (already done in call to validate dependencies) #2485 *) @@ -286,7 +291,7 @@ let process_transition ~context:(module Context : CONTEXT) ~trust_system add_and_finalize ~logger ~frontier ~catchup_scheduler ~processed_transition_writer ~only_if_present:false ~time_controller ~source:`Gossip breadcrumb ~precomputed_values ~valid_cb - ~block_window_duration:compile_config.block_window_duration + ~block_window_duration in ( match result with | Ok () -> @@ -325,6 +330,10 @@ let run ~context:(module Context : CONTEXT) ~verifier ~trust_system , unit ) Writer.t ) ~processed_transition_writer = let open Context in + let block_window_duration = + Float.of_int constraint_constants.block_window_duration_ms + |> Time.Span.of_ms + in let catchup_scheduler = Catchup_scheduler.create ~logger ~precomputed_values ~verifier ~trust_system ~frontier ~time_controller ~catchup_job_writer ~catchup_breadcrumbs_writer @@ -380,8 +389,7 @@ let run ~context:(module Context : CONTEXT) ~verifier ~trust_system let%map result = add_and_finalize ~logger ~only_if_present:true ~source:`Catchup ~valid_cb b - ~block_window_duration: - compile_config.block_window_duration + ~block_window_duration in Internal_tracing.with_state_hash state_hash @@ fun () -> @@ -445,8 +453,7 @@ let run ~context:(module Context : CONTEXT) ~verifier ~trust_system match%map add_and_finalize ~logger ~only_if_present:false ~source:`Internal breadcrumb ~valid_cb:None - ~block_window_duration: - compile_config.block_window_duration + ~block_window_duration with | Ok () -> [%log internal] "Breadcrumb_integrated" ; @@ -494,8 +501,6 @@ let%test_module "Transition_handler.Processor tests" = let trust_system = Trust_system.null () - let compile_config = Mina_compile_config.For_unit_tests.t - let verifier = Async.Thread_safe.block_on_async_exn (fun () -> Verifier.create ~logger ~proof_level ~constraint_constants @@ -511,8 +516,6 @@ let%test_module "Transition_handler.Processor tests" = let constraint_constants = constraint_constants let consensus_constants = precomputed_values.consensus_constants - - let compile_config = compile_config end let downcast_breadcrumb breadcrumb = diff --git a/src/lib/transition_handler/validator.ml b/src/lib/transition_handler/validator.ml index 805a88b749e..20ee229dbfd 100644 --- a/src/lib/transition_handler/validator.ml +++ b/src/lib/transition_handler/validator.ml @@ -14,8 +14,6 @@ module type CONTEXT = sig val constraint_constants : Genesis_constants.Constraint_constants.t val consensus_constants : Consensus.Constants.t - - val compile_config : Mina_compile_config.t end let validate_header_is_relevant ~context:(module Context : CONTEXT) ~frontier @@ -24,6 +22,8 @@ let validate_header_is_relevant ~context:(module Context : CONTEXT) ~frontier let module Context = struct include Context + let genesis_constants = precomputed_values.genesis_constants + let logger = Logger.extend logger [ ("selection_context", `String "Transition_handler.Validator") ] diff --git a/src/lib/transition_router/transition_router.ml b/src/lib/transition_router/transition_router.ml index a8b57177966..21855ad463a 100644 --- a/src/lib/transition_router/transition_router.ml +++ b/src/lib/transition_router/transition_router.ml @@ -12,8 +12,6 @@ module type CONTEXT = sig val constraint_constants : Genesis_constants.Constraint_constants.t val consensus_constants : Consensus.Constants.t - - val compile_config : Mina_compile_config.t end type Structured_log_events.t += Starting_transition_frontier_controller @@ -57,8 +55,8 @@ let to_consensus_state h = (Fn.compose Mina_state.Protocol_state.consensus_state Mina_block.Header.protocol_state ) -let is_transition_for_bootstrap ~context:(module Context : CONTEXT) frontier - new_header = +let is_transition_for_bootstrap + ~context:(module Context : Consensus.Intf.CONTEXT) frontier new_header = let root_consensus_state = Transition_frontier.root frontier |> Transition_frontier.Breadcrumb.consensus_state_with_hashes @@ -285,6 +283,11 @@ let download_best_tip ~context:(module Context : CONTEXT) ~notify_online [ ("actual", `Int (List.length tips)); ("expected", `Int num_peers) ] "Finished requesting tips. Got $actual / $expected" ; let%map () = notify_online () in + let module Consensus_context = struct + include Context + + let genesis_constants = precomputed_values.genesis_constants + end in let res = List.fold tips ~init:None ~f:(fun acc enveloped_candidate_best_tip -> Option.merge acc (Option.return enveloped_candidate_best_tip) @@ -295,7 +298,7 @@ let download_best_tip ~context:(module Context : CONTEXT) ~notify_online in match Consensus.Hooks.select - ~context:(module Context) + ~context:(module Consensus_context) ~existing:(f enveloped_existing_best_tip.data.data) ~candidate:(f enveloped_candidate_best_tip.data.data) with @@ -404,6 +407,11 @@ let initialize ~context:(module Context : CONTEXT) ~sync_local_state ~network let genesis_constants = Precomputed_values.genesis_constants precomputed_values in + let module Consensus_context = struct + include Context + + let genesis_constants = precomputed_values.genesis_constants + end in match%bind Deferred.both (download_best_tip @@ -433,7 +441,7 @@ let initialize ~context:(module Context : CONTEXT) ~sync_local_state ~network (Option.map ~f:(fun x -> `Block x) best_seen_transition) | Some best_tip, Some frontier when is_transition_for_bootstrap - ~context:(module Context) + ~context:(module Consensus_context) frontier ( best_tip |> Envelope.Incoming.data |> Mina_block.Validation.to_header ) -> @@ -503,7 +511,7 @@ let initialize ~context:(module Context : CONTEXT) ~sync_local_state ~network Consensus.Hooks.sync_local_state ~local_state:consensus_local_state ~glue_sync_ledger:(Mina_networking.glue_sync_ledger network) - ~context:(module Context) + ~context:(module Consensus_context) ~trust_system sync_jobs with | Error e -> @@ -569,6 +577,11 @@ let run ?(sync_local_state = true) ?(cache_exceptions = false) ~get_most_recent_valid_block ~most_recent_valid_block_writer ~get_completed_work ~catchup_mode ~notify_online () = let open Context in + let module Consensus_context = struct + include Context + + let genesis_constants = precomputed_values.genesis_constants + end in [%log info] "Starting transition router" ; let initialization_finish_signal = Ivar.create () in let clear_reader, clear_writer = @@ -662,7 +675,7 @@ let run ?(sync_local_state = true) ?(cache_exceptions = false) if Consensus.Hooks.equal_select_status `Take (Consensus.Hooks.select - ~context:(module Context) + ~context:(module Consensus_context) ~existing:(to_consensus_state current_header_with_hash) ~candidate:(to_consensus_state header_with_hash) ) then @@ -682,7 +695,7 @@ let run ?(sync_local_state = true) ?(cache_exceptions = false) | Some frontier -> if is_transition_for_bootstrap - ~context:(module Context) + ~context:(module Consensus_context) frontier header_with_hash then ( Strict_pipe.Writer.kill !transition_writer_ref ; diff --git a/src/lib/vrf_evaluator/vrf_evaluator.ml b/src/lib/vrf_evaluator/vrf_evaluator.ml index 561f9292f0a..baab2b8e7e6 100644 --- a/src/lib/vrf_evaluator/vrf_evaluator.ml +++ b/src/lib/vrf_evaluator/vrf_evaluator.ml @@ -11,7 +11,7 @@ module type CONTEXT = sig val consensus_constants : Consensus.Constants.t - val compile_config : Mina_compile_config.t + val genesis_constants : Genesis_constants.t end (*Slot number within an epoch*) @@ -77,7 +77,7 @@ module Worker_state = struct type init_arg = { constraint_constants : Genesis_constants.Constraint_constants.t ; consensus_constants : Consensus.Constants.Stable.Latest.t - ; compile_config : Mina_compile_config.t + ; genesis_constants : Genesis_constants.t ; conf_dir : string ; logger : Logger.t ; commit_id : string @@ -87,7 +87,7 @@ module Worker_state = struct let context_of_config ({ constraint_constants ; consensus_constants - ; compile_config + ; genesis_constants ; logger ; conf_dir = _ ; commit_id = _ @@ -100,7 +100,7 @@ module Worker_state = struct let logger = logger - let compile_config = compile_config + let genesis_constants = genesis_constants end ) type t = @@ -420,7 +420,7 @@ let update_block_producer_keys { connection; process = _ } ~keypairs = ~arg:(Keypair.And_compressed_pk.Set.to_list keypairs) let create ~constraint_constants ~pids ~consensus_constants ~conf_dir ~logger - ~keypairs ~commit_id ~compile_config = + ~keypairs ~commit_id ~genesis_constants = let on_failure err = [%log error] "VRF evaluator process failed with error $err" ~metadata:[ ("err", Error_json.error_to_yojson err) ] ; @@ -432,7 +432,7 @@ let create ~constraint_constants ~pids ~consensus_constants ~conf_dir ~logger ~on_failure ~shutdown_on:Connection_closed ~connection_state_init_arg:() { constraint_constants ; consensus_constants - ; compile_config + ; genesis_constants ; conf_dir ; logger ; commit_id