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

Make compile-time genesis proof creation optional #8497

Merged
merged 4 commits into from
Apr 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions src/app/cli/src/cli_entrypoint/mina_cli_entrypoint.ml
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,11 @@ let setup_daemon logger =
and may_generate =
flag "--generate-genesis-proof" ~aliases:["generate-genesis-proof"]
~doc:
"true|false Generate a new genesis proof for the current \
configuration if none is found (default: false)"
(sprintf
"true|false Generate a new genesis proof for the current \
configuration if none is found (default: %s)"
( if Mina_compile_config.generate_genesis_proof then "false"
else "true" ))
(optional bool)
and disable_node_status =
flag "--disable-node-status" ~aliases:["disable-node-status"] no_arg
Expand Down Expand Up @@ -499,7 +502,13 @@ let setup_daemon logger =
let time_controller =
Block_time.Controller.create @@ Block_time.Controller.basic ~logger
in
let may_generate = Option.value ~default:false may_generate in
let may_generate =
(* Default is [true] if there is no compile-time genesis proof to fall
back on, or [false] otherwise.
*)
Option.value may_generate
~default:(not Mina_compile_config.generate_genesis_proof)
in
(* FIXME adapt to new system, move into child_processes lib *)
let pids = Child_processes.Termination.create_pid_table () in
let rec terminated_child_loop () =
Expand Down
2 changes: 1 addition & 1 deletion src/app/cli/src/init/transaction_snark_profiler.ml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ let rec pair_up = function
| _ ->
failwith "Expected even length list"

let precomputed_values = Precomputed_values.compiled
let precomputed_values = Precomputed_values.compiled_inputs

