Skip to content

Commit

Permalink
Merge pull request #16266 from MinaProtocol/georgeee/merge-compatible…
Browse files Browse the repository at this point in the history
…-to-develop-20oct2024

Merge compatible to develop (20 Oct 2024)
  • Loading branch information
georgeee authored Oct 21, 2024
2 parents 4b6844c + 2ff5676 commit de0440f
Show file tree
Hide file tree
Showing 88 changed files with 1,414 additions and 1,361 deletions.
2 changes: 1 addition & 1 deletion nix/libp2p_helper.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"go.mod":"d5de7e35a76f5c9ce7d6c98f0da39c763961e77b8c94761b1e89ab4bdfdc2a97","go.sum":"586fd920114d3875ec3e1d739921d77d30ad8e2f297b67781ca41d25a81b65a9","vendorSha256":"sha256-vyKrKi5bqm8Mf2rUOojSY0IXHcuNpcVNvd1Iu1RBxDo="}
{"go.mod":"6c45e03ccef1f79541f021cf358fa69bf80cb69b58ae92c776bc09cbb1cc8096","go.sum":"d0f40cfc7b2dc7000cd0a0be051c6a832bdbf880fee88550f2b409690cc18774","vendorSha256":"sha256-x/ZReaHGNsDshohcF4+p9Xj/JTK3gMUyeTgJkaN/eUc="}
32 changes: 22 additions & 10 deletions src/app/archive/cli/archive_cli.ml
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,38 @@ let command_run =
"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 )
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 config =
Runtime_config.Json_loader.load_config_files ~logger
(Option.to_list runtime_config_file)
|> Deferred.Or_error.ok_exn
in
let constants = Runtime_config.Constants.load_constants' config in
let%bind precomputed_values_opt =
match runtime_config_file with
| None ->
return None
| Some _ ->
Deferred.Or_error.(
Genesis_ledger_helper.Config_loader.init_from_config_file ~logger
~constants config
>>| fun (a, _) -> Option.some a)
|> Deferred.Or_error.ok_exn
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
~genesis_constants:
(Runtime_config.Constants.genesis_constants constants)
~constraint_constants:
(Runtime_config.Constants.constraint_constants 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 ~precomputed_values_opt ~missing_blocks_width )

let time_arg =
(* Same timezone as Genesis_constants.genesis_state_timestamp. *)
Expand Down
32 changes: 8 additions & 24 deletions src/app/archive/lib/processor.ml
Original file line number Diff line number Diff line change
Expand Up @@ -4728,26 +4728,12 @@ 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
let add_genesis_accounts ~logger
~(precomputed_values_opt : Precomputed_values.t option) pool =
match precomputed_values_opt with
| None ->
Deferred.unit
| Some runtime_config -> (
let%bind precomputed_values =
match%map
Genesis_ledger_helper.init_from_config_file ~logger
~proof_level:Genesis_constants.Compiled.proof_level
~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
| Some precomputed_values -> (
let ledger =
Precomputed_values.genesis_ledger precomputed_values |> Lazy.force
in
Expand All @@ -4767,7 +4753,8 @@ let add_genesis_accounts ~logger ~(runtime_config_opt : Runtime_config.t option)
let%bind.Deferred.Result genesis_block_id =
Block.add_if_doesn't_exist
(module Conn)
~constraint_constants genesis_block
~constraint_constants:precomputed_values.constraint_constants
genesis_block
in
let%bind.Deferred.Result { ledger_hash; _ } =
Block.load (module Conn) ~id:genesis_block_id
Expand Down Expand Up @@ -4874,7 +4861,7 @@ let create_metrics_server ~logger ~metrics_server_port ~missing_blocks_width
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 =
~delete_older_than ~precomputed_values_opt ~missing_blocks_width =
let where_to_listen =
Async.Tcp.Where_to_listen.bind_to All_addresses (On_port server_port)
in
Expand Down Expand Up @@ -4903,10 +4890,7 @@ let setup_server ~(genesis_constants : Genesis_constants.t)
~metadata:[ ("error", `String (Caqti_error.show e)) ] ;
Deferred.unit
| Ok pool ->
let%bind () =
add_genesis_accounts pool ~logger ~genesis_constants
~constraint_constants ~runtime_config_opt
in
let%bind () = add_genesis_accounts pool ~logger ~precomputed_values_opt in
run ~constraint_constants ~genesis_constants pool reader ~logger
~delete_older_than
|> don't_wait_for ;
Expand Down
36 changes: 21 additions & 15 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,10 @@ 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 ~logger () =
let open Deferred.Let_syntax in
(* define the rate limiting function *)
let open Logger in
let logger = Logger.create () in
let limit_level =
let slot_limit =
Float.(
Expand Down Expand Up @@ -310,8 +309,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 +387,32 @@ 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.config_files
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
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 )
and minimum_user_command_fee_opt = Cli_lib.Flag.fee_common in
fun () ->
let open Deferred.Let_syntax in
let logger = Logger.create () in
let%bind minimum_user_command_fee =
let%map conf =
Runtime_config.Constants.load_constants ~logger config_file
in
Option.value
~default:
(Runtime_config.Constants.genesis_constants conf)
.minimum_user_command_fee minimum_user_command_fee_opt
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 ~logger () )

let () =
Command.run
Expand Down
Loading

0 comments on commit de0440f

Please sign in to comment.