From 0f247adea6fcc5f3cec6a17f9208b67c18119555 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Henry?= Date: Wed, 12 Apr 2017 18:22:40 +0200 Subject: [PATCH] Shell: add the `protocol level` in the header of block --- src/client/client_node_rpcs.ml | 5 ++-- src/client/client_node_rpcs.mli | 2 ++ .../alpha/baker/client_mining_forge.ml | 2 ++ .../embedded/alpha/client_proto_rpcs.ml | 6 ++--- .../embedded/alpha/client_proto_rpcs.mli | 1 + .../embedded/genesis/client_proto_main.ml | 2 +- src/node/db/store.ml | 12 +++++---- src/node/db/store.mli | 1 + src/node/shell/node.ml | 8 ++++++ src/node/shell/node_rpc.ml | 6 +++-- src/node/shell/node_rpc_services.ml | 12 +++++---- src/node/shell/node_rpc_services.mli | 5 ++-- src/node/shell/state.ml | 5 ++++ src/node/shell/state.mli | 3 +++ src/node/shell/validator.ml | 25 +++++++++++++++++- src/node/updater/protocol.mli | 1 + src/node/updater/updater.ml | 1 + src/node/updater/updater.mli | 1 + src/proto/alpha/block_repr.ml | 4 +-- src/proto/alpha/services.ml | 26 +++++++++++-------- src/proto/alpha/services_registration.ml | 6 ++--- src/proto/environment/updater.mli | 2 ++ src/proto/genesis/services.ml | 8 +++--- test/proto_alpha/proto_alpha_helpers.ml | 4 ++- test/shell/test_state.ml | 2 ++ test/shell/test_store.ml | 1 + 26 files changed, 110 insertions(+), 41 deletions(-) diff --git a/src/client/client_node_rpcs.ml b/src/client/client_node_rpcs.ml index 479a8000c..696bc6eb1 100644 --- a/src/client/client_node_rpcs.ml +++ b/src/client/client_node_rpcs.ml @@ -15,9 +15,9 @@ module Services = Node_rpc_services let errors cctxt = call_service0 cctxt Services.Error.service () -let forge_block cctxt ?net_id ?level ?predecessor ?timestamp fitness ops header = +let forge_block cctxt ?net_id ?level ?proto_level ?predecessor ?timestamp fitness ops header = call_service0 cctxt Services.forge_block - (net_id, level, predecessor, timestamp, fitness, ops, header) + (net_id, level, proto_level, predecessor, timestamp, fitness, ops, header) let validate_block cctxt net block = call_err_service0 cctxt Services.validate_block (net, block) @@ -55,6 +55,7 @@ module Blocks = struct hash: Block_hash.t ; net_id: Net_id.t ; level: Int32.t ; + proto_level: int ; (* uint8 *) predecessor: Block_hash.t ; timestamp: Time.t ; operations_hash: Operation_list_list_hash.t ; diff --git a/src/client/client_node_rpcs.mli b/src/client/client_node_rpcs.mli index 3ca3f3ae3..c61b6ec96 100644 --- a/src/client/client_node_rpcs.mli +++ b/src/client/client_node_rpcs.mli @@ -16,6 +16,7 @@ val forge_block: config -> ?net_id:Net_id.t -> ?level:Int32.t -> + ?proto_level:int -> ?predecessor:Block_hash.t -> ?timestamp:Time.t -> Fitness.fitness -> @@ -105,6 +106,7 @@ module Blocks : sig hash: Block_hash.t ; net_id: Net_id.t ; level: Int32.t ; + proto_level: int ; (* uint8 *) predecessor: Block_hash.t ; timestamp: Time.t ; operations_hash: Operation_list_list_hash.t ; diff --git a/src/client/embedded/alpha/baker/client_mining_forge.ml b/src/client/embedded/alpha/baker/client_mining_forge.ml index 30427c09b..78b182b53 100644 --- a/src/client/embedded/alpha/baker/client_mining_forge.ml +++ b/src/client/embedded/alpha/baker/client_mining_forge.ml @@ -52,6 +52,7 @@ let inject_block cctxt block (List.map Operation_list_hash.compute operations) in let shell = { Store.Block_header.net_id = bi.net_id ; level = bi.level ; + proto_level = bi.proto_level ; predecessor = bi.hash ; timestamp ; fitness ; operations_hash } in compute_stamp cctxt block src_sk shell priority seed_nonce_hash >>=? fun proof_of_work_nonce -> @@ -63,6 +64,7 @@ let inject_block cctxt block ~fitness ~operations_hash ~level:level.level + ~proto_level:bi.proto_level ~priority:priority ~seed_nonce_hash ~proof_of_work_nonce diff --git a/src/client/embedded/alpha/client_proto_rpcs.ml b/src/client/embedded/alpha/client_proto_rpcs.ml index b7f49553a..af876e697 100644 --- a/src/client/embedded/alpha/client_proto_rpcs.ml +++ b/src/client/embedded/alpha/client_proto_rpcs.ml @@ -246,10 +246,10 @@ module Helpers = struct end let block cctxt block ~net ~predecessor ~timestamp ~fitness ~operations_hash - ~level ~priority ~seed_nonce_hash ~proof_of_work_nonce () = + ~level ~priority ~proto_level ~seed_nonce_hash ~proof_of_work_nonce () = call_error_service1 cctxt Services.Helpers.Forge.block block - (net, predecessor, timestamp, fitness, operations_hash, - level, priority, seed_nonce_hash, proof_of_work_nonce) + ((net, predecessor, timestamp, fitness, operations_hash), + (level, priority, proto_level, seed_nonce_hash, proof_of_work_nonce)) end module Parse = struct diff --git a/src/client/embedded/alpha/client_proto_rpcs.mli b/src/client/embedded/alpha/client_proto_rpcs.mli index 64ab01a15..6e0d712b3 100644 --- a/src/client/embedded/alpha/client_proto_rpcs.mli +++ b/src/client/embedded/alpha/client_proto_rpcs.mli @@ -301,6 +301,7 @@ module Helpers : sig operations_hash:Operation_list_list_hash.t -> level:Raw_level.t -> priority:int -> + proto_level:int -> seed_nonce_hash:Nonce_hash.t -> proof_of_work_nonce:MBytes.t -> unit -> MBytes.t tzresult Lwt.t diff --git a/src/client/embedded/genesis/client_proto_main.ml b/src/client/embedded/genesis/client_proto_main.ml index 3ecd0a140..985beb5a2 100644 --- a/src/client/embedded/genesis/client_proto_main.ml +++ b/src/client/embedded/genesis/client_proto_main.ml @@ -29,7 +29,7 @@ let forge_block Client_node_rpcs.Blocks.level rpc_config block >>=? fun level -> call_service1 rpc_config Services.Forge.block block - ((net_id, Int32.succ level, pred, timestamp, fitness), command) + ((net_id, Int32.succ level, 1, pred, timestamp, fitness), command) let mine rpc_config ?timestamp block command fitness seckey = Client_blocks.get_block_info rpc_config block >>=? fun bi -> diff --git a/src/node/db/store.ml b/src/node/db/store.ml index be1e8cb41..f74b7db02 100644 --- a/src/node/db/store.ml +++ b/src/node/db/store.ml @@ -253,6 +253,7 @@ module Block_header = struct type shell_header = { net_id: Net_id.t ; level: Int32.t ; + proto_level: int ; (* uint8 *) predecessor: Block_hash.t ; timestamp: Time.t ; operations_hash: Operation_list_list_hash.t ; @@ -262,17 +263,18 @@ module Block_header = struct let shell_header_encoding = let open Data_encoding in conv - (fun { net_id ; level ; predecessor ; + (fun { net_id ; level ; proto_level ; predecessor ; timestamp ; operations_hash ; fitness } -> - (net_id, level, predecessor, + (net_id, level, proto_level, predecessor, timestamp, operations_hash, fitness)) - (fun (net_id, level, predecessor, + (fun (net_id, level, proto_level, predecessor, timestamp, operations_hash, fitness) -> - { net_id ; level ; predecessor ; + { net_id ; level ; proto_level ; predecessor ; timestamp ; operations_hash ; fitness }) - (obj6 + (obj7 (req "net_id" Net_id.encoding) (req "level" int32) + (req "proto" uint8) (req "predecessor" Block_hash.encoding) (req "timestamp" Time.encoding) (req "operations_hash" Operation_list_list_hash.encoding) diff --git a/src/node/db/store.mli b/src/node/db/store.mli index ff8431baa..0fefb13ba 100644 --- a/src/node/db/store.mli +++ b/src/node/db/store.mli @@ -172,6 +172,7 @@ module Block_header : sig type shell_header = { net_id: Net_id.t ; level: Int32.t ; + proto_level: int ; (* uint8 *) predecessor: Block_hash.t ; timestamp: Time.t ; operations_hash: Operation_list_list_hash.t ; diff --git a/src/node/shell/node.ml b/src/node/shell/node.ml index 876cd23fe..ffcf794d5 100644 --- a/src/node/shell/node.ml +++ b/src/node/shell/node.ml @@ -139,6 +139,7 @@ module RPC = struct hash: Block_hash.t ; net_id: Net_id.t ; level: Int32.t ; + proto_level: int ; (* uint8 *) predecessor: Block_hash.t ; timestamp: Time.t ; operations_hash: Operation_list_list_hash.t ; @@ -153,6 +154,7 @@ module RPC = struct hash = block.hash ; net_id = block.net_id ; level = block.level ; + proto_level = block.proto_level ; predecessor = block.predecessor ; timestamp = block.timestamp ; operations_hash = block.operations_hash ; @@ -266,12 +268,18 @@ module RPC = struct | Ok { context ; fitness } -> Context.get_protocol context >>= fun protocol -> Context.get_test_network context >>= fun test_network -> + let proto_level = + if Protocol_hash.equal protocol head.protocol_hash then + head.proto_level + else + ((head.proto_level + 1) mod 256) in let operations = let pv_result, _ = Prevalidator.operations pv in [ pv_result.applied ] in Lwt.return { hash = prevalidation_hash ; level = Int32.succ head.level ; + proto_level ; predecessor = head.hash ; fitness ; timestamp = Prevalidator.timestamp pv ; diff --git a/src/node/shell/node_rpc.ml b/src/node/shell/node_rpc.ml index 309f2d966..912f46ea8 100644 --- a/src/node/shell/node_rpc.ml +++ b/src/node/shell/node_rpc.ml @@ -401,15 +401,17 @@ let build_rpc_directory node = RPC.register1 dir Services.Protocols.contents (get_protocols node) in let dir = let implementation - (net_id, level, pred, time, fitness, operations_hash, header) = + (net_id, level, proto_level, pred, time, + fitness, operations_hash, header) = Node.RPC.block_info node (`Head 0) >>= fun bi -> let timestamp = Utils.unopt ~default:(Time.now ()) time in let net_id = Utils.unopt ~default:bi.net_id net_id in let predecessor = Utils.unopt ~default:bi.hash pred in let level = Utils.unopt ~default:(Int32.succ bi.level) level in + let proto_level = Utils.unopt ~default:bi.proto_level proto_level in let res = Data_encoding.Binary.to_bytes Store.Block_header.encoding { - shell = { net_id ; predecessor ; level ; + shell = { net_id ; predecessor ; level ; proto_level ; timestamp ; fitness ; operations_hash } ; proto = header ; } in diff --git a/src/node/shell/node_rpc_services.ml b/src/node/shell/node_rpc_services.ml index 5ac00f63f..4a6cdae90 100644 --- a/src/node/shell/node_rpc_services.ml +++ b/src/node/shell/node_rpc_services.ml @@ -59,6 +59,7 @@ module Blocks = struct hash: Block_hash.t ; net_id: Net_id.t ; level: Int32.t ; + proto_level: int ; (* uint8 *) predecessor: Block_hash.t ; timestamp: Time.t ; operations_hash: Operation_list_list_hash.t ; @@ -71,20 +72,20 @@ module Blocks = struct let block_info_encoding = conv - (fun { hash ; net_id ; level ; predecessor ; + (fun { hash ; net_id ; level ; proto_level ; predecessor ; fitness ; timestamp ; protocol ; operations_hash ; data ; operations ; test_network } -> ({ Store.Block_header.shell = - { net_id ; level ; predecessor ; + { net_id ; level ; proto_level ; predecessor ; timestamp ; operations_hash ; fitness } ; proto = data }, (hash, operations, protocol, test_network))) (fun ({ Store.Block_header.shell = - { net_id ; level ; predecessor ; + { net_id ; level ; proto_level ; predecessor ; timestamp ; operations_hash ; fitness } ; proto = data }, (hash, operations, protocol, test_network)) -> - { hash ; net_id ; level ; predecessor ; + { hash ; net_id ; level ; proto_level ; predecessor ; fitness ; timestamp ; protocol ; operations_hash ; data ; operations ; test_network }) (dynamic_size @@ -632,9 +633,10 @@ let forge_block = RPC.service ~description: "Forge a block header" ~input: - (obj7 + (obj8 (opt "net_id" Net_id.encoding) (opt "level" int32) + (opt "proto_level" uint8) (opt "predecessor" Block_hash.encoding) (opt "timestamp" Time.encoding) (req "fitness" Fitness.encoding) diff --git a/src/node/shell/node_rpc_services.mli b/src/node/shell/node_rpc_services.mli index 010a16297..b2228e47f 100644 --- a/src/node/shell/node_rpc_services.mli +++ b/src/node/shell/node_rpc_services.mli @@ -30,6 +30,7 @@ module Blocks : sig hash: Block_hash.t ; net_id: Net_id.t ; level: Int32.t ; + proto_level: int ; (* uint8 *) predecessor: Block_hash.t ; timestamp: Time.t ; operations_hash: Operation_list_list_hash.t ; @@ -178,8 +179,8 @@ end val forge_block: (unit, unit, - Net_id.t option * Int32.t option * Block_hash.t option * Time.t option * - Fitness.fitness * Operation_list_list_hash.t * MBytes.t, + Net_id.t option * Int32.t option * int option * Block_hash.t option * + Time.t option * Fitness.fitness * Operation_list_list_hash.t * MBytes.t, MBytes.t) RPC.service val validate_block: diff --git a/src/node/shell/state.ml b/src/node/shell/state.ml index 9ee199372..a21ca4188 100644 --- a/src/node/shell/state.ml +++ b/src/node/shell/state.ml @@ -111,6 +111,7 @@ and valid_block = { net_id: Net_id.t ; hash: Block_hash.t ; level: Int32.t ; + proto_level: int ; predecessor: Block_hash.t ; timestamp: Time.t ; fitness: Protocol.fitness ; @@ -136,6 +137,7 @@ let build_valid_block net_id = header.Store.Block_header.shell.net_id ; hash ; level = header.shell.level ; + proto_level = header.shell.proto_level ; predecessor = header.shell.predecessor ; timestamp = header.shell.timestamp ; discovery_time ; @@ -531,6 +533,7 @@ module Raw_block_header = struct let shell : Store.Block_header.shell_header = { net_id = Net_id.of_block_hash genesis.block; level = 0l ; + proto_level = 0 ; predecessor = genesis.block ; timestamp = genesis.time ; fitness = [] ; @@ -686,6 +689,7 @@ module Block_header = struct type shell_header = Store.Block_header.shell_header = { net_id: Net_id.t ; level: Int32.t ; + proto_level: int ; (* uint8 *) predecessor: Block_hash.t ; timestamp: Time.t ; operations_hash: Operation_list_list_hash.t ; @@ -927,6 +931,7 @@ module Valid_block = struct net_id: Net_id.t ; hash: Block_hash.t ; level: Int32.t ; + proto_level: int ; predecessor: Block_hash.t ; timestamp: Time.t ; fitness: Fitness.fitness ; diff --git a/src/node/shell/state.mli b/src/node/shell/state.mli index f054542b0..a840c7f43 100644 --- a/src/node/shell/state.mli +++ b/src/node/shell/state.mli @@ -145,6 +145,7 @@ module Block_header : sig type shell_header = Store.Block_header.shell_header = { net_id: Net_id.t ; level: Int32.t ; + proto_level: int ; (* uint8 *) predecessor: Block_hash.t ; timestamp: Time.t ; operations_hash: Operation_list_list_hash.t ; @@ -248,6 +249,8 @@ module Valid_block : sig (** The block hash. *) level: Int32.t ; (** The number of preceding block in the chain. *) + proto_level: int ; + (** The number of protocol amendment block in the chain (modulo 256) *) predecessor: Block_hash.t ; (** The preceding block in the chain. *) timestamp: Time.t ; diff --git a/src/node/shell/validator.ml b/src/node/shell/validator.ml index e11b1b36f..29df775f7 100644 --- a/src/node/shell/validator.ml +++ b/src/node/shell/validator.ml @@ -145,6 +145,7 @@ type error += | Non_increasing_timestamp | Non_increasing_fitness | Wrong_level of Int32.t * Int32.t + | Wrong_proto_level of int * int let () = register_error_kind @@ -159,7 +160,20 @@ let () = (req "expected" int32) (req "provided" int32)) (function Wrong_level (e, g) -> Some (e, g) | _ -> None) - (fun (e, g) -> Wrong_level (e, g)) + (fun (e, g) -> Wrong_level (e, g)) ; + register_error_kind + `Permanent + ~id:"validator.wrong_proto_level" + ~title:"Wrong protocol level" + ~description:"The protocol level is not the expected one" + ~pp:(fun ppf (e, g) -> + Format.fprintf ppf + "The declared protocol level %d is not %d" g e) + Data_encoding.(obj2 + (req "expected" uint8) + (req "provided" uint8)) + (function Wrong_proto_level (e, g) -> Some (e, g) | _ -> None) + (fun (e, g) -> Wrong_proto_level (e, g)) let apply_block net db (pred: State.Valid_block.t) hash (block: State.Block_header.t) = @@ -231,6 +245,15 @@ let apply_block net db return state) state parsed_operations >>=? fun state -> Proto.finalize_block state >>=? fun new_context -> + Context.get_protocol new_context.context >>= fun new_protocol -> + let expected_proto_level = + if Protocol_hash.equal new_protocol pred.protocol_hash then + pred.proto_level + else + (pred.proto_level + 1) mod 256 in + fail_when (block.shell.proto_level <> expected_proto_level) + (Wrong_proto_level (block.shell.proto_level, expected_proto_level)) + >>=? fun () -> lwt_log_info "validation of %a: success" Block_hash.pp_short hash >>= fun () -> return new_context diff --git a/src/node/updater/protocol.mli b/src/node/updater/protocol.mli index 7ead89112..1692449bf 100644 --- a/src/node/updater/protocol.mli +++ b/src/node/updater/protocol.mli @@ -25,6 +25,7 @@ type raw_operation = Store.Operation.t = { type shell_block = Store.Block_header.shell_header = { net_id: Net_id.t ; level: Int32.t ; + proto_level: int ; (* uint8 *) predecessor: Block_hash.t ; timestamp: Time.t ; operations_hash: Operation_list_list_hash.t ; diff --git a/src/node/updater/updater.ml b/src/node/updater/updater.ml index 38c3d184f..705ad8ae7 100644 --- a/src/node/updater/updater.ml +++ b/src/node/updater/updater.ml @@ -46,6 +46,7 @@ let raw_operation_encoding = Store.Operation.encoding type shell_block = Store.Block_header.shell_header = { net_id: Net_id.t ; level: Int32.t ; + proto_level: int ; (* uint8 *) predecessor: Block_hash.t ; timestamp: Time.t ; operations_hash: Operation_list_list_hash.t ; diff --git a/src/node/updater/updater.mli b/src/node/updater/updater.mli index 247ee3c19..bbd0d5259 100644 --- a/src/node/updater/updater.mli +++ b/src/node/updater/updater.mli @@ -21,6 +21,7 @@ val raw_operation_encoding: raw_operation Data_encoding.t type shell_block = Store.Block_header.shell_header = { net_id: Net_id.t ; level: Int32.t ; + proto_level: int ; (* uint8 *) predecessor: Block_hash.t ; timestamp: Time.t ; operations_hash: Operation_list_list_hash.t ; diff --git a/src/proto/alpha/block_repr.ml b/src/proto/alpha/block_repr.ml index 22fda8587..ebdf33fda 100644 --- a/src/proto/alpha/block_repr.ml +++ b/src/proto/alpha/block_repr.ml @@ -62,14 +62,14 @@ type error += | Cant_parse_proto_header let parse_header - ({ shell = { net_id ; level ; predecessor ; + ({ shell = { net_id ; level ; proto_level ; predecessor ; timestamp ; fitness ; operations_hash } ; proto } : Updater.raw_block) : header tzresult = match Data_encoding.Binary.of_bytes signed_proto_header_encoding proto with | None -> Error [Cant_parse_proto_header] | Some (proto, signature) -> let shell = - { Updater.net_id ; level ; predecessor ; + { Updater.net_id ; level ; proto_level ; predecessor ; timestamp ; fitness ; operations_hash } in Ok { shell ; proto ; signature } diff --git a/src/proto/alpha/services.ml b/src/proto/alpha/services.ml index 71ee0c4d1..7e3944558 100644 --- a/src/proto/alpha/services.ml +++ b/src/proto/alpha/services.ml @@ -556,17 +556,21 @@ module Helpers = struct RPC.service ~description: "Forge a block header" ~input: - (obj9 - (req "net_id" Net_id.encoding) - (req "predecessor" Block_hash.encoding) - (req "timestamp" Timestamp.encoding) - (req "fitness" Fitness.encoding) - (req "operations" Operation_list_list_hash.encoding) - (req "level" Raw_level.encoding) - (req "priority" uint16) - (req "nonce_hash" Nonce_hash.encoding) - (req "proof_of_work_nonce" - (Fixed.bytes Tezos_context.Constants.proof_of_work_nonce_size))) + (merge_objs + (obj5 + (req "net_id" Net_id.encoding) + (req "predecessor" Block_hash.encoding) + (req "timestamp" Timestamp.encoding) + (req "fitness" Fitness.encoding) + (req "operations" Operation_list_list_hash.encoding)) + (obj5 + (req "level" Raw_level.encoding) + (req "priority" uint16) + (req "proto_level" uint8) + (req "nonce_hash" Nonce_hash.encoding) + (req "proof_of_work_nonce" + (Fixed.bytes + Tezos_context.Constants.proof_of_work_nonce_size)))) ~output: (wrap_tzerror bytes) RPC.Path.(custom_root / "helpers" / "forge" / "block") diff --git a/src/proto/alpha/services_registration.ml b/src/proto/alpha/services_registration.ml index b4bb98ef4..716aeecba 100644 --- a/src/proto/alpha/services_registration.ml +++ b/src/proto/alpha/services_registration.ml @@ -434,11 +434,11 @@ let forge_operations _ctxt (shell, proto) = let () = register1 Services.Helpers.Forge.operations forge_operations let forge_block _ctxt - (net_id, predecessor, timestamp, fitness, operations_hash, - level, priority, seed_nonce_hash, proof_of_work_nonce) : MBytes.t tzresult Lwt.t = + ((net_id, predecessor, timestamp, fitness, operations_hash), + (level, priority, proto_level, seed_nonce_hash, proof_of_work_nonce)) : MBytes.t tzresult Lwt.t = let level = Raw_level.to_int32 level in return (Block.forge_header - { net_id ; level ; predecessor ; + { net_id ; level ; proto_level ; predecessor ; timestamp ; fitness ; operations_hash } { priority ; seed_nonce_hash ; proof_of_work_nonce }) diff --git a/src/proto/environment/updater.mli b/src/proto/environment/updater.mli index 181499bd0..b5be855b8 100644 --- a/src/proto/environment/updater.mli +++ b/src/proto/environment/updater.mli @@ -21,6 +21,8 @@ type shell_block = { (** The genesis of the chain this block belongs to. *) level: Int32.t ; (** The number of predecessing block in the chain. *) + proto_level: int ; + (** The number of protocol amendment block in the chain (modulo 256) *) predecessor: Block_hash.t ; (** The preceding block in the chain. *) timestamp: Time.t ; diff --git a/src/proto/genesis/services.ml b/src/proto/genesis/services.ml index 36ffd1a53..26ac9cd12 100644 --- a/src/proto/genesis/services.ml +++ b/src/proto/genesis/services.ml @@ -38,9 +38,10 @@ module Forge = struct ~description: "Forge a block" ~input: (merge_objs - (obj5 + (obj6 (req "net_id" Net_id.encoding) (req "level" int32) + (req "proto_level" uint8) (req "predecessor" Block_hash.encoding) (req "timestamp" Time.encoding) (req "fitness" Fitness.encoding)) @@ -63,8 +64,9 @@ let rpc_services : Updater.rpc_context RPC.directory = RPC.register dir (Forge.block RPC.Path.root) - (fun _ctxt ((net_id, level, predecessor, timestamp, fitness), command) -> - let shell = { Updater.net_id ; level ; predecessor ; + (fun _ctxt ((net_id, level, proto_level, predecessor, + timestamp, fitness), command) -> + let shell = { Updater.net_id ; level ; proto_level ; predecessor ; timestamp ; fitness ; operations_hash } in let bytes = Data.Command.forge shell command in RPC.Answer.return bytes) in diff --git a/test/proto_alpha/proto_alpha_helpers.ml b/test/proto_alpha/proto_alpha_helpers.ml index 592c3fd45..798e1da19 100644 --- a/test/proto_alpha/proto_alpha_helpers.ml +++ b/test/proto_alpha/proto_alpha_helpers.ml @@ -399,7 +399,8 @@ module Mining = struct let shell = { Store.Block_header.net_id = bi.net_id ; predecessor = bi.hash ; timestamp ; fitness ; operations_hash ; - level = Raw_level.to_int32 level.level } in + level = Raw_level.to_int32 level.level ; + proto_level = 1 } in mine_stamp block src_sk shell priority seed_nonce_hash >>=? fun proof_of_work_nonce -> Client_proto_rpcs.Helpers.Forge.block rpc_config @@ -410,6 +411,7 @@ module Mining = struct ~fitness ~operations_hash ~level:level.level + ~proto_level:1 ~priority ~seed_nonce_hash ~proof_of_work_nonce diff --git a/test/shell/test_state.ml b/test/shell/test_state.ml index b26911f8c..eb03eae88 100644 --- a/test/shell/test_state.ml +++ b/test/shell/test_state.ml @@ -70,6 +70,7 @@ let block _state ?(operations = []) pred_hash pred name : Store.Block_header.t = { shell = { net_id = pred.shell.net_id ; level = Int32.succ pred.shell.level ; + proto_level = pred.shell.proto_level ; predecessor = pred_hash ; timestamp ; operations_hash ; fitness } ; proto = MBytes.of_string name ; @@ -141,6 +142,7 @@ let block _state ?(operations = []) (pred: State.Valid_block.t) name let timestamp = incr_timestamp pred.timestamp in { shell = { net_id = pred.net_id ; level = Int32.succ pred.level ; + proto_level = pred.proto_level ; predecessor = pred.hash ; timestamp ; operations_hash ; fitness } ; proto = MBytes.of_string name ; diff --git a/test/shell/test_store.ml b/test/shell/test_store.ml index a5574be0c..fa97875e6 100644 --- a/test/shell/test_store.ml +++ b/test/shell/test_store.ml @@ -95,6 +95,7 @@ let lolblock ?(operations = []) header = { Store.Block_header.shell = { timestamp = Time.of_seconds (Random.int64 1500L) ; level = 0l ; (* dummy *) + proto_level = 0 ; (* dummy *) net_id ; predecessor = genesis_block ; operations_hash ; fitness = [MBytes.of_string @@ string_of_int @@ String.length header;