From c277b5b56d9ed547dca4f8e817407bc940bb4e1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Henry?= Date: Sat, 25 Feb 2017 18:01:29 +0100 Subject: [PATCH] Proto: let `genesis` be agnostic on fitness --- src/client/embedded/genesis/client_proto_main.ml | 4 ++++ src/client/embedded/genesis/client_proto_main.mli | 4 +++- src/proto/genesis/services.ml | 3 +-- test/test_basic.ml | 4 +++- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/client/embedded/genesis/client_proto_main.ml b/src/client/embedded/genesis/client_proto_main.ml index 501849b43..3240718eb 100644 --- a/src/client/embedded/genesis/client_proto_main.ml +++ b/src/client/embedded/genesis/client_proto_main.ml @@ -59,6 +59,8 @@ let commands () = end (fun hash fitness seckey cctxt -> 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) ; command ~desc: "Fork a test protocol" begin @@ -77,6 +79,8 @@ let commands () = end (fun hash fitness seckey cctxt -> 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) ; ] diff --git a/src/client/embedded/genesis/client_proto_main.mli b/src/client/embedded/genesis/client_proto_main.mli index 1035fb59e..07550b9ec 100644 --- a/src/client/embedded/genesis/client_proto_main.mli +++ b/src/client/embedded/genesis/client_proto_main.mli @@ -11,5 +11,7 @@ val mine: Client_commands.context -> Client_node_rpcs.Blocks.block -> Data.Command.t -> - int64 -> Sodium.secret Sodium.Sign.key -> unit tzresult Lwt.t + Fitness.fitness -> + Environment.Ed25519.secret_key -> + unit tzresult Lwt.t diff --git a/src/proto/genesis/services.ml b/src/proto/genesis/services.ml index acec82c3f..1d60480be 100644 --- a/src/proto/genesis/services.ml +++ b/src/proto/genesis/services.ml @@ -42,7 +42,7 @@ module Forge = struct (req "net_id" Updater.Net_id.encoding) (req "predecessor" Block_hash.encoding) (req "timestamp" Time.encoding) - (req "fitness" Data_encoding.int64)) + (req "fitness" Fitness.encoding)) Data.Command.encoding) ~output: (obj1 (req "payload" bytes)) RPC.Path.(custom_root / "helpers" / "forge" / "block") @@ -60,7 +60,6 @@ let rpc_services : Context.t RPC.directory = dir (Forge.block RPC.Path.root) (fun _ctxt ((net_id, predecessor, timestamp, fitness), command) -> - let fitness = [ MBytes.of_string "\000" ; int64_to_bytes fitness ] in let shell = { Updater.net_id ; predecessor ; timestamp ; fitness ; operations = [] } in let bytes = Data.Command.forge shell command in diff --git a/test/test_basic.ml b/test/test_basic.ml index 9113eb400..f417f4661 100644 --- a/test/test_basic.ml +++ b/test/test_basic.ml @@ -82,9 +82,11 @@ let genesis_sk = "edskRhxswacLW6jF6ULavDdzwqnKJVS4UcDTNiCyiH6H8ZNnn2pmNviL7pRNz9kRxxaWQFzEQEcZExGHKbwmuaAcoMegj5T99z" let switch_protocol () = + let fitness = + Client_embedded_proto_alpha.Fitness_repr.from_int64 0L in Client_genesis.Client_proto_main.mine cctxt `Genesis (Activate Client_alpha.Client_proto_main.protocol) - 0L genesis_sk + fitness genesis_sk let bootstrap_accounts () = Client_proto_rpcs.Constants.bootstrap cctxt (`Head 0)