Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set all metrics to 0 for unregistered quorums #524

Merged
merged 3 commits into from
Apr 26, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
set all metrics to 0 for unregistered quorums
  • Loading branch information
shrimalmadhur committed Apr 26, 2024
commit 18a83b03d708afe4a3960b397bd7e80c8f04b91f
16 changes: 16 additions & 0 deletions node/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ type Metrics struct {
onchainMetricsInterval int64
tx core.Transactor
chainState core.ChainState
allQuorumCache map[core.QuorumID]bool
}

func NewMetrics(eigenMetrics eigenmetrics.Metrics, reg *prometheus.Registry, logger logging.Logger, socketAddr string, operatorId core.OperatorID, onchainMetricsInterval int64, tx core.Transactor, chainState core.ChainState) *Metrics {
Expand Down Expand Up @@ -136,6 +137,7 @@ func NewMetrics(eigenMetrics eigenmetrics.Metrics, reg *prometheus.Registry, log
onchainMetricsInterval: onchainMetricsInterval,
tx: tx,
chainState: chainState,
allQuorumCache: make(map[core.QuorumID]bool),
}

return metrics
Expand Down Expand Up @@ -225,12 +227,26 @@ func (g *Metrics) collectOnchainMetrics() {
})
for i, op := range operatorStakeShares {
if op.operatorId == g.operatorId {
g.allQuorumCache[q] = true
g.RegisteredQuorumsStakeShare.WithLabelValues(fmt.Sprintf("%d", q)).Set(op.stakeShare)
g.RegisteredQuorumsRank.WithLabelValues(fmt.Sprintf("%d", q)).Set(float64(i + 1))
g.logger.Info("Current operator registration onchain", "operatorId", g.operatorId.Hex(), "blockNumber", blockNum, "quorumId", q, "stakeShare (basis point)", op.stakeShare, "rank", i+1)
break
}
}
}
// Check if operator deregistered for an existing quorum, set the stake share and rank to 0
shrimalmadhur marked this conversation as resolved.
Show resolved Hide resolved
for q := range g.allQuorumCache {
// If this quorum was deregistered then set the stake share and rank to 0
if !g.allQuorumCache[q] {
g.RegisteredQuorumsStakeShare.WithLabelValues(fmt.Sprintf("%d", q)).Set(0)
g.RegisteredQuorumsRank.WithLabelValues(fmt.Sprintf("%d", q)).Set(0)
g.logger.Info("Current operator deregistration onchain", "operatorId", g.operatorId.Hex(), "blockNumber", blockNum, "quorumId", q)
} else {
shrimalmadhur marked this conversation as resolved.
Show resolved Hide resolved
// Reset the cache to false for all quorum for next cycle
g.allQuorumCache[q] = false
}

}
}
}
Loading