2018-06-29 16:08:08 +04:00
|
|
|
(*****************************************************************************)
|
|
|
|
(* *)
|
|
|
|
(* Open Source License *)
|
|
|
|
(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
|
|
|
|
(* *)
|
|
|
|
(* Permission is hereby granted, free of charge, to any person obtaining a *)
|
|
|
|
(* copy of this software and associated documentation files (the "Software"),*)
|
|
|
|
(* to deal in the Software without restriction, including without limitation *)
|
|
|
|
(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)
|
|
|
|
(* and/or sell copies of the Software, and to permit persons to whom the *)
|
|
|
|
(* Software is furnished to do so, subject to the following conditions: *)
|
|
|
|
(* *)
|
|
|
|
(* The above copyright notice and this permission notice shall be included *)
|
|
|
|
(* in all copies or substantial portions of the Software. *)
|
|
|
|
(* *)
|
|
|
|
(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)
|
|
|
|
(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)
|
|
|
|
(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)
|
|
|
|
(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)
|
|
|
|
(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)
|
|
|
|
(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)
|
|
|
|
(* DEALINGS IN THE SOFTWARE. *)
|
|
|
|
(* *)
|
|
|
|
(*****************************************************************************)
|
2016-09-08 21:13:10 +04:00
|
|
|
|
2018-01-29 04:06:47 +04:00
|
|
|
open Proto_alpha
|
2018-02-11 22:17:39 +04:00
|
|
|
open Alpha_context
|
2018-01-29 04:06:47 +04:00
|
|
|
|
2018-08-22 18:44:55 +04:00
|
|
|
module State : sig
|
|
|
|
val get:
|
|
|
|
#Client_context.wallet ->
|
|
|
|
Signature.Public_key_hash.t ->
|
|
|
|
Raw_level.t option tzresult Lwt.t
|
|
|
|
|
|
|
|
val record:
|
|
|
|
#Client_context.wallet ->
|
|
|
|
Signature.Public_key_hash.t ->
|
|
|
|
Raw_level.t ->
|
|
|
|
unit tzresult Lwt.t
|
|
|
|
end
|
|
|
|
|
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:
|
2018-02-16 21:10:18 +04:00
|
|
|
#Proto_alpha.full ->
|
2016-09-08 21:13:10 +04:00
|
|
|
?force:bool ->
|
2018-04-16 02:44:24 +04:00
|
|
|
?chain:Chain_services.chain ->
|
2018-08-23 18:59:38 +04:00
|
|
|
?seed_nonce_hash:Nonce_hash.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 ->
|
2018-05-26 15:14:33 +04:00
|
|
|
src_sk:Client_keys.sk_uri ->
|
2018-01-31 19:39:18 +04:00
|
|
|
Operation.raw 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:
|
2018-02-16 21:10:18 +04:00
|
|
|
#Proto_alpha.full ->
|
2018-04-16 02:44:24 +04:00
|
|
|
?chain:Chain_services.chain ->
|
2016-09-08 21:13:10 +04:00
|
|
|
?force:bool ->
|
2018-04-30 21:06:06 +04:00
|
|
|
?operations: Operation.packed list ->
|
2016-09-08 21:13:10 +04:00
|
|
|
?best_effort:bool ->
|
|
|
|
?sort:bool ->
|
2018-11-22 23:37:38 +04:00
|
|
|
?minimal_fees: Tez.t ->
|
2018-12-02 01:43:17 +04:00
|
|
|
?minimal_nanotez_per_gas_unit: Z.t ->
|
|
|
|
?minimal_nanotez_per_byte: Z.t ->
|
2018-11-22 23:37:38 +04:00
|
|
|
?await_endorsements: bool ->
|
2016-09-08 21:13:10 +04:00
|
|
|
?timestamp:Time.t ->
|
2018-08-08 18:34:32 +04:00
|
|
|
?mempool:string ->
|
2018-08-08 17:48:59 +04:00
|
|
|
?context_path:string ->
|
2018-02-24 01:22:10 +04:00
|
|
|
?seed_nonce_hash:Nonce_hash.t ->
|
2018-08-23 18:59:38 +04:00
|
|
|
priority:[`Set of int | `Auto of (public_key_hash * int option)] ->
|
2018-05-26 15:14:33 +04:00
|
|
|
src_sk:Client_keys.sk_uri ->
|
2018-08-23 18:59:38 +04:00
|
|
|
Block_services.block ->
|
2016-09-08 21:13:10 +04:00
|
|
|
Block_hash.t tzresult Lwt.t
|
2018-08-23 18:59:38 +04:00
|
|
|
(** [forge_block cctxt ?fee_threshold ?force ?operations ?best_effort
|
2017-03-14 19:32:29 +04:00
|
|
|
?sort ?timestamp ?max_priority ?priority ~seed_nonce ~src_sk
|
2018-08-23 18:59:38 +04:00
|
|
|
pk_hash parent_blk] injects a block in the node. In addition of inject_block,
|
2017-03-14 19:32:29 +04:00
|
|
|
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.
|
2018-06-19 11:28:35 +04:00
|
|
|
|
2018-08-08 15:35:12 +04:00
|
|
|
* Fee Threshold: If [?fee_threshold] is given, operations with fees lower than it
|
2018-06-19 11:28:35 +04:00
|
|
|
are not added to the block.
|
2017-03-14 19:32:29 +04:00
|
|
|
*)
|
2016-09-08 21:13:10 +04:00
|
|
|
|
|
|
|
val create:
|
2018-02-16 21:10:18 +04:00
|
|
|
#Proto_alpha.full ->
|
2018-11-22 23:37:38 +04:00
|
|
|
?minimal_fees: Tez.t ->
|
2018-12-02 01:43:17 +04:00
|
|
|
?minimal_nanotez_per_gas_unit: Z.t ->
|
|
|
|
?minimal_nanotez_per_byte: Z.t ->
|
2018-11-22 23:37:38 +04:00
|
|
|
?await_endorsements: bool ->
|
2016-09-08 21:13:10 +04:00
|
|
|
?max_priority: int ->
|
2018-06-14 14:16:17 +04:00
|
|
|
context_path: string ->
|
2016-09-08 21:13:10 +04:00
|
|
|
public_key_hash list ->
|
2018-04-16 02:44:24 +04:00
|
|
|
Client_baking_blocks.block_info 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:
|
2018-02-16 21:10:18 +04:00
|
|
|
#Proto_alpha.full ->
|
2017-02-14 13:33:34 +04:00
|
|
|
?force:bool ->
|
2018-04-16 02:44:24 +04:00
|
|
|
?chain:Chain_services.chain ->
|
2018-02-11 22:17:39 +04:00
|
|
|
Block_services.block ->
|
2017-02-14 13:33:34 +04:00
|
|
|
(Block_hash.t * (Raw_level.t * Nonce.t)) list tzresult Lwt.t
|
2018-11-07 19:30:18 +04:00
|
|
|
|
|
|
|
val filter_outdated_nonces:
|
|
|
|
#Proto_alpha.full ->
|
|
|
|
?chain:Block_services.chain ->
|
|
|
|
Shell_services.block ->
|
|
|
|
unit tzresult Lwt.t
|