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.
This type is used to represent an operation contained in a block that we want to validate and/or apply.
val mk_operation :
?known_valid_operation_set:Mavryk_base.TzPervasives.Operation_hash.Set.t ->
Mavryk_base.TzPervasives.Operation.t ->
operation
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 = {
resulting_context_hash : Mavryk_base.TzPervasives.Context_hash.t;
timestamp : Mavryk_base.TzPervasives.Time.Protocol.t;
message : string option;
max_operations_ttl : int;
last_finalized_block_level : Stdlib.Int32.t;
Oldest block for which reorganizations can happen
*)last_preserved_block_level : Stdlib.Int32.t;
}
val may_patch_protocol :
user_activated_upgrades:Mavryk_base.TzPervasives.User_activated.upgrades ->
user_activated_protocol_overrides:
Mavryk_base.TzPervasives.User_activated.protocol_overrides ->
level:Stdlib.Int32.t ->
Mavryk_protocol_environment.validation_result ->
Mavryk_protocol_environment.validation_result Lwt.t
val update_testchain_status :
Mavryk_protocol_environment.Context.t ->
predecessor_hash:Mavryk_base.TzPervasives.Block_hash.t ->
Mavryk_base.TzPervasives.Time.Protocol.t ->
Mavryk_protocol_environment.Context.t Lwt.t
val check_proto_environment_version_increasing :
Mavryk_base.TzPervasives.Block_hash.t ->
Mavryk_base.TzPervasives.Protocol.env_version ->
Mavryk_base.TzPervasives.Protocol.env_version ->
unit Mavryk_base.TzPervasives.tzresult
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.
val init_test_chain :
Mavryk_base.TzPervasives.Chain_id.t ->
Mavryk_protocol_environment.Context.t ->
Mavryk_base.TzPervasives.Block_header.t ->
Mavryk_base.TzPervasives.Block_header.t Mavryk_base.TzPervasives.tzresult
Lwt.t
init_test_chain
must only be called on a forking block.
val operation_metadata_equal : operation_metadata -> operation_metadata -> bool
val operation_metadata_encoding :
operation_metadata Mavryk_base.TzPervasives.Data_encoding.t
type ops_metadata =
| No_metadata_hash of operation_metadata list list
| Metadata_hash of (operation_metadata
* Mavryk_base.TzPervasives.Operation_metadata_hash.t)
list
list
type result = {
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.
*)validation_store : validation_store;
block_metadata : bytes * Mavryk_base.TzPervasives.Block_metadata_hash.t option;
ops_metadata : ops_metadata;
}
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
val check_liveness :
live_blocks:Mavryk_base.TzPervasives.Block_hash.Set.t ->
live_operations:Mavryk_base.TzPervasives.Operation_hash.Set.t ->
Mavryk_base.TzPervasives.Block_hash.t ->
operation list list ->
unit Mavryk_base.TzPervasives.tzresult
check_liveness live_blocks live_operations hash ops
checks there is no duplicate operation and that is not out-of-date
type apply_environment = {
max_operations_ttl : int;
time to live of an operation
*)chain_id : Mavryk_base.TzPervasives.Chain_id.t;
chain_id of the current branch
*)predecessor_block_header : Mavryk_base.TzPervasives.Block_header.t;
header of the predecessor block being validated
*)predecessor_context : Mavryk_protocol_environment.Context.t;
context associated to the predecessor block
*)predecessor_resulting_context_hash : Mavryk_base.TzPervasives.Context_hash.t;
predecessor block resulting context hash
*)predecessor_block_metadata_hash : Mavryk_base.TzPervasives.Block_metadata_hash.t
option;
hash of block header metadata of the predecessor block
*)predecessor_ops_metadata_hash : Mavryk_base.TzPervasives.Operation_metadata_list_list_hash.t
option;
hash of operation metadata of the predecessor block
*)user_activated_upgrades : Mavryk_base.TzPervasives.User_activated.upgrades;
user activated upgrades
*)user_activated_protocol_overrides : Mavryk_base.TzPervasives.User_activated.protocol_overrides;
user activated protocol overrides
*)operation_metadata_size_limit : Mavryk_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 * Mavryk_protocol_environment.Context.t) ->
?should_precheck:bool ->
apply_environment ->
cache:Mavryk_protocol_environment.Context.source_of_cache ->
Mavryk_base.TzPervasives.Block_header.t ->
operation list list ->
apply_result Mavryk_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:Mavryk_base.TzPervasives.Chain_id.t ->
predecessor_block_header:Mavryk_base.TzPervasives.Block_header.t ->
predecessor_block_hash:Mavryk_base.TzPervasives.Block_hash.t ->
predecessor_context:Mavryk_protocol_environment.Context.t ->
predecessor_resulting_context_hash:Mavryk_base.TzPervasives.Context_hash.t ->
cache:Mavryk_protocol_environment.Context.source_of_cache ->
Mavryk_base.TzPervasives.Block_header.t ->
operation list list ->
unit Mavryk_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:Mavryk_base.TzPervasives.Chain_id.t ->
user_activated_upgrades:Mavryk_base.User_activated.upgrades ->
user_activated_protocol_overrides:
Mavryk_base.User_activated.protocol_overrides ->
operation_metadata_size_limit:
Mavryk_shell_services.Shell_limits.operation_metadata_size_limit ->
timestamp:Mavryk_base.TzPervasives.Time.Protocol.t ->
protocol_data:bytes ->
live_blocks:Mavryk_base.TzPervasives.Block_hash.Set.t ->
live_operations:Mavryk_base.TzPervasives.Operation_hash.Set.t ->
predecessor_context:Mavryk_protocol_environment.Context.t ->
predecessor_resulting_context_hash:Mavryk_base.TzPervasives.Context_hash.t ->
predecessor_shell_header:Mavryk_base.TzPervasives.Block_header.shell_header ->
predecessor_hash:Mavryk_base.TzPervasives.Block_hash.t ->
predecessor_max_operations_ttl:int ->
predecessor_block_metadata_hash:
Mavryk_base.TzPervasives.Block_metadata_hash.t option ->
predecessor_ops_metadata_hash:
Mavryk_base.TzPervasives.Operation_metadata_list_list_hash.t option ->
cache:Mavryk_protocol_environment.Context.source_of_cache ->
operation list list ->
((Mavryk_base.TzPervasives.Block_header.shell_header
* Mavryk_base.TzPervasives.error Mavryk_shell_services.Preapply_result.t
list)
* (apply_result * Mavryk_protocol_environment.Context.t))
Mavryk_base.TzPervasives.tzresult
Lwt.t
val recompute_metadata :
chain_id:Mavryk_base.TzPervasives.Chain_id.t ->
predecessor_block_header:Mavryk_base.TzPervasives.Block_header.t ->
predecessor_context:Mavryk_protocol_environment.Context.t ->
predecessor_block_metadata_hash:
Mavryk_base.TzPervasives.Block_metadata_hash.t option ->
predecessor_ops_metadata_hash:
Mavryk_base.TzPervasives.Operation_metadata_list_list_hash.t option ->
block_header:Mavryk_base.TzPervasives.Block_header.t ->
operations:
operation Mavryk_base.TzPervasives.trace Mavryk_base.TzPervasives.trace ->
cache:Mavryk_protocol_environment.Context.source_of_cache ->
((bytes * Mavryk_base.TzPervasives.Block_metadata_hash.t option)
* ops_metadata)
Mavryk_base.TzPervasives.tzresult
Lwt.t
Hypothesis: we assume that the given block has already been validated -- E.g. by calling precheck
.