Module Tezos_validation.Protocol_plugin

module type T = sig ... end

Type of a protocol accompanied with its main plugin (aka the validation & mempool plugin).

module type RPC = sig ... end

Type of a protocol-specific RPC plug-in.

To use when no registered plugin is found. This module is functional; it just misses on the smarter logic that a plugin can add on top of the protocol.

module type METRICS = sig ... end

This is a protocol specific module that is used to collect all the * protocol-specific metrics. This module * allows to decode protocol data payload and provide back basic * types that can be used as metrics.

module type HTTP_CACHE_HEADERS = sig ... end

Protocol specific plugin to expose helper functions in the implementation of Http cache headers RPC middleware.

module Undefined_metrics_plugin (P : sig ... end) : METRICS

Empty metrics module. All metrics are -1.

module type SHELL_HELPERS = sig ... end

Protocol specific plugin to expose some helpers function that are helpful in scope of the Shell.

val register_validation_plugin : (module T) -> unit

Register a validation plugin for a specific protocol (according to its Proto.hash).

val register_rpc : (module RPC) -> unit

Registers a RPC plug-in for a specific protocol

val register_metrics : (module METRICS) -> unit

Register a metrics plugin module

val register_http_cache_headers_plugin : (module HTTP_CACHE_HEADERS) -> unit

Register a Http_cache_headers plugin module

val register_shell_helpers : (module SHELL_HELPERS) -> unit

Register a Shell_helpers plugin module

Retrieves the registered protocol with the provided hash and wraps it together with its validation plugin.

If no validation plugin has been registered for the protocol, then uses No_plugin which is functional, but not as smart as a protocol-specific plugin.

Returns the error Block_validator_errors.Unavailable_protocol when there is no registered protocol with the given hash.

The block_hash argument is only used as additional information for the potential aforementioned error.

val find_rpc : Tezos_base.TzPervasives.Protocol_hash.t -> (module RPC) option

Looks for an rpc plug-in for a specific protocol.

val find_metrics : Tezos_base.TzPervasives.Protocol_hash.t -> (module METRICS) option

Looks for a metrics plugin module for a specific protocol

val safe_find_metrics : Tezos_base.TzPervasives.Protocol_hash.t -> (module METRICS) Lwt.t

Same as find_metrics but returns Undefined_metrics_plugin if not found

val find_http_cache_headers : Tezos_base.TzPervasives.Protocol_hash.t -> (module HTTP_CACHE_HEADERS) option

Looks for a http cache headers plugin module for a specific protocol

val find_shell_helpers : Tezos_base.TzPervasives.Protocol_hash.t -> (module SHELL_HELPERS) option

Looks for a shell helpers plugin module for a specific protocol

The types below are used to implement the Shell_services.Chain.S.delegators_contribution RPC in src/lib_shell/chain_directory.ml.

type delegated_breakdown_at_sampling = {
  1. min_delegated_amount : int64;
    (*

    Sum of the contribution to the delegate's baking rights from the delegated balances of the delegate and its (current and former) delegators. Includes the delegate and current delegators' spendable balances, frozen bonds, and unstake requests associated with this delegate. Also includes unstaked requests that belong to former delegators but are still associated with this delegate. Excludes delegators' lingering unstake requests associated with an older delegate.

    *)
  2. min_delegated_level : int32;
    (*

    Level of min-delegated-in-current-cycle, whose context contains the information needed to break down min_delegated_amount.

    *)
  3. overstaked : int64;
    (*

    Tez that are part of external stakers' staked balances, but contribute to the delegated portion of baking power because of overstaking.

    *)
  4. total_delegated_including_overdelegated : int64;
    (*

    Total contribution to the delegated portion of baking power, before computing overdelegation.

    Invariant: total_delegated_including_overdelegated = min_delegated_amount + overstaked

    *)
  5. total_delegated_after_limits : int64;
    (*

    Actual total contribution to the delegated portion of baking power, constrained by overdelegation.

    Invariant: total_delegated_after_limits <= total_delegated_including_overdelegated

    *)
  6. overdelegated : int64;
    (*

    Amount that is delegated to the delegate but contributes nothing to its baking power because of overdelegation.

    Invariant: total_delegated_including_overdelegated = total_delegated_after_limits + overdelegated

    *)
}

Partial breakdown of delegated tez contribution to baking rights.

Contains the data available from the context at the level when the baking rights for the cycle of interest were sampled. In particular, only the total sum min_delegated_amount is available for the contributions from delegated balances of both the delegate and its delegators; breaking it down further requires access to the context at min_delegated_level.

All int64 values are mutez amount.

type min_delegated_breakdown = {
  1. total_delegated : int64;
    (*

    Sum of all contributions to the delegate's baking power from delegated balances. Same as min_delegated_amount.

    *)
  2. own_delegated : int64;
    (*

    Contribution from the delegate's own delegated balance. Includes the delegate's spendable balance, frozen bonds, and unstake requests associated with itself. Exclude any unstake requests associated with an older delegate.

    *)
  3. delegators_contributions : (string * int64) list;
    (*

    Contract hash (pkh or KT) and contribution for each current external delegator. Includes the delegator's spendable balance, frozen bonds, and unstake requests associated with the delegate. Exclude any unstake requests associated with an older delegate.

    *)
  4. former_delegators_unstake_requests : int64;
    (*

    Sum of the unstake requests that belong to the delegate's former delegators but are still associated with the delegate.

    *)
}

Breakdown of min_delegated_amount.

Invariant: total_delegated = own_delegated + sum_amounts(delegators_contributions) + former_delegators_unstake_requests

module type DELEGATORS_CONTRIBUTION = sig ... end
val register_delegators_contribution : (module DELEGATORS_CONTRIBUTION) -> unit
val find_delegators_contribution : Tezos_base.TzPervasives.Protocol_hash.t -> (module DELEGATORS_CONTRIBUTION) option