package octez-shell-libs

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

The module for handling block-related operations such as storing and reading data associated to a single block.

type t

The abstract type for a block.

type block = t

The type alias for a block.

type metadata = Tezos_store_shared.Block_repr.metadata = {
  1. message : string option;
  2. max_operations_ttl : int;
  3. last_allowed_fork_level : Int32.t;
  4. block_metadata : Tezos_base.TzPervasives.Bytes.t;
  5. operations_metadata : Tezos_validation.Block_validation.operation_metadata list list;
}

The type for block's metadata.

val equal : block -> block -> bool

equal b1 b2 tests the equality between b1 and b2. Warning only block hashes are compared.

is_known_valid chain_store bh tests that the block bh is known and valid in chain_store (i.e. the block is present in the block store).

val is_known_invalid : chain_store -> Tezos_base.TzPervasives.Block_hash.t -> bool Lwt.t

is_known_invalid chain_store bh tests that the block bh is invalid in chain_store (i.e. the block is present in the invalid blocks file).

val is_known_validated : chain_store -> Tezos_base.TzPervasives.Block_hash.t -> bool Lwt.t

is_known_validated chain_store bh tests that the block bh is validated in chain_store (i.e. the block is present in the validated block cache).

is_known chain_store bh tests that the block bh is either known valid or known invalid in chain_store.

is_genesis chain_store bh tests that the block bh is the genesis initialized in chain_store.

validity chain_store bh computes the Block_locator.validity (Unknown, Known_valid or Known_invalid) for the block bh in chain_store.

read_block chain_store ?distance bh tries to read in the chain_store the block bh or the predecessing block at the offset distance of bh. By default, distance is 0.

val read_block_opt : chain_store -> ?distance:int -> Tezos_base.TzPervasives.Block_hash.t -> block option Lwt.t

read_block_opt chain_store ?distance bh optional version of read_block.

val read_block_by_level : chain_store -> int32 -> block Tezos_base.TzPervasives.tzresult Lwt.t

read_block_by_level chain_store level reads in the chain_store the block at level. The block retrieved will be the (level(current_head) - level)-th predecessor of the chain_store's current head.

val read_block_by_level_opt : chain_store -> int32 -> block option Lwt.t

read_block_by_level_opt chain_store level optional version of read_block_by_level.

read_block_metadata ?distance chain_store bh reads in the chain_store the metadata associated to the block bh or its distance-th predecessor if given. Returns None otherwise. By default, distance is 0.

Warning If the block is already read, prefer the usage of get_block_metadata which will memoize the result.

val read_block_metadata_opt : ?distance:int -> chain_store -> Tezos_base.TzPervasives.Block_hash.t -> metadata option Lwt.t

read_block_metadata_opt ?distance chain_store bh same as read_block_metadata but returns None in case of errors.

get_block_metadata chain_store block reads in the chain_store the metadata associated to the block. Returns None if the metadata cannot be retrieved. This function also memoize the result in the block structure so subsequent calls will be disk I/O free.

val get_block_metadata_opt : chain_store -> block -> metadata option Lwt.t

get_block_metadata_opt chain_store block optional version of get_block_metadata

read_predecessor chain_store block reads in the chain_store the direct predecessor of block. Returns None if it cannot be found.

val read_predecessor_opt : chain_store -> block -> block option Lwt.t

read_predecessor_opt chain_store block optional version of read_predecessor.

read_predecessor_of_hash chain_store bh reads in chain_store the predecessor's block of bh.

read_ancestor_hash chain_store ~distance bh retrieves in the chain_store the hash of the ancestor of the block bh at distance if it exists. Returns None otherwise.

val read_ancestor_hash_opt : chain_store -> distance:int -> Tezos_base.TzPervasives.Block_hash.t -> Tezos_base.TzPervasives.Block_hash.t option Lwt.t

read_ancestor_hash_opt chain_store ~distance bh same as read_ancestor_hash but returns None on errors.

val read_predecessor_of_hash_opt : chain_store -> Tezos_base.TzPervasives.Block_hash.t -> block option Lwt.t

read_ancestor_opt chain_store block optional version of read_ancestor.

read_validated_block chain_store bh tries to read in the chain_store's validated block cache the block bh.

val read_validated_block_opt : chain_store -> Tezos_base.TzPervasives.Block_hash.t -> block option Lwt.t

read_validated_block_opt chain_store bh optional version of read_validated_block.

store_block chain_store ~block_header ~operations validation_result stores in chain_store the block with its block_header, operations and validation result. Inconsistent blocks and validation will result in failures. Returns None if the block was already stored. If the block is correctly stored, the newly created block is returned.

If the block was successfully stored, then the block is removed from the validated block cache.

store_validated_block chain_store ~hash ~block_header ~operations stores in chain_store's validated block cache the block with its block_header and operations.

resulting_context_hash chain_store block returns the resulting context hash of the block. This context depends on the block's protocol associated semantics, i.e., it can either be the one contained in its block header or the stored result of its application.

context_exn chain_store block checkouts the resulting context of the block which may differ from its block header's one depending on the block's associated protocol semantics.

context_opt chain_store block optional version of context_exn.

context chain_store block error monad version of context_exn.

val context_exists : chain_store -> block -> bool Lwt.t

context_exists chain_store block tests the existence of the block's commit in the context.

testchain_status chain_store block returns the test chain status stored in context of block along with testchain's genesis if the testchain is found Forking or Running.

protocol_hash_exn chain_store block reads the protocol associated to block in its associated context. Fails when the context is unknown.

protocol_hash chain_store block error monad version of protocol_hash_exn.

read_invalid_block_opt chain_store bh reads in the chain_store the invalid block bh if it exists.

read_invalid_blocks chain_store returns the map of all invalid blocks of chain_store.

mark_invalid chain_store bh ~level errors stores the block bh at level with the given errors. Fails when trying to mark the genesis block as invalid.

unmark_invalid chain_store bh unmarks invalid the block bh in the chain_store.

descriptor block returns the pair (hash x level) of block.

Block field accessors

val operations : block -> Tezos_base.TzPervasives.Operation.t list list
val level : block -> int32
val proto_level : block -> int
val validation_passes : block -> int
val protocol_data : block -> bytes
val block_metadata_hash : block -> Tezos_base.TzPervasives.Block_metadata_hash.t option
val operations_metadata_hashes : block -> Tezos_base.TzPervasives.Operation_metadata_hash.t list list option
val operations_metadata_hashes_path : block -> int -> Tezos_base.TzPervasives.Operation_metadata_hash.t list option
val all_operations_metadata_hash : block -> Tezos_base.TzPervasives.Operation_metadata_list_list_hash.t option

Block metadata field accessors

val message : metadata -> string option
val max_operations_ttl : metadata -> int
val last_allowed_fork_level : metadata -> int32
val operations_metadata : metadata -> Tezos_validation.Block_validation.operation_metadata list list

operations_path block nth computes the nth operations list of block along with the hash of all operations.

operations_hashes_path block nth computes the nth operations hash list of block along with the hash of all operations.

val all_operation_hashes : block -> Tezos_base.TzPervasives.Operation_hash.t list list

all_operation_hashes block computes the hash of all operations in block.

OCaml

Innovation. Community. Security.