Skip to content

Commit

Permalink
Remove CLI configuration flags. Use compile config directly.
Browse files Browse the repository at this point in the history
  • Loading branch information
joaosreis committed Nov 28, 2023
1 parent 10c9ce0 commit bde4359
Show file tree
Hide file tree
Showing 16 changed files with 73 additions and 134 deletions.
39 changes: 1 addition & 38 deletions src/app/cli/src/cli_entrypoint/mina_cli_entrypoint.ml
Original file line number Diff line number Diff line change
Expand Up @@ -430,24 +430,6 @@ let setup_daemon logger =
for the associated private key that is being tracked by this daemon. \
You cannot provide both `uptime-submitter-key` and \
`uptime-submitter-pubkey`."
and slot_tx_end =
flag "--slot-tx-end" ~aliases:[ "slot-tx-end" ]
~doc:
(sprintf
"SLOT Slot after which the node will stop accepting transactions, or\n\
\ `none` to disable the feature. (default: %s)"
(Option.value_map Mina_compile_config.slot_tx_end ~default:"none"
~f:Mina_numbers.Global_slot.to_string ) )
(optional string)
and slot_chain_end =
flag "--slot-network-end" ~aliases:[ "slot-network-end" ]
~doc:
(sprintf
"SLOT Slot after which the node will stop producing/validating \
blocks, or `none` to disable the feature. (default: %s)"
(Option.value_map Mina_compile_config.slot_chain_end ~default:"none"
~f:Mina_numbers.Global_slot.to_string ) )
(optional string)
in
let to_pubsub_topic_mode_option =
let open Gossip_net.Libp2p in
Expand Down Expand Up @@ -1288,24 +1270,6 @@ Pass one of -peer, -peer-list-file, -seed, -peer-list-url.|} ;
"Cannot provide both uptime submitter public key and uptime \
submitter keyfile"
in
let slot_tx_end =
match slot_tx_end with
| Some "none" ->
None
| Some slot ->
Some (Mina_numbers.Global_slot.of_string slot)
| None ->
Mina_compile_config.slot_tx_end
in
let slot_chain_end =
match slot_chain_end with
| Some "none" ->
None
| Some slot ->
Some (Mina_numbers.Global_slot.of_string slot)
| None ->
Mina_compile_config.slot_chain_end
in
let start_time = Time.now () in
let%map coda =
Mina_lib.create ~wallets
Expand Down Expand Up @@ -1336,8 +1300,7 @@ Pass one of -peer, -peer-list-file, -seed, -peer-list-url.|} ;
~log_block_creation ~precomputed_values ~start_time
?precomputed_blocks_path ~log_precomputed_blocks
~upload_blocks_to_gcloud ~block_reward_threshold ~uptime_url
~uptime_submitter_keypair ~stop_time ~node_status_url
~slot_tx_end ~slot_chain_end () )
~uptime_submitter_keypair ~stop_time ~node_status_url () )
in
{ Coda_initialization.coda
; client_trustlist
Expand Down
18 changes: 8 additions & 10 deletions src/lib/block_producer/block_producer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -111,18 +111,17 @@ end
let generate_next_state ~constraint_constants ~previous_protocol_state
~time_controller ~staged_ledger ~transactions ~get_completed_work ~logger
~(block_data : Consensus.Data.Block_data.t) ~winner_pk ~scheduled_time
~log_block_creation ~block_reward_threshold ~consensus_constants
~slot_tx_end ~slot_chain_end =
~log_block_creation ~block_reward_threshold ~consensus_constants =
let open Interruptible.Let_syntax in
let current_global_slot =
Consensus.Data.Consensus_time.(
to_global_slot
(of_time_exn ~constants:consensus_constants
(Block_time.now time_controller) ))
in
match slot_chain_end with
| Some slot_chain_end'
when Mina_numbers.Global_slot.(current_global_slot >= slot_chain_end') ->
match Mina_compile_config.slot_chain_end with
| Some slot_chain_end
when Mina_numbers.Global_slot.(current_global_slot >= slot_chain_end) ->
Interruptible.return None
| None | Some _ -> (
let previous_protocol_state_body_hash =
Expand Down Expand Up @@ -160,10 +159,10 @@ let generate_next_state ~constraint_constants ~previous_protocol_state
(of_time_exn ~constants:consensus_constants
(Block_time.now time_controller) ))
in
match slot_tx_end with
| Some slot_tx_end'
match Mina_compile_config.slot_tx_end with
| Some slot_tx_end
when Mina_numbers.Global_slot.(
current_global_slot >= slot_tx_end') ->
current_global_slot >= slot_tx_end) ->
Ok
Staged_ledger_diff.With_valid_signatures_and_proofs
.empty_diff
Expand Down Expand Up @@ -574,7 +573,7 @@ let run ~logger ~vrf_evaluator ~prover ~verifier ~trust_system
~consensus_local_state ~coinbase_receiver ~frontier_reader
~transition_writer ~set_next_producer_timing ~log_block_creation
~(precomputed_values : Precomputed_values.t) ~block_reward_threshold
~block_produced_bvar ~slot_tx_end ~slot_chain_end =
~block_produced_bvar =
O1trace.sync_thread "produce_blocks" (fun () ->
let constraint_constants = precomputed_values.constraint_constants in
let consensus_constants = precomputed_values.consensus_constants in
Expand Down Expand Up @@ -700,7 +699,6 @@ let run ~logger ~vrf_evaluator ~prover ~verifier ~trust_system
~staged_ledger:(Breadcrumb.staged_ledger crumb)
~transactions ~get_completed_work ~logger ~log_block_creation
~winner_pk ~block_reward_threshold ~consensus_constants
~slot_tx_end ~slot_chain_end
in
match next_state_opt with
| None ->
Expand Down
16 changes: 6 additions & 10 deletions src/lib/block_producer/test/block_producer_test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,6 @@ let%test_module "Block producer test" =

let block_produced_bvar = Bvar.create ()

let slot_tx_end = None

(* let max_frontier_length =
Transition_frontier.global_max_length Genesis_constants.compiled *)

Expand All @@ -183,7 +181,7 @@ let%test_module "Block producer test" =
~coinbase_receiver ~frontier_reader:frontier_broadcast_pipe_r
~transition_writer:producer_transition_writer
~set_next_producer_timing ~log_block_creation ~precomputed_values
~block_reward_threshold:None ~block_produced_bvar ~slot_tx_end
~block_reward_threshold:None ~block_produced_bvar

(* let gen_crumb =
Transition_frontier.Breadcrumb.For_tests.gen ~logger ~precomputed_values
Expand All @@ -195,13 +193,13 @@ let%test_module "Block producer test" =

(* let generate_next_state ~previous_protocol_state ~staged_ledger
~transactions ~get_completed_work ~block_data ~winner_pk
~scheduled_time ~block_reward_threshold ~slot_tx_end =
~scheduled_time ~block_reward_threshold =
Block_producer.generate_next_state ~constraint_constants
~previous_protocol_state ~time_controller ~staged_ledger ~transactions
~get_completed_work ~logger
~(block_data : Consensus.Data.Block_data.t)
~winner_pk ~scheduled_time ~log_block_creation ~block_reward_threshold
~slot_tx_end *)
*)

(* let gen_transition_frontier =
Transition_frontier.For_tests.gen ~logger ~verifier ~trust_system
Expand Down Expand Up @@ -233,7 +231,6 @@ let%test_module "Block producer test" =
let get_completed_work _ = None in
let scheduled_time = Block_time.now Test_setup.time_controller in
let block_reward_threshold = None in
let slot_tx_end = None in
let now = Block_time.now Test_setup.time_controller in
let consensus_state =
Transition_frontier.best_tip transition_frontier
Expand Down Expand Up @@ -315,8 +312,7 @@ let%test_module "Block producer test" =
precomputed_values:Genesis_proof.t ;
block_reward_threshold:Currency.Amount.t option ;
block_produced_bvar:(Frontier_base.Breadcrumb.t, [> Core.write ])
Async.Bvar.t ;
slot_tx_end:Mina_numbers.Global_slot.t option
Async.Bvar.t
}
Expand Down Expand Up @@ -367,7 +363,7 @@ let%test_module "Block producer test" =
~frontier_reader:frontier_broadcast_pipe_r
~transition_writer:producer_transition_writer ~set_next_producer_timing
~log_block_creation:false ~precomputed_values
~block_reward_threshold:None ~block_produced_bvar ~slot_tx_end *)
~block_reward_threshold:None ~block_produced_bvar *)
let%test_unit "generate_next_state with slot_tx_end not set" =
match Broadcast_pipe.Reader.peek frontier_reader with
Expand All @@ -386,7 +382,7 @@ let%test_module "Block producer test" =
~get_completed_work ~logger
~(block_data : Consensus.Data.Block_data.t)
~winner_pk ~scheduled_time ~log_block_creation ~block_reward_threshold
~consensus_constants ~slot_tx_end
~consensus_constants
in
() *)

