package tezos-protocol-012-Psithaca

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

This module defines the protocol representation of a level. Besides the "raw level", which is the shell's notion of the level, this representation also contains additional information, like the cycle the level belongs to.

type t = private {
  1. level : Raw_level_repr.t;
    (*

    The level of the block relative to genesis. This is also the Shell's notion of level.

    *)
  2. level_position : int32;
    (*

    The level of the block relative to the block that starts the alpha family of protocols.

    *)
  3. cycle : Cycle_repr.t;
    (*

    The current cycle's number. Note that cycles are a protocol-specific notion. As a result, the cycle number starts at 0 with the first block of the first version of protocol alpha.

    *)
  4. cycle_position : int32;
    (*

    The current level of the block relative to the first block of the current cycle.

    *)
  5. expected_commitment : bool;
}
type level = t
val (=) : level -> level -> bool
val (<>) : level -> level -> bool
val (<) : level -> level -> bool
val (<=) : level -> level -> bool
val (>=) : level -> level -> bool
val (>) : level -> level -> bool
val compare : level -> level -> int
val equal : level -> level -> bool
val max : level -> level -> level
val min : level -> level -> level
val encoding : level Data_encoding.t
val pp : Stdlib.Format.formatter -> level -> unit
val pp_full : Stdlib.Format.formatter -> level -> unit
val diff : level -> level -> int32
type cycle_era = {
  1. first_level : Raw_level_repr.t;
    (*

    The first level of a cycle era.

    *)
  2. first_cycle : Cycle_repr.t;
    (*

    The first cycle of a cycle era.

    *)
  3. blocks_per_cycle : int32;
    (*

    The value of the blocks_per_cycle constant used during the cycle era starting with first_level.

    *)
  4. blocks_per_commitment : int32;
    (*

    The value of the blocks_per_commitment constant used during the cycle era starting with first_level.

    *)
}

A cycle era is a chunk of cycles having the same number of levels per cycle and the same number of blocks per commitment.

type cycle_eras

Stores the cycles eras of the Alpha family of protocols

val cycle_eras_encoding : cycle_eras Data_encoding.t
val create_cycle_eras : cycle_era list -> (cycle_eras, Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.error Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.trace) Stdlib.result

Preconditions on the input list of cycle eras:

  • the list is not empty
  • the first levels and the first cycles are decreasing, meaning that the first era in the list is the current era, and the last era in the list is the oldest era Invariants:
  • the first era therefore contains the same constants as in Constants
  • the first level of an era is the first level of a cycle
val current_era : cycle_eras -> cycle_era

Returns the current era

val root_level : cycle_eras -> level

Returns the first level of the oldest era

val from_raw : cycle_eras:cycle_eras -> Raw_level_repr.t -> level

Returns the annotated level corresponding to a raw level

val from_raw_with_offset : cycle_eras:cycle_eras -> offset:int32 -> Raw_level_repr.t -> (level, Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.error Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.trace) Stdlib.result

Returns the annotated level corresponding to a raw level and an offset. A positive offset corresponds to a higher level. Fails with Negative_level_and_offset_sum if the sum of the raw_level and the offset is negative. Fails with Level_not_in_alpha if the sum of the raw_level and the offset is a level before the first level in the Alpha family of protocols.

val first_level_in_cycle_from_eras : cycle_eras:cycle_eras -> Cycle_repr.t -> level

Returns the first level of the given cycle.

val last_of_cycle : cycle_eras:cycle_eras -> level -> bool

Returns true if the given level is the last of a cycle.

OCaml

Innovation. Community. Security.