Module Operation_core.Consensus

type t

A representation of a consensus operation.

val consensus : use_legacy_name:bool -> kind:consensus_kind -> slot:int -> level:int -> round:int -> block_payload_hash:string -> t

consensus ~kind ~use_legacy_name ~level ~round ~slot ~block_payload_hash crafts a consensus operation with the kind at level on the round with the slot and block_payload_hash. If use_legacy_name is set, the kind field in the crafted JSON will be "(pre)endorsement" instead of "(pre)attestation".

val preattestation : use_legacy_name:bool -> slot:int -> level:int -> round:int -> block_payload_hash:string -> t

preattestation ?use_legacy_name ~level ~round ~slot ~block_payload_hash crafts a preattestation operation at level on the round with the slot and block_payload_hash. If use_legacy_name is set, the kind field in the crafted JSON will be "preendorsement" instead of "preattestation".

val attestation : use_legacy_name:bool -> slot:int -> level:int -> round:int -> block_payload_hash:string -> ?dal_attestation:bool array -> unit -> t

attestation ?use_legacy_name ~level ~round ~slot ~block_payload_hash ?dal_attestation () crafts an attestation operation at the given level on the given round with the given slot and block_payload_hash and optionally the given dal_attestation. If use_legacy_name is set, the kind field in the crafted JSON will be "endorsement" instead of "attestation".

val kind_to_string : consensus_kind -> use_legacy_name:bool -> string

kind_to_string kind ~use_legacy_name returns the name of the kind. If use_legacy_name is set, the name corresponding to the kind will be "(pre)endorsement" instead of "(pre)attestation".

val operation : ?branch:string -> ?chain_id:string -> signer:Account.key -> t -> Client.t -> operation Lwt.t

operation constructs an operation from a consensus operation. the client is used to fetch the branch and the chain_id.

val inject : ?request:[ `Inject | `Notify ] -> ?force:bool -> ?branch:string -> ?chain_id:string -> ?error:Tezt_wrapper.Base.rex -> signer:Account.key -> t -> Client.t -> [ `OpHash of string ] Lwt.t

A wrapper for inject with consensus operations. The client is used to get all the data that was not provided if it can be recovered via RPCs. Mainly those are the branch and the chain_id.

val get_slots : level:int -> Client.t -> Tezt_wrapper.JSON.t Lwt.t

Retrieves the attestation slots at level by calling the GET /chains/<chain>/blocks/<block>/helpers/validators RPC.

val first_slot : slots_json:Tezt_wrapper.JSON.t -> Account.key -> int

Returns the first slot of the provided delegate in the slots_json that describes all attestation rights at some level.

Causes the test to fail if the delegate is not found.

val get_block_payload_hash : ?block:string -> Client.t -> string Lwt.t

Calls the GET /chains/<chain>/blocks/<block>/header RPC and extracts the head block's payload hash from the result.