package tezos-store

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

Module Tezos_store_shared.Block_reprSource

Block representation effectively stored on disk and its accessors.

Type definitions and encodings

Sourcetype contents = {
  1. header : Tezos_base.TzPervasives.Block_header.t;
  2. operations : Tezos_base.TzPervasives.Operation.t list list;
  3. block_metadata_hash : Tezos_base.TzPervasives.Block_metadata_hash.t option;
  4. operations_metadata_hashes : Tezos_base.TzPervasives.Operation_metadata_hash.t list list option;
}

The type for the effective contents of a block is its header and the operations it contains. Their metadata hashes are also present.

Sourcetype 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 a block's metadata stored on disk. This representation is tightly linked to Tezos_validation.Block_validation.result which also has a strong dependency to Tezos_protocol_environment.validation_result.

Some fields exposed by Tezos_validation.Block_validation.result are unnecessary hence the lack of direct link.

Sourcetype block = {
  1. hash : Tezos_base.TzPervasives.Block_hash.t;
  2. contents : contents;
  3. mutable metadata : metadata option;
}

The type for a block stored on disk.

The hash of the block is also stored to improve efficiency by not forcing the user to hash the header. This also allows to store fake hashes (e.g. sandbox's genesis blocks) but should be prevented by the API.

The metadata might not be present. The mutability flag allows users to re-use the same structure to store freshly loaded metadata.

Sourcetype t = block

Genesis

create_genesis_block ~genesis context_hash creates a default genesis block for the given genesis and its context_hash that contains metadata.

Sourceval contents_encoding : contents Tezos_base.TzPervasives.Data_encoding.t

Encoding for contents.

Sourceval metadata_encoding : metadata Tezos_base.TzPervasives.Data_encoding.t

Encoding for metadata.

Sourceval equal : t -> t -> bool

Equality on block

Sourceval encoding : t Tezos_base.TzPervasives.Data_encoding.t

Encoding for t (and block).

Important An encoded block is prefixed by 4 bytes which stands for the length of the data. This is the case with Data_encoding.dynamic_size ~kind:`Uint30 encodings. This will be expected to be present to improve the store efficiency.

Sourceval pp_json : Format.formatter -> t -> unit

pp_json pretty-print a block as JSON.

Accessors

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

hash block returns the stored block's hash. It is not guaranteed to be the same as Block_header.hash (header block) (e.g. in sandbox, the genesis block might have a fake hash).

Sourceval operations : t -> Tezos_base.TzPervasives.Operation.t list list

operations block returns the list of list of operations contained in the block.

Block header accessors

Sourceval level : t -> Int32.t
Sourceval proto_level : t -> int
Sourceval validation_passes : t -> int
Sourceval block_metadata_hash : t -> Tezos_base.TzPervasives.Block_metadata_hash.t option
Sourceval operations_metadata_hashes : t -> Tezos_base.TzPervasives.Operation_metadata_hash.t list list option

Metadata accessors

Sourceval metadata : t -> metadata option
Sourceval message : metadata -> string option
Sourceval max_operations_ttl : metadata -> int
Sourceval last_allowed_fork_level : metadata -> Int32.t
Sourceval block_metadata : metadata -> bytes

Utility functions

Sourceval check_block_consistency : ?genesis_hash:Tezos_base.TzPervasives.Block_hash.t -> ?pred_block:t -> t -> unit Tezos_base.TzPervasives.tzresult Lwt.t

check_block_consistency ?genesis_hash ?pred_block block checks that the stored data is consistent:

  • Does the hash stored equals the result of Block_header.hash of its header and, if not, is this the stored genesis_hash?
  • Is the block a successor of pred_block with regards to its level and its predecessor's hash?
  • Are the stored operations hashes consistent regarding the stored operations hashes?
Sourceval decode_metadata : string -> metadata option

decode_metadata data decodes metadata from data encoded either with the new encoding or the legacy one.

OCaml

Innovation. Community. Security.