package octez-libs
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=dbc3b675aee59c2c574e5d0a771193a2ecfca31e7a5bc5aed66598080596ce1c
sha512=b97ed762b9d24744305c358af0d20f394376b64bfdd758dd4a81775326caf445caa57c4f6445da3dd6468ff492de18e4c14af6f374dfcbb7e4d64b7b720e5e2a
doc/octez-libs.tezos-gossipsub/Tezos_gossipsub/Make/index.html
Module Tezos_gossipsub.MakeSource
Parameters
module C : Gossipsub_intf.AUTOMATON_CONFIGSignature
Module for peer
Module for topic
Module for message_id
Module for message
Module for time
Module for time duration
Module for peers scores
The state managed by the gossipsub automaton. The state is purely functional.
type limits := (Topic.t, Peer.t, Message_id.t, span) Gossipsub_intf.limitsLimits of the gossipsub protocol.
type parameters := (Peer.t, Message_id.t) Gossipsub_intf.parametersParameters of the gossipsub protocol.
The types of payloads for inputs to the gossipsub automaton.
type receive_message = {sender : Peer.t;topic : Topic.t;message_id : Message_id.t;message : message;
}type _ output = | Ihave_from_peer_with_low_score : {score : Score.t;threshold : float;
} -> [ `IHave ] output(*The peer who sent an IHave message has a
*)scorebelowthreshold.| Too_many_recv_ihave_messages : {} -> [ `IHave ] output(*The peer sent us more than
*)maxIHave messages within two successive heartbeat calls.| Too_many_sent_iwant_messages : {} -> [ `IHave ] output(*We sent more than
*)maxIWant messages to this peer within two successive heartbeat calls.| Message_topic_not_tracked : [ `IHave ] output(*We received an IHave message for a topic we don't track.
*)| Message_requested_message_ids : Message_id.t list -> [ `IHave ] output(*The messages ids we want to request from the peer which sent us an IHave message. The implementation honors the
*)max_sent_iwant_per_heartbeatlimit.| Iwant_from_peer_with_low_score : {score : Score.t;threshold : float;
} -> [ `IWant ] output(*The peer who sent an IWant message has a
*)scorebelowthreshold.| On_iwant_messages_to_route : {routed_message_ids : [ `Ignored | `Not_found | `Too_many_requests | `Message of message ] Message_id.Map.t;
} -> [ `IWant ] output(*As an answer for an
*)`IWantmessage, the automaton returns a map associating to each requested message_id either`Ignoredif the peer is filtered out bypeer_filter,`Not_foundif the message is not found, orMessage mifmis the message with the given id.| Peer_filtered : [ `Graft ] output(*The peer we attempt to graft has not been selected by
*)peer_filter.| Unsubscribed_topic : [ `Graft ] output(*We didn't join the topic for which we are attempting to graft a peer.
*)| Peer_already_in_mesh : [ `Graft ] output(*Attempting to graft a peer which has already been grafted.
*)| Grafting_direct_peer : [ `Graft ] output(*Attempting to graft a direct peer.
*)| Unexpected_grafting_peer : [ `Graft ] output(*The peer we attempt to graft is not known.
*)| Grafting_peer_with_negative_score : [ `Graft ] output(*Attempting to graft a peer with a negative score.
*)| Grafting_successfully : [ `Graft ] output(*Grafting the given peer for the provided topic succeeded.
*)| Peer_backed_off : [ `Graft ] output(*We cannot graft the given peer because it is backed off.
*)| Mesh_full : [ `Graft ] output(*Grafting a peer for a topic whose mesh has already sufficiently many peers.
*)| Prune_topic_not_tracked : [ `Prune ] output(*Attempting to prune a peer for a non-tracked topic.
*)| Peer_not_in_mesh : [ `Prune ] output(*Attempting to prune a peer which is not in the mesh.
*)| Ignore_PX_score_too_low : Score.t -> [ `Prune ] output(*The given peer has been pruned for the given topic, but no alternative peers are returned because the peer's score is too low. The score of the peer is included in the return value.
*)| No_PX : [ `Prune ] output(*The given peer has been pruned for the given topic. No alternatives peers was provided in
*)prune.| PX : Peer.Set.t -> [ `Prune ] output(*The given peer has been pruned for the given topic. The given set of peers alternatives in
*)prunefor that topic is returned.| Publish_message : {to_publish : Peer.Set.t;
} -> [ `Publish_message ] output(*to_publishcontains:- Direct peers for the message's topic;
- The peers in the topic's mesh, if the peer is subscribed to the topic. Otherwise, the peers in the topic's fanout.
| Already_published : [ `Publish_message ] output(*Attempting to publish a message that has already been published.
*)| Route_message : {to_route : Peer.Set.t;
} -> [ `Receive_message ] output(*to_routecontains:- Direct peers for the message's topic;
- The peers in the topic's mesh minus the original sender of the message.
| Already_received : [ `Receive_message ] output(*Received a message that has already been recevied before.
*)| Not_subscribed : [ `Receive_message ] output(*Received a message from a remote peer for a topic we are not subscribed to (called "unknown topic" in the Go implementation).
*)| Invalid_message : [ `Receive_message ] output| Unknown_validity : [ `Receive_message ] output(*Attempting to publish a message that is invalid.
*)| Already_joined : [ `Join ] output(*Attempting to join a topic we already joined.
*)| Joining_topic : {to_graft : Peer.Set.t;
} -> [ `Join ] output(*When successfully joining a topic, the set of grafted peers for that topic is returned.
*)| Not_joined : [ `Leave ] output(*Attempting to leave a topic which we didn't join or had already left.
*)| Leaving_topic : {to_prune : Peer.Set.t;noPX_peers : Peer.Set.t;
} -> [ `Leave ] output(*When successfully leaving a topic, the set of pruned peers for that topic is returned alongside a subset of those peers for which no alternative PX will be proposed.
*)| Heartbeat : {to_graft : Topic.Set.t Peer.Map.t;(*The set of topics per peer that have been grafted.
*)to_prune : Topic.Set.t Peer.Map.t;(*The set of topics per peer that have been pruned.
*)noPX_peers : Peer.Set.t;(*Set of peers for which peer exchange (PX) will not be proposed.
*)
} -> [ `Heartbeat ] output| Peer_added : [ `Add_peer ] output(*The output returned when successfully adding a peer.
*)| Peer_already_known : [ `Add_peer ] output(*The output returned when attempting to add a peer which is already known.
*)| Removing_peer : [ `Remove_peer ] output(*The output returned when successfully removing a peer.
*)| Subscribed : [ `Subscribe ] output(*The output returned once we successfully processed a subscribe request sent from a peer.
*)| Subscribe_to_unknown_peer : [ `Subscribe ] output(*The output returned when we receive a subscribe message from a peer we don't know.
*)| Unsubscribed : [ `Unsubscribe ] output(*The output returned once we successfully processed an unsubscribe request sent from a peer.
*)| Unsubscribe_from_unknown_peer : [ `Unsubscribe ] output(*The output returned when we receive an unsubscribe message from a peer we don't know.
*)| Set_application_score : [ `Set_application_score ] output(*The output returned when we set the application score of a peer
*)
Output produced by one of the actions below.
Initialise a state.
add_peer { direct; outbound; peer } is called to notify a new connection. If direct is true, the gossipsub always forwards messages to those peers. outbound is true if it is an outbound connection, that is, a connection initiated by the local (not the remote) peer. Note however that the notion of "outbound" connections can be refined, relaxed or redefined by the application layer to fit its own needs.
remove_peer { peer } notifies gossipsub that we are disconnected from a peer. Do note that the state still maintain information for this connection for retain_duration seconds.
handle_subscribe {topic; peer} handles a request from a remote peer informing us that it is subscribed to topic.
handle_unsubscribe {topic; peer} handles a request from a remote peer informing us that it unsubscribed from topic.
handle_ihave { peer; topic; message_ids } handles the gossip message IHave emitted by peer for topic with the message_ids.
handle_iwant { peer; message_ids } handles the gossip message IWant emitted by peer for topic with the message_ids.
handle_graft { peer; topic } handles the gossip message Graft emitted by peer for topic. This action allows to graft a connection to a full connection allowing the transmission of full messages for the given topic.
handle_prune { peer; topic; px; backoff } handles the gossip message Prune emitted by peer for topic. This action allows to prune a full connection. In that case, the remote peer can send a list of peers to connect to as well as a backoff time, which is a duration for which we cannot Graft this peer on this topic.
handle_receive_message { sender; topic; message_id; message } handles a message received from sender on the gossip network. The function returns a set of peers to which the (full) message will be directly forwarded.
publish { topic; message_id; message } allows to publish a message on the gossip network from the local node. The function returns a set of peers to which the (full) message will be directly forwarded.
heartbeat executes the heartbeat routine of the algorithm.
join { topic } handles a join to a new topic. On success, the function returns the set of peers that have been grafted to form the mesh of the joined topic.
leave { topic } handles a leave from a topic. On success, the function returns the set of peers, forming the mesh, that have been pruned for that topic.
set_application_score {peer; score} handles setting the application score of peer. If the peer is not known, this does nothing.
val select_px_peers :
state ->
peer_to_prune:Peer.t ->
Topic.t ->
noPX_peers:Peer.Set.t ->
Peer.t listSelect random peers for Peer eXchange. Note that function is deterministic; however, it has side effects in that it updates the state's random state.
Select the gossip messages to be sent. These are IHave control messages referring to recently seen messages (that is, sent during the last history_gossip_length heartbeat ticks), to be sent to a random selection of peers. The message ids for a peer and a topic are also selected at random among the possible ones. At most max_sent_iwant_per_heartbeat message ids are sent.
The local peer will send gossip to at most gossip_factor * (total number of non-mesh/non-fanout peers), or degree_lazy random peers, whichever is greater.
Note that function is deterministic; however, it has side effects in that it updates the state's random state.