Skip to content

Commit 0c01637

Browse files
committed
commit from main instead of fork
1 parent 45ebe2e commit 0c01637

File tree

1 file changed

+26
-7
lines changed

1 file changed

+26
-7
lines changed

fly/cmd/prom_gossip/main.go

+26-7
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ var (
9292
Name: "gossip_vaas_unique_total",
9393
Help: "The unique number of vaas received over gossip",
9494
})
95+
uniqueVAAsByGuardianPerChain = promauto.NewCounterVec(prometheus.CounterOpts{
96+
Name: "gossip_vaas_by_guardian_per_chain_total",
97+
Help: "The number of unique VAAs received over gossip, grouped by guardian and chain",
98+
}, []string{"guardian_name", "chain_name"})
9599
heartbeatsByGuardian = promauto.NewCounterVec(prometheus.CounterOpts{
96100
Name: "gossip_heartbeats_by_guardian_total",
97101
Help: "The number of heartbeats received over gossip by guardian",
@@ -293,7 +297,6 @@ func main() {
293297

294298
// Count signed VAAs
295299
go func() {
296-
// TODO: move this to a function / struct with a mutex so that the cleanup can be run independently from the message handling, so as to not back up the channel
297300
uniqueVAAs := make(map[string]time.Time)
298301
timeout := time.Hour
299302
delay := time.Minute * 10
@@ -314,18 +317,34 @@ func main() {
314317
logger.Info("Cleaned up unique VAAs cache", zap.Int("beforeCount", beforeCount), zap.Int("afterCount", afterCount), zap.Int("cleanedUpCount", beforeCount-afterCount))
315318
timer.Reset(delay)
316319
case m := <-signedInC:
317-
// This only has VAABytes. It doesn't have the guardian address
318320
gossipByType.WithLabelValues("vaa").Inc()
319321
v, err := vaa.Unmarshal(m.Vaa)
320322
if err != nil {
321323
logger.Warn("received invalid VAA in SignedVAAWithQuorum message", zap.Error(err), zap.Any("message", m))
322-
} else {
323-
digest := v.HexDigest()
324-
if _, exists := uniqueVAAs[digest]; exists {
325-
uniqueVAAsCounter.Inc()
324+
continue
325+
}
326+
327+
digest := v.HexDigest()
328+
chain := v.EmitterChain.String() // Extract chain name
329+
330+
// Extract guardian name using signature index
331+
guardianName := "unknown"
332+
for _, sig := range v.Signatures {
333+
guardianIndex := int(sig.Index) // Extract the guardian index
334+
if name, found := guardianIndexToNameMap[guardianIndex]; found {
335+
guardianName = name
336+
break // Take the first matched guardian
326337
}
327-
uniqueVAAs[digest] = time.Now()
328338
}
339+
340+
if _, exists := uniqueVAAs[digest]; !exists {
341+
// Increment the original gossip_vaas_unique_total metric
342+
uniqueVAAsCounter.Inc()
343+
344+
// Increment the new metric with guardian and chain labels
345+
uniqueVAAsByGuardianPerChain.WithLabelValues(guardianName, chain).Inc()
346+
}
347+
uniqueVAAs[digest] = time.Now()
329348
}
330349
}
331350
}()

0 commit comments

Comments
 (0)