package octez-shell-libs

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

This module is a proxy for the shell of the protocol (for the application part). The main function of this module is apply whichs calls the one of the protocol.

type operation

This type is used to represent an operation contained in a block that we want to validate and/or apply.

Create an operation from the Operation.t by hashing it and by checking whether the protocol should check the operation's signature. The signature should always be checked unless the operation hash is already known in the known_valid_operations_set

type validation_store = {
  1. resulting_context_hash : Tezos_base.TzPervasives.Context_hash.t;
  2. timestamp : Tezos_base.TzPervasives.Time.Protocol.t;
  3. message : string option;
  4. max_operations_ttl : int;
  5. last_allowed_fork_level : Stdlib.Int32.t;
    (*

    Oldest block for which reorganizations can happen

    *)
}
val may_patch_protocol : user_activated_upgrades:Tezos_base.TzPervasives.User_activated.upgrades -> user_activated_protocol_overrides: Tezos_base.TzPervasives.User_activated.protocol_overrides -> level:Stdlib.Int32.t -> Tezos_protocol_environment.validation_result -> Tezos_protocol_environment.validation_result Lwt.t
val update_testchain_status : Tezos_protocol_environment.Context.t -> predecessor_hash:Tezos_base.TzPervasives.Block_hash.t -> Tezos_base.TzPervasives.Time.Protocol.t -> Tezos_protocol_environment.Context.t Lwt.t

check_proto_environment_version_increasing hash before after returns successfully if the environment version stays the same or increases from before to after. Otherwise, an Invalid_protocol_environment_transition error is returned.

init_test_chain must only be called on a forking block.

type operation_metadata =
  1. | Metadata of Tezos_base.TzPervasives.Bytes.t
  2. | Too_large_metadata
val operation_metadata_equal : operation_metadata -> operation_metadata -> bool
type ops_metadata =
  1. | No_metadata_hash of operation_metadata list list
  2. | Metadata_hash of (operation_metadata * Tezos_base.TzPervasives.Operation_metadata_hash.t) list list
type result = {
  1. shell_header_hash : Shell_header_hash.t;
    (*

    This field is used as a (local) unique identifier for blocks in order to implement the preapply cache mechanism.

    *)
  2. validation_store : validation_store;
  3. block_metadata : bytes * Tezos_base.TzPervasives.Block_metadata_hash.t option;
  4. ops_metadata : ops_metadata;
}
type apply_result = {
  1. result : result;
  2. cache : Tezos_protocol_environment.Context.cache;
}

check_liveness live_blocks live_operations hash ops checks there is no duplicate operation and that is not out-of-date

type apply_environment = {
  1. max_operations_ttl : int;
    (*

    time to live of an operation

    *)
  2. chain_id : Tezos_base.TzPervasives.Chain_id.t;
    (*

    chain_id of the current branch

    *)
  3. predecessor_block_header : Tezos_base.TzPervasives.Block_header.t;
    (*

    header of the predecessor block being validated

    *)
  4. predecessor_context : Tezos_protocol_environment.Context.t;
    (*

    context associated to the predecessor block

    *)
  5. predecessor_resulting_context_hash : Tezos_base.TzPervasives.Context_hash.t;
    (*

    predecessor block resulting context hash

    *)
  6. predecessor_block_metadata_hash : Tezos_base.TzPervasives.Block_metadata_hash.t option;
    (*

    hash of block header metadata of the predecessor block

    *)
  7. predecessor_ops_metadata_hash : Tezos_base.TzPervasives.Operation_metadata_list_list_hash.t option;
    (*

    hash of operation metadata of the predecessor block

    *)
  8. user_activated_upgrades : Tezos_base.TzPervasives.User_activated.upgrades;
    (*

    user activated upgrades

    *)
  9. user_activated_protocol_overrides : Tezos_base.TzPervasives.User_activated.protocol_overrides;
    (*

    user activated protocol overrides

    *)
  10. operation_metadata_size_limit : Tezos_shell_services.Shell_limits.operation_metadata_size_limit;
    (*

    size limit for operation metadata that should be written on disk

    *)
}
val apply : ?simulate:bool -> ?cached_result:(apply_result * Tezos_protocol_environment.Context.t) -> ?should_precheck:bool -> apply_environment -> cache:Tezos_protocol_environment.Context.source_of_cache -> Tezos_base.TzPervasives.Block_header.t -> operation list list -> apply_result Tezos_base.TzPervasives.tzresult Lwt.t

