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

All config is runtime config #16070

Draft
wants to merge 29 commits into
base: compatible
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
10add49
delete node config values where possible
martyall Sep 17, 2024
d50c0e8
update genesis_constants and compile_config
martyall Sep 17, 2024
43983fd
add all config to runtime config. Remove the config semigroup methods…
martyall Sep 17, 2024
9e5ef93
update logic for loading in config file from json
martyall Sep 18, 2024
6525567
remove runtime_config from precomputed values, add runtime_config to …
martyall Sep 18, 2024
44678f9
access slot_tx_end and slot_chain_end through compile_config
martyall Sep 18, 2024
4f957c3
fix module typos. add print_config back in
martyall Sep 18, 2024
62bc882
add config_file to cli_lib flags
martyall Sep 18, 2024
8c316a0
access slot_tx_end through compile_config
martyall Sep 18, 2024
1d5d632
load in config for snark-worker
martyall Sep 18, 2024
0cbd700
integratin test libs
martyall Sep 18, 2024
d8350bd
formatting
martyall Sep 18, 2024
e7e4710
zkapp_limits
martyall Sep 18, 2024
8718312
runtime_genesis_ledger
martyall Sep 18, 2024
fdb8660
ledger_export_benchmark
martyall Sep 18, 2024
334519a
archive_blocks
martyall Sep 18, 2024
294b16f
archive
martyall Sep 18, 2024
6d96471
snark_work_debugger
martyall Sep 18, 2024
2a73d07
delegation_verify
martyall Sep 18, 2024
c835473
replayer
martyall Sep 18, 2024
2260581
zkapp_test_transation
martyall Sep 18, 2024
d200561
cli args cannot be dependent on config values
martyall Sep 18, 2024
110c998
src/app/cli
martyall Sep 18, 2024
500ac20
heap_usage
martyall Sep 18, 2024
a01eeb2
rosetta
martyall Sep 18, 2024
60e62ef
break up config loading into json-file-reading+pure-transformations a…
martyall Sep 19, 2024
ac144dd
disk_caching_stats
martyall Sep 19, 2024
5f2da17
mina_cli_entrypoint
martyall Sep 19, 2024
6265665
rework test executive config for sanity sake
martyall Sep 19, 2024
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
26 changes: 13 additions & 13 deletions src/app/archive/cli/archive_cli.ml
Original file line number Diff line number Diff line change
Expand Up @@ -28,36 +28,36 @@ let command_run =
Archive_lib.Metrics.default_missing_blocks_width )
(optional int)
and postgres = Flag.Uri.Archive.postgres
and runtime_config_file =
flag "--config-file" ~aliases:[ "-config-file" ] (optional string)
~doc:"PATH to the configuration file containing the genesis ledger"
and delete_older_than =
flag "--delete-older-than" ~aliases:[ "-delete-older-than" ]
(optional int)
~doc:
"int Delete blocks that are more than n blocks lower than the \
maximum seen block."
in
let runtime_config_opt =
Option.map runtime_config_file ~f:(fun file ->
Yojson.Safe.from_file file |> Runtime_config.of_yojson
|> Result.ok_or_failwith )
and config_file = Cli_lib.Flag.conf_file
and add_genesis_accounts_opt =
Command.Param.flag "--add-genesis-accounts"
~doc:"add genesis accounts to the db" Command.Param.no_arg
in
fun () ->
let logger = Logger.create () in
let genesis_constants = Genesis_constants.Compiled.genesis_constants in
let constraint_constants =
Genesis_constants.Compiled.constraint_constants
let open Deferred.Let_syntax in
let%bind precomputed_values, _ =
let%bind config =
Runtime_config.Config_loader.load_config_exn ~config_file ()
in
Deferred.Or_error.ok_exn
@@ Genesis_ledger_helper.Config_initializer.initialize ~logger config
in
Stdout_log.setup log_json log_level ;
[%log info] "Starting archive process; built with commit $commit"
~metadata:[ ("commit", `String Mina_version.commit_id) ] ;
Archive_lib.Processor.setup_server ~metrics_server_port ~logger
~genesis_constants ~constraint_constants
~postgres_address:postgres.value
~server_port:
(Option.value server_port.value ~default:server_port.default)
~delete_older_than ~runtime_config_opt ~missing_blocks_width )
~delete_older_than ~missing_blocks_width ~precomputed_values
~add_genesis_accounts_opt )

let time_arg =
(* Same timezone as Genesis_constants.genesis_state_timestamp. *)
Expand Down
219 changes: 99 additions & 120 deletions src/app/archive/lib/processor.ml
Original file line number Diff line number Diff line change
Expand Up @@ -4728,123 +4728,100 @@ let run pool reader ~genesis_constants ~constraint_constants ~logger
Deferred.unit )

(* [add_genesis_accounts] is called when starting the archive process *)
let add_genesis_accounts ~logger ~(runtime_config_opt : Runtime_config.t option)
~(genesis_constants : Genesis_constants.t)
~(constraint_constants : Genesis_constants.Constraint_constants.t) pool =
match runtime_config_opt with
| None ->
Deferred.unit
| Some runtime_config -> (
let%bind precomputed_values =
match%map
Genesis_ledger_helper.init_from_config_file ~logger ~proof_level:None
~genesis_constants ~constraint_constants runtime_config
~cli_proof_level:None
with
| Ok (precomputed_values, _) ->
precomputed_values
| Error err ->
failwithf "Could not get precomputed values, error: %s"
(Error.to_string_hum err) ()
in
let ledger =
Precomputed_values.genesis_ledger precomputed_values |> Lazy.force
in
let%bind account_ids =
let%map account_id_set = Mina_ledger.Ledger.accounts ledger in
Account_id.Set.to_list account_id_set
in
let genesis_block =
let With_hash.{ data = block; hash = the_hash }, _ =
Mina_block.genesis ~precomputed_values
let add_genesis_accounts ~logger ~(precomputed_values : Genesis_proof.t) pool =
let ledger =
Precomputed_values.genesis_ledger precomputed_values |> Lazy.force
in
let%bind account_ids =
let%map account_id_set = Mina_ledger.Ledger.accounts ledger in
Account_id.Set.to_list account_id_set
in
let genesis_block =
let With_hash.{ data = block; hash = the_hash }, _ =
Mina_block.genesis ~precomputed_values
in
With_hash.{ data = block; hash = the_hash }
in
let add_accounts () =
Caqti_async.Pool.use
(fun (module Conn : CONNECTION) ->
let%bind.Deferred.Result genesis_block_id =
Block.add_if_doesn't_exist
(module Conn)
~constraint_constants:precomputed_values.constraint_constants
genesis_block
in
With_hash.{ data = block; hash = the_hash }
in
let add_accounts () =
Caqti_async.Pool.use
(fun (module Conn : CONNECTION) ->
let%bind.Deferred.Result genesis_block_id =
Block.add_if_doesn't_exist
(module Conn)
~constraint_constants genesis_block
in
let%bind.Deferred.Result { ledger_hash; _ } =
Block.load (module Conn) ~id:genesis_block_id
in
let db_ledger_hash = Ledger_hash.of_base58_check_exn ledger_hash in
let actual_ledger_hash = Mina_ledger.Ledger.merkle_root ledger in
if Ledger_hash.equal db_ledger_hash actual_ledger_hash then
[%log info]
"Archived genesis block ledger hash equals actual genesis \
ledger hash"
~metadata:
[ ("ledger_hash", Ledger_hash.to_yojson actual_ledger_hash) ]
else (
[%log error]
"Archived genesis block ledger hash different than actual \
genesis ledger hash"
~metadata:
[ ( "archived_ledger_hash"
, Ledger_hash.to_yojson db_ledger_hash )
; ( "actual_ledger_hash"
, Ledger_hash.to_yojson actual_ledger_hash )
] ;
exit 1 ) ;
let%bind.Deferred.Result () = Conn.start () in
let open Deferred.Let_syntax in
let%bind () =
Deferred.List.iter account_ids ~f:(fun acct_id ->
match
Mina_ledger.Ledger.location_of_account ledger acct_id
let%bind.Deferred.Result { ledger_hash; _ } =
Block.load (module Conn) ~id:genesis_block_id
in
let db_ledger_hash = Ledger_hash.of_base58_check_exn ledger_hash in
let actual_ledger_hash = Mina_ledger.Ledger.merkle_root ledger in
if Ledger_hash.equal db_ledger_hash actual_ledger_hash then
[%log info]
"Archived genesis block ledger hash equals actual genesis ledger \
hash"
~metadata:
[ ("ledger_hash", Ledger_hash.to_yojson actual_ledger_hash) ]
else (
[%log error]
"Archived genesis block ledger hash different than actual genesis \
ledger hash"
~metadata:
[ ("archived_ledger_hash", Ledger_hash.to_yojson db_ledger_hash)
; ("actual_ledger_hash", Ledger_hash.to_yojson actual_ledger_hash)
] ;
exit 1 ) ;
let%bind.Deferred.Result () = Conn.start () in
let open Deferred.Let_syntax in
let%bind () =
Deferred.List.iter account_ids ~f:(fun acct_id ->
match Mina_ledger.Ledger.location_of_account ledger acct_id with
| None ->
[%log error] "Could not get location for account"
~metadata:[ ("account_id", Account_id.to_yojson acct_id) ] ;
failwith "Could not get location for genesis account"
| Some loc -> (
let index =
Mina_ledger.Ledger.index_of_account_exn ledger acct_id
in
let acct =
match Mina_ledger.Ledger.get ledger loc with
| None ->
[%log error] "Could not get account, given a location"
~metadata:
[ ("account_id", Account_id.to_yojson acct_id) ] ;
failwith
"Could not get genesis account, given a location"
| Some acct ->
acct
in
match%bind
Accounts_accessed.add_if_doesn't_exist
(module Conn)
genesis_block_id (index, acct)
with
| None ->
[%log error] "Could not get location for account"
| Ok _ ->
return ()
| Error err ->
[%log error] "Could not add genesis account"
~metadata:
[ ("account_id", Account_id.to_yojson acct_id) ] ;
failwith "Could not get location for genesis account"
| Some loc -> (
let index =
Mina_ledger.Ledger.index_of_account_exn ledger acct_id
in
let acct =
match Mina_ledger.Ledger.get ledger loc with
| None ->
[%log error]
"Could not get account, given a location"
~metadata:
[ ("account_id", Account_id.to_yojson acct_id) ] ;
failwith
"Could not get genesis account, given a location"
| Some acct ->
acct
in
match%bind
Accounts_accessed.add_if_doesn't_exist
(module Conn)
genesis_block_id (index, acct)
with
| Ok _ ->
return ()
| Error err ->
[%log error] "Could not add genesis account"
~metadata:
[ ("account_id", Account_id.to_yojson acct_id)
; ("error", `String (Caqti_error.show err))
] ;
failwith "Could not add add genesis account" ) )
in
Conn.commit () )
pool
in
match%map
retry ~f:add_accounts ~logger ~error_str:"add_genesis_accounts" 3
with
| Error e ->
[%log warn] "genesis accounts could not be added"
~metadata:[ ("error", `String (Caqti_error.show e)) ] ;
failwith "Failed to add genesis accounts"
| Ok () ->
() )
[ ("account_id", Account_id.to_yojson acct_id)
; ("error", `String (Caqti_error.show err))
] ;
failwith "Could not add add genesis account" ) )
in
Conn.commit () )
pool
in
match%map
retry ~f:add_accounts ~logger ~error_str:"add_genesis_accounts" 3
with
| Error e ->
[%log warn] "genesis accounts could not be added"
~metadata:[ ("error", `String (Caqti_error.show e)) ] ;
failwith "Failed to add genesis accounts"
| Ok () ->
()

let create_metrics_server ~logger ~metrics_server_port ~missing_blocks_width
~block_window_duration_ms pool =
Expand All @@ -4870,10 +4847,11 @@ let create_metrics_server ~logger ~metrics_server_port ~missing_blocks_width
go ()

(* for running the archive process *)
let setup_server ~(genesis_constants : Genesis_constants.t)
~(constraint_constants : Genesis_constants.Constraint_constants.t)
~metrics_server_port ~logger ~postgres_address ~server_port
~delete_older_than ~runtime_config_opt ~missing_blocks_width =
let setup_server ~metrics_server_port ~logger ~postgres_address ~server_port
~delete_older_than ~(precomputed_values : Genesis_proof.t)
~missing_blocks_width ~add_genesis_accounts_opt =
let genesis_constants = precomputed_values.genesis_constants in
let constraint_constants = precomputed_values.constraint_constants in
let where_to_listen =
Async.Tcp.Where_to_listen.bind_to All_addresses (On_port server_port)
in
Expand Down Expand Up @@ -4903,8 +4881,9 @@ let setup_server ~(genesis_constants : Genesis_constants.t)
Deferred.unit
| Ok pool ->
let%bind () =
add_genesis_accounts pool ~logger ~genesis_constants
~constraint_constants ~runtime_config_opt
if add_genesis_accounts_opt then
add_genesis_accounts pool ~logger ~precomputed_values
else Deferred.unit
in
run ~constraint_constants ~genesis_constants pool reader ~logger
~delete_older_than
Expand Down
18 changes: 10 additions & 8 deletions src/app/archive_blocks/archive_blocks.ml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@ open Core_kernel
open Async
open Archive_lib

let main ~genesis_constants ~constraint_constants ~archive_uri ~precomputed
~extensional ~success_file ~failure_file ~log_successes ~files () =
let main ~config_file ~archive_uri ~precomputed ~extensional ~success_file
~failure_file ~log_successes ~files () =
let%bind config =
Runtime_config.Config_loader.load_config_exn ~config_file ()
in
let genesis_constants = config.genesis_constants in
let constraint_constants = config.constraint_config.constraint_constants in
let output_file_line path =
match path with
| Some path ->
Expand Down Expand Up @@ -99,10 +104,6 @@ let main ~genesis_constants ~constraint_constants ~archive_uri ~precomputed

let () =
Command.(
let genesis_constants = Genesis_constants.Compiled.genesis_constants in
let constraint_constants =
Genesis_constants.Compiled.constraint_constants
in
run
(let open Let_syntax in
async ~summary:"Write blocks to an archive database"
Expand Down Expand Up @@ -133,6 +134,7 @@ let () =
"true/false Whether to log messages for files that were \
processed successfully"
(Flag.optional_with_default true Param.bool)
and config_file = Cli_lib.Flag.conf_file
and files = Param.anon Anons.(sequence ("FILES" %: Param.string)) in
main ~genesis_constants ~constraint_constants ~archive_uri ~precomputed
~extensional ~success_file ~failure_file ~log_successes ~files )))
main ~config_file ~archive_uri ~precomputed ~extensional ~success_file
~failure_file ~log_successes ~files )))
1 change: 1 addition & 0 deletions src/app/archive_blocks/dune
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
base.caml
async.async_command
;; local libraries
cli_lib
logger
mina_block
bounded_types
Expand Down
21 changes: 11 additions & 10 deletions src/app/batch_txn_tool/batch_txn_tool.ml
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,18 @@ let there_and_back_again ~num_txn_per_acct ~txns_per_block ~slot_time ~fill_rate
~origin_sender_secret_key_path
~(origin_sender_secret_key_pw_option : string option)
~returner_secret_key_path ~(returner_secret_key_pw_option : string option)
~graphql_target_node_option ~minimum_user_command_fee () =
~graphql_target_node_option ~minimum_user_command_fee_opt ~config_file () =
let open Deferred.Let_syntax in
(* define the rate limiting function *)
let open Logger in
let logger = Logger.create () in
let%bind minimum_user_command_fee =
let%map config =
Runtime_config.Config_loader.load_config_exn ~config_file ()
in
Option.value ~default:config.genesis_constants.minimum_user_command_fee
minimum_user_command_fee_opt
in
let limit_level =
let slot_limit =
Float.(
Expand Down Expand Up @@ -310,8 +317,6 @@ let there_and_back_again ~num_txn_per_acct ~txns_per_block ~slot_time ~fill_rate
return ()

let output_there_and_back_cmds =
let genesis_constants = Genesis_constants.Compiled.genesis_constants in
let compile_config = Mina_compile_config.Compiled.t in
let open Command.Let_syntax in
Command.async
~summary:
Expand Down Expand Up @@ -390,23 +395,19 @@ let output_there_and_back_cmds =
transactions, if this is not present then we use the env var \
MINA_PRIVKEY_PASS"
(optional string)
and config_file = Cli_lib.Flag.conf_file
and graphql_target_node_option =
flag "--graphql-target-node" ~aliases:[ "graphql-target-node" ]
~doc:
"URL The graphql node to send graphl commands to. must be in \
format `<ip>:<port>`. default is `127.0.0.1:3085`"
(optional string)
and minimum_user_command_fee =
let default = compile_config.default_transaction_fee in
Cli_lib.Flag.fee_common
~minimum_user_command_fee:genesis_constants.minimum_user_command_fee
~default_transaction_fee:default
in
and minimum_user_command_fee_opt = Cli_lib.Flag.fee_common in
there_and_back_again ~num_txn_per_acct ~txns_per_block ~txn_fee_option
~slot_time ~fill_rate ~rate_limit ~rate_limit_level ~rate_limit_interval
~origin_sender_secret_key_path ~origin_sender_secret_key_pw_option
~returner_secret_key_path ~returner_secret_key_pw_option
~graphql_target_node_option ~minimum_user_command_fee )
~graphql_target_node_option ~minimum_user_command_fee_opt ~config_file )

let () =
Command.run
Expand Down
Loading