Module Operation.Consensus

type t

A representation of a consensus operation.

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

consensus ~kind ~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.

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

preattestation ~level ~round ~slot ~block_payload_hash crafts a preattestation operation at level on the round with the slot and block_payload_hash.

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

attestation ~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.

val kind_to_string : consensus_kind -> string

kind_to_string kind returns the name of the kind.

val operation : ?branch:string -> ?chain_id:string -> ?signer_companion:Account.key -> 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 -> protocol:Protocol.t -> ?signer_companion:Account.key -> 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 -> (string * int list) list Lwt.t

Retrieves the attestation slots at level by calling the GET /chains/<chain>/blocks/<block>/helpers/validators RPC. Returns an association list that maps a public key hash to the owned slot list

val get_slots_by_consensus_key : level:int -> Client.t -> (string * int list) list Lwt.t

Same as get_slots but maps a consensus key to the owned slot list.

val first_slot : slots:(string * int list) list -> Account.key -> int

Returns the first slot of the provided delegate in the slots association list 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.

val get_branch : attested_level:int -> Client.t -> string Lwt.t

Calls the GET /chains/main/blocks/<block>/hash RPC with <block> = attested_level - 2. The returned block hash can be used as the branch field of a consensus operation for attested_level.

val preattest_for : ?error:Tezt_wrapper.Base.rex -> protocol:Protocol.t -> slot:int -> level:int -> round:int -> block_payload_hash:string -> ?branch:string -> Account.key -> Client.t -> [ `OpHash of string ] Lwt.t

Forge and inject a preattestation for the given account.

val attest_for : ?error:Tezt_wrapper.Base.rex -> protocol:Protocol.t -> slot:int -> level:int -> round:int -> block_payload_hash:string -> ?branch:string -> ?dal_attestation:bool array -> ?companion_key:Account.key -> Account.key -> Client.t -> [ `OpHash of string ] Lwt.t

Forge and inject an attestation for the given account.