2017-04-19 21:21:23 +04:00
|
|
|
(**************************************************************************)
|
|
|
|
(* *)
|
2017-11-14 03:36:14 +04:00
|
|
|
(* Copyright (c) 2014 - 2017. *)
|
2017-04-19 21:21:23 +04:00
|
|
|
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
|
|
|
|
(* *)
|
|
|
|
(* All rights reserved. No warranty, explicit or implicit, provided. *)
|
|
|
|
(* *)
|
|
|
|
(**************************************************************************)
|
|
|
|
|
2017-11-14 03:42:58 +04:00
|
|
|
(** Tezos Protocol Environment - Basic data structures *)
|
|
|
|
|
|
|
|
(** Generic interface for a datatype with comparison, pretty-printer
|
|
|
|
and serialization functions. *)
|
2017-04-19 21:21:23 +04:00
|
|
|
module type DATA = sig
|
|
|
|
|
|
|
|
type t
|
|
|
|
|
|
|
|
val compare: t -> t -> int
|
|
|
|
val equal: t -> t -> bool
|
|
|
|
|
2017-09-29 20:43:13 +04:00
|
|
|
val (=): t -> t -> bool
|
|
|
|
val (<>): t -> t -> bool
|
|
|
|
val (<): t -> t -> bool
|
|
|
|
val (<=): t -> t -> bool
|
|
|
|
val (>=): t -> t -> bool
|
|
|
|
val (>): t -> t -> bool
|
|
|
|
val min: t -> t -> t
|
|
|
|
val max: t -> t -> t
|
|
|
|
|
2017-04-19 21:21:23 +04:00
|
|
|
val pp: Format.formatter -> t -> unit
|
|
|
|
|
|
|
|
val encoding: t Data_encoding.t
|
|
|
|
val to_bytes: t -> MBytes.t
|
|
|
|
val of_bytes: MBytes.t -> t option
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2017-11-14 03:42:58 +04:00
|
|
|
(** Generic interface for a datatype with comparison, pretty-printer,
|
|
|
|
serialization functions and a hashing function. *)
|
2017-04-19 21:21:23 +04:00
|
|
|
module type HASHABLE_DATA = sig
|
|
|
|
|
|
|
|
include DATA
|
|
|
|
|
|
|
|
type hash
|
|
|
|
val hash: t -> hash
|
|
|
|
val hash_raw: MBytes.t -> hash
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2017-11-14 03:42:58 +04:00
|
|
|
(** The fitness of a block is defined as a list of bytes,
|
|
|
|
compared in a lexicographical order (longer list are greater). *)
|
|
|
|
module Fitness : DATA with type t = MBytes.t list
|
|
|
|
|
|
|
|
(** Tezos operations. *)
|
2017-04-19 21:21:23 +04:00
|
|
|
module Operation : sig
|
|
|
|
|
|
|
|
type shell_header = {
|
2017-04-20 10:49:14 +04:00
|
|
|
branch: Block_hash.t ;
|
2017-11-14 03:42:58 +04:00
|
|
|
(** The operation is only valid in a branch containing the
|
|
|
|
block [branch]. *)
|
2017-04-19 21:21:23 +04:00
|
|
|
}
|
|
|
|
val shell_header_encoding: shell_header Data_encoding.t
|
|
|
|
|
|
|
|
type t = {
|
|
|
|
shell: shell_header ;
|
|
|
|
proto: MBytes.t ;
|
|
|
|
}
|
|
|
|
|
|
|
|
include HASHABLE_DATA with type t := t
|
|
|
|
and type hash := Operation_hash.t
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
module Block_header : sig
|
|
|
|
|
|
|
|
type shell_header = {
|
|
|
|
level: Int32.t ;
|
2017-11-14 03:42:58 +04:00
|
|
|
(** The number of preceding block in this chain, i.e. the genesis
|
|
|
|
has level 0. *)
|
|
|
|
proto_level: int ;
|
|
|
|
(** The number of preceding protocol change in the chain (modulo 256),
|
|
|
|
i.e the genesis has proto_level 0. *)
|
2017-04-19 21:21:23 +04:00
|
|
|
predecessor: Block_hash.t ;
|
|
|
|
timestamp: Time.t ;
|
2017-11-14 03:42:58 +04:00
|
|
|
validation_passes: int ;
|
2017-04-19 21:21:23 +04:00
|
|
|
operations_hash: Operation_list_list_hash.t ;
|
|
|
|
fitness: MBytes.t list ;
|
|
|
|
}
|
|
|
|
|
|
|
|
val shell_header_encoding: shell_header Data_encoding.t
|
|
|
|
|
|
|
|
type t = {
|
|
|
|
shell: shell_header ;
|
|
|
|
proto: MBytes.t ;
|
|
|
|
}
|
|
|
|
|
|
|
|
include HASHABLE_DATA with type t := t
|
|
|
|
and type hash := Block_hash.t
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
module Protocol : sig
|
|
|
|
|
2017-10-09 12:55:12 +04:00
|
|
|
type t = {
|
|
|
|
expected_env: env_version ;
|
|
|
|
components: component list ;
|
|
|
|
}
|
|
|
|
|
2017-04-19 21:21:23 +04:00
|
|
|
(** An OCaml source component of a protocol implementation. *)
|
2017-10-09 12:55:12 +04:00
|
|
|
and component = {
|
2017-11-13 17:29:28 +04:00
|
|
|
(* The OCaml module name. *)
|
2017-04-19 21:21:23 +04:00
|
|
|
name : string ;
|
2017-11-13 17:29:28 +04:00
|
|
|
(* The OCaml interface source code *)
|
2017-04-19 21:21:23 +04:00
|
|
|
interface : string option ;
|
2017-11-13 17:29:28 +04:00
|
|
|
(* The OCaml source code *)
|
2017-04-19 21:21:23 +04:00
|
|
|
implementation : string ;
|
|
|
|
}
|
|
|
|
|
2017-10-09 12:55:12 +04:00
|
|
|
and env_version = V1
|
2017-04-19 21:21:23 +04:00
|
|
|
|
|
|
|
val component_encoding: component Data_encoding.t
|
2017-10-09 12:55:12 +04:00
|
|
|
val env_version_encoding: env_version Data_encoding.t
|
2017-04-19 21:21:23 +04:00
|
|
|
|
|
|
|
include HASHABLE_DATA with type t := t
|
|
|
|
and type hash := Protocol_hash.t
|
|
|
|
|
|
|
|
end
|