ligo/src/proto/environment/updater.mli

146 lines
5.2 KiB
OCaml
Raw Normal View History

2016-09-08 21:13:10 +04:00
(** Tezos Protocol Environment - Protocol Implementation Updater *)
open Hash
module Net_id : sig
type t
val encoding : t Data_encoding.t
end
2016-09-08 21:13:10 +04:00
type shell_operation = {
net_id: Net_id.t ;
2016-09-08 21:13:10 +04:00
}
val shell_operation_encoding: shell_operation Data_encoding.t
type raw_operation = {
shell: shell_operation ;
proto: MBytes.t ;
}
val raw_operation_encoding: raw_operation Data_encoding.t
2016-09-08 21:13:10 +04:00
(** The version agnostic toplevel structure of blocks. *)
2016-10-19 22:47:04 +04:00
type shell_block = {
net_id: Net_id.t ;
2016-09-08 21:13:10 +04:00
(** The genesis of the chain this block belongs to. *)
predecessor: Block_hash.t ;
(** The preceding block in the chain. *)
timestamp: Time.t ;
(** The date at which this block has been forged. *)
fitness: MBytes.t list ;
(** The announced score of the block. As a sequence of sequences
of unsigned bytes. Ordered by length and then by contents
lexicographically. *)
operations: Operation_hash.t list ;
(** The sequence of operations. *)
}
2016-10-19 22:47:04 +04:00
val shell_block_encoding: shell_block Data_encoding.t
2016-09-08 21:13:10 +04:00
2016-10-19 22:47:04 +04:00
type raw_block = {
shell: shell_block ;
2016-09-08 21:13:10 +04:00
proto: MBytes.t ;
}
(** Result of the {!PROTOCOL.preapply} function of the protocol for
discriminating cacheable operations from droppable ones. *)
type 'error preapply_result =
{ applied: Operation_hash.t list;
(** Operations that where successfully applied. *)
refused: 'error list Operation_hash.Map.t;
2016-09-08 21:13:10 +04:00
(** Operations which triggered a context independent, unavoidable
error (e.g. invalid signature). *)
branch_refused: 'error list Operation_hash.Map.t;
2016-09-08 21:13:10 +04:00
(** Operations which triggered an error that might not arise in a
different context (e.g. past account counter, insufficent
balance). *)
branch_delayed: 'error list Operation_hash.Map.t;
2016-09-08 21:13:10 +04:00
(** Operations which triggered an error that might not arise in a
future update of this context (e.g. futur account counter). *) }
(** This is the signature of a Tezos protocol implementation. It has
access to the Environment module. *)
module type PROTOCOL = sig
type error = ..
type 'a tzresult = ('a, error list) result
(** The version specific type of operations. *)
type operation
(** The maximum size of operations in bytes *)
val max_operation_data_length : int
(** The version specific part of blocks. *)
2016-10-19 22:47:04 +04:00
type block
2016-09-08 21:13:10 +04:00
(** The maximum size of block headers in bytes *)
2016-10-19 22:47:04 +04:00
val max_block_length : int
2016-09-08 21:13:10 +04:00
(** The maximum *)
val max_number_of_operations : int
(** The parsing / preliminary validation function for blocks. Its
role is to check that the raw header is well formed, and to
produce a pre-decomposed value of the high level, protocol defined
2016-10-19 22:47:04 +04:00
{!block} type. It does not have access to the storage
2016-09-08 21:13:10 +04:00
context. It may store the hash and raw bytes for later signature
verification by {!apply} or {!preapply}. The timestamp of the
predecessor block is also provided for early delay checks. *)
val parse_block : raw_block -> Time.t -> block tzresult
2016-09-08 21:13:10 +04:00
(** The parsing / preliminary validation function for
2016-10-19 22:47:04 +04:00
operations. Similar to {!parse_block}. *)
2016-09-08 21:13:10 +04:00
val parse_operation :
Operation_hash.t -> raw_operation -> operation tzresult
(** The main protocol function that validates blocks. It receives the
block header and the list of associated operations, as
2016-10-19 22:47:04 +04:00
pre-decomposed by {!parse_block} and {!parse_operation}. *)
2016-09-08 21:13:10 +04:00
val apply :
2016-10-19 22:47:04 +04:00
Context.t -> block -> operation list -> Context.t tzresult Lwt.t
2016-09-08 21:13:10 +04:00
(** The auxiliary protocol entry point that validates pending
operations out of blocks. This function tries to apply the all
operations in the given order, and returns which applications have
suceeded and which ones have failed. The first two parameters
are a context in which to apply the operations and the hash of the
preceding block. This function is used by the shell for accepting or
2016-09-08 21:13:10 +04:00
dropping operations, as well as the mining client to check that a
sequence of operations forms a valid block. *)
val preapply :
Context.t -> Block_hash.t -> bool -> operation list ->
2016-09-08 21:13:10 +04:00
(Context.t * error preapply_result) tzresult Lwt.t
(** The list of remote procedures exported by this implementation *)
val rpc_services : Context.t RPC.directory
val configure_sandbox :
Context.t -> Data_encoding.json option -> Context.t tzresult Lwt.t
end
(** An OCaml source component of a protocol implementation. *)
type component = {
(** The OCaml module name. *)
name : string ;
(** The OCaml interface source code *)
interface : string option ;
(** The OCaml source code *)
implementation : string ;
}
(** Takes a version hash, a list of OCaml components in compilation
order. The last element must be named [protocol] and respect the
[protocol.ml] interface. Tries to compile it and returns true
2016-09-08 21:13:10 +04:00
if the operation was successful. *)
val compile : Protocol_hash.t -> component list -> bool Lwt.t
(** Activates a given protocol version from a given context. This
means that the context used for the next block will use this
version (this is not an immediate change). The version must have
been previously compiled successfully. *)
val activate : Context.t -> Protocol_hash.t -> Context.t Lwt.t
val set_test_protocol: Context.t -> Protocol_hash.t -> Context.t Lwt.t
val fork_test_network: Context.t -> Context.t Lwt.t