Expand Down
6 changes: 3 additions & 3 deletions src/lib/ledger_catchup/ledger_catchup.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ module Best_tip_lru = Best_tip_lru

let run ~logger ~precomputed_values ~trust_system ~verifier ~network ~frontier
~catchup_job_reader ~catchup_breadcrumbs_writer
~unprocessed_transition_cache ~slot_tx_end : unit =
~unprocessed_transition_cache : unit =
match Transition_frontier.catchup_tree frontier with
| Hash _ ->
Normal_catchup.run ~logger ~precomputed_values ~trust_system ~verifier
~network ~frontier ~catchup_job_reader ~catchup_breadcrumbs_writer
~unprocessed_transition_cache ~slot_tx_end
~unprocessed_transition_cache
| Full _ ->
Super_catchup.run ~logger ~precomputed_values ~trust_system ~verifier
~network ~frontier ~catchup_job_reader ~catchup_breadcrumbs_writer
~unprocessed_transition_cache ~slot_tx_end
~unprocessed_transition_cache
1 change: 0 additions & 1 deletion src/lib/ledger_catchup/ledger_catchup.mli
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,4 @@ val run :
Strict_pipe.Writer.t
-> unprocessed_transition_cache:
Transition_handler.Unprocessed_transition_cache.t
-> slot_tx_end:Mina_numbers.Global_slot.t option
-> unit
33 changes: 14 additions & 19 deletions src/lib/ledger_catchup/normal_catchup.ml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ open Network_peer
the [Processor] via writing them to catchup_breadcrumbs_writer. *)

