diff --git a/src/client/embedded/genesis/client_proto_main.ml b/src/client/embedded/genesis/client_proto_main.ml index 14c325bfe..7f9c17d1b 100644 --- a/src/client/embedded/genesis/client_proto_main.ml +++ b/src/client/embedded/genesis/client_proto_main.ml @@ -25,9 +25,9 @@ let forge_block Services.Forge.block block ((net_id, pred, timestamp, fitness), command) -let mine cctxt block command fitness seckey = +let mine cctxt ?timestamp block command fitness seckey = Client_blocks.get_block_info cctxt block >>= fun bi -> - forge_block cctxt block bi.net command fitness >>= fun blk -> + forge_block cctxt ?timestamp block bi.net command fitness >>= fun blk -> let signed_blk = Environment.Ed25519.Signature.append seckey blk in Client_node_rpcs.inject_block cctxt ~wait:true signed_blk >>=? fun hash -> cctxt.answer "Injected %a" Block_hash.pp_short hash >>= fun () -> @@ -41,9 +41,14 @@ let handle_error cctxt = function cctxt.Client_commands.error "%s" "cannot continue" let commands () = + let timestamp = ref None in + let args = + [ "-timestamp", + Arg.String (fun t -> timestamp := Some (Time.of_notation_exn t)), + "Set the timestamp of the block (and initial time of the chain)" ] in let open Cli_entries in [ - command ~desc: "Activate a protocol" begin + command ~args ~desc: "Activate a protocol" begin prefixes [ "activate" ; "protocol" ] @@ param ~name:"version" ~desc:"Protocol version (b58check)" (fun _ p -> Lwt.return @@ Protocol_hash.of_b58check p) @@ @@ -57,12 +62,14 @@ let commands () = stop end (fun hash fitness seckey cctxt -> + let timestamp = !timestamp in let block = Client_config.block () in let fitness = Client_embedded_proto_alpha.Fitness_repr.from_int64 fitness in - mine cctxt block (Activate hash) fitness seckey >>= handle_error cctxt) + mine cctxt ?timestamp block (Activate hash) fitness seckey >>= + handle_error cctxt) ; - command ~desc: "Fork a test protocol" begin + command ~args ~desc: "Fork a test protocol" begin prefixes [ "fork" ; "test" ; "protocol" ] @@ param ~name:"version" ~desc:"Protocol version (b58check)" (fun _ p -> Lwt.return (Protocol_hash.of_b58check p)) @@ @@ -77,10 +84,12 @@ let commands () = stop end (fun hash fitness seckey cctxt -> + let timestamp = !timestamp in let block = Client_config.block () in let fitness = Client_embedded_proto_alpha.Fitness_repr.from_int64 fitness in - mine cctxt block (Activate_testnet hash) fitness seckey >>= handle_error cctxt) ; + mine cctxt ?timestamp block (Activate_testnet hash) fitness seckey >>= + handle_error cctxt) ; ] let () = diff --git a/src/client/embedded/genesis/client_proto_main.mli b/src/client/embedded/genesis/client_proto_main.mli index c548f2bb8..451964484 100644 --- a/src/client/embedded/genesis/client_proto_main.mli +++ b/src/client/embedded/genesis/client_proto_main.mli @@ -9,6 +9,7 @@ val mine: Client_commands.context -> + ?timestamp: Time.t -> Client_node_rpcs.Blocks.block -> Data.Command.t -> Fitness.fitness ->