ligo/src/proto/alpha/baking.mli

120 lines
4.9 KiB
OCaml
Raw Normal View History

2016-09-08 19:13:10 +02:00
(**************************************************************************)
(* *)
2017-11-14 00:36:14 +01:00
(* Copyright (c) 2014 - 2017. *)
2016-09-08 19:13:10 +02:00
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
(* *)
(* All rights reserved. No warranty, explicit or implicit, provided. *)
(* *)
(**************************************************************************)
open Tezos_context
open Misc
type error += Invalid_fitness_gap of int64 * int64 (* `Permanent *)
type error += Invalid_endorsement_slot of int * int (* `Permanent *)
type error += Timestamp_too_early of Timestamp.t * Timestamp.t (* `Permanent *)
type error += Wrong_delegate of public_key_hash * public_key_hash (* `Permanent *)
2017-11-01 04:07:33 -07:00
type error += Cannot_pay_baking_bond (* `Permanent *)
type error += Cannot_pay_endorsement_bond (* `Permanent *)
val paying_priorities: context -> int list
2016-09-08 19:13:10 +02:00
2017-03-08 18:47:01 +01:00
(** [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
2017-03-08 18:47:01 +01:00
mine. Fail with [Invalid_slot_durations_constant] if the minimal
time cannot be computed. *)
2017-11-14 04:33:50 +01:00
val minimal_time: context -> int -> Time.t -> Time.t tzresult Lwt.t
(** [pay_baking_bond: cxt baker] Debit the baking bond (See
!Constants.baking_bond_cost) from the default account of the
[baker]. No bond is debited if the baking priority of this block is
greater than the maximum number of paying baking in the network
(meaning that n. bakers skipped their turn).
2016-09-08 19:13:10 +02:00
2017-11-14 04:33:50 +01:00
Raise an error if the baker account does not have enough
funds to claim baking rights. *)
2017-11-01 04:07:33 -07:00
val pay_baking_bond:
2016-09-08 19:13:10 +02:00
context ->
Block_header.proto_header ->
2016-09-08 19:13:10 +02:00
public_key_hash ->
context tzresult Lwt.t
2017-11-14 04:33:50 +01:00
(** [pay_endorsement_bond: cxt baker] Debit the endorsement bond
(See !Constants.endorsement_bond_cost) from the default account
of the [baker]. Raise an error if the baker account does not
have enough funds to claim endorsement rights *)
2016-09-08 19:13:10 +02:00
val pay_endorsement_bond:
context -> public_key_hash -> (context * Tez.t) tzresult Lwt.t
2017-11-01 04:07:33 -07:00
(** [check_baking_rights ctxt block pred_timestamp] verifies that:
2016-09-08 19:13:10 +02:00
* the contract that owned the roll at cycle start has the block signer as delegate.
* the timestamp is coherent with the announced slot.
2017-11-01 04:07:33 -07:00
* the bond have been payed if the slot is below [Constants.first_free_baking_slot].
2016-09-08 19:13:10 +02:00
*)
2017-11-01 04:07:33 -07:00
val check_baking_rights:
context -> Block_header.proto_header -> Time.t ->
public_key_hash tzresult Lwt.t
2016-09-08 19:13:10 +02:00
(** [check_signing_rights c slot contract] verifies that:
* the slot is valid;
* [contract] owned, at cycle start, the roll that has the right to sign
for the slot and the current level.
*)
val check_signing_rights:
context -> int -> public_key_hash -> unit tzresult Lwt.t
2017-11-01 04:07:33 -07:00
(** If this priority should have payed the bond it is the base baking
2016-09-08 19:13:10 +02:00
reward and the bond, or just the base reward otherwise *)
2017-11-01 04:07:33 -07:00
val base_baking_reward: context -> priority:int -> Tez.t
2016-09-08 19:13:10 +02:00
2017-11-14 04:33:50 +01:00
(** Returns the endorsement reward calculated w.r.t a given priotiry. *)
val endorsement_reward: block_priority:int -> Tez.t tzresult Lwt.t
2016-09-08 19:13:10 +02:00
2017-11-01 04:07:33 -07:00
(** [baking_priorities ctxt level] is the lazy list of contract's
2017-03-08 18:47:01 +01:00
public key hashes that are allowed to mine for [level]. *)
2017-11-14 04:33:50 +01:00
val baking_priorities:
context -> Level.t -> public_key_hash lazy_list
2017-03-08 18:47:01 +01:00
2017-11-14 04:33:50 +01:00
(** [endorsement_priorities ctxt level] is the lazy list of contract's
public key hashes that are allowed to endorse for [level]. *)
2016-09-08 19:13:10 +02:00
val endorsement_priorities:
context -> Level.t -> public_key_hash lazy_list
2017-11-14 04:33:50 +01:00
(** [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 mine for [level]. If
[?max_priority] is [None], a sensible number of priorities is
returned. *)
2017-11-01 04:07:33 -07:00
val first_baking_priorities:
2016-09-08 19:13:10 +02:00
context ->
?max_priority:int ->
2016-09-08 19:13:10 +02:00
public_key_hash ->
Level.t ->
int list tzresult Lwt.t
2016-09-08 19:13:10 +02:00
val first_endorsement_slots:
context ->
?max_priority:int ->
2016-09-08 19:13:10 +02:00
public_key_hash ->
Level.t -> int list tzresult Lwt.t
2016-09-08 19:13:10 +02:00
2017-11-14 04:33:50 +01:00
(** [check_signature ctxt block id] check if the block is signed with
the given key *)
2016-09-08 19:13:10 +02:00
val check_signature:
2017-04-20 15:21:10 +02:00
context -> Block_header.t -> public_key_hash -> unit tzresult Lwt.t
2016-09-08 19:13:10 +02:00
val check_hash: Block_hash.t -> int64 -> bool
2017-11-14 04:33:50 +01:00
(** verify if the proof of work stamp is valid *)
2016-09-08 19:13:10 +02:00
val check_proof_of_work_stamp:
2017-04-20 15:21:10 +02:00
context -> Block_header.t -> unit tzresult Lwt.t
2016-09-08 19:13:10 +02:00
2017-11-14 04:33:50 +01:00
(** check if the gap between the fitness of the current context
and the given block is within the protocol parameters *)
2016-09-08 19:13:10 +02:00
val check_fitness_gap:
2017-04-20 15:21:10 +02:00
context -> Block_header.t -> unit tzresult Lwt.t
2016-09-08 19:13:10 +02:00
val dawn_of_a_new_cycle: context -> Cycle.t option tzresult Lwt.t