Mavryk_shell.Prevalidator
Mavryk Shell - Prevalidation of pending operations (a.k.a Mempool)
The prevalidator is the worker in charge of the mempool
, that is, the operations that are not yet included in a block. It keeps track of which operations are valid (according to the economic protocol), maybe-valid-later, or invalid. The prevalidator is also responsible for deciding which operations are appropriate to broadcast to peers.
Before including an operation into the mempool, the prevalidator performs a few preliminary checks: unparsable
operations are noted down so that they will never be considered again; already handled operations or operations that are not branched on any live_block
are simply ignored; operations which do not meet some configurable requirements (e.g. minimal fees) are refused
at this point.
If the operation passes these preliminary checks, the prevalidator then asks the protocol to validate the operation in its maintained mempool context. Only an operation that passes this validation gets added to the mempool context and broadcast. If the operation is flat-out refused
by the protocol, it is noted down to be ignored by the node from now on. If the operation is only branch_refused
or branch_delayed
, it is kept for later: it may be evaluated again in the future when the mempool's head (a.k.a. the last block it is built on) changes, then added to the mempool and broadcast if it passes this new validation.
See the prevalidator implementation overview to learn more.
An (abstract) prevalidator context. Separate prevalidator contexts should be used for separate chains (e.g., mainchain vs testchain).
val create :
Mavryk_shell_services.Shell_limits.prevalidator_limits ->
(module Mavryk_validation.Protocol_plugin.T) ->
Distributed_db.chain_db ->
t Mavryk_base.TzPervasives.tzresult Lwt.t
Creates/tear-down a new prevalidator context.
val shutdown : t -> unit Lwt.t
val notify_operations :
t ->
Mavryk_base.P2p_peer.Id.t ->
Mavryk_base.Mempool.t ->
unit Lwt.t
Notify the prevalidator that the identified peer has sent a bunch of operations relevant to the specified context.
val inject_operation :
t ->
force:bool ->
Mavryk_base.Operation.t ->
unit Mavryk_base.TzPervasives.tzresult Lwt.t
inject_operation t ~force op
notifies the prevalidator worker of a new injected operation. If force
is set to true
the operation is injected without any check. force
should be used for test purpose only.
val flush :
t ->
Mavryk_shell_services.Chain_validator_worker_state.update ->
Mavryk_base.TzPervasives.Block_hash.t ->
Mavryk_base.TzPervasives.Block_hash.Set.t ->
Mavryk_base.TzPervasives.Operation_hash.Set.t ->
unit Mavryk_base.TzPervasives.tzresult Lwt.t
Notify the prevalidator that a new head has been selected. update
is used as an optimisation to know which operations previously classified require to be prevalidated again.
val running_workers :
unit ->
(Mavryk_base.TzPervasives.Chain_id.t
* Mavryk_base.TzPervasives.Protocol_hash.t
* t)
list
Returns the list of prevalidation contexts running and their associated chain
Worker status and events
val status : t -> Mavryk_base.Worker_types.worker_status
val pending_requests :
t ->
(Mavryk_base.Time.System.t
* Mavryk_shell_services.Prevalidator_worker_state.Request.view)
list
val current_request :
t ->
(Mavryk_base.Time.System.t
* Mavryk_base.Time.System.t
* Mavryk_shell_services.Prevalidator_worker_state.Request.view)
option
val information : t -> Mavryk_base.Worker_types.worker_information
val pipeline_length : t -> int
val rpc_directory : t option Mavryk_rpc.Directory.t
module Internal_for_tests : sig ... end