ligo/src/proto/environment/updater.mli
Grégoire Henry 245fa66140 Shell: Split the operations list out of the (minimal) block header.
The minimal header now (classically) contains the root of a Merkle tree,
wrapping a list of lists of operations. Currently, the validator only
accept a single list of operations, but the 3+pass validator will
requires at least two lists.
2017-03-31 01:19:34 +02:00

147 lines
5.3 KiB
OCaml

(** Tezos Protocol Environment - Protocol Implementation Updater *)
open Hash
module Net_id : sig
type t
val encoding : t Data_encoding.t
end
type shell_operation = {
net_id: Net_id.t ;
}
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
(** The version agnostic toplevel structure of blocks. *)
type shell_block = {
net_id: Net_id.t ;
(** 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. *)
operations: Operation_list_list_hash.t ;
(** The sequence of operations. *)
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. *)
}
val shell_block_encoding: shell_block Data_encoding.t
type raw_block = {
shell: shell_block ;
proto: MBytes.t ;
}
val raw_block_encoding: raw_block Data_encoding.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;
(** Operations which triggered a context independent, unavoidable
error (e.g. invalid signature). *)
branch_refused: 'error list Operation_hash.Map.t;
(** 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;
(** 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. *)
type block
(** The maximum size of block headers in bytes *)
val max_block_length : int
(** 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
{!block} type. It does not have access to the storage
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
(** The parsing / preliminary validation function for
operations. Similar to {!parse_block}. *)
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
pre-decomposed by {!parse_block} and {!parse_operation}. *)
val apply :
Context.t -> block -> operation list -> Context.t tzresult Lwt.t
(** 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
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 ->
(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
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