package tezos-shell

  1. Overview
  2. Docs

This module is the main entry point to valide blocks and protocols.

type t
type limits = {
  1. protocol_timeout : Tezos_base.Time.System.Span.t;
  2. operation_metadata_size_limit : int option;
}
val create : limits -> Distributed_db.t -> Block_validator_process.t -> start_testchain:bool -> (t, Tezos_error_monad.TzCore.error list) Stdlib.result Lwt.t

create limits ddb bvp start_testchain creates a Block_validator.

  • limits contains various timeout limits.
  • ddb is used to commit a block on the storage and get the state of the chain for which the block is submitted to validation.
  • bvp is an instance of the Block_validator_process. bvp is a proxy between the shell and the validation part related to the economic protocol (See Block_validator_process).
  • start_testchain if set to true allows to run the testchain.

This function is not supposed to fail. It is implemented this way because of the interface implemented by the Worker module.

type block_validity =
  1. | Valid
  2. | Invalid_after_precheck of Tezos_error_monad.TzCore.error list
  3. | Invalid of Tezos_error_monad.TzCore.error list
val validate : t -> ?canceler:Lwt_canceler.t -> ?peer:Tezos_base.P2p_peer.Id.t -> ?notify_new_block:(Tezos_store.Store.Block.t -> unit) -> ?precheck_and_notify:bool -> Distributed_db.chain_db -> Tezos_crypto.Block_hash.t -> Tezos_base.Block_header.t -> Tezos_base.Operation.t list list -> block_validity Lwt.t

validate ?precheck_and_notify validator ddb hash header ops validates a block header ops of hash hash. It is a no-op in the following cases:

  • If the block has already been validated.
  • If the block level is before the savepoint

Otherwise it calls the Block_validator_process process associated to the current validator.

  • canceler is trigerred when the validation of a block fails.
  • peer is the peer which sent the block.

If the validation succeeded it processes as follows:

1. The ddb commits the block on the storage.

2. If the next block requires a switch of protocol, it tries to fetch and precompile the next protocol.

3. Call notify_new_block with the committed block.

An error is raised if the validation failed or if the block was already known as invalid. However, if the first validation attempt failed because the protocol was missing, it tries to fetch and download the protocol before trying to validate the block a second time.

preapply validator canceler chains_store predecessor timestamp protocol_data operations creates a new block and returns it. It may call the Block_validator_process process associated to the current validator. If the preapply is a succeeded, the application resulted is cached to avoid re-apply the block if the next call block validation, through validate, targets the same block.

An error is raised if the pre-apply failed. However, if the first pre-apply attempt failed because the protocol was missing, it tries to fetch and download the protocol before trying to pre-apply the block a second time.

val shutdown : t -> unit Lwt.t
val running_worker : unit -> t
OCaml

Innovation. Community. Security.