Skip to content

Commit eb89c40

Browse files
authored
Merge pull request #17816 from MinaProtocol/cjjdespres/full-fork-config
Add an initial method to generate a full reference hard fork config for testing
2 parents d1ae172 + 8b315da commit eb89c40

File tree

7 files changed

+362
-20
lines changed

7 files changed

+362
-20
lines changed

src/app/cli/src/init/client.ml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2289,6 +2289,30 @@ let thread_graph =
22892289
(humanize_graphql_error ~graphql_endpoint e) ) ;
22902290
exit 1 ) )
22912291

2292+
let generate_hardfork_config =
2293+
let open Command.Param in
2294+
let hardfork_config_dir_flag =
2295+
flag "--hardfork-config-dir"
2296+
~doc:
2297+
"DIR Directory to generate hardfork configuration, relative to the \
2298+
daemon working directory"
2299+
(required string)
2300+
in
2301+
Command.async ~summary:"Generate reference hardfork configuration"
2302+
(Cli_lib.Background_daemon.rpc_init hardfork_config_dir_flag
2303+
~f:(fun port directory_name ->
2304+
match%bind
2305+
Daemon_rpcs.Client.dispatch_join_errors
2306+
Daemon_rpcs.Generate_hardfork_config.rpc directory_name port
2307+
with
2308+
| Ok () ->
2309+
printf "Hardfork configuration successfully generated\n" ;
2310+
exit 0
2311+
| Error e ->
2312+
eprintf "Failed to generate hard fork config: %s\n"
2313+
(Error.to_string_hum e) ;
2314+
exit 1 ) )
2315+
22922316
let signature_kind =
22932317
Command.basic
22942318
~summary:"Print the signature kind that this binary is compiled with"
@@ -2533,6 +2557,7 @@ let advanced ~itn_features =
25332557
; ("vrf", Cli_lib.Commands.Vrf.command_group)
25342558
; ("thread-graph", thread_graph)
25352559
; ("print-signature-kind", signature_kind)
2560+
; ("generate-hardfork-config", generate_hardfork_config)
25362561
; ( "test"
25372562
, Command.group ~summary:"Testing-only commands"
25382563
[ ("create-genesis", test_genesis_creation) ] )

src/app/cli/src/init/mina_run.ml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,10 @@ let setup_local_server ?(client_trustlist = []) ?rest_server_port
369369
; implement Daemon_rpcs.Get_object_lifetime_statistics.rpc (fun () () ->
370370
return
371371
(Yojson.Safe.pretty_to_string @@ Allocation_functor.Table.dump ()) )
372+
; implement Daemon_rpcs.Generate_hardfork_config.rpc
373+
(fun () directory_name ->
374+
Mina_lib.Hardfork_config.dump_reference_config
375+
~breadcrumb_spec:`Stop_slot ~directory_name mina )
372376
; implement Daemon_rpcs.Submit_internal_log.rpc
373377
(fun () { timestamp; message; metadata; process } ->
374378
let metadata =

src/lib/daemon_rpcs/daemon_rpcs.ml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,3 +346,13 @@ module Get_object_lifetime_statistics = struct
346346
Rpc.Rpc.create ~name:"Get_object_lifetime_statistics" ~version:0 ~bin_query
347347
~bin_response
348348
end
349+
350+
module Generate_hardfork_config = struct
351+
type query = string [@@deriving bin_io_unversioned]
352+
353+
type response = unit Or_error.t [@@deriving bin_io_unversioned]
354+
355+
let rpc : (query, response) Rpc.Rpc.t =
356+
Rpc.Rpc.create ~name:"Generate_hardfork_config" ~version:0 ~bin_query
357+
~bin_response
358+
end

src/lib/mina_graphql/mina_graphql.ml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2612,17 +2612,25 @@ module Queries = struct
26122612
Deferred.Or_error.error_string
26132613
"Cannot specify both state hash and height"
26142614
in
2615-
let%bind { staged_ledger
2615+
let%bind { source_ledgers
26162616
; global_slot_since_genesis
26172617
; state_hash
2618-
; staking_ledger
26192618
; staking_epoch_seed
2620-
; next_epoch_ledger
26212619
; next_epoch_seed
26222620
; blockchain_length
2621+
; block_timestamp = _
26232622
} =
26242623
Mina_lib.Hardfork_config.prepare_inputs ~breadcrumb_spec mina
26252624
in
2625+
let staged_ledger = source_ledgers.staged_ledger in
2626+
let staking_ledger =
2627+
Mina_lib.Hardfork_config.genesis_source_ledger_cast
2628+
source_ledgers.staking_ledger
2629+
in
2630+
let next_epoch_ledger =
2631+
Mina_lib.Hardfork_config.genesis_source_ledger_cast
2632+
source_ledgers.next_epoch_ledger
2633+
in
26262634
let%bind new_config =
26272635
Runtime_config.make_fork_config ~staged_ledger
26282636
~global_slot_since_genesis ~state_hash ~staking_ledger

src/lib/mina_ledger/root.mli

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,9 @@ module Make
147147
backed by that checkpoint. *)
148148
val create_checkpoint_with_directory : t -> directory_name:string -> t
149149

150-
(** Convert a root backed by a [Config.Stable_db] to *)
150+
(** Convert a root backed by a [Config.Stable_db] to one backed by a
151+
[Config.Converting_db] by gradually migrating the stable database. Does
152+
nothing if the backing is already [Config.Converting_db]. *)
151153
val make_converting : t -> t Async.Deferred.t
152154

153155
(** View the root ledger as an unmasked [Any_ledger] so it can be used by code

0 commit comments

Comments
 (0)