let state_body =
Mina_state.(
Expand Down
4 changes: 2 additions & 2 deletions src/app/cli/src/tests/coda_archive_processor_test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ let main () =
let postgres_address =
Uri.of_string "postgres://admin:codarules@localhost:5432/archiver"
in
let precomputed_values = Lazy.force Precomputed_values.compiled in
let precomputed_values = Lazy.force Precomputed_values.compiled_inputs in
let constraint_constants = precomputed_values.constraint_constants in
let%bind conn =
match%map Caqti_async.connect postgres_address with
Expand All @@ -26,7 +26,7 @@ let main () =
(Some (Lazy.force Runtime_config.Test_configs.transactions))
|> don't_wait_for ;
let public_key =
Precomputed_values.largest_account_pk_exn precomputed_values
Genesis_proof.Inputs.largest_account_pk_exn precomputed_values
in
let n = 2 in
let block_production_keys i = if i = 0 then Some i else None in
Expand Down
3 changes: 1 addition & 2 deletions src/app/cli/src/tests/coda_block_production_test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ let runtime_config = Runtime_config.Test_configs.split_snarkless
let main () =
let logger = Logger.create () in
let%bind precomputed_values, _runtime_config =
Genesis_ledger_helper.init_from_config_file ~logger ~may_generate:false
~proof_level:None
Genesis_ledger_helper.inputs_from_config_file ~logger ~proof_level:None
(Lazy.force runtime_config)
>>| Or_error.ok_exn
in
Expand Down
5 changes: 2 additions & 3 deletions src/app/cli/src/tests/coda_bootstrap_test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,15 @@ let runtime_config = Runtime_config.Test_configs.bootstrap
let main () =
let logger = Logger.create () in
let%bind precomputed_values, _runtime_config =
Genesis_ledger_helper.init_from_config_file ~logger ~may_generate:false
~proof_level:None
Genesis_ledger_helper.inputs_from_config_file ~logger ~proof_level:None
(Lazy.force runtime_config)
>>| Or_error.ok_exn
in
let n = 2 in
let block_production_keys i = Some i in
let snark_work_public_keys i =
if i = 0 then
Some (Precomputed_values.largest_account_pk_exn precomputed_values)
Some (Genesis_proof.Inputs.largest_account_pk_exn precomputed_values)
else None
in
let%bind testnet =
Expand Down
7 changes: 3 additions & 4 deletions src/app/cli/src/tests/coda_change_snark_worker_test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,12 @@ let main () =
if i = snark_worker_and_block_producer_id then Some i else None
in
let%bind precomputed_values, _runtime_config =
Genesis_ledger_helper.init_from_config_file ~logger ~may_generate:false
~proof_level:None
Genesis_ledger_helper.inputs_from_config_file ~logger ~proof_level:None
(Lazy.force runtime_config)
>>| Or_error.ok_exn
in
let largest_public_key =
Precomputed_values.largest_account_pk_exn precomputed_values
Genesis_proof.Inputs.largest_account_pk_exn precomputed_values
in
let snark_work_public_keys i =
if i = snark_worker_and_block_producer_id then Some largest_public_key
Expand Down Expand Up @@ -70,7 +69,7 @@ let main () =
wait_for_snark_worker_proof new_block_pipe1 largest_public_key
in
let new_snark_worker =
Precomputed_values.find_new_account_record_exn_ precomputed_values
Genesis_proof.Inputs.find_new_account_record_exn_ precomputed_values
[largest_public_key]
|> Precomputed_values.pk_of_account_record
in
Expand Down
9 changes: 5 additions & 4 deletions src/app/cli/src/tests/coda_delegation_test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ let runtime_config = Runtime_config.Test_configs.delegation
let main () =
let logger = Logger.create () in
let%bind precomputed_values, _runtime_config =
Genesis_ledger_helper.init_from_config_file ~logger ~may_generate:false
~proof_level:None
Genesis_ledger_helper.inputs_from_config_file ~logger ~proof_level:None
(Lazy.force runtime_config)
>>| Or_error.ok_exn
in
let num_block_producers = 3 in
let accounts = Lazy.force (Precomputed_values.accounts precomputed_values) in
let accounts =
Lazy.force (Genesis_proof.Inputs.accounts precomputed_values)
in
let snark_work_public_keys ndx =
List.nth_exn accounts ndx
|> fun (_, acct) -> Some (Account.public_key acct)
Expand Down Expand Up @@ -53,7 +54,7 @@ let main () =
let ((_, delegator_account) as delegator) = List.nth_exn accounts 2 in
let delegator_pubkey = Account.public_key delegator_account in
let delegator_keypair =
Precomputed_values.keypair_of_account_record_exn delegator
Genesis_proof.Inputs.keypair_of_account_record_exn delegator
in
(* zeroth account is delegatee *)
let _, delegatee_account = List.nth_exn accounts 0 in
Expand Down
4 changes: 2 additions & 2 deletions src/app/cli/src/tests/coda_five_nodes_test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ let name = "coda-five-nodes-test"

let main () =
let logger = Logger.create () in
let precomputed_values = Lazy.force Precomputed_values.compiled in
let precomputed_values = Lazy.force Precomputed_values.compiled_inputs in
let n = 5 in
let snark_work_public_keys = function
| 0 ->
Some
( List.nth_exn
(Lazy.force (Precomputed_values.accounts precomputed_values))
(Lazy.force (Genesis_proof.Inputs.accounts precomputed_values))
5
|> snd |> Account.public_key )
| _ ->
Expand Down
6 changes: 3 additions & 3 deletions src/app/cli/src/tests/coda_long_fork.ml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ let name = "coda-long-fork"
let main n waiting_time () =
let precomputed_values =
(* TODO: Load for this specific test. *)
Lazy.force Precomputed_values.compiled
Lazy.force Precomputed_values.compiled_inputs
in
let consensus_constants = precomputed_values.consensus_constants in
let logger = Logger.create () in
let public_keys =
List.map
(Lazy.force (Precomputed_values.accounts precomputed_values))
~f:Precomputed_values.pk_of_account_record
(Lazy.force (Genesis_proof.Inputs.accounts precomputed_values))
~f:Genesis_proof.Inputs.pk_of_account_record
in
let snark_work_public_keys i = Some (List.nth_exn public_keys i) in
let%bind testnet =
Expand Down
3 changes: 1 addition & 2 deletions src/app/cli/src/tests/coda_peers_test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ let runtime_config = Runtime_config.Test_configs.split_snarkless
let main () =
let logger = Logger.create () in
let%bind precomputed_values, _runtime_config =
Genesis_ledger_helper.init_from_config_file ~logger ~may_generate:false
~proof_level:None
Genesis_ledger_helper.inputs_from_config_file ~logger ~proof_level:None
(Lazy.force runtime_config)
>>| Or_error.ok_exn
in
Expand Down
2 changes: 1 addition & 1 deletion src/app/cli/src/tests/coda_processes.ml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ let local_configs ?block_production_interval
| Some timestamp ->
Genesis_constants.genesis_timestamp_of_string timestamp
| None ->
(Lazy.force Precomputed_values.compiled).consensus_constants
(Lazy.force Precomputed_values.compiled_inputs).consensus_constants
.genesis_state_timestamp |> Block_time.to_time
in
Core.Time.(diff (now ())) genesis_state_timestamp
Expand Down
4 changes: 2 additions & 2 deletions src/app/cli/src/tests/coda_restart_node_test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ include Heartbeat.Make ()

let main () =
let logger = Logger.create () in
let precomputed_values = Lazy.force Precomputed_values.compiled in
let precomputed_values = Lazy.force Precomputed_values.compiled_inputs in
let largest_account_pk =
Precomputed_values.largest_account_pk_exn precomputed_values
Genesis_proof.Inputs.largest_account_pk_exn precomputed_values
in
Deferred.don't_wait_for (print_heartbeat logger) ;
let n = 2 in
Expand Down
8 changes: 5 additions & 3 deletions src/app/cli/src/tests/coda_restarts_and_txns_holy_grail.ml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ let main n () =
let wait_time = Time.Span.of_min 2. in
assert (n > 1) ;
let logger = Logger.create () in
let precomputed_values = Lazy.force Precomputed_values.compiled in
let accounts = Lazy.force (Precomputed_values.accounts precomputed_values) in
let precomputed_values = Lazy.force Precomputed_values.compiled_inputs in
let accounts =
Lazy.force (Genesis_proof.Inputs.accounts precomputed_values)
in
let snark_work_public_keys =
Fn.const @@ Some (List.nth_exn accounts 5 |> snd |> Account.public_key)
in
Expand All @@ -21,7 +23,7 @@ let main n () =
in
(* SEND TXNS *)
let keypairs =
List.map accounts ~f:Precomputed_values.keypair_of_account_record_exn
List.map accounts ~f:Genesis_proof.Inputs.keypair_of_account_record_exn
in
let random_block_producer () = Random.int 2 + 1 in
let random_non_block_producer () = Random.int 2 + 3 in
Expand Down
10 changes: 5 additions & 5 deletions src/app/cli/src/tests/coda_shared_prefix_multiproducer_test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ let name = "coda-shared-prefix-multiproducer-test"

let main n enable_payments () =
let logger = Logger.create () in
let precomputed_values = Lazy.force Precomputed_values.compiled in
let precomputed_values = Lazy.force Precomputed_values.compiled_inputs in
let keypairs =
List.map
(Lazy.force (Precomputed_values.accounts precomputed_values))
~f:Precomputed_values.keypair_of_account_record_exn
(Lazy.force (Genesis_proof.Inputs.accounts precomputed_values))
~f:Genesis_proof.Inputs.keypair_of_account_record_exn
in
let public_keys =
List.map ~f:Precomputed_values.pk_of_account_record
(Lazy.force (Precomputed_values.accounts precomputed_values))
List.map ~f:Genesis_proof.Inputs.pk_of_account_record
(Lazy.force (Genesis_proof.Inputs.accounts precomputed_values))
in
let snark_work_public_keys i = Some (List.nth_exn public_keys i) in
let%bind testnet =
Expand Down
3 changes: 1 addition & 2 deletions src/app/cli/src/tests/coda_shared_prefix_test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ let runtime_config = Runtime_config.Test_configs.split_snarkless
let main who_produces () =
let logger = Logger.create () in
let%bind precomputed_values, _runtime_config =
Genesis_ledger_helper.init_from_config_file ~logger ~may_generate:false
~proof_level:None
Genesis_ledger_helper.inputs_from_config_file ~logger ~proof_level:None
(Lazy.force runtime_config)
>>| Or_error.ok_exn
in
Expand Down
11 changes: 5 additions & 6 deletions src/app/cli/src/tests/coda_shared_state_test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,20 @@ let runtime_config = Runtime_config.Test_configs.transactions
let main () =
let logger = Logger.create () in
let%bind precomputed_values, _runtime_config =
Genesis_ledger_helper.init_from_config_file ~logger ~may_generate:false
~proof_level:None
Genesis_ledger_helper.inputs_from_config_file ~logger ~proof_level:None
(Lazy.force runtime_config)
>>| Or_error.ok_exn
in
(* keep CI alive *)
let n = 2 in
let keypairs =
List.map
(Lazy.force (Precomputed_values.accounts precomputed_values))
~f:Precomputed_values.keypair_of_account_record_exn
(Lazy.force (Genesis_proof.Inputs.accounts precomputed_values))
~f:Genesis_proof.Inputs.keypair_of_account_record_exn
in
let public_keys =
List.map ~f:Precomputed_values.pk_of_account_record
(Lazy.force (Precomputed_values.accounts precomputed_values))
List.map ~f:Genesis_proof.Inputs.pk_of_account_record
(Lazy.force (Genesis_proof.Inputs.accounts precomputed_values))
in
let snark_work_public_keys i = Some (List.nth_exn public_keys i) in
let%bind testnet =
Expand Down
3 changes: 1 addition & 2 deletions src/app/cli/src/tests/coda_transitive_peers_test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ let runtime_config = Runtime_config.Test_configs.split_snarkless
let main () =
let logger = Logger.create () in
let%bind precomputed_values, _runtime_config =
Genesis_ledger_helper.init_from_config_file ~logger ~may_generate:false
~proof_level:None
Genesis_ledger_helper.inputs_from_config_file ~logger ~proof_level:None
(Lazy.force runtime_config)
>>| Or_error.ok_exn
in
Expand Down
8 changes: 5 additions & 3 deletions src/app/cli/src/tests/coda_txns_and_restart_non_producers.ml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ let name = "coda-txns-and-restart-non-producers"
let main () =
let wait_time = Time.Span.of_min 2. in
let logger = Logger.create () in
let precomputed_values = Lazy.force Precomputed_values.compiled in
let accounts = Lazy.force (Precomputed_values.accounts precomputed_values) in
let precomputed_values = Lazy.force Precomputed_values.compiled_inputs in
let accounts =
Lazy.force (Genesis_proof.Inputs.accounts precomputed_values)
in
let snark_work_public_keys =
Fn.const @@ Some (List.nth_exn accounts 5 |> snd |> Account.public_key)
in
Expand All @@ -20,7 +22,7 @@ let main () =
in
(* send txns *)
let keypairs =
List.map accounts ~f:Precomputed_values.keypair_of_account_record_exn
List.map accounts ~f:Genesis_proof.Inputs.keypair_of_account_record_exn
in
let%bind () = after wait_time in
Coda_worker_testnet.Payments.send_several_payments testnet ~node:0 ~keypairs
Expand Down
2 changes: 1 addition & 1 deletion src/app/cli/src/tests/coda_worker.ml
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ module T = struct
()
in
let%bind precomputed_values, _runtime_config =
Genesis_ledger_helper.init_from_config_file ~logger ~may_generate:false
Genesis_ledger_helper.init_from_config_file ~logger ~may_generate:true
~proof_level:None runtime_config
>>| Or_error.ok_exn
in
Expand Down
8 changes: 5 additions & 3 deletions src/app/cli/src/tests/coda_worker_testnet.ml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module Api = struct
so eventually the counter _must_ become 0, ensuring progress. *)
; root_lengths: int Array.t
; restart_signals: (restart_type * unit Ivar.t) Option.t Array.t
; precomputed_values: Precomputed_values.t }
; precomputed_values: Genesis_proof.Inputs.t }

