From df0379576c962ac4446c7847e917787831801f26 Mon Sep 17 00:00:00 2001 From: Godspower Eze Date: Mon, 27 Nov 2023 11:50:40 +0100 Subject: [PATCH 01/14] feat: boilerplate --- .../internal/subscriptions/subscriptions.go | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/native/libp2p_port/internal/subscriptions/subscriptions.go b/native/libp2p_port/internal/subscriptions/subscriptions.go index 74e526d6c..7308b8944 100644 --- a/native/libp2p_port/internal/subscriptions/subscriptions.go +++ b/native/libp2p_port/internal/subscriptions/subscriptions.go @@ -14,6 +14,7 @@ import ( pubsub "github.com/libp2p/go-libp2p-pubsub" "github.com/libp2p/go-libp2p/core/host" "github.com/libp2p/go-libp2p/core/peer" + "github.com/libp2p/go-libp2p/core/protocol" ) type subscription struct { @@ -28,6 +29,70 @@ type Subscriber struct { port *port.Port } +type GossipTracer struct { + host host.Host +} + +func (g GossipTracer) AddPeer(p peer.ID, proto protocol.ID) { + // no-op +} + +func (g GossipTracer) RemovePeer(p peer.ID) { + // no-op +} + +func (g GossipTracer) Join(topic string) { + // no-op +} + +func (g GossipTracer) Leave(topic string) { + // no-op +} + +func (g GossipTracer) Graft(p peer.ID, topic string) { + // no-op +} + +func (g GossipTracer) Prune(p peer.ID, topic string) { + // no-op +} + +func (g GossipTracer) ValidateMessage(msg *pubsub.Message) { + // no-op +} + +func (g GossipTracer) DeliverMessage(msg *pubsub.Message) { + // no-op +} + +func (g GossipTracer) RejectMessage(msg *pubsub.Message, reason string) { + // no-op +} + +func (g GossipTracer) DuplicateMessage(msg *pubsub.Message) { + // no-op +} + +func (g GossipTracer) ThrottlePeer(p peer.ID) { + // no-op +} + +func (g GossipTracer) RecvRPC(rpc *pubsub.RPC) { + // no-op +} + +func (g GossipTracer) SendRPC(rpc *pubsub.RPC, p peer.ID) { + // no-op +} + +func (g GossipTracer) DropRPC(rpc *pubsub.RPC, p peer.ID) { + // no-op +} + +func (g GossipTracer) UndeliverableMessage(msg *pubsub.Message) { + // no-op +} + func NewSubscriber(p *port.Port, h host.Host) Subscriber { heartbeat := 700 * time.Millisecond gsubParams := pubsub.DefaultGossipSubParams() @@ -74,6 +139,7 @@ func NewSubscriber(p *port.Port, h host.Host) Subscriber { pubsub.WithPeerOutboundQueueSize(600), pubsub.WithValidateQueueSize(600), pubsub.WithMaxMessageSize(10 * (1 << 20)), // 10 MB + pubsub.WithRawTracer(GossipTracer{host: h}), } gsub, err := pubsub.NewGossipSub(context.Background(), h, options...) From 2b84bcb3b0d40c18acc8814749ac26036de1c50b Mon Sep 17 00:00:00 2001 From: Godspower Eze Date: Tue, 28 Nov 2023 08:23:49 +0100 Subject: [PATCH 02/14] feat: added proto defs and helpers --- .../internal/proto_helpers/proto_helpers.go | 20 ++++++++++++++++ .../internal/subscriptions/subscriptions.go | 6 ++--- proto/libp2p.proto | 24 +++++++++++++++++++ 3 files changed, 47 insertions(+), 3 deletions(-) diff --git a/native/libp2p_port/internal/proto_helpers/proto_helpers.go b/native/libp2p_port/internal/proto_helpers/proto_helpers.go index 694e4ad94..a8364443e 100644 --- a/native/libp2p_port/internal/proto_helpers/proto_helpers.go +++ b/native/libp2p_port/internal/proto_helpers/proto_helpers.go @@ -20,6 +20,26 @@ func ConfigFromInitArgs(initArgs *proto_defs.InitArgs) Config { } } +func JoinNotification(topic string) proto_defs.Notification{ + joinNotification := &proto_defs.Join{Topic: topic} + return proto_defs.Notification{N: &proto_defs.Notification_Joined{Joined: joinNotification}} +} + +func LeaveNofication(topic string) proto_defs.Notification { + leaveNofication := &proto_defs.Leave{Topic: topic} + return proto_defs.Notification{N: &proto_defs.Notification_Left{Left: leaveNofication}} +} + +func GraftNotification(id []byte, topic string) proto_defs.Notification { + graftNotification := &proto_defs.Graft{PeerId: id, Topic: topic} + return proto_defs.Notification{N: &proto_defs.Notification_Grafted{Grafted: graftNotification}} +} + +func PruneNotification(id [] byte, topic string) proto_defs.Notification { + pruneNotification := &proto_defs.Prune{PeerId: id, Topic: topic} + return proto_defs.Notification{N: &proto_defs.Notification_Pruned{Pruned: pruneNotification}} +} + func GossipNotification(topic string, handler, msgId, message []byte) proto_defs.Notification { gossipSubNotification := &proto_defs.GossipSub{Topic: topic, Handler: handler, MsgId: msgId, Message: message} return proto_defs.Notification{N: &proto_defs.Notification_Gossip{Gossip: gossipSubNotification}} diff --git a/native/libp2p_port/internal/subscriptions/subscriptions.go b/native/libp2p_port/internal/subscriptions/subscriptions.go index 7308b8944..e140f9a29 100644 --- a/native/libp2p_port/internal/subscriptions/subscriptions.go +++ b/native/libp2p_port/internal/subscriptions/subscriptions.go @@ -30,7 +30,7 @@ type Subscriber struct { } type GossipTracer struct { - host host.Host + port *port.Port } func (g GossipTracer) AddPeer(p peer.ID, proto protocol.ID) { @@ -42,7 +42,7 @@ func (g GossipTracer) RemovePeer(p peer.ID) { } func (g GossipTracer) Join(topic string) { - // no-op + // g.port.SendNotification() } func (g GossipTracer) Leave(topic string) { @@ -139,7 +139,7 @@ func NewSubscriber(p *port.Port, h host.Host) Subscriber { pubsub.WithPeerOutboundQueueSize(600), pubsub.WithValidateQueueSize(600), pubsub.WithMaxMessageSize(10 * (1 << 20)), // 10 MB - pubsub.WithRawTracer(GossipTracer{host: h}), + pubsub.WithRawTracer(GossipTracer{port: p}), } gsub, err := pubsub.NewGossipSub(context.Background(), h, options...) diff --git a/proto/libp2p.proto b/proto/libp2p.proto index 2a12d5b09..c9eb2c3df 100644 --- a/proto/libp2p.proto +++ b/proto/libp2p.proto @@ -27,6 +27,26 @@ message UnsubscribeFromTopic { string name = 1; } +message Join { + // topic that was joined + string topic = 1; +} + +message Leave { + // topic that was abandoned + string topic = 1; +} + +message Graft { + bytes peer_id = 1; + string topic = 2; +} + +message Prune { + bytes peer_id = 1; + string topic = 2; +} + message AddPeer { bytes id = 1; repeated string addrs = 2; @@ -120,5 +140,9 @@ message Notification { Request request = 2; NewPeer new_peer = 3; Result result = 4; + Join joined = 5; + Leave left = 6; + Graft grafted = 7; + Prune pruned = 8; } } From c6fa8a62083d875ccd807eded27afa3ac54c4972 Mon Sep 17 00:00:00 2001 From: Godspower Eze Date: Tue, 28 Nov 2023 08:42:34 +0100 Subject: [PATCH 03/14] feat: added notification sender --- .../internal/subscriptions/subscriptions.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/native/libp2p_port/internal/subscriptions/subscriptions.go b/native/libp2p_port/internal/subscriptions/subscriptions.go index e140f9a29..2ac33b39f 100644 --- a/native/libp2p_port/internal/subscriptions/subscriptions.go +++ b/native/libp2p_port/internal/subscriptions/subscriptions.go @@ -42,19 +42,23 @@ func (g GossipTracer) RemovePeer(p peer.ID) { } func (g GossipTracer) Join(topic string) { - // g.port.SendNotification() + notification := proto_helpers.JoinNotification(topic) + g.port.SendNotification(¬ification) } func (g GossipTracer) Leave(topic string) { - // no-op + notification := proto_helpers.LeaveNofication(topic) + g.port.SendNotification(¬ification) } func (g GossipTracer) Graft(p peer.ID, topic string) { - // no-op + notification := proto_helpers.GraftNotification([]byte(p), topic) + g.port.SendNotification(¬ification) } func (g GossipTracer) Prune(p peer.ID, topic string) { - // no-op + notification := proto_helpers.PruneNotification([]byte(p), topic) + g.port.SendNotification(¬ification) } func (g GossipTracer) ValidateMessage(msg *pubsub.Message) { From 11222beb7b252df1f8878f4ed49e8f4645fb55a7 Mon Sep 17 00:00:00 2001 From: Godspower Eze Date: Tue, 28 Nov 2023 11:06:02 +0100 Subject: [PATCH 04/14] feat: added handler --- lib/lambda_ethereum_consensus/telemetry.ex | 1 + lib/libp2p_port.ex | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/lambda_ethereum_consensus/telemetry.ex b/lib/lambda_ethereum_consensus/telemetry.ex index 91cfff172..cf3f7ebf8 100644 --- a/lib/lambda_ethereum_consensus/telemetry.ex +++ b/lib/lambda_ethereum_consensus/telemetry.ex @@ -58,6 +58,7 @@ defmodule LambdaEthereumConsensus.Telemetry do # Peer metrics counter("peers.connection.count", tags: [:result]), counter("network.request.count", tags: [:result, :type, :reason]), + # counter("network.pubsub.topic") sum("network.request.blocks", tags: [:result, :type, :reason]), # Sync metrics diff --git a/lib/libp2p_port.ex b/lib/libp2p_port.ex index d8f228dac..7f40c9b6f 100644 --- a/lib/libp2p_port.ex +++ b/lib/libp2p_port.ex @@ -1,8 +1,7 @@ defmodule LambdaEthereumConsensus.Libp2pPort do @moduledoc """ A GenServer that allows other elixir processes to send and receive commands to/from - the LibP2P server in Go. For now, it only supports subscribing and unsubscribing from - topics. + the LibP2P server in Go. Requests are generated with an ID, which is returned when calling. Those IDs appear in the responses that might be listened to by other processes. @@ -15,10 +14,14 @@ defmodule LambdaEthereumConsensus.Libp2pPort do Command, GetId, GossipSub, + Graft, InitArgs, + Join, + Leave, NewPeer, Notification, Publish, + Prune, Request, Result, ResultMessage, @@ -277,6 +280,10 @@ defmodule LambdaEthereumConsensus.Libp2pPort do send(pid, {:response, result}) end + defp handle_notification(%Join{topic: topic}, _state) do + :telemetry.execute([:network, :pubsub], %{topic: topic}) + end + defp parse_args(args) do args |> Keyword.validate!(@default_args) From f7bd8d071817283f1a199cca02125fd860ca8307 Mon Sep 17 00:00:00 2001 From: Godspower Eze Date: Tue, 28 Nov 2023 11:21:30 +0100 Subject: [PATCH 05/14] fix: lint --- native/libp2p_port/internal/proto_helpers/proto_helpers.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/native/libp2p_port/internal/proto_helpers/proto_helpers.go b/native/libp2p_port/internal/proto_helpers/proto_helpers.go index 2eedcd24b..92931100e 100644 --- a/native/libp2p_port/internal/proto_helpers/proto_helpers.go +++ b/native/libp2p_port/internal/proto_helpers/proto_helpers.go @@ -20,7 +20,7 @@ func ConfigFromInitArgs(initArgs *proto_defs.InitArgs) Config { } } -func JoinNotification(topic string) proto_defs.Notification{ +func JoinNotification(topic string) proto_defs.Notification { joinNotification := &proto_defs.Join{Topic: topic} return proto_defs.Notification{N: &proto_defs.Notification_Joined{Joined: joinNotification}} } @@ -35,7 +35,7 @@ func GraftNotification(id []byte, topic string) proto_defs.Notification { return proto_defs.Notification{N: &proto_defs.Notification_Grafted{Grafted: graftNotification}} } -func PruneNotification(id [] byte, topic string) proto_defs.Notification { +func PruneNotification(id []byte, topic string) proto_defs.Notification { pruneNotification := &proto_defs.Prune{PeerId: id, Topic: topic} return proto_defs.Notification{N: &proto_defs.Notification_Pruned{Pruned: pruneNotification}} } From 19bd92c6ea6fbab126e3c8c65dd1ba2dc00e7beb Mon Sep 17 00:00:00 2001 From: Godspower Eze Date: Tue, 28 Nov 2023 19:15:56 +0100 Subject: [PATCH 06/14] update --- lib/lambda_ethereum_consensus/telemetry.ex | 4 +- lib/libp2p_port.ex | 14 ++- .../grafana/provisioning/dashboards/home.json | 109 +++++++++++++++++- 3 files changed, 119 insertions(+), 8 deletions(-) diff --git a/lib/lambda_ethereum_consensus/telemetry.ex b/lib/lambda_ethereum_consensus/telemetry.ex index 0169f7062..25d5a5986 100644 --- a/lib/lambda_ethereum_consensus/telemetry.ex +++ b/lib/lambda_ethereum_consensus/telemetry.ex @@ -59,7 +59,9 @@ defmodule LambdaEthereumConsensus.Telemetry do counter("peers.connection.count", tags: [:result]), counter("peers.challenge.count", tags: [:result]), counter("network.request.count", tags: [:result, :type, :reason]), - # counter("network.pubsub.topic") + counter("network.pubsub_topic_active.count", tags: [:topic]), + counter("network.pubsub_topics_graft.count", tags: [:topic]), + counter("network.pubsub_topics_prune.count", tags: [:topic]), counter("port.message.count", tags: [:function, :direction]), sum("network.request.blocks", tags: [:result, :type, :reason]), diff --git a/lib/libp2p_port.ex b/lib/libp2p_port.ex index 45a2f918c..889f32a3b 100644 --- a/lib/libp2p_port.ex +++ b/lib/libp2p_port.ex @@ -314,7 +314,19 @@ defmodule LambdaEthereumConsensus.Libp2pPort do end defp handle_notification(%Join{topic: topic}, _state) do - :telemetry.execute([:network, :pubsub], %{topic: topic}) + :telemetry.execute([:network, :pubsub_topic_active], %{}, %{topic: topic}) + end + + defp handle_notification(%Leave{topic: topic}, _state) do + :telemetry.execute([:network, :pubsub_topic_active], %{}, %{topic: topic}) + end + + defp handle_notification(%Graft{peer_id: peer_id, topic: topic}, _state) do + :telemetry.execute([:network, :pubsub_topics_graft], %{}, %{topic: topic}) + end + + defp handle_notification(%Prune{peer_id: peer_id, topic: topic}, _state) do + :telemetry.execute([:network, :pubsub_topics_prune], %{}, %{topic: topic}) end defp parse_args(args) do diff --git a/metrics/grafana/provisioning/dashboards/home.json b/metrics/grafana/provisioning/dashboards/home.json index 17eadf027..dee7d70e7 100644 --- a/metrics/grafana/provisioning/dashboards/home.json +++ b/metrics/grafana/provisioning/dashboards/home.json @@ -67,9 +67,7 @@ "minVizWidth": 75, "orientation": "auto", "reduceOptions": { - "calcs": [ - "lastNotNull" - ], + "calcs": ["lastNotNull"], "fields": "", "values": false }, @@ -130,9 +128,7 @@ }, "pieType": "pie", "reduceOptions": { - "calcs": [ - "lastNotNull" - ], + "calcs": ["lastNotNull"], "fields": "", "values": false }, @@ -899,6 +895,107 @@ ], "title": "Libp2pPort messages", "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 12, + "x": 0, + "y": 18 + }, + "id": 12, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "disableTextWrap": false, + "editorMode": "code", + "exemplar": false, + "expr": "network_pubsub_topics_graft_count", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "interval": "", + "legendFormat": "incoming", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Graft", + "type": "timeseries" } ], "refresh": "30s", From f2e267e457daf739d1dbbae8973512380f7fa5c2 Mon Sep 17 00:00:00 2001 From: Godspower Eze Date: Tue, 28 Nov 2023 19:18:26 +0100 Subject: [PATCH 07/14] fix lint --- lib/libp2p_port.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libp2p_port.ex b/lib/libp2p_port.ex index 889f32a3b..7918965ed 100644 --- a/lib/libp2p_port.ex +++ b/lib/libp2p_port.ex @@ -20,8 +20,8 @@ defmodule LambdaEthereumConsensus.Libp2pPort do Leave, NewPeer, Notification, - Publish, Prune, + Publish, Request, Result, ResultMessage, From 0721dc47e343786e360964301a018b9fa6870dd8 Mon Sep 17 00:00:00 2001 From: Godspower Eze Date: Wed, 29 Nov 2023 15:18:52 +0100 Subject: [PATCH 08/14] feat: added new graphs --- lib/lambda_ethereum_consensus/telemetry.ex | 5 + lib/libp2p_port.ex | 27 +- .../grafana/provisioning/dashboards/home.json | 614 +++++++++++++++++- .../internal/proto_helpers/proto_helpers.go | 25 + .../internal/subscriptions/subscriptions.go | 21 +- proto/libp2p.proto | 25 + 6 files changed, 704 insertions(+), 13 deletions(-) diff --git a/lib/lambda_ethereum_consensus/telemetry.ex b/lib/lambda_ethereum_consensus/telemetry.ex index 25d5a5986..dae0bfc42 100644 --- a/lib/lambda_ethereum_consensus/telemetry.ex +++ b/lib/lambda_ethereum_consensus/telemetry.ex @@ -62,6 +62,11 @@ defmodule LambdaEthereumConsensus.Telemetry do counter("network.pubsub_topic_active.count", tags: [:topic]), counter("network.pubsub_topics_graft.count", tags: [:topic]), counter("network.pubsub_topics_prune.count", tags: [:topic]), + counter("network.pubsub_topics_deliver_message.count", tags: [:topic]), + counter("network.pubsub_topics_duplicate_message.count", tags: [:topic]), + counter("network.pubsub_topics_reject_message.count", tags: [:topic]), + counter("network.pubsub_topics_un_deliverable_message.count", tags: [:topic]), + counter("network.pubsub_topics_validate_message.count", tags: [:topic]), counter("port.message.count", tags: [:function, :direction]), sum("network.request.blocks", tags: [:result, :type, :reason]), diff --git a/lib/libp2p_port.ex b/lib/libp2p_port.ex index 7918965ed..56881a74c 100644 --- a/lib/libp2p_port.ex +++ b/lib/libp2p_port.ex @@ -12,6 +12,8 @@ defmodule LambdaEthereumConsensus.Libp2pPort do alias Libp2pProto.{ AddPeer, Command, + DeliverMessage, + DuplicateMessage, GetId, GossipSub, Graft, @@ -22,6 +24,7 @@ defmodule LambdaEthereumConsensus.Libp2pPort do Notification, Prune, Publish, + RejectMessage, Request, Result, ResultMessage, @@ -29,8 +32,10 @@ defmodule LambdaEthereumConsensus.Libp2pPort do SendResponse, SetHandler, SubscribeToTopic, + UnDeliverableMessage, UnsubscribeFromTopic, - ValidateMessage + ValidateMessage, + ValidateMessageGossip } require Logger @@ -329,6 +334,26 @@ defmodule LambdaEthereumConsensus.Libp2pPort do :telemetry.execute([:network, :pubsub_topics_prune], %{}, %{topic: topic}) end + defp handle_notification(%DeliverMessage{topic: topic}, _state) do + :telemetry.execute([:network, :pubsub_topics_deliver_message], %{}, %{topic: topic}) + end + + defp handle_notification(%DuplicateMessage{topic: topic}, _state) do + :telemetry.execute([:network, :pubsub_topics_duplicate_message], %{}, %{topic: topic}) + end + + defp handle_notification(%RejectMessage{topic: topic}, _state) do + :telemetry.execute([:network, :pubsub_topics_reject_message], %{}, %{topic: topic}) + end + + defp handle_notification(%UnDeliverableMessage{topic: topic}, _state) do + :telemetry.execute([:network, :pubsub_topics_un_deliverable_message], %{}, %{topic: topic}) + end + + defp handle_notification(%ValidateMessageGossip{topic: topic}, _state) do + :telemetry.execute([:network, :pubsub_topics_validate_message], %{}, %{topic: topic}) + end + defp parse_args(args) do args |> Keyword.validate!(@default_args) diff --git a/metrics/grafana/provisioning/dashboards/home.json b/metrics/grafana/provisioning/dashboards/home.json index dee7d70e7..4e3e89aa8 100644 --- a/metrics/grafana/provisioning/dashboards/home.json +++ b/metrics/grafana/provisioning/dashboards/home.json @@ -893,7 +893,411 @@ "refId": "D" } ], - "title": "Libp2pPort messages", + "title": "Libp2pPort Messages", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 12, + "x": 12, + "y": 18 + }, + "id": 12, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "disableTextWrap": false, + "editorMode": "code", + "exemplar": false, + "expr": "rate(network_pubsub_topics_graft_count{}[$__rate_interval])", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "interval": "", + "legendFormat": "{{topic}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Graft", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 12, + "x": 0, + "y": 18 + }, + "id": 12, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "disableTextWrap": false, + "editorMode": "code", + "exemplar": false, + "expr": "rate(network_pubsub_topics_prune_count{}[$__rate_interval])", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "interval": "", + "legendFormat": "{{topic}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Prune", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 12, + "x": 12, + "y": 18 + }, + "id": 12, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "disableTextWrap": false, + "editorMode": "code", + "exemplar": false, + "expr": "rate(network_pubsub_topics_deliver_message_count{}[$__rate_interval])", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "interval": "", + "legendFormat": "{{topic}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Deliver Messages", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 12, + "x": 0, + "y": 18 + }, + "id": 12, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "disableTextWrap": false, + "editorMode": "code", + "exemplar": false, + "expr": "rate(network_pubsub_topics_duplicate_message_count{}[$__rate_interval])", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "interval": "", + "legendFormat": "{{topic}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Duplicate Messages", "type": "timeseries" }, { @@ -983,18 +1387,220 @@ "disableTextWrap": false, "editorMode": "code", "exemplar": false, - "expr": "network_pubsub_topics_graft_count", + "expr": "rate(network_pubsub_topics_reject_message_count{}[$__rate_interval])", "fullMetaSearch": false, "includeNullMetadata": true, "instant": false, "interval": "", - "legendFormat": "incoming", + "legendFormat": "{{topic}}", "range": true, "refId": "A", "useBackend": false } ], - "title": "Graft", + "title": "Reject Messages", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 12, + "x": 12, + "y": 18 + }, + "id": 12, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "disableTextWrap": false, + "editorMode": "code", + "exemplar": false, + "expr": "rate(network_pubsub_topics_un_deliverable_message_count{}[$__rate_interval])", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "interval": "", + "legendFormat": "{{topic}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Undeliverable Messages", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 12, + "x": 12, + "y": 18 + }, + "id": 12, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "disableTextWrap": false, + "editorMode": "code", + "exemplar": false, + "expr": "rate(network_pubsub_topics_validate_message_count{}[$__rate_interval])", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "interval": "", + "legendFormat": "{{topic}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Validate Messages", "type": "timeseries" } ], diff --git a/native/libp2p_port/internal/proto_helpers/proto_helpers.go b/native/libp2p_port/internal/proto_helpers/proto_helpers.go index 92931100e..43c24c443 100644 --- a/native/libp2p_port/internal/proto_helpers/proto_helpers.go +++ b/native/libp2p_port/internal/proto_helpers/proto_helpers.go @@ -40,6 +40,31 @@ func PruneNotification(id []byte, topic string) proto_defs.Notification { return proto_defs.Notification{N: &proto_defs.Notification_Pruned{Pruned: pruneNotification}} } +func ValidateMessageNotification(topic string) proto_defs.Notification { + validateMessageNotification := &proto_defs.ValidateMessageGossip{Topic: topic} + return proto_defs.Notification{N: &proto_defs.Notification_ValidateMessage{ValidateMessage: validateMessageNotification}} +} + +func DeliverMessageNotification(topic string) proto_defs.Notification { + deliverMessageNotification := &proto_defs.DeliverMessage{Topic: topic} + return proto_defs.Notification{N: &proto_defs.Notification_DeliverMessage{DeliverMessage: deliverMessageNotification}} +} + +func UndeliverableMessageNotification(topic string) proto_defs.Notification { + unDeliverableMessageNotification := &proto_defs.UnDeliverableMessage{Topic: topic} + return proto_defs.Notification{N: &proto_defs.Notification_UnDeliverableMessage{UnDeliverableMessage: unDeliverableMessageNotification}} +} + +func RejectMessageNotification(topic string) proto_defs.Notification { + rejectMessageNotification := &proto_defs.RejectMessage{Topic: topic} + return proto_defs.Notification{N: &proto_defs.Notification_RejectMessage{RejectMessage: rejectMessageNotification}} +} + +func DuplicateMessageNotification(topic string) proto_defs.Notification { + duplicateMessageNotification := &proto_defs.DuplicateMessage{Topic: topic} + return proto_defs.Notification{N: &proto_defs.Notification_DuplicateMessage{DuplicateMessage: duplicateMessageNotification}} +} + func GossipNotification(topic string, handler, msgId, message []byte) proto_defs.Notification { gossipSubNotification := &proto_defs.GossipSub{Topic: []byte(topic), Handler: handler, MsgId: msgId, Message: message} return proto_defs.Notification{N: &proto_defs.Notification_Gossip{Gossip: gossipSubNotification}} diff --git a/native/libp2p_port/internal/subscriptions/subscriptions.go b/native/libp2p_port/internal/subscriptions/subscriptions.go index 2ac33b39f..72de83d2d 100644 --- a/native/libp2p_port/internal/subscriptions/subscriptions.go +++ b/native/libp2p_port/internal/subscriptions/subscriptions.go @@ -62,19 +62,28 @@ func (g GossipTracer) Prune(p peer.ID, topic string) { } func (g GossipTracer) ValidateMessage(msg *pubsub.Message) { - // no-op + notification := proto_helpers.ValidateMessageNotification(*msg.Topic) + g.port.SendNotification(¬ification) } func (g GossipTracer) DeliverMessage(msg *pubsub.Message) { - // no-op + notification := proto_helpers.DeliverMessageNotification(*msg.Topic) + g.port.SendNotification(¬ification) +} + +func (g GossipTracer) UndeliverableMessage(msg *pubsub.Message) { + notification := proto_helpers.UndeliverableMessageNotification(*msg.Topic) + g.port.SendNotification(¬ification) } func (g GossipTracer) RejectMessage(msg *pubsub.Message, reason string) { - // no-op + notification := proto_helpers.RejectMessageNotification(*msg.Topic) + g.port.SendNotification(¬ification) } func (g GossipTracer) DuplicateMessage(msg *pubsub.Message) { - // no-op + notification := proto_helpers.DuplicateMessageNotification(*msg.Topic) + g.port.SendNotification(¬ification) } func (g GossipTracer) ThrottlePeer(p peer.ID) { @@ -93,10 +102,6 @@ func (g GossipTracer) DropRPC(rpc *pubsub.RPC, p peer.ID) { // no-op } -func (g GossipTracer) UndeliverableMessage(msg *pubsub.Message) { - // no-op -} - func NewSubscriber(p *port.Port, h host.Host) Subscriber { heartbeat := 700 * time.Millisecond gsubParams := pubsub.DefaultGossipSubParams() diff --git a/proto/libp2p.proto b/proto/libp2p.proto index 655492a88..d0c66c4ba 100644 --- a/proto/libp2p.proto +++ b/proto/libp2p.proto @@ -47,6 +47,26 @@ message Prune { string topic = 2; } +message ValidateMessageGossip { + string topic = 1; +} + +message DeliverMessage { + string topic = 1; +} + +message UnDeliverableMessage { + string topic = 1; +} + +message RejectMessage { + string topic = 1; +} + +message DuplicateMessage { + string topic = 1; +} + message AddPeer { bytes id = 1; repeated string addrs = 2; @@ -147,5 +167,10 @@ message Notification { Leave left = 6; Graft grafted = 7; Prune pruned = 8; + ValidateMessageGossip validate_message = 9; + DeliverMessage deliver_message = 10; + UnDeliverableMessage un_deliverable_message = 11; + RejectMessage reject_message = 12; + DuplicateMessage duplicate_message = 13; } } From f58a2691079f4593902d5d83a522dd183a09e4d6 Mon Sep 17 00:00:00 2001 From: Godspower Eze Date: Wed, 29 Nov 2023 18:08:31 +0100 Subject: [PATCH 09/14] feat: added topics activity --- lib/lambda_ethereum_consensus/telemetry.ex | 2 +- lib/libp2p_port.ex | 26 +++-- .../grafana/provisioning/dashboards/home.json | 103 +++++++++++++++++- 3 files changed, 118 insertions(+), 13 deletions(-) diff --git a/lib/lambda_ethereum_consensus/telemetry.ex b/lib/lambda_ethereum_consensus/telemetry.ex index dae0bfc42..d834437e7 100644 --- a/lib/lambda_ethereum_consensus/telemetry.ex +++ b/lib/lambda_ethereum_consensus/telemetry.ex @@ -59,7 +59,7 @@ defmodule LambdaEthereumConsensus.Telemetry do counter("peers.connection.count", tags: [:result]), counter("peers.challenge.count", tags: [:result]), counter("network.request.count", tags: [:result, :type, :reason]), - counter("network.pubsub_topic_active.count", tags: [:topic]), + last_value("network.pubsub_topic_active.active", tags: [:topic]), counter("network.pubsub_topics_graft.count", tags: [:topic]), counter("network.pubsub_topics_prune.count", tags: [:topic]), counter("network.pubsub_topics_deliver_message.count", tags: [:topic]), diff --git a/lib/libp2p_port.ex b/lib/libp2p_port.ex index 56881a74c..19383536c 100644 --- a/lib/libp2p_port.ex +++ b/lib/libp2p_port.ex @@ -319,39 +319,39 @@ defmodule LambdaEthereumConsensus.Libp2pPort do end defp handle_notification(%Join{topic: topic}, _state) do - :telemetry.execute([:network, :pubsub_topic_active], %{}, %{topic: topic}) + :telemetry.execute([:network, :pubsub_topic_active], %{active: 1}, %{topic: get_topic_name(topic)}) end defp handle_notification(%Leave{topic: topic}, _state) do - :telemetry.execute([:network, :pubsub_topic_active], %{}, %{topic: topic}) + :telemetry.execute([:network, :pubsub_topic_active], %{active: 0}, %{topic: get_topic_name(topic)}) end - defp handle_notification(%Graft{peer_id: peer_id, topic: topic}, _state) do - :telemetry.execute([:network, :pubsub_topics_graft], %{}, %{topic: topic}) + defp handle_notification(%Graft{peer_id: _peer_id, topic: topic}, _state) do + :telemetry.execute([:network, :pubsub_topics_graft], %{}, %{topic: get_topic_name(topic)}) end - defp handle_notification(%Prune{peer_id: peer_id, topic: topic}, _state) do - :telemetry.execute([:network, :pubsub_topics_prune], %{}, %{topic: topic}) + defp handle_notification(%Prune{peer_id: _peer_id, topic: topic}, _state) do + :telemetry.execute([:network, :pubsub_topics_prune], %{}, %{topic: get_topic_name(topic)}) end defp handle_notification(%DeliverMessage{topic: topic}, _state) do - :telemetry.execute([:network, :pubsub_topics_deliver_message], %{}, %{topic: topic}) + :telemetry.execute([:network, :pubsub_topics_deliver_message], %{}, %{topic: get_topic_name(topic)}) end defp handle_notification(%DuplicateMessage{topic: topic}, _state) do - :telemetry.execute([:network, :pubsub_topics_duplicate_message], %{}, %{topic: topic}) + :telemetry.execute([:network, :pubsub_topics_duplicate_message], %{}, %{topic: get_topic_name(topic)}) end defp handle_notification(%RejectMessage{topic: topic}, _state) do - :telemetry.execute([:network, :pubsub_topics_reject_message], %{}, %{topic: topic}) + :telemetry.execute([:network, :pubsub_topics_reject_message], %{}, %{topic: get_topic_name(topic)}) end defp handle_notification(%UnDeliverableMessage{topic: topic}, _state) do - :telemetry.execute([:network, :pubsub_topics_un_deliverable_message], %{}, %{topic: topic}) + :telemetry.execute([:network, :pubsub_topics_un_deliverable_message], %{}, %{topic: get_topic_name(topic)}) end defp handle_notification(%ValidateMessageGossip{topic: topic}, _state) do - :telemetry.execute([:network, :pubsub_topics_validate_message], %{}, %{topic: topic}) + :telemetry.execute([:network, :pubsub_topics_validate_message], %{}, %{topic: get_topic_name(topic)}) end defp parse_args(args) do @@ -383,4 +383,8 @@ defmodule LambdaEthereumConsensus.Libp2pPort do {:response, {res, %ResultMessage{message: message}}} -> [res | message] |> List.to_tuple() end end + + defp get_topic_name(topic) do + topic |> String.split("/") |> Enum.fetch!(3) + end end diff --git a/metrics/grafana/provisioning/dashboards/home.json b/metrics/grafana/provisioning/dashboards/home.json index 4e3e89aa8..496ed3f5e 100644 --- a/metrics/grafana/provisioning/dashboards/home.json +++ b/metrics/grafana/provisioning/dashboards/home.json @@ -542,7 +542,7 @@ }, "gridPos": { "h": 6, - "w": 12, + "w": 24, "x": 0, "y": 12 }, @@ -896,6 +896,107 @@ "title": "Libp2pPort Messages", "type": "timeseries" }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 24, + "x": 12, + "y": 12 + }, + "id": 12, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "disableTextWrap": false, + "editorMode": "code", + "exemplar": false, + "expr": "network_pubsub_topic_active_active", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "interval": "", + "legendFormat": "{{topic}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Topics Activity", + "type": "heatmap" + }, { "datasource": { "type": "prometheus", From 62f7f00526eeffb9a8e1cc06b7c7491d0cf9bf10 Mon Sep 17 00:00:00 2001 From: Godspower Eze Date: Wed, 29 Nov 2023 18:11:10 +0100 Subject: [PATCH 10/14] fix: lint --- lib/libp2p_port.ex | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/lib/libp2p_port.ex b/lib/libp2p_port.ex index 19383536c..9838a323b 100644 --- a/lib/libp2p_port.ex +++ b/lib/libp2p_port.ex @@ -319,11 +319,15 @@ defmodule LambdaEthereumConsensus.Libp2pPort do end defp handle_notification(%Join{topic: topic}, _state) do - :telemetry.execute([:network, :pubsub_topic_active], %{active: 1}, %{topic: get_topic_name(topic)}) + :telemetry.execute([:network, :pubsub_topic_active], %{active: 1}, %{ + topic: get_topic_name(topic) + }) end defp handle_notification(%Leave{topic: topic}, _state) do - :telemetry.execute([:network, :pubsub_topic_active], %{active: 0}, %{topic: get_topic_name(topic)}) + :telemetry.execute([:network, :pubsub_topic_active], %{active: 0}, %{ + topic: get_topic_name(topic) + }) end defp handle_notification(%Graft{peer_id: _peer_id, topic: topic}, _state) do @@ -335,23 +339,33 @@ defmodule LambdaEthereumConsensus.Libp2pPort do end defp handle_notification(%DeliverMessage{topic: topic}, _state) do - :telemetry.execute([:network, :pubsub_topics_deliver_message], %{}, %{topic: get_topic_name(topic)}) + :telemetry.execute([:network, :pubsub_topics_deliver_message], %{}, %{ + topic: get_topic_name(topic) + }) end defp handle_notification(%DuplicateMessage{topic: topic}, _state) do - :telemetry.execute([:network, :pubsub_topics_duplicate_message], %{}, %{topic: get_topic_name(topic)}) + :telemetry.execute([:network, :pubsub_topics_duplicate_message], %{}, %{ + topic: get_topic_name(topic) + }) end defp handle_notification(%RejectMessage{topic: topic}, _state) do - :telemetry.execute([:network, :pubsub_topics_reject_message], %{}, %{topic: get_topic_name(topic)}) + :telemetry.execute([:network, :pubsub_topics_reject_message], %{}, %{ + topic: get_topic_name(topic) + }) end defp handle_notification(%UnDeliverableMessage{topic: topic}, _state) do - :telemetry.execute([:network, :pubsub_topics_un_deliverable_message], %{}, %{topic: get_topic_name(topic)}) + :telemetry.execute([:network, :pubsub_topics_un_deliverable_message], %{}, %{ + topic: get_topic_name(topic) + }) end defp handle_notification(%ValidateMessageGossip{topic: topic}, _state) do - :telemetry.execute([:network, :pubsub_topics_validate_message], %{}, %{topic: get_topic_name(topic)}) + :telemetry.execute([:network, :pubsub_topics_validate_message], %{}, %{ + topic: get_topic_name(topic) + }) end defp parse_args(args) do From e3dc54cd8fba0e8f820e864341cbead3fe1c4d47 Mon Sep 17 00:00:00 2001 From: Godspower Eze Date: Wed, 29 Nov 2023 19:09:03 +0100 Subject: [PATCH 11/14] feat: added add/remove peer --- lib/lambda_ethereum_consensus/telemetry.ex | 3 +- lib/libp2p_port.ex | 18 +++- .../grafana/provisioning/dashboards/home.json | 101 ++++++++++++++++++ .../internal/proto_helpers/proto_helpers.go | 16 ++- .../internal/subscriptions/subscriptions.go | 10 +- proto/libp2p.proto | 11 +- 6 files changed, 144 insertions(+), 15 deletions(-) diff --git a/lib/lambda_ethereum_consensus/telemetry.ex b/lib/lambda_ethereum_consensus/telemetry.ex index d834437e7..777275913 100644 --- a/lib/lambda_ethereum_consensus/telemetry.ex +++ b/lib/lambda_ethereum_consensus/telemetry.ex @@ -59,7 +59,8 @@ defmodule LambdaEthereumConsensus.Telemetry do counter("peers.connection.count", tags: [:result]), counter("peers.challenge.count", tags: [:result]), counter("network.request.count", tags: [:result, :type, :reason]), - last_value("network.pubsub_topic_active.active", tags: [:topic]), + sum("network.pubsub_peers.peers", tags: [:result]), + counter("network.pubsub_topic_active.active", tags: [:topic]), counter("network.pubsub_topics_graft.count", tags: [:topic]), counter("network.pubsub_topics_prune.count", tags: [:topic]), counter("network.pubsub_topics_deliver_message.count", tags: [:topic]), diff --git a/lib/libp2p_port.ex b/lib/libp2p_port.ex index 9838a323b..40f8e2a90 100644 --- a/lib/libp2p_port.ex +++ b/lib/libp2p_port.ex @@ -11,6 +11,7 @@ defmodule LambdaEthereumConsensus.Libp2pPort do alias Libp2pProto.{ AddPeer, + AddPeerGossip, Command, DeliverMessage, DuplicateMessage, @@ -25,6 +26,7 @@ defmodule LambdaEthereumConsensus.Libp2pPort do Prune, Publish, RejectMessage, + RemovePeerGossip, Request, Result, ResultMessage, @@ -318,6 +320,18 @@ defmodule LambdaEthereumConsensus.Libp2pPort do send(pid, {:response, result}) end + defp handle_notification(%AddPeerGossip{}, _state) do + :telemetry.execute([:network, :pubsub_peers], %{peers: 1}, %{ + result: "add" + }) + end + + defp handle_notification(%RemovePeerGossip{}, _state) do + :telemetry.execute([:network, :pubsub_peers], %{peers: 0}, %{ + result: "remove" + }) + end + defp handle_notification(%Join{topic: topic}, _state) do :telemetry.execute([:network, :pubsub_topic_active], %{active: 1}, %{ topic: get_topic_name(topic) @@ -330,11 +344,11 @@ defmodule LambdaEthereumConsensus.Libp2pPort do }) end - defp handle_notification(%Graft{peer_id: _peer_id, topic: topic}, _state) do + defp handle_notification(%Graft{topic: topic}, _state) do :telemetry.execute([:network, :pubsub_topics_graft], %{}, %{topic: get_topic_name(topic)}) end - defp handle_notification(%Prune{peer_id: _peer_id, topic: topic}, _state) do + defp handle_notification(%Prune{topic: topic}, _state) do :telemetry.execute([:network, :pubsub_topics_prune], %{}, %{topic: get_topic_name(topic)}) end diff --git a/metrics/grafana/provisioning/dashboards/home.json b/metrics/grafana/provisioning/dashboards/home.json index 496ed3f5e..67529bae7 100644 --- a/metrics/grafana/provisioning/dashboards/home.json +++ b/metrics/grafana/provisioning/dashboards/home.json @@ -896,6 +896,107 @@ "title": "Libp2pPort Messages", "type": "timeseries" }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 24, + "x": 12, + "y": 12 + }, + "id": 12, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "disableTextWrap": false, + "editorMode": "code", + "exemplar": false, + "expr": "sum(network_pubsub_peers_peers{result=\"add\"}) - sum(network_pubsub_peers_peers{result=\"remove\"})", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "interval": "", + "legendFormat": "{{topic}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Peers (Gossip)", + "type": "timeseries" + }, { "datasource": { "type": "prometheus", diff --git a/native/libp2p_port/internal/proto_helpers/proto_helpers.go b/native/libp2p_port/internal/proto_helpers/proto_helpers.go index 43c24c443..b92c768ea 100644 --- a/native/libp2p_port/internal/proto_helpers/proto_helpers.go +++ b/native/libp2p_port/internal/proto_helpers/proto_helpers.go @@ -20,6 +20,14 @@ func ConfigFromInitArgs(initArgs *proto_defs.InitArgs) Config { } } +func AddPeerNotification() proto_defs.Notification { + return proto_defs.Notification{N: &proto_defs.Notification_AddPeer{}} +} + +func RemovePeerNotification() proto_defs.Notification { + return proto_defs.Notification{N: &proto_defs.Notification_RemovePeer{}} +} + func JoinNotification(topic string) proto_defs.Notification { joinNotification := &proto_defs.Join{Topic: topic} return proto_defs.Notification{N: &proto_defs.Notification_Joined{Joined: joinNotification}} @@ -30,13 +38,13 @@ func LeaveNofication(topic string) proto_defs.Notification { return proto_defs.Notification{N: &proto_defs.Notification_Left{Left: leaveNofication}} } -func GraftNotification(id []byte, topic string) proto_defs.Notification { - graftNotification := &proto_defs.Graft{PeerId: id, Topic: topic} +func GraftNotification(topic string) proto_defs.Notification { + graftNotification := &proto_defs.Graft{Topic: topic} return proto_defs.Notification{N: &proto_defs.Notification_Grafted{Grafted: graftNotification}} } -func PruneNotification(id []byte, topic string) proto_defs.Notification { - pruneNotification := &proto_defs.Prune{PeerId: id, Topic: topic} +func PruneNotification(topic string) proto_defs.Notification { + pruneNotification := &proto_defs.Prune{Topic: topic} return proto_defs.Notification{N: &proto_defs.Notification_Pruned{Pruned: pruneNotification}} } diff --git a/native/libp2p_port/internal/subscriptions/subscriptions.go b/native/libp2p_port/internal/subscriptions/subscriptions.go index 72de83d2d..bdd69de95 100644 --- a/native/libp2p_port/internal/subscriptions/subscriptions.go +++ b/native/libp2p_port/internal/subscriptions/subscriptions.go @@ -34,11 +34,13 @@ type GossipTracer struct { } func (g GossipTracer) AddPeer(p peer.ID, proto protocol.ID) { - // no-op + notification := proto_helpers.AddPeerNotification() + g.port.SendNotification(¬ification) } func (g GossipTracer) RemovePeer(p peer.ID) { - // no-op + notification := proto_helpers.RemovePeerNotification() + g.port.SendNotification(¬ification) } func (g GossipTracer) Join(topic string) { @@ -52,12 +54,12 @@ func (g GossipTracer) Leave(topic string) { } func (g GossipTracer) Graft(p peer.ID, topic string) { - notification := proto_helpers.GraftNotification([]byte(p), topic) + notification := proto_helpers.GraftNotification(topic) g.port.SendNotification(¬ification) } func (g GossipTracer) Prune(p peer.ID, topic string) { - notification := proto_helpers.PruneNotification([]byte(p), topic) + notification := proto_helpers.PruneNotification(topic) g.port.SendNotification(¬ification) } diff --git a/proto/libp2p.proto b/proto/libp2p.proto index d0c66c4ba..c0e0111a6 100644 --- a/proto/libp2p.proto +++ b/proto/libp2p.proto @@ -27,6 +27,9 @@ message UnsubscribeFromTopic { string name = 1; } +message AddPeerGossip {} +message RemovePeerGossip {} + message Join { // topic that was joined string topic = 1; @@ -38,13 +41,11 @@ message Leave { } message Graft { - bytes peer_id = 1; - string topic = 2; + string topic = 1; } message Prune { - bytes peer_id = 1; - string topic = 2; + string topic = 1; } message ValidateMessageGossip { @@ -172,5 +173,7 @@ message Notification { UnDeliverableMessage un_deliverable_message = 11; RejectMessage reject_message = 12; DuplicateMessage duplicate_message = 13; + AddPeerGossip add_peer = 14; + RemovePeerGossip remove_peer = 15; } } From fbac9f3f8e7c1ccd2ae786451385a6ded9ec0754 Mon Sep 17 00:00:00 2001 From: Godspower Eze Date: Wed, 29 Nov 2023 19:30:42 +0100 Subject: [PATCH 12/14] fix --- lib/libp2p_port.ex | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/libp2p_port.ex b/lib/libp2p_port.ex index 40f8e2a90..e30a25bee 100644 --- a/lib/libp2p_port.ex +++ b/lib/libp2p_port.ex @@ -413,6 +413,9 @@ defmodule LambdaEthereumConsensus.Libp2pPort do end defp get_topic_name(topic) do - topic |> String.split("/") |> Enum.fetch!(3) + case topic |> String.split("/") |> Enum.fetch(3) do + {:ok, name} -> name + :error -> topic + end end end From 4c8e99437ed865715c3e980dd50bb9dd5d12ea4c Mon Sep 17 00:00:00 2001 From: Godspower Eze Date: Fri, 1 Dec 2023 01:24:01 +0100 Subject: [PATCH 13/14] fic --- lib/lambda_ethereum_consensus/telemetry.ex | 4 +- lib/libp2p_port.ex | 42 +++++++------------ .../grafana/provisioning/dashboards/home.json | 4 +- .../internal/proto_helpers/proto_helpers.go | 35 +++++++++++----- proto/libp2p.proto | 28 ++++++++----- 5 files changed, 61 insertions(+), 52 deletions(-) diff --git a/lib/lambda_ethereum_consensus/telemetry.ex b/lib/lambda_ethereum_consensus/telemetry.ex index 777275913..79920d62e 100644 --- a/lib/lambda_ethereum_consensus/telemetry.ex +++ b/lib/lambda_ethereum_consensus/telemetry.ex @@ -59,8 +59,8 @@ defmodule LambdaEthereumConsensus.Telemetry do counter("peers.connection.count", tags: [:result]), counter("peers.challenge.count", tags: [:result]), counter("network.request.count", tags: [:result, :type, :reason]), - sum("network.pubsub_peers.peers", tags: [:result]), - counter("network.pubsub_topic_active.active", tags: [:topic]), + counter("network.pubsub_peers.count", tags: [:result]), + sum("network.pubsub_topic_active.active", tags: [:topic]), counter("network.pubsub_topics_graft.count", tags: [:topic]), counter("network.pubsub_topics_prune.count", tags: [:topic]), counter("network.pubsub_topics_deliver_message.count", tags: [:topic]), diff --git a/lib/libp2p_port.ex b/lib/libp2p_port.ex index e30a25bee..32593996d 100644 --- a/lib/libp2p_port.ex +++ b/lib/libp2p_port.ex @@ -11,22 +11,13 @@ defmodule LambdaEthereumConsensus.Libp2pPort do alias Libp2pProto.{ AddPeer, - AddPeerGossip, Command, - DeliverMessage, - DuplicateMessage, GetId, GossipSub, - Graft, InitArgs, - Join, - Leave, NewPeer, Notification, - Prune, Publish, - RejectMessage, - RemovePeerGossip, Request, Result, ResultMessage, @@ -34,10 +25,9 @@ defmodule LambdaEthereumConsensus.Libp2pPort do SendResponse, SetHandler, SubscribeToTopic, - UnDeliverableMessage, + Tracer, UnsubscribeFromTopic, - ValidateMessage, - ValidateMessageGossip + ValidateMessage } require Logger @@ -320,63 +310,63 @@ defmodule LambdaEthereumConsensus.Libp2pPort do send(pid, {:response, result}) end - defp handle_notification(%AddPeerGossip{}, _state) do - :telemetry.execute([:network, :pubsub_peers], %{peers: 1}, %{ + defp handle_notification(%Tracer{t: {:add_peer, %{}}}, _state) do + :telemetry.execute([:network, :pubsub_peers], %{}, %{ result: "add" }) end - defp handle_notification(%RemovePeerGossip{}, _state) do - :telemetry.execute([:network, :pubsub_peers], %{peers: 0}, %{ + defp handle_notification(%Tracer{t: {:remove_peer, %{}}}, _state) do + :telemetry.execute([:network, :pubsub_peers], %{}, %{ result: "remove" }) end - defp handle_notification(%Join{topic: topic}, _state) do + defp handle_notification(%Tracer{t: {:joined, %{topic: topic}}}, _state) do :telemetry.execute([:network, :pubsub_topic_active], %{active: 1}, %{ topic: get_topic_name(topic) }) end - defp handle_notification(%Leave{topic: topic}, _state) do - :telemetry.execute([:network, :pubsub_topic_active], %{active: 0}, %{ + defp handle_notification(%Tracer{t: {:left, %{topic: topic}}}, _state) do + :telemetry.execute([:network, :pubsub_topic_active], %{active: -1}, %{ topic: get_topic_name(topic) }) end - defp handle_notification(%Graft{topic: topic}, _state) do + defp handle_notification(%Tracer{t: {:grafted, %{topic: topic}}}, _state) do :telemetry.execute([:network, :pubsub_topics_graft], %{}, %{topic: get_topic_name(topic)}) end - defp handle_notification(%Prune{topic: topic}, _state) do + defp handle_notification(%Tracer{t: {:pruned, %{topic: topic}}}, _state) do :telemetry.execute([:network, :pubsub_topics_prune], %{}, %{topic: get_topic_name(topic)}) end - defp handle_notification(%DeliverMessage{topic: topic}, _state) do + defp handle_notification(%Tracer{t: {:deliver_message, %{topic: topic}}}, _state) do :telemetry.execute([:network, :pubsub_topics_deliver_message], %{}, %{ topic: get_topic_name(topic) }) end - defp handle_notification(%DuplicateMessage{topic: topic}, _state) do + defp handle_notification(%Tracer{t: {:duplicate_message, %{topic: topic}}}, _state) do :telemetry.execute([:network, :pubsub_topics_duplicate_message], %{}, %{ topic: get_topic_name(topic) }) end - defp handle_notification(%RejectMessage{topic: topic}, _state) do + defp handle_notification(%Tracer{t: {:reject_message, %{topic: topic}}}, _state) do :telemetry.execute([:network, :pubsub_topics_reject_message], %{}, %{ topic: get_topic_name(topic) }) end - defp handle_notification(%UnDeliverableMessage{topic: topic}, _state) do + defp handle_notification(%Tracer{t: {:un_deliverable_message, %{topic: topic}}}, _state) do :telemetry.execute([:network, :pubsub_topics_un_deliverable_message], %{}, %{ topic: get_topic_name(topic) }) end - defp handle_notification(%ValidateMessageGossip{topic: topic}, _state) do + defp handle_notification(%Tracer{t: {:validate_message, %{topic: topic}}}, _state) do :telemetry.execute([:network, :pubsub_topics_validate_message], %{}, %{ topic: get_topic_name(topic) }) diff --git a/metrics/grafana/provisioning/dashboards/home.json b/metrics/grafana/provisioning/dashboards/home.json index 67529bae7..a4f1482ce 100644 --- a/metrics/grafana/provisioning/dashboards/home.json +++ b/metrics/grafana/provisioning/dashboards/home.json @@ -983,12 +983,12 @@ "disableTextWrap": false, "editorMode": "code", "exemplar": false, - "expr": "sum(network_pubsub_peers_peers{result=\"add\"}) - sum(network_pubsub_peers_peers{result=\"remove\"})", + "expr": "sum(network_pubsub_peers_count{result=\"add\"}) - sum(network_pubsub_peers_count{result=\"remove\"})", "fullMetaSearch": false, "includeNullMetadata": true, "instant": false, "interval": "", - "legendFormat": "{{topic}}", + "legendFormat": "__auto", "range": true, "refId": "A", "useBackend": false diff --git a/native/libp2p_port/internal/proto_helpers/proto_helpers.go b/native/libp2p_port/internal/proto_helpers/proto_helpers.go index b92c768ea..9fb9b6888 100644 --- a/native/libp2p_port/internal/proto_helpers/proto_helpers.go +++ b/native/libp2p_port/internal/proto_helpers/proto_helpers.go @@ -21,56 +21,69 @@ func ConfigFromInitArgs(initArgs *proto_defs.InitArgs) Config { } func AddPeerNotification() proto_defs.Notification { - return proto_defs.Notification{N: &proto_defs.Notification_AddPeer{}} + addPeerNotification := &proto_defs.AddPeerGossip{} + tracer := &proto_defs.Tracer{T: &proto_defs.Tracer_AddPeer{AddPeer: addPeerNotification}} + return proto_defs.Notification{N: &proto_defs.Notification_Tracer{Tracer: tracer}} } func RemovePeerNotification() proto_defs.Notification { - return proto_defs.Notification{N: &proto_defs.Notification_RemovePeer{}} + removePeerNotification := &proto_defs.RemovePeerGossip{} + tracer := &proto_defs.Tracer{T: &proto_defs.Tracer_RemovePeer{RemovePeer: removePeerNotification}} + return proto_defs.Notification{N: &proto_defs.Notification_Tracer{Tracer: tracer}} } func JoinNotification(topic string) proto_defs.Notification { joinNotification := &proto_defs.Join{Topic: topic} - return proto_defs.Notification{N: &proto_defs.Notification_Joined{Joined: joinNotification}} + tracer := &proto_defs.Tracer{T: &proto_defs.Tracer_Joined{Joined: joinNotification}} + return proto_defs.Notification{N: &proto_defs.Notification_Tracer{Tracer: tracer}} } func LeaveNofication(topic string) proto_defs.Notification { leaveNofication := &proto_defs.Leave{Topic: topic} - return proto_defs.Notification{N: &proto_defs.Notification_Left{Left: leaveNofication}} + tracer := &proto_defs.Tracer{T: &proto_defs.Tracer_Left{Left: leaveNofication}} + return proto_defs.Notification{N: &proto_defs.Notification_Tracer{Tracer: tracer}} } func GraftNotification(topic string) proto_defs.Notification { graftNotification := &proto_defs.Graft{Topic: topic} - return proto_defs.Notification{N: &proto_defs.Notification_Grafted{Grafted: graftNotification}} + tracer := &proto_defs.Tracer{T: &proto_defs.Tracer_Grafted{Grafted: graftNotification}} + return proto_defs.Notification{N: &proto_defs.Notification_Tracer{Tracer: tracer}} } func PruneNotification(topic string) proto_defs.Notification { pruneNotification := &proto_defs.Prune{Topic: topic} - return proto_defs.Notification{N: &proto_defs.Notification_Pruned{Pruned: pruneNotification}} + tracer := &proto_defs.Tracer{T: &proto_defs.Tracer_Pruned{Pruned: pruneNotification}} + return proto_defs.Notification{N: &proto_defs.Notification_Tracer{Tracer: tracer}} } func ValidateMessageNotification(topic string) proto_defs.Notification { validateMessageNotification := &proto_defs.ValidateMessageGossip{Topic: topic} - return proto_defs.Notification{N: &proto_defs.Notification_ValidateMessage{ValidateMessage: validateMessageNotification}} + tracer := &proto_defs.Tracer{T: &proto_defs.Tracer_ValidateMessage{ValidateMessage: validateMessageNotification}} + return proto_defs.Notification{N: &proto_defs.Notification_Tracer{Tracer: tracer}} } func DeliverMessageNotification(topic string) proto_defs.Notification { deliverMessageNotification := &proto_defs.DeliverMessage{Topic: topic} - return proto_defs.Notification{N: &proto_defs.Notification_DeliverMessage{DeliverMessage: deliverMessageNotification}} + tracer := &proto_defs.Tracer{T: &proto_defs.Tracer_DeliverMessage{DeliverMessage: deliverMessageNotification}} + return proto_defs.Notification{N: &proto_defs.Notification_Tracer{Tracer: tracer}} } func UndeliverableMessageNotification(topic string) proto_defs.Notification { unDeliverableMessageNotification := &proto_defs.UnDeliverableMessage{Topic: topic} - return proto_defs.Notification{N: &proto_defs.Notification_UnDeliverableMessage{UnDeliverableMessage: unDeliverableMessageNotification}} + tracer := &proto_defs.Tracer{T: &proto_defs.Tracer_UnDeliverableMessage{UnDeliverableMessage: unDeliverableMessageNotification}} + return proto_defs.Notification{N: &proto_defs.Notification_Tracer{Tracer: tracer}} } func RejectMessageNotification(topic string) proto_defs.Notification { rejectMessageNotification := &proto_defs.RejectMessage{Topic: topic} - return proto_defs.Notification{N: &proto_defs.Notification_RejectMessage{RejectMessage: rejectMessageNotification}} + tracer := &proto_defs.Tracer{T: &proto_defs.Tracer_RejectMessage{RejectMessage: rejectMessageNotification}} + return proto_defs.Notification{N: &proto_defs.Notification_Tracer{Tracer: tracer}} } func DuplicateMessageNotification(topic string) proto_defs.Notification { duplicateMessageNotification := &proto_defs.DuplicateMessage{Topic: topic} - return proto_defs.Notification{N: &proto_defs.Notification_DuplicateMessage{DuplicateMessage: duplicateMessageNotification}} + tracer := &proto_defs.Tracer{T: &proto_defs.Tracer_DuplicateMessage{DuplicateMessage: duplicateMessageNotification}} + return proto_defs.Notification{N: &proto_defs.Notification_Tracer{Tracer: tracer}} } func GossipNotification(topic string, handler, msgId, message []byte) proto_defs.Notification { diff --git a/proto/libp2p.proto b/proto/libp2p.proto index c0e0111a6..936852217 100644 --- a/proto/libp2p.proto +++ b/proto/libp2p.proto @@ -158,22 +158,28 @@ message Result { } } +message Tracer { + oneof t { + Join joined = 1; + Leave left = 2; + Graft grafted = 3; + Prune pruned = 4; + ValidateMessageGossip validate_message = 5; + DeliverMessage deliver_message = 6; + UnDeliverableMessage un_deliverable_message = 7; + RejectMessage reject_message = 8; + DuplicateMessage duplicate_message = 9; + AddPeerGossip add_peer = 10; + RemovePeerGossip remove_peer = 11; + } +} + message Notification { oneof n { GossipSub gossip = 1; Request request = 2; NewPeer new_peer = 3; Result result = 4; - Join joined = 5; - Leave left = 6; - Graft grafted = 7; - Prune pruned = 8; - ValidateMessageGossip validate_message = 9; - DeliverMessage deliver_message = 10; - UnDeliverableMessage un_deliverable_message = 11; - RejectMessage reject_message = 12; - DuplicateMessage duplicate_message = 13; - AddPeerGossip add_peer = 14; - RemovePeerGossip remove_peer = 15; + Tracer tracer = 5; } } From 4cb1d20b85048706035124f295f36f993e232eb9 Mon Sep 17 00:00:00 2001 From: Godspower Eze Date: Mon, 4 Dec 2023 08:27:17 +0100 Subject: [PATCH 14/14] fix --- .../grafana/provisioning/dashboards/home.json | 105 +----------------- 1 file changed, 2 insertions(+), 103 deletions(-) diff --git a/metrics/grafana/provisioning/dashboards/home.json b/metrics/grafana/provisioning/dashboards/home.json index a4f1482ce..feda66b71 100644 --- a/metrics/grafana/provisioning/dashboards/home.json +++ b/metrics/grafana/provisioning/dashboards/home.json @@ -1185,7 +1185,7 @@ "disableTextWrap": false, "editorMode": "code", "exemplar": false, - "expr": "rate(network_pubsub_topics_graft_count{}[$__rate_interval])", + "expr": "network_pubsub_topics_graft_count{} - network_pubsub_topics_prune_count{}", "fullMetaSearch": false, "includeNullMetadata": true, "instant": false, @@ -1196,108 +1196,7 @@ "useBackend": false } ], - "title": "Graft", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "PBFA97CFB590B2093" - }, - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisBorderShow": false, - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 0, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "insertNulls": false, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "auto", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - } - }, - "overrides": [] - }, - "gridPos": { - "h": 6, - "w": 12, - "x": 0, - "y": 18 - }, - "id": 12, - "options": { - "legend": { - "calcs": [], - "displayMode": "list", - "placement": "bottom", - "showLegend": true - }, - "tooltip": { - "mode": "single", - "sort": "none" - } - }, - "targets": [ - { - "datasource": { - "type": "prometheus", - "uid": "PBFA97CFB590B2093" - }, - "disableTextWrap": false, - "editorMode": "code", - "exemplar": false, - "expr": "rate(network_pubsub_topics_prune_count{}[$__rate_interval])", - "fullMetaSearch": false, - "includeNullMetadata": true, - "instant": false, - "interval": "", - "legendFormat": "{{topic}}", - "range": true, - "refId": "A", - "useBackend": false - } - ], - "title": "Prune", + "title": "Grafted", "type": "timeseries" }, {