let verify_transition ~logger ~consensus_constants ~trust_system ~frontier
~unprocessed_transition_cache ~slot_tx_end enveloped_transition =
~unprocessed_transition_cache enveloped_transition =
let sender = Envelope.Incoming.sender enveloped_transition in
let genesis_state_hash = Transition_frontier.genesis_state_hash frontier in
let transition_with_hash = Envelope.Incoming.data enveloped_transition in
Expand All @@ -66,7 +66,7 @@ let verify_transition ~logger ~consensus_constants ~trust_system ~frontier
~f:(Fn.const initially_validated_transition)
in
Transition_handler.Validator.validate_transition ~logger ~frontier
~consensus_constants ~unprocessed_transition_cache ~slot_tx_end
~consensus_constants ~unprocessed_transition_cache
enveloped_initially_validated_transition
in
let open Deferred.Let_syntax in
Expand Down Expand Up @@ -467,7 +467,7 @@ let download_transitions ~target_hash ~logger ~trust_system ~network
let verify_transitions_and_build_breadcrumbs ~logger
~(precomputed_values : Precomputed_values.t) ~trust_system ~verifier
~frontier ~unprocessed_transition_cache ~transitions ~target_hash ~subtrees
~slot_tx_end =
=
let open Deferred.Or_error.Let_syntax in
let verification_start_time = Core.Time.now () in
let%bind transitions_with_initial_validation, initial_hash =
Expand Down Expand Up @@ -519,8 +519,7 @@ let verify_transitions_and_build_breadcrumbs ~logger
match%bind
verify_transition ~logger
~consensus_constants:precomputed_values.consensus_constants
~trust_system ~frontier ~unprocessed_transition_cache ~slot_tx_end
transition
~trust_system ~frontier ~unprocessed_transition_cache transition
with
| Error e ->
List.iter acc ~f:(fun (node, vc) ->
Expand Down Expand Up @@ -622,7 +621,7 @@ let garbage_collect_subtrees ~logger ~subtrees =

let run ~logger ~precomputed_values ~trust_system ~verifier ~network ~frontier
~catchup_job_reader ~catchup_breadcrumbs_writer
~unprocessed_transition_cache ~slot_tx_end : unit =
~unprocessed_transition_cache : unit =
let hash_tree =
match Transition_frontier.catchup_tree frontier with
| Hash t ->
Expand Down Expand Up @@ -790,7 +789,7 @@ let run ~logger ~precomputed_values ~trust_system ~verifier ~network ~frontier
verify_transitions_and_build_breadcrumbs ~logger
~precomputed_values ~trust_system ~verifier ~frontier
~unprocessed_transition_cache ~transitions ~target_hash
~subtrees ~slot_tx_end
~subtrees
with
| Ok trees_of_breadcrumbs ->
[%log trace]
Expand Down Expand Up @@ -904,7 +903,7 @@ let%test_module "Ledger_catchup tests" =
Strict_pipe.Reader.t
}