let create ~precomputed_values configs workers start_writer =
let status =
Expand Down Expand Up @@ -392,7 +392,8 @@ let start_payment_check logger root_pipe (testnet : Api.t) =
| _ ->
Deferred.unit ) ))

let events ~(precomputed_values : Precomputed_values.t) workers start_reader =
let events ~(precomputed_values : Genesis_proof.Inputs.t) workers start_reader
=
let event_r, event_w = Linear_pipe.create () in
let root_r, root_w = Linear_pipe.create () in
let connect_worker i worker =
Expand Down Expand Up @@ -458,7 +459,8 @@ let start_checks logger (workers : Coda_process.t array) start_reader
* change network connectivity *)
let test ?archive_process_location ?is_archive_rocksdb ~name logger n
block_production_keys snark_work_public_keys work_selection_method
~max_concurrent_connections ~(precomputed_values : Precomputed_values.t) =
~max_concurrent_connections ~(precomputed_values : Genesis_proof.Inputs.t)
=
let logger = Logger.extend logger [("worker_testnet", `Bool true)] in
let block_production_interval =
precomputed_values.constraint_constants.block_window_duration_ms
Expand Down
7 changes: 6 additions & 1 deletion src/app/cli/src/tests/full_test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ let print_heartbeat logger =

let run_test () : unit Deferred.t =
let logger = Logger.create () in
let precomputed_values = Lazy.force Precomputed_values.compiled in
let precomputed_values = Lazy.force Precomputed_values.compiled_inputs in
let constraint_constants = precomputed_values.constraint_constants in
let (module Genesis_ledger) = precomputed_values.genesis_ledger in
let pids = Child_processes.Termination.create_pid_table () in
Expand Down Expand Up @@ -183,6 +183,11 @@ let run_test () : unit Deferred.t =
if with_snark then (fee 0, fee 0) else (fee 100, fee 200)
in
let start_time = Time.now () in
let%bind precomputed_values =
Deferred.Or_error.ok_exn
@@ Genesis_ledger_helper.init_from_inputs ~logger ~may_generate:true
precomputed_values
in
let%bind coda =
Mina_lib.create
(Mina_lib.Config.make ~logger ~pids ~trust_system ~net_config
Expand Down
1 change: 1 addition & 0 deletions src/config/debug.mlh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
[%%define force_updates false]

[%%define download_snark_keys false]
[%%define generate_genesis_proof false]

[%%define print_versioned_types false]

Expand Down
1 change: 1 addition & 0 deletions src/config/dev.mlh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
[%%define force_updates false]

[%%define download_snark_keys false]
[%%define generate_genesis_proof false]

[%%define print_versioned_types false]

Expand Down
1 change: 1 addition & 0 deletions src/config/dev_medium_curves.mlh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
[%%define force_updates false]

[%%define download_snark_keys false]
[%%define generate_genesis_proof false]

[%%define print_versioned_types false]

Expand Down
Loading