2016-09-08 21:13:10 +04:00
|
|
|
(**************************************************************************)
|
|
|
|
(* *)
|
2017-11-14 03:36:14 +04:00
|
|
|
(* Copyright (c) 2014 - 2017. *)
|
2016-09-08 21:13:10 +04:00
|
|
|
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
|
|
|
|
(* *)
|
|
|
|
(* All rights reserved. No warranty, explicit or implicit, provided. *)
|
|
|
|
(* *)
|
|
|
|
(**************************************************************************)
|
|
|
|
|
2018-01-29 04:06:47 +04:00
|
|
|
open Proto_alpha
|
|
|
|
open Tezos_context
|
|
|
|
|
2016-09-08 21:13:10 +04:00
|
|
|
val generate_seed_nonce: unit -> Nonce.t
|
2017-03-08 21:47:01 +04:00
|
|
|
(** [generate_seed_nonce ()] is a random nonce that is typically used
|
|
|
|
in block headers. When baking, bakers generate random nonces whose
|
|
|
|
hash is commited in the block they bake. They will typically
|
|
|
|
reveal the aforementionned nonce during the next cycle. *)
|
2016-09-08 21:13:10 +04:00
|
|
|
|
|
|
|
val inject_block:
|
2017-12-07 20:43:21 +04:00
|
|
|
#Client_rpcs.ctxt ->
|
2016-09-08 21:13:10 +04:00
|
|
|
?force:bool ->
|
2017-11-14 06:14:26 +04:00
|
|
|
?net_id:Net_id.t ->
|
2017-04-27 03:01:05 +04:00
|
|
|
shell_header:Block_header.shell_header ->
|
2016-09-08 21:13:10 +04:00
|
|
|
priority:int ->
|
2017-04-27 03:01:05 +04:00
|
|
|
seed_nonce_hash:Nonce_hash.t ->
|
2018-02-01 20:31:08 +04:00
|
|
|
src_sk:Client_keys.sk_locator ->
|
2017-11-27 09:13:12 +04:00
|
|
|
Tezos_base.Operation.t list list ->
|
2016-09-08 21:13:10 +04:00
|
|
|
Block_hash.t tzresult Lwt.t
|
2017-03-08 21:47:01 +04:00
|
|
|
(** [inject_block cctxt blk ?force ~priority ~timestamp ~fitness
|
|
|
|
~seed_nonce ~src_sk ops] tries to inject a block in the node. If
|
|
|
|
[?force] is set, the fitness check will be bypassed. [priority]
|
2017-11-01 15:07:33 +04:00
|
|
|
will be used to compute the baking slot (level is
|
2017-03-08 21:47:01 +04:00
|
|
|
precomputed). [src_sk] is used to sign the block header. *)
|
2016-09-08 21:13:10 +04:00
|
|
|
|
2017-04-27 03:01:05 +04:00
|
|
|
type error +=
|
2017-11-27 09:13:12 +04:00
|
|
|
| Failed_to_preapply of Tezos_base.Operation.t * error list
|
2017-04-27 03:01:05 +04:00
|
|
|
|
2016-09-08 21:13:10 +04:00
|
|
|
val forge_block:
|
2017-12-07 20:43:21 +04:00
|
|
|
#Client_rpcs.ctxt ->
|
2016-09-08 21:13:10 +04:00
|
|
|
Client_proto_rpcs.block ->
|
|
|
|
?force:bool ->
|
2017-11-27 09:13:12 +04:00
|
|
|
?operations:Tezos_base.Operation.t list ->
|
2016-09-08 21:13:10 +04:00
|
|
|
?best_effort:bool ->
|
|
|
|
?sort:bool ->
|
|
|
|
?timestamp:Time.t ->
|
2017-05-08 23:35:29 +04:00
|
|
|
priority:[`Set of int | `Auto of (public_key_hash * int option * bool)] ->
|
2017-04-27 03:01:05 +04:00
|
|
|
seed_nonce_hash:Nonce_hash.t ->
|
2018-02-01 20:31:08 +04:00
|
|
|
src_sk:Client_keys.sk_locator ->
|
2017-03-08 21:47:01 +04:00
|
|
|
unit ->
|
2016-09-08 21:13:10 +04:00
|
|
|
Block_hash.t tzresult Lwt.t
|
2017-03-14 19:32:29 +04:00
|
|
|
(** [forge_block cctxt parent_blk ?force ?operations ?best_effort
|
|
|
|
?sort ?timestamp ?max_priority ?priority ~seed_nonce ~src_sk
|
|
|
|
pk_hash] injects a block in the node. In addition of inject_block,
|
|
|
|
it will:
|
|
|
|
|
|
|
|
* Operations: If [?operations] is [None], it will get pending
|
|
|
|
operations and add them to the block. Otherwise, provided
|
|
|
|
operations will be used. In both cases, they will be validated.
|
|
|
|
|
2017-11-01 19:42:37 +04:00
|
|
|
* Baking priority: If [`Auto] is used, it will be computed from
|
2017-03-14 19:32:29 +04:00
|
|
|
the public key hash of the specified contract, optionally capped
|
2017-11-01 15:07:33 +04:00
|
|
|
to a maximum value, and optionnaly restricting for free baking slot.
|
2017-03-14 19:32:29 +04:00
|
|
|
|
|
|
|
* Timestamp: If [?timestamp] is set, and is compatible with the
|
2017-11-01 15:07:33 +04:00
|
|
|
computed baking priority, it will be used. Otherwise, it will be
|
|
|
|
set at the best baking priority.
|
2017-03-14 19:32:29 +04:00
|
|
|
*)
|
2016-09-08 21:13:10 +04:00
|
|
|
|
|
|
|
module State : sig
|
2016-12-03 16:05:02 +04:00
|
|
|
val get_block:
|
2017-11-07 20:38:11 +04:00
|
|
|
Client_commands.full_context ->
|
2016-12-03 16:05:02 +04:00
|
|
|
Raw_level.t -> Block_hash.t list tzresult Lwt.t
|
|
|
|
val record_block:
|
2017-11-07 20:38:11 +04:00
|
|
|
Client_commands.full_context ->
|
2016-12-03 16:05:02 +04:00
|
|
|
Raw_level.t -> Block_hash.t -> Nonce.t -> unit tzresult Lwt.t
|
2016-09-08 21:13:10 +04:00
|
|
|
end
|
|
|
|
|
|
|
|
val create:
|
2017-11-07 20:38:11 +04:00
|
|
|
Client_commands.full_context ->
|
2016-09-08 21:13:10 +04:00
|
|
|
?max_priority: int ->
|
|
|
|
public_key_hash list ->
|
2017-11-01 15:07:33 +04:00
|
|
|
Client_baking_blocks.block_info list tzresult Lwt_stream.t ->
|
|
|
|
Client_baking_operations.valid_endorsement tzresult Lwt_stream.t ->
|
2017-04-05 01:35:41 +04:00
|
|
|
unit tzresult Lwt.t
|
2017-02-14 13:33:34 +04:00
|
|
|
|
|
|
|
val get_unrevealed_nonces:
|
2017-11-07 20:38:11 +04:00
|
|
|
Client_commands.full_context ->
|
2017-02-14 13:33:34 +04:00
|
|
|
?force:bool ->
|
|
|
|
Client_proto_rpcs.block ->
|
|
|
|
(Block_hash.t * (Raw_level.t * Nonce.t)) list tzresult Lwt.t
|