package octez-libs

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

The SCORE module type describes primitives used to update the scores associated to each peer. Score computation is described in more details in the specification.

The score associated to a peer is a weighted sum of various counters, some of which are indexed by topics. Each captures a certain aspect of what a well-behaving peer should do. A short description follows, keeping the naming P1, P2, ... used in the specification.

  • P1: For each topic, we measure how long a peer has spent in the mesh for that topic. The longest, the better.
  • P2: For each topic, we measure how many times the peer was the first among all peers to send us a message on that topic.
  • P3: For each topic, we measure the number of message deliveries. If the number is below a threshold, we penalize the associated peer.
  • P3b: Trigger P3 computation when the peer gets pruned or removed, so as to not forget yet unaccounted for bad message delivery counts.
  • P4: For each topic, penalize peers sending invalid messages on that topic.
  • P5: The applicative layer can assign an arbitrary application-specific score to a peer.
  • P7: When a peer is pruned from the mesh for a topic, we install a backoff that prevents that peer from regrafting too soon. If the peer does not respect this backoff, it is penalized.
type t

The type of peer scoring statistics.

type value
type span
type time
type topic
val newly_connected : (topic, span) score_limits -> t

newly_connected params creates a fresh statistics record.

val value : t -> value

value ps evaluates the score of ps.

val penalty : t -> int -> t

penalty ps penalty increments the behavioural penalty of ps.

val set_connected : t -> t

set_connected ps marks ps as being associated to a connected peer.

val remove_peer : t -> retain_duration:span -> t option

remove_peer ps ~retain_duration will either return None if the peer statistics can be cleared, or Some ps' with ps' some statistics to be retained for at least retain_duration.

val expires : t -> time option

expires ps returns None if the score statistics has no expiration time or Some t if it expires at time t.

val graft : t -> topic -> t

graft ps topic allows to measure the time spent by the peer in the mesh. It is to be called upon grafting a peer to topic.

val prune : t -> topic -> t

prune ps topic allows to measure the time spent by the peer in the mesh. It is to be called upon pruning a peer from topic.

val first_message_delivered : t -> topic -> t

first_message_delivered ps topic increments the counter related to first message deliveries and mesh message deliveries on topic by the associated peer.

val duplicate_message_delivered : t -> topic -> time -> t

duplicate_message_delivered ps topic validated increments the counter related to near-first mesh message deliveries on topic by the associated peer. validated is the time at which the message was seen by the automaton for the first time.

val invalid_message_delivered : t -> topic -> t

invalid_message_delivered ps topic increments the counter related to invalid messages sent by the associated peer.

val set_application_score : t -> float -> t

set_application_score ps score sets the application-specific score. This score can be positive or negative.

val refresh : t -> t option

refresh ps returns Some ps' with ps' a refreshed score record or None if the score expired. Refreshing a ps allows to update time-dependent spects of the scoring statistics.

val zero : value

The zero score value, corresponding to a neutral score.

val of_float : float -> value

Convert a float into a score value.

include Tezos_stdlib.Compare.S with type t := value
val (=) : value -> value -> bool

x = y iff compare x y = 0

val (<>) : value -> value -> bool

x <> y iff compare x y <> 0

val (<) : value -> value -> bool

x < y iff compare x y < 0

val (<=) : value -> value -> bool

x <= y iff compare x y <= 0

val (>=) : value -> value -> bool

x >= y iff compare x y >= 0

val (>) : value -> value -> bool

x > y iff compare x y > 0

val compare : value -> value -> int

compare an alias for the functor parameter's compare function

val equal : value -> value -> bool

equal x y iff compare x y = 0

val max : value -> value -> value

max x y is x if x >= y otherwise it is y

val min : value -> value -> value

min x y is x if x <= y otherwise it is y

include Tezos_base.TzPervasives.PRINTABLE with type t := t
val pp : Stdlib.Format.formatter -> t -> unit
val pp_value : Stdlib.Format.formatter -> value -> unit
module Introspection : sig ... end
module Internal_for_tests : sig ... end
OCaml

Innovation. Community. Security.