Module Alpha_context.Consensus

This module re-exports definitions from Raw_context.Consensus.

include Raw_context.CONSENSUS with type t := t and type slot := Slot.t and type 'a slot_map := 'a Slot.Map.t and type slot_set := Slot.Set.t and type round := Round.t and type consensus_pk := Consensus_key.pk
val allowed_attestations : t -> (Consensus_key.pk * int) Slot.Map.t option

Returns a map where each attester's pkh is associated to the list of its attesting slots (in decreasing order) for a given level.

val allowed_preattestations : t -> (Consensus_key.pk * int) Slot.Map.t option

Returns a map where each attester's pkh is associated to the list of its attesting slots (in decreasing order) for a given level.

Returns the set of delegates that are not allowed to bake or attest blocks; i.e., delegates which have zero frozen deposit due to a previous slashing.

type Mavryk_protocol_environment_001_PtAtLas.Error_monad.error +=
  1. | Slot_map_not_found of {
    1. loc : string;
    }

Missing pre-computed map by first slot. This error should not happen.

val current_attestation_power : t -> int

attestation power ctx returns the attestation power of the current block.

val initialize_consensus_operation : t -> allowed_attestations:(Consensus_key.pk * int) Slot.Map.t option -> allowed_preattestations:(Consensus_key.pk * int) Slot.Map.t option -> t

Initializes the map of allowed attestations and preattestations, this function must be called only once and before applying any consensus operation.

val record_attestation : t -> initial_slot:Slot.t -> power:int -> t Mavryk_protocol_environment_001_PtAtLas.Error_monad.tzresult

record_attestation ctx ~initial_slot ~power records an attestation for the current block.

The attestation should be valid in the sense that Int_map.find_opt initial_slot allowed_attestation ctx = Some (pkh, power).

val record_preattestation : t -> initial_slot:Slot.t -> power:int -> Round.t -> t Mavryk_protocol_environment_001_PtAtLas.Error_monad.tzresult

record_preattestation ctx ~initial_slot ~power round payload_hash power records a preattestation for a proposal at round with payload payload_hash.

The preattestation should be valid in the sense that Int_map.find_opt initial_slot allowed_preattestation ctx = Some (pkh, power).

forbid_delegate ctx delegate adds delegate to the set of forbidden delegates, which prevents this delegate from baking or attesting.

set_forbidden_delegate ctx delegates sets delegates as the current forbidden delegates.

val attestations_seen : t -> Slot.Set.t
val get_preattestations_quorum_round : t -> Round.t option

get_preattestations_quorum_round ctx returns None if no preattestation are included in the current block. Otherwise, return Some r where r is the round of the preattestations included in the block.

val set_preattestations_quorum_round : t -> Round.t -> t

set_preattestations_quorum_round ctx round sets the round for preattestations included in this block. This function should be called only once.

This function is only used in Full_construction mode.

val locked_round_evidence : t -> (Round.t * int) option

locked_round_evidence ctx returns the round of the recorded preattestations as well as their power.

store_attestation_branch context branch sets the "attestation branch" (see Storage.Tenderbake.Attestation_branch to branch in both the disk storage and RAM.