apply env header ops gets the protocol P of the context of the predecessor block and calls successively: 1. P.begin_application 2. P.apply 3. P.finalize_block

should_precheck when set (default), triggers the block prechecking before applying it, see precheck. If it is set to false the given block must have been prechecked.

If simulate is true, the context resulting from the application is not committed to disk using `Context.commit`, only the commit hash is computed, using `Context.hash`. Set to false by default.

val precheck : chain_id:Tezos_base.TzPervasives.Chain_id.t -> predecessor_block_header:Tezos_base.TzPervasives.Block_header.t -> predecessor_block_hash:Tezos_base.TzPervasives.Block_hash.t -> predecessor_context:Tezos_protocol_environment.Context.t -> predecessor_resulting_context_hash:Tezos_base.TzPervasives.Context_hash.t -> cache:Tezos_protocol_environment.Context.source_of_cache -> Tezos_base.TzPervasives.Block_header.t -> operation list list -> unit Tezos_base.TzPervasives.tzresult Lwt.t

precheck chain_id ~predecessor_block_header ~predecessor_block_hash ~predecessor_context ~predecessor_resulting_context_hash ~cache header ops gets the protocol P of the context of the predecessor block and calls successively: 1. P.begin_validate 2. P.validate_operation 3. P.finalize_validation

val preapply : chain_id:Tezos_base.TzPervasives.Chain_id.t -> user_activated_upgrades:Tezos_base.User_activated.upgrades -> user_activated_protocol_overrides: Tezos_base.User_activated.protocol_overrides -> operation_metadata_size_limit: Tezos_shell_services.Shell_limits.operation_metadata_size_limit -> timestamp:Tezos_base.TzPervasives.Time.Protocol.t -> protocol_data:bytes -> live_blocks:Tezos_base.TzPervasives.Block_hash.Set.t -> live_operations:Tezos_base.TzPervasives.Operation_hash.Set.t -> predecessor_context:Tezos_protocol_environment.Context.t -> predecessor_resulting_context_hash:Tezos_base.TzPervasives.Context_hash.t -> predecessor_shell_header:Tezos_base.TzPervasives.Block_header.shell_header -> predecessor_hash:Tezos_base.TzPervasives.Block_hash.t -> predecessor_max_operations_ttl:int -> predecessor_block_metadata_hash: Tezos_base.TzPervasives.Block_metadata_hash.t option -> predecessor_ops_metadata_hash: Tezos_base.TzPervasives.Operation_metadata_list_list_hash.t option -> operation list list -> ((Tezos_base.TzPervasives.Block_header.shell_header * Tezos_base.TzPervasives.error Tezos_shell_services.Preapply_result.t list) * (apply_result * Tezos_protocol_environment.Context.t)) Tezos_base.TzPervasives.tzresult Lwt.t
val recompute_metadata : chain_id:Tezos_base.TzPervasives.Chain_id.t -> predecessor_block_header:Tezos_base.TzPervasives.Block_header.t -> predecessor_context:Tezos_protocol_environment.Context.t -> predecessor_block_metadata_hash: Tezos_base.TzPervasives.Block_metadata_hash.t option -> predecessor_ops_metadata_hash: Tezos_base.TzPervasives.Operation_metadata_list_list_hash.t option -> block_header:Tezos_base.TzPervasives.Block_header.t -> operations: operation Tezos_base.TzPervasives.trace Tezos_base.TzPervasives.trace -> cache:Tezos_protocol_environment.Context.source_of_cache -> ((bytes * Tezos_base.TzPervasives.Block_metadata_hash.t option) * ops_metadata) Tezos_base.TzPervasives.tzresult Lwt.t

Hypothesis: we assume that the given block has already been validated -- E.g. by calling precheck.

OCaml

Innovation. Community. Security.