Module Mavryk_validation.Block_validation

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

val operation_encoding : operation Mavryk_base.TzPervasives.Data_encoding.t
type validation_store = {
  1. resulting_context_hash : Mavryk_base.TzPervasives.Context_hash.t;
  2. timestamp : Mavryk_base.TzPervasives.Time.Protocol.t;
  3. message : string option;
  4. max_operations_ttl : int;
  5. last_finalized_block_level : Stdlib.Int32.t;
    (*

    Oldest block for which reorganizations can happen

    *)
  6. last_preserved_block_level : Stdlib.Int32.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 Mavryk_base.TzPervasives.Bytes.t
  2. | Too_large_metadata
val operation_metadata_equal : operation_metadata -> operation_metadata -> bool
val operation_metadata_encoding : operation_metadata Mavryk_base.TzPervasives.Data_encoding.t
type ops_metadata =
  1. | No_metadata_hash of operation_metadata list list
  2. | Metadata_hash of (operation_metadata * Mavryk_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 * Mavryk_base.TzPervasives.Block_metadata_hash.t option;
  4. ops_metadata : ops_metadata;
}
type apply_result = {
  1. result : result;
  2. cache : Mavryk_protocol_environment.Context.cache;
}
val result_encoding : result Mavryk_base.TzPervasives.Data_encoding.t
val preapply_result_encoding : (Mavryk_base.TzPervasives.Block_header.shell_header * Mavryk_base.TzPervasives.error Mavryk_shell_services.Preapply_result.t list) Mavryk_base.TzPervasives.Data_encoding.t

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 : Mavryk_base.TzPervasives.Chain_id.t;
    (*

    chain_id of the current branch

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

    header of the predecessor block being validated

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

    context associated to the predecessor block

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

    predecessor block resulting context hash

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

    hash of block header metadata of the predecessor block

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

    hash of operation metadata of the predecessor block

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

    user activated upgrades

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

    user activated protocol overrides

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

    size limit for operation metadata that should be written on disk

    *)
}

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.

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

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