diff --git a/cl/sentinel/service/service.go b/cl/sentinel/service/service.go index ae5464b890a..ef260b86141 100644 --- a/cl/sentinel/service/service.go +++ b/cl/sentinel/service/service.go @@ -427,6 +427,7 @@ func trackPeerStatistics(peerID string, inbound bool, msgType string, msgCap str isDiagEnabled := diagnostics.TypeOf(diagnostics.PeerStatisticMsgUpdate{}).Enabled() if isDiagEnabled { diagnostics.Send(diagnostics.PeerStatisticMsgUpdate{ + PeerName: "TODO", PeerType: "Sentinel", PeerID: peerID, Inbound: inbound, diff --git a/diagnostics/peers.go b/diagnostics/peers.go index b3b231d9e17..7a3d671a1b7 100644 --- a/diagnostics/peers.go +++ b/diagnostics/peers.go @@ -80,7 +80,7 @@ func peers(diag *diaglib.DiagnosticClient) []*PeerResponse { ENR: "", //TODO: find a way how to get missing data Enode: "", ID: key, - Name: "", + Name: value.PeerName, Type: value.PeerType, Caps: []string{}, Network: PeerNetworkInfo{ diff --git a/erigon-lib/diagnostics/entities.go b/erigon-lib/diagnostics/entities.go index dc850e2fb50..47ed915b8bb 100644 --- a/erigon-lib/diagnostics/entities.go +++ b/erigon-lib/diagnostics/entities.go @@ -23,6 +23,7 @@ import ( ) type PeerStatistics struct { + PeerName string PeerType string BytesIn uint64 BytesOut uint64 @@ -48,7 +49,8 @@ func (p PeerStatistics) Equal(p2 PeerStatistics) bool { maps.Equal(p.CapBytesIn, p2.CapBytesIn) && maps.Equal(p.CapBytesOut, p2.CapBytesOut) && maps.Equal(p.TypeBytesIn, p2.TypeBytesIn) && - maps.Equal(p.TypeBytesOut, p2.TypeBytesOut) + maps.Equal(p.TypeBytesOut, p2.TypeBytesOut) && + p.PeerName == p2.PeerName } type PeerDataUpdate struct { @@ -62,6 +64,7 @@ type PeerDataUpdate struct { } type PeerStatisticMsgUpdate struct { + PeerName string PeerType string PeerID string Inbound bool diff --git a/erigon-lib/diagnostics/network.go b/erigon-lib/diagnostics/network.go index 004d2025de7..9cd39a7d02b 100644 --- a/erigon-lib/diagnostics/network.go +++ b/erigon-lib/diagnostics/network.go @@ -93,6 +93,7 @@ func PeerStatisticsFromMsgUpdate(msg PeerStatisticMsgUpdate, prevValue any) Peer func peerStatisticsFromMsgUpdate(msg PeerStatisticMsgUpdate, prevValue any) PeerStatistics { ps := PeerStatistics{ + PeerName: msg.PeerName, PeerType: msg.PeerType, BytesIn: 0, BytesOut: 0, diff --git a/erigon-lib/diagnostics/network_test.go b/erigon-lib/diagnostics/network_test.go index 3ea6f916391..ac2749ce1ec 100644 --- a/erigon-lib/diagnostics/network_test.go +++ b/erigon-lib/diagnostics/network_test.go @@ -45,6 +45,7 @@ var mockOutboundPeerStats = diagnostics.PeerStatistics{ } var mockInboundUpdMsg = diagnostics.PeerStatisticMsgUpdate{ + PeerName: "", PeerType: "Sentinel", PeerID: "test1", Inbound: true, @@ -54,6 +55,7 @@ var mockInboundUpdMsg = diagnostics.PeerStatisticMsgUpdate{ } var mockOutboundUpdMsg = diagnostics.PeerStatisticMsgUpdate{ + PeerName: "", PeerType: "Sentinel", PeerID: "test1", Inbound: false, diff --git a/p2p/sentry/sentry_grpc_server.go b/p2p/sentry/sentry_grpc_server.go index c6f57fbb32b..0e1c0258bb4 100644 --- a/p2p/sentry/sentry_grpc_server.go +++ b/p2p/sentry/sentry_grpc_server.go @@ -558,17 +558,18 @@ func runPeer( msgType := eth.ToProto[protocol][msg.Code] msgCap := cap.String() - trackPeerStatistics(peerInfo.peer.Info().ID, true, msgType.String(), msgCap, int(msg.Size)) + trackPeerStatistics(peerInfo.peer.Info().Name, peerInfo.peer.Info().ID, true, msgType.String(), msgCap, int(msg.Size)) msg.Discard() peerInfo.ClearDeadlines(time.Now(), givePermit) } } -func trackPeerStatistics(peerID string, inbound bool, msgType string, msgCap string, bytes int) { +func trackPeerStatistics(peerName string, peerID string, inbound bool, msgType string, msgCap string, bytes int) { isDiagEnabled := diagnostics.TypeOf(diagnostics.PeerStatisticMsgUpdate{}).Enabled() if isDiagEnabled { stats := diagnostics.PeerStatisticMsgUpdate{ + PeerName: peerName, PeerID: peerID, Inbound: inbound, MsgType: msgType, @@ -778,7 +779,7 @@ func (ss *GrpcServer) writePeer(logPrefix string, peerInfo *PeerInfo, msgcode ui cap := p2p.Cap{Name: eth.ProtocolName, Version: peerInfo.protocol} msgType := eth.ToProto[cap.Version][msgcode] - trackPeerStatistics(peerInfo.peer.Info().ID, false, msgType.String(), cap.String(), len(data)) + trackPeerStatistics(peerInfo.peer.Info().Name, peerInfo.peer.Info().ID, false, msgType.String(), cap.String(), len(data)) err := peerInfo.rw.WriteMsg(p2p.Msg{Code: msgcode, Size: uint32(len(data)), Payload: bytes.NewReader(data)}) if err != nil {