let run_catchup ~network ~frontier ~slot_tx_end =
let run_catchup ~network ~frontier =
let catchup_job_reader, catchup_job_writer =
Strict_pipe.create ~name:(__MODULE__ ^ __LOC__)
(Buffered (`Capacity 10, `Overflow Crash))
Expand All @@ -918,15 +917,14 @@ let%test_module "Ledger_catchup tests" =
in
run ~logger ~precomputed_values ~verifier ~trust_system ~network ~frontier
~catchup_breadcrumbs_writer ~catchup_job_reader
~unprocessed_transition_cache ~slot_tx_end ;
~unprocessed_transition_cache ;
{ cache = unprocessed_transition_cache
; job_writer = catchup_job_writer
; breadcrumbs_reader = catchup_breadcrumbs_reader
}

let run_catchup_with_target ~network ~frontier ~target_breadcrumb
~slot_tx_end =
let test = run_catchup ~network ~frontier ~slot_tx_end in
let run_catchup_with_target ~network ~frontier ~target_breadcrumb =
let test = run_catchup ~network ~frontier in
let parent_hash =
Transition_frontier.Breadcrumb.parent_hash target_breadcrumb
in
Expand All @@ -938,12 +936,12 @@ let%test_module "Ledger_catchup tests" =
(parent_hash, [ Rose_tree.T ((target_transition, None), []) ]) ;
(`Test test, `Cached_transition target_transition)

let test_successful_catchup ~my_net ~target_best_tip_path ~slot_tx_end =
let test_successful_catchup ~my_net ~target_best_tip_path =
let open Fake_network in
let target_breadcrumb = List.last_exn target_best_tip_path in
let `Test { breadcrumbs_reader; _ }, _ =
run_catchup_with_target ~network:my_net.network
~frontier:my_net.state.frontier ~target_breadcrumb ~slot_tx_end
~frontier:my_net.state.frontier ~target_breadcrumb
in
(* TODO: expose Strict_pipe.read *)
let%map cached_catchup_breadcrumbs =
Expand Down Expand Up @@ -1003,8 +1001,7 @@ let%test_module "Ledger_catchup tests" =
(best_tip peer_net.state.frontier))
in
Thread_safe.block_on_async_exn (fun () ->
test_successful_catchup ~my_net ~target_best_tip_path
~slot_tx_end:None ) )
test_successful_catchup ~my_net ~target_best_tip_path ) )

let%test_unit "catchup succeeds even if the parent transition is already \
in the frontier" =
Expand All @@ -1020,8 +1017,7 @@ let%test_module "Ledger_catchup tests" =
[ Transition_frontier.best_tip peer_net.state.frontier ]
in
Thread_safe.block_on_async_exn (fun () ->
test_successful_catchup ~my_net ~target_best_tip_path
~slot_tx_end:None ) )
test_successful_catchup ~my_net ~target_best_tip_path ) )

let%test_unit "catchup fails if one of the parent transitions fail" =
Quickcheck.test ~trials:1
Expand Down Expand Up @@ -1056,7 +1052,6 @@ let%test_module "Ledger_catchup tests" =
let `Test { cache; _ }, `Cached_transition cached_transition =
run_catchup_with_target ~network:my_net.network
~frontier:my_net.state.frontier ~target_breadcrumb
~slot_tx_end:None
in
let cached_failing_transition =
Transition_handler.Unprocessed_transition_cache.register_exn
Expand Down
Loading

0 comments on commit bde4359

Please sign in to comment.