diff --git a/cli/operator/node.go b/cli/operator/node.go index 226d25c629..a4514a4cef 100644 --- a/cli/operator/node.go +++ b/cli/operator/node.go @@ -45,7 +45,6 @@ import ( genesisvalidation "github.com/ssvlabs/ssv/message/validation/genesis" "github.com/ssvlabs/ssv/migrations" "github.com/ssvlabs/ssv/monitoring/metrics" - "github.com/ssvlabs/ssv/monitoring/metricsreporter" "github.com/ssvlabs/ssv/network" p2pv1 "github.com/ssvlabs/ssv/network/p2p" "github.com/ssvlabs/ssv/networkconfig" @@ -115,10 +114,6 @@ var StartNodeCmd = &cobra.Command{ logger.Info(fmt.Sprintf("starting %v", commons.GetBuildData())) - metricsReporter := metricsreporter.New( - metricsreporter.WithLogger(logger), - ) - observabilityShutdown, err := observability.Initialize( cmd.Parent().Short, cmd.Parent().Version, @@ -268,7 +263,7 @@ var StartNodeCmd = &cobra.Command{ cfg.P2pNetworkConfig.MessageValidator = messageValidator cfg.SSVOptions.ValidatorOptions.MessageValidator = messageValidator - p2pNetwork, genesisP2pNetwork := setupP2P(logger, db, metricsReporter) + p2pNetwork, genesisP2pNetwork := setupP2P(logger, db) cfg.SSVOptions.Context = cmd.Context() cfg.SSVOptions.DB = db @@ -378,7 +373,6 @@ var StartNodeCmd = &cobra.Command{ logger, executionClient, validatorCtrl, - metricsReporter, networkConfig, nodeStorage, operatorDataStore, @@ -655,7 +649,7 @@ func setupSSVNetwork(logger *zap.Logger) (networkconfig.NetworkConfig, error) { return networkConfig, nil } -func setupP2P(logger *zap.Logger, db basedb.Database, mr metricsreporter.MetricsReporter) (network.P2PNetwork, p2pv1.GenesisP2P) { +func setupP2P(logger *zap.Logger, db basedb.Database) (network.P2PNetwork, p2pv1.GenesisP2P) { istore := ssv_identity.NewIdentityStore(db) netPrivKey, err := istore.SetupNetworkKey(logger, cfg.NetworkPrivateKey) if err != nil { @@ -689,7 +683,6 @@ func setupEventHandling( logger *zap.Logger, executionClient *executionclient.ExecutionClient, validatorCtrl validator.Controller, - metricsReporter metricsreporter.MetricsReporter, networkConfig networkconfig.NetworkConfig, nodeStorage operatorstorage.Storage, operatorDataStore operatordatastore.OperatorDataStore, diff --git a/message/validation/genesis/validation.go b/message/validation/genesis/validation.go index 873726b00c..e796d6a4b9 100644 --- a/message/validation/genesis/validation.go +++ b/message/validation/genesis/validation.go @@ -27,7 +27,6 @@ import ( "github.com/ssvlabs/ssv/utils/hashmap" "github.com/ssvlabs/ssv/logging/fields" - "github.com/ssvlabs/ssv/monitoring/metricsreporter" "github.com/ssvlabs/ssv/network/commons" "github.com/ssvlabs/ssv/networkconfig" "github.com/ssvlabs/ssv/operator/duties/dutystore" @@ -63,7 +62,6 @@ type MessageValidator interface { type messageValidator struct { logger *zap.Logger - metrics metricsreporter.MetricsReporter netCfg networkconfig.NetworkConfig index sync.Map nodeStorage operatorstorage.Storage @@ -83,7 +81,6 @@ type messageValidator struct { func New(netCfg networkconfig.NetworkConfig, opts ...Option) MessageValidator { mv := &messageValidator{ logger: zap.NewNop(), - metrics: metricsreporter.NewNop(), netCfg: netCfg, operatorIDToPubkeyCache: hashmap.New[spectypes.OperatorID, keys.OperatorPublicKey](), validationLocks: make(map[spectypes.MessageID]*sync.Mutex), @@ -106,13 +103,6 @@ func WithLogger(logger *zap.Logger) Option { } } -// WithMetrics sets the metrics for the messageValidator. -func WithMetrics(metrics metricsreporter.MetricsReporter) Option { - return func(mv *messageValidator) { - mv.metrics = metrics - } -} - // WithDutyStore sets the duty store for the messageValidator. func WithDutyStore(dutyStore *dutystore.Store) Option { return func(mv *messageValidator) { @@ -292,7 +282,6 @@ func (mv *messageValidator) validateP2PMessage(pMsg *pubsub.Message, receivedAt } signatureVerifier := func() error { - mv.metrics.MessageValidationRSAVerifications() return mv.verifySignature(signedSSVMsg) } diff --git a/monitoring/metricsreporter/metrics_reporter.go b/monitoring/metricsreporter/metrics_reporter.go deleted file mode 100644 index 4e4fc065f6..0000000000 --- a/monitoring/metricsreporter/metrics_reporter.go +++ /dev/null @@ -1,168 +0,0 @@ -package metricsreporter - -import ( - "crypto/sha256" - "fmt" - "strconv" - "time" - - "github.com/libp2p/go-libp2p/core/peer" - "github.com/prometheus/client_golang/prometheus" - "github.com/prometheus/client_golang/prometheus/promauto" - spectypes "github.com/ssvlabs/ssv-spec/types" - "go.uber.org/zap" - - ssvmessage "github.com/ssvlabs/ssv/protocol/v2/message" -) - -var ( - operatorIndex = promauto.NewGaugeVec(prometheus.GaugeOpts{ - Name: "ssv:exporter:operator_index", - Help: "operator footprint", - }, []string{"pubKey", "index"}) - signatureValidationDuration = promauto.NewHistogramVec(prometheus.HistogramOpts{ - Name: "ssv_signature_validation_duration_seconds", - Help: "Signature validation duration (seconds)", - Buckets: []float64{0.001, 0.005, 0.010, 0.020, 0.050}, - }, []string{}) - incomingQueueMessages = promauto.NewCounterVec(prometheus.CounterOpts{ - Name: "ssv_message_queue_incoming", - Help: "The amount of message incoming to the validator's msg queue", - }, []string{"msg_id"}) - outgoingQueueMessages = promauto.NewCounterVec(prometheus.CounterOpts{ - Name: "ssv_message_queue_outgoing", - Help: "The amount of message outgoing from the validator's msg queue", - }, []string{"msg_id"}) - messageQueueSize = promauto.NewGaugeVec(prometheus.GaugeOpts{ - Name: "ssv_message_queue_size", - Help: "Size of message queue", - }, []string{}) - messageQueueCapacity = promauto.NewGaugeVec(prometheus.GaugeOpts{ - Name: "ssv_message_queue_capacity", - Help: "Capacity of message queue", - }, []string{}) - messageTimeInQueue = promauto.NewHistogramVec(prometheus.HistogramOpts{ - Name: "ssv_message_time_in_queue_seconds", - Help: "Time message spent in queue (seconds)", - Buckets: []float64{0.001, 0.005, 0.010, 0.050, 0.100, 0.500, 1, 5, 10, 60}, - }, []string{"msg_id"}) - inCommitteeMessages = promauto.NewCounterVec(prometheus.CounterOpts{ - Name: "ssv_message_in_committee", - Help: "The amount of messages in committee", - }, []string{"ssv_msg_type", "decided"}) - nonCommitteeMessages = promauto.NewCounterVec(prometheus.CounterOpts{ - Name: "ssv_message_non_committee", - Help: "The amount of messages not in committee", - }, []string{"ssv_msg_type", "decided"}) - messageValidationRSAVerifications = promauto.NewCounterVec(prometheus.CounterOpts{ - Name: "ssv_message_validation_rsa_checks", - Help: "The amount message validations", - }, []string{}) - pubsubPeerScore = promauto.NewGaugeVec(prometheus.GaugeOpts{ - Name: "ssv:p2p:pubsub:score:inspect", - Help: "Pubsub peer scores", - }, []string{"pid"}) - pubsubPeerP4Score = promauto.NewGaugeVec(prometheus.GaugeOpts{ - Name: "ssv:p2p:pubsub:score:invalid_message_deliveries", - Help: "Pubsub peer P4 scores (sum of square of counters for invalid message deliveries)", - }, []string{"pid"}) -) - -type MetricsReporter interface { - OperatorPublicKey(operatorID spectypes.OperatorID, publicKey []byte) - MessageValidationRSAVerifications() - SignatureValidationDuration(duration time.Duration, labels ...string) - IncomingQueueMessage(messageID spectypes.MessageID) - OutgoingQueueMessage(messageID spectypes.MessageID) - MessageQueueSize(size int) - MessageQueueCapacity(size int) - MessageTimeInQueue(messageID spectypes.MessageID, d time.Duration) - InCommitteeMessage(msgType spectypes.MsgType, decided bool) - NonCommitteeMessage(msgType spectypes.MsgType, decided bool) - PeerScore(peerId peer.ID, score float64) - PeerP4Score(peerId peer.ID, score float64) - ResetPeerScores() - PeerDisconnected(peerId peer.ID) -} - -type metricsReporter struct { - logger *zap.Logger -} - -func New(opts ...Option) MetricsReporter { - mr := &metricsReporter{ - logger: zap.NewNop(), - } - - for _, opt := range opts { - opt(mr) - } - - return &metricsReporter{} -} - -func (m *metricsReporter) OperatorPublicKey(operatorID spectypes.OperatorID, publicKey []byte) { - pkHash := fmt.Sprintf("%x", sha256.Sum256(publicKey)) - operatorIndex.WithLabelValues(pkHash, strconv.FormatUint(operatorID, 10)).Set(float64(operatorID)) -} - -func (m *metricsReporter) MessageValidationRSAVerifications() { - messageValidationRSAVerifications.WithLabelValues().Inc() -} - -func (m *metricsReporter) SignatureValidationDuration(duration time.Duration, labels ...string) { - signatureValidationDuration.WithLabelValues(labels...).Observe(duration.Seconds()) -} - -func (m *metricsReporter) IncomingQueueMessage(messageID spectypes.MessageID) { - incomingQueueMessages.WithLabelValues(messageID.String()).Inc() -} - -func (m *metricsReporter) OutgoingQueueMessage(messageID spectypes.MessageID) { - outgoingQueueMessages.WithLabelValues(messageID.String()).Inc() -} - -func (m *metricsReporter) MessageQueueSize(size int) { - messageQueueSize.WithLabelValues().Set(float64(size)) -} - -func (m *metricsReporter) MessageQueueCapacity(size int) { - messageQueueCapacity.WithLabelValues().Set(float64(size)) -} - -func (m *metricsReporter) MessageTimeInQueue(messageID spectypes.MessageID, d time.Duration) { - messageTimeInQueue.WithLabelValues(messageID.String()).Observe(d.Seconds()) -} - -func (m *metricsReporter) InCommitteeMessage(msgType spectypes.MsgType, decided bool) { - str := "non-decided" - if decided { - str = "decided" - } - inCommitteeMessages.WithLabelValues(ssvmessage.MsgTypeToString(msgType), str).Inc() -} - -func (m *metricsReporter) NonCommitteeMessage(msgType spectypes.MsgType, decided bool) { - str := "non-decided" - if decided { - str = "decided" - } - nonCommitteeMessages.WithLabelValues(ssvmessage.MsgTypeToString(msgType), str).Inc() -} - -func (m *metricsReporter) PeerScore(peerId peer.ID, score float64) { - pubsubPeerScore.WithLabelValues(peerId.String()).Set(score) -} - -func (m *metricsReporter) PeerP4Score(peerId peer.ID, score float64) { - pubsubPeerP4Score.WithLabelValues(peerId.String()).Set(score) -} - -func (m *metricsReporter) ResetPeerScores() { - pubsubPeerScore.Reset() - pubsubPeerP4Score.Reset() -} - -// PeerDisconnected deletes all data about peers which connections have been closed by the current node -func (m *metricsReporter) PeerDisconnected(peerId peer.ID) { -} diff --git a/monitoring/metricsreporter/nop_metrics_reporter.go b/monitoring/metricsreporter/nop_metrics_reporter.go deleted file mode 100644 index eb4f57f593..0000000000 --- a/monitoring/metricsreporter/nop_metrics_reporter.go +++ /dev/null @@ -1,37 +0,0 @@ -package metricsreporter - -import ( - "time" - - "github.com/libp2p/go-libp2p/core/peer" - genesisspecqbft "github.com/ssvlabs/ssv-spec-pre-cc/qbft" - genesisspectypes "github.com/ssvlabs/ssv-spec-pre-cc/types" - spectypes "github.com/ssvlabs/ssv-spec/types" -) - -type nopMetrics struct{} - -func NewNop() MetricsReporter { - return &nopMetrics{} -} - -func (n *nopMetrics) OperatorPublicKey(operatorID spectypes.OperatorID, publicKey []byte) {} -func (n *nopMetrics) MessageValidationRSAVerifications() {} -func (n *nopMetrics) GenesisMessageAccepted(role genesisspectypes.BeaconRole, round genesisspecqbft.Round) { -} -func (n *nopMetrics) GenesisMessageIgnored(reason string, role genesisspectypes.BeaconRole, round genesisspecqbft.Round) { -} -func (n *nopMetrics) GenesisMessageRejected(reason string, role genesisspectypes.BeaconRole, round genesisspecqbft.Round) { -} -func (n *nopMetrics) SignatureValidationDuration(duration time.Duration, labels ...string) {} -func (n *nopMetrics) IncomingQueueMessage(messageID spectypes.MessageID) {} -func (n *nopMetrics) OutgoingQueueMessage(messageID spectypes.MessageID) {} -func (n *nopMetrics) MessageQueueSize(size int) {} -func (n *nopMetrics) MessageQueueCapacity(size int) {} -func (n *nopMetrics) MessageTimeInQueue(messageID spectypes.MessageID, d time.Duration) {} -func (n *nopMetrics) InCommitteeMessage(msgType spectypes.MsgType, decided bool) {} -func (n *nopMetrics) NonCommitteeMessage(msgType spectypes.MsgType, decided bool) {} -func (n *nopMetrics) PeerScore(peerId peer.ID, score float64) {} -func (n *nopMetrics) PeerP4Score(peerId peer.ID, score float64) {} -func (n *nopMetrics) ResetPeerScores() {} -func (n *nopMetrics) PeerDisconnected(peerId peer.ID) {} diff --git a/monitoring/metricsreporter/options.go b/monitoring/metricsreporter/options.go deleted file mode 100644 index 8434bda29f..0000000000 --- a/monitoring/metricsreporter/options.go +++ /dev/null @@ -1,15 +0,0 @@ -package metricsreporter - -import ( - "go.uber.org/zap" -) - -// Option defines EventSyncer configuration option. -type Option func(reporter *metricsReporter) - -// WithLogger enables logging. -func WithLogger(logger *zap.Logger) Option { - return func(ed *metricsReporter) { - ed.logger = logger.Named("metrics_reporter") - } -}