From b3542282dd4d90b5e430bbc168f27fef6d8b39ba Mon Sep 17 00:00:00 2001 From: Bruce Riley Date: Wed, 21 Aug 2024 10:43:58 -0600 Subject: [PATCH] Code review rework --- fly/cmd/heartbeats/main.go | 6 +++++- fly/cmd/observation_stats/main.go | 2 -- fly/cmd/prom_gossip/main.go | 11 +++++++---- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/fly/cmd/heartbeats/main.go b/fly/cmd/heartbeats/main.go index 8ef5c4bd..25dab1af 100644 --- a/fly/cmd/heartbeats/main.go +++ b/fly/cmd/heartbeats/main.go @@ -381,7 +381,11 @@ func main() { if handleObsv(uint(idx)) { obsvRateTable.ResetRows() for i := 0; i < numGuardians; i++ { - obsvRateTable.AppendRow(table.Row{i, obsvRateRows[int(i)].guardianName, obsvRateRows[int(i)].obsvCount, obsvRateRows[uint(i)].percents[0], obsvRateRows[uint(i)].percents[1], obsvRateRows[uint(i)].percents[2], obsvRateRows[uint(i)].percents[3], obsvRateRows[uint(i)].percents[4], obsvRateRows[uint(i)].percents[5], obsvRateRows[uint(i)].percents[6], obsvRateRows[uint(i)].percents[7], obsvRateRows[uint(i)].percents[8], obsvRateRows[uint(i)].percents[9]}) + obsvRateTable.AppendRow(table.Row{i, obsvRateRows[int(i)].guardianName, obsvRateRows[int(i)].obsvCount, + obsvRateRows[uint(i)].percents[0], obsvRateRows[uint(i)].percents[1], obsvRateRows[uint(i)].percents[2], + obsvRateRows[uint(i)].percents[3], obsvRateRows[uint(i)].percents[4], obsvRateRows[uint(i)].percents[5], + obsvRateRows[uint(i)].percents[6], obsvRateRows[uint(i)].percents[7], obsvRateRows[uint(i)].percents[8], + obsvRateRows[uint(i)].percents[9]}) } } gossipCounter[idx][GSM_signedObservation]++ diff --git a/fly/cmd/observation_stats/main.go b/fly/cmd/observation_stats/main.go index 4fd3d793..24f7fd48 100644 --- a/fly/cmd/observation_stats/main.go +++ b/fly/cmd/observation_stats/main.go @@ -96,7 +96,6 @@ func main() { case o := <-obsvC: // TODO: Rip out this code once we cut over to batching. if o.Msg.MessageId[:3] != "26/" && o.Msg.MessageId[:2] != "7/" { ga := eth_common.BytesToAddress(o.Msg.Addr).String() - // logger.Warn("observation", zap.String("id",o.MessageId), zap.String("addr",ga)) if _, ok := obsvByHash[o.Msg.MessageId]; !ok { obsvByHash[o.Msg.MessageId] = map[string]time.Time{} } @@ -109,7 +108,6 @@ func main() { for _, o := range batch.Msg.Observations { if o.MessageId[:3] != "26/" && o.MessageId[:2] != "7/" { ga := eth_common.BytesToAddress(batch.Msg.Addr).String() - // logger.Warn("observation", zap.String("id",o.MessageId), zap.String("addr",ga)) if _, ok := obsvByHash[o.MessageId]; !ok { obsvByHash[o.MessageId] = map[string]time.Time{} } diff --git a/fly/cmd/prom_gossip/main.go b/fly/cmd/prom_gossip/main.go index 78c3f956..7ce21487 100644 --- a/fly/cmd/prom_gossip/main.go +++ b/fly/cmd/prom_gossip/main.go @@ -272,17 +272,20 @@ func main() { } uniqueObs[hash] = time.Now() case batch := <-batchObsvC: + gossipByType.WithLabelValues("batch_observation").Inc() + addr := "0x" + string(hex.EncodeToString(batch.Msg.Addr)) + name := addr + idx, found := guardianIndexMap[strings.ToLower(addr)] + if found { + name = guardianIndexToNameMap[idx] + } for _, o := range batch.Msg.Observations { - gossipByType.WithLabelValues("observation").Inc() spl := strings.Split(o.MessageId, "/") chain, err := parseChainID(spl[0]) if err != nil { chain = vaa.ChainIDUnset } emitter := strings.ToLower(spl[1]) - addr := "0x" + string(hex.EncodeToString(batch.Msg.Addr)) - idx := guardianIndexMap[strings.ToLower(addr)] - name := guardianIndexToNameMap[idx] observationsByGuardianPerChain.WithLabelValues(name, chain.String()).Inc() if knownEmitters[emitter] { tbObservationsByGuardianPerChain.WithLabelValues(name, chain.String()).Inc()