diff --git a/src/node/shell/validator.ml b/src/node/shell/validator.ml index 8db0c0ff6..470e251e3 100644 --- a/src/node/shell/validator.ml +++ b/src/node/shell/validator.ml @@ -102,7 +102,10 @@ let rec may_set_head v (block: State.Valid_block.t) = (** Block validation *) -type error += Invalid_operation of Operation_hash.t +type error += + | Invalid_operation of Operation_hash.t + | Non_increasing_timestamp + | Non_increasing_fitness let apply_block net db (pred: State.Valid_block.t) hash (block: State.Block_header.t) = @@ -125,6 +128,18 @@ let apply_block net db failwith "This test network expired..." | None | Some _ -> return () end >>=? fun () -> + begin + if Time.(pred.timestamp >= block.shell.timestamp) then + fail Non_increasing_timestamp + else + return () + end >>=? fun () -> + begin + if Fitness.compare pred.fitness block.shell.fitness >= 0 then + fail Non_increasing_fitness + else + return () + end >>=? fun () -> begin match pred.protocol with | None -> fail (State.Unknown_protocol pred.protocol_hash) diff --git a/src/node/shell/validator.mli b/src/node/shell/validator.mli index 5f2913ede..3148ff2ac 100644 --- a/src/node/shell/validator.mli +++ b/src/node/shell/validator.mli @@ -16,6 +16,10 @@ val notify_block: worker -> Block_hash.t -> State.Block_header.t -> unit Lwt.t type t +type error += + | Non_increasing_timestamp + | Non_increasing_fitness + val activate: worker -> State.Net.t -> t Lwt.t val get: worker -> State.Net_id.t -> t tzresult Lwt.t val get_exn: worker -> State.Net_id.t -> t Lwt.t