package tezos-protocol-011-PtHangz2

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
type Tezos_protocol_environment_011_PtHangz2__Environment.Error_monad.error +=
  1. | Invalid_fitness_gap of int64 * int64
type Tezos_protocol_environment_011_PtHangz2__Environment.Error_monad.error +=
  1. | Timestamp_too_early of {
    1. minimal_time : Alpha_context.Timestamp.t;
    2. provided_time : Alpha_context.Timestamp.t;
    3. priority : int;
    4. endorsing_power_opt : int option;
    }
type Tezos_protocol_environment_011_PtHangz2__Environment.Error_monad.error +=
  1. | Invalid_block_signature of Tezos_crypto.Block_hash.t * Tezos_crypto.Signature.public_key_hash
type Tezos_protocol_environment_011_PtHangz2__Environment.Error_monad.error +=
  1. | Unexpected_endorsement
type Tezos_protocol_environment_011_PtHangz2__Environment.Error_monad.error +=
  1. | Invalid_endorsement_slot of int
type Tezos_protocol_environment_011_PtHangz2__Environment.Error_monad.error +=
  1. | Unexpected_endorsement_slot of int
type Tezos_protocol_environment_011_PtHangz2__Environment.Error_monad.error +=
  1. | Invalid_signature
type Tezos_protocol_environment_011_PtHangz2__Environment.Error_monad.error +=
  1. | Invalid_stamp
val minimal_time : Alpha_context.Constants.parametric -> priority:int -> Tezos_base.Time.Protocol.t -> (Tezos_base.Time.Protocol.t, Tezos_protocol_environment_011_PtHangz2__Environment.Error_monad.error Tezos_protocol_environment_011_PtHangz2__Environment.Error_monad.trace) result

minimal_time ctxt priority pred_block_time returns the minimal time, given the predecessor block timestamp pred_block_time, after which a baker with priority priority is allowed to bake in principle, that is, assuming the block will contain enough endorsements.

val check_timestamp : Alpha_context.context -> priority:int -> Tezos_base.Time.Protocol.t -> (unit, Tezos_protocol_environment_011_PtHangz2__Environment.Error_monad.error Tezos_protocol_environment_011_PtHangz2__Environment.Error_monad.trace) result

check_timestamp ctxt priority pred_timestamp verifies that the timestamp is coherent with the announced baking slot.

val endorsement_rights : Alpha_context.context -> Alpha_context.Level.t -> ((Alpha_context.public_key * int list * bool) Tezos_protocol_environment_011_PtHangz2__Environment.Signature.Public_key_hash.Map.t, Tezos_protocol_environment_011_PtHangz2__Environment.Error_monad.error Tezos_protocol_environment_011_PtHangz2__Environment.Error_monad.trace) result Lwt.t

For a given level computes who has the right to include an endorsement in the next block. The result can be stored in Alpha_context.allowed_endorsements

val check_endorsement_right : Alpha_context.context -> Tezos_crypto.Chain_id.t -> slot:int -> Alpha_context.Kind.endorsement Alpha_context.Operation.t -> (Alpha_context.public_key_hash, Tezos_protocol_environment_011_PtHangz2__Environment.Error_monad.error Tezos_protocol_environment_011_PtHangz2__Environment.Error_monad.trace) result Lwt.t

Check that the operation was signed by the delegate allowed to endorse at the given slot and at the level specified by the endorsement. Returns the delegate.

val check_endorsement_slots_at_current_level : Alpha_context.context -> slot:int -> Alpha_context.public_key_hash -> (int list * bool, Tezos_protocol_environment_011_PtHangz2__Environment.Error_monad.error Tezos_protocol_environment_011_PtHangz2__Environment.Error_monad.trace) result Lwt.t

Check that, at current level, the given slot is the smallest among the delegate's slots. Returns all the slots of the delegate and "if the slot has been used already"

val baking_reward : Alpha_context.context -> block_priority:int -> included_endorsements:int -> (Alpha_context.Tez.t, Tezos_protocol_environment_011_PtHangz2__Environment.Error_monad.error Tezos_protocol_environment_011_PtHangz2__Environment.Error_monad.trace) result

