package tezos-store

  1. Overview
  2. Docs

Module Protocol_levels represents an associative map of protocol levels to corresponding blocks which supposedly activate new protocols, that is to say blocks that acknowledge a protocol change in the next block.

type key = int
type !+'a t
module Legacy : sig ... end
val empty : 'a t
val is_empty : 'a t -> bool
val mem : key -> 'a t -> bool
val add : key -> 'a -> 'a t -> 'a t
val update : key -> ('a option -> 'a option) -> 'a t -> 'a t
val singleton : key -> 'a -> 'a t
val remove : key -> 'a t -> 'a t
val merge : (key -> 'a option -> 'b option -> 'c option) -> 'a t -> 'b t -> 'c t
val union : (key -> 'a -> 'a -> 'a option) -> 'a t -> 'a t -> 'a t
val compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int
val equal : ('a -> 'a -> bool) -> 'a t -> 'a t -> bool
val iter : (key -> 'a -> unit) -> 'a t -> unit
val iter_e : (key -> 'a -> (unit, 'trace) result) -> 'a t -> (unit, 'trace) result
val iter_s : (key -> 'a -> unit Lwt.t) -> 'a t -> unit Lwt.t
val iter_p : (key -> 'a -> unit Lwt.t) -> 'a t -> unit Lwt.t
val iter_es : (key -> 'a -> (unit, 'trace) result Lwt.t) -> 'a t -> (unit, 'trace) result Lwt.t
val fold : (key -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b
val fold_e : (key -> 'a -> 'b -> ('b, 'trace) result) -> 'a t -> 'b -> ('b, 'trace) result
val fold_s : (key -> 'a -> 'b -> 'b Lwt.t) -> 'a t -> 'b -> 'b Lwt.t
val fold_es : (key -> 'a -> 'b -> ('b, 'trace) result Lwt.t) -> 'a t -> 'b -> ('b, 'trace) result Lwt.t
val for_all : (key -> 'a -> bool) -> 'a t -> bool
val exists : (key -> 'a -> bool) -> 'a t -> bool
val filter : (key -> 'a -> bool) -> 'a t -> 'a t
val partition : (key -> 'a -> bool) -> 'a t -> 'a t * 'a t
val cardinal : 'a t -> int
val bindings : 'a t -> (key * 'a) list
val min_binding : 'a t -> (key * 'a) option
val max_binding : 'a t -> (key * 'a) option
val choose : 'a t -> (key * 'a) option
val split : key -> 'a t -> 'a t * 'a option * 'a t
val find : key -> 'a t -> 'a option
val find_first : (key -> bool) -> 'a t -> (key * 'a) option
val find_last : (key -> bool) -> 'a t -> (key * 'a) option
val map : ('a -> 'b) -> 'a t -> 'b t
val mapi : (key -> 'a -> 'b) -> 'a t -> 'b t
val to_seq : 'a t -> (key * 'a) Seq.t
val to_seq_from : key -> 'a t -> (key * 'a) Seq.t
val add_seq : (key * 'a) Seq.t -> 'a t -> 'a t
val of_seq : (key * 'a) Seq.t -> 'a t
val iter_ep : (key -> 'a -> (unit, 'error Tezos_error_monad.TzTrace.trace) result Lwt.t) -> 'a t -> (unit, 'error Tezos_error_monad.TzTrace.trace) result Lwt.t
type commit_info = {
  1. author : string;
  2. message : string;
  3. test_chain_status : Tezos_base.Test_chain_status.t;
  4. predecessor_block_metadata_hash : Tezos_crypto.Block_metadata_hash.t option;
  5. predecessor_ops_metadata_hash : Tezos_crypto.Operation_metadata_list_list_hash.t option;
  6. data_merkle_root : Tezos_crypto.Context_hash.t;
  7. parents_contexts : Tezos_crypto.Context_hash.t list;
}

The type representing a subset of the commit information. These are used to easily check that a given Context_hash.t, with the associated context not present on disk, is consistent. It is used to verify that an announced protocol is indeed the one that was committed on disk. Fields are:

  • author is the commit's author;
  • message is the commit's message;
  • test_chain_status is the status of the test chain at commit time;
  • data_merkle_root is the merkle root of the context's data main node;
  • parents_contexts are the context hashes of this commit's parents.

This structure should be populated with the result of Tezos_context.Context.retrieve_commit_info. The consistency check is done by Tezos_context.Context.check_protocol_commit_consistency when a context in imported in the leger state, for example, when importing a snapshot.

val commit_info_encoding : commit_info Data_encoding.t

Encoding for commit_info.

type activation_block = {
  1. block : block_descriptor;
  2. protocol : Tezos_crypto.Protocol_hash.t;
  3. commit_info : commit_info option;
}

The type for activation blocks.

An activation block refers to a block which activated a new protocol N+1. Thus, the block header related to that activation block will have a protocol level which differs from its predecessor. As this block aims to activate a new protocol, the next_protocol and protocol fields from the metadata differs: next_protocol refers to the hash of the activated protocol. As a consequence, this block handled by protocol N and is the last block of that protocol.

WARNING. Commit information are optional to allow retro-compatibility: the LMDB legacy store does not contain such information. Thus, populating the protocol levels' map while upgrading the storage would prevent us from storing an activation block which is used to retrieve the protocol to load, and therefore, being unable to decode stored blocks. In the future, when a sufficient number of nodes have fully migrated, we can stitch the missing commit information by hard-coding them, allowing us to remove the option.

Encoding for the protocol level's association map.

OCaml

Innovation. Community. Security.