Skip to content

Commit

Permalink
Add attestation metrics (#1122)
Browse files Browse the repository at this point in the history
  • Loading branch information
dmanc authored Jan 17, 2025
1 parent c4567f9 commit da53dec
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
17 changes: 17 additions & 0 deletions disperser/controller/dispatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,23 @@ func (d *Dispatcher) HandleSignatures(ctx context.Context, batchData *batchData,
quorumResults[quorumID] = quorumResult.PercentSigned
}
}

// Track attestation metrics
operatorCount := make(map[core.QuorumID]int)
signerCount := make(map[core.QuorumID]int)
for quorumID, opState := range batchData.OperatorState.Operators {
operatorCount[quorumID] = len(opState)
if _, ok := signerCount[quorumID]; !ok {
signerCount[quorumID] = 0
}
for opID := range opState {
if _, ok := quorumAttestation.SignerMap[opID]; ok {
signerCount[quorumID]++
}
}
}
d.metrics.reportAttestation(operatorCount, signerCount, quorumAttestation.QuorumResults)

if len(nonZeroQuorums) == 0 {
err = d.updateBatchStatus(ctx, batchData, quorumResults)
if err != nil {
Expand Down
32 changes: 32 additions & 0 deletions disperser/controller/dispatcher_metrics.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package controller

import (
"fmt"
"time"

common "github.com/Layr-Labs/eigenda/common"
"github.com/Layr-Labs/eigenda/core"
dispv2 "github.com/Layr-Labs/eigenda/disperser/common/v2"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
Expand Down Expand Up @@ -34,12 +36,22 @@ type dispatcherMetrics struct {
updateBatchStatusLatency *prometheus.SummaryVec
blobE2EDispersalLatency *prometheus.SummaryVec
completedBlobs *prometheus.CounterVec
attestation *prometheus.GaugeVec
}

// NewDispatcherMetrics sets up metrics for the dispatcher.
func newDispatcherMetrics(registry *prometheus.Registry) *dispatcherMetrics {
objectives := map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001}

attestation := promauto.With(registry).NewGaugeVec(
prometheus.GaugeOpts{
Namespace: dispatcherNamespace,
Name: "attestation",
Help: "number of signers and non-signers for the batch",
},
[]string{"type", "quorum"},
)

handleBatchLatency := promauto.With(registry).NewSummaryVec(
prometheus.SummaryOpts{
Namespace: dispatcherNamespace,
Expand Down Expand Up @@ -270,6 +282,7 @@ func newDispatcherMetrics(registry *prometheus.Registry) *dispatcherMetrics {
updateBatchStatusLatency: updateBatchStatusLatency,
blobE2EDispersalLatency: blobE2EDispersalLatency,
completedBlobs: completedBlobs,
attestation: attestation,
}
}

Expand Down Expand Up @@ -371,3 +384,22 @@ func (m *dispatcherMetrics) reportCompletedBlob(size int, status dispv2.BlobStat
m.completedBlobs.WithLabelValues("total", "number").Inc()
m.completedBlobs.WithLabelValues("total", "size").Add(float64(size))
}

func (m *dispatcherMetrics) reportAttestation(operatorCount map[core.QuorumID]int, signerCount map[core.QuorumID]int, quorumResults map[core.QuorumID]*core.QuorumResult) {
for quorumID, count := range operatorCount {
quorumStr := fmt.Sprintf("%d", quorumID)
signers, ok := signerCount[quorumID]
if !ok {
continue
}
nonSigners := count - signers
quorumResult, ok := quorumResults[quorumID]
if !ok {
continue
}

m.attestation.WithLabelValues("signers", quorumStr).Set(float64(signers))
m.attestation.WithLabelValues("non_signers", quorumStr).Set(float64(nonSigners))
m.attestation.WithLabelValues("percent_signed", quorumStr).Set(float64(quorumResult.PercentSigned))
}
}

0 comments on commit da53dec

Please sign in to comment.