Returns the baking reward calculated w.r.t a given priority p and a number e of included endorsements

val endorsing_reward : Alpha_context.context -> block_priority:int -> int -> (Alpha_context.Tez.t, Tezos_protocol_environment_011_PtHangz2__Environment.Error_monad.error Tezos_protocol_environment_011_PtHangz2__Environment.Error_monad.trace) result

Returns the endorsing reward calculated w.r.t a given priority.

baking_priorities ctxt level is the lazy list of contract's public key hashes that are allowed to bake for level.

val first_baking_priorities : Alpha_context.context -> ?max_priority:int -> Alpha_context.public_key_hash -> Alpha_context.Level.t -> (int list, Tezos_protocol_environment_011_PtHangz2__Environment.Error_monad.error Tezos_protocol_environment_011_PtHangz2__Environment.Error_monad.trace) result Lwt.t

first_baking_priorities ctxt ?max_priority contract_hash level is a list of priorities of max ?max_priority elements, where the delegate of contract_hash is allowed to bake for level. If ?max_priority is None, a sensible number of priorities is returned.

val check_signature : Alpha_context.Block_header.t -> Tezos_crypto.Chain_id.t -> Alpha_context.public_key -> (unit, Tezos_protocol_environment_011_PtHangz2__Environment.Error_monad.error Tezos_protocol_environment_011_PtHangz2__Environment.Error_monad.trace) result Lwt.t

check_signature ctxt chain_id block id check if the block is signed with the given key, and belongs to the given chain_id

val check_header_proof_of_work_stamp : Alpha_context.Block_header.shell_header -> Alpha_context.Block_header.contents -> int64 -> bool

Checks if the header that would be built from the given components is valid for the given difficulty. The signature is not passed as it is does not impact the proof-of-work stamp. The stamp is checked on the hash of a block header whose signature has been zeroed-out.

val check_proof_of_work_stamp : Alpha_context.context -> Alpha_context.Block_header.t -> (unit, Tezos_protocol_environment_011_PtHangz2__Environment.Error_monad.error Tezos_protocol_environment_011_PtHangz2__Environment.Error_monad.trace) result

verify if the proof of work stamp is valid

val check_fitness_gap : Alpha_context.context -> Alpha_context.Block_header.t -> (unit, Tezos_protocol_environment_011_PtHangz2__Environment.Error_monad.error Tezos_protocol_environment_011_PtHangz2__Environment.Error_monad.trace) result

check if the gap between the fitness of the current context and the given block is within the protocol parameters

val earlier_predecessor_timestamp : Alpha_context.context -> Alpha_context.Level.t -> (Alpha_context.Timestamp.t, Tezos_protocol_environment_011_PtHangz2__Environment.Error_monad.error Tezos_protocol_environment_011_PtHangz2__Environment.Error_monad.trace) result

Since Emmy+

A block is valid only if its timestamp has a minimal delay with respect to the previous block's timestamp, and this minimal delay depends not only on the block's priority but also on the number of endorsement operations included in the block.

In Emmy+, blocks' fitness increases by one unit with each level.

In this way, Emmy+ simplifies the optimal baking strategy: The bakers used to have to choose whether to wait for more endorsements to include in their block, or to publish the block immediately, without waiting. The incentive for including more endorsements was to increase the fitness and win against unknown blocks. However, when a block was produced too late in the priority period, there was the risk that the block did not reach endorsers before the block of next priority. In Emmy+, the baker does not need to take such a decision, because the baker cannot publish a block too early.

val minimal_valid_time : Alpha_context.Constants.parametric -> priority:int -> endorsing_power:int -> predecessor_timestamp:Tezos_base.Time.Protocol.t -> (Tezos_base.Time.Protocol.t, Tezos_protocol_environment_011_PtHangz2__Environment.Error_monad.error Tezos_protocol_environment_011_PtHangz2__Environment.Error_monad.trace) result

Given a block priority and a number of endorsement slots (given by the `endorsing_power` argument), it returns the minimum time at which the next block can be baked.

OCaml

Innovation. Community. Security.