From 40a0360d0b5989998987ed9f68b7fb5a1f9496c1 Mon Sep 17 00:00:00 2001 From: oleg-ssvlabs Date: Thu, 10 Oct 2024 13:24:35 +0200 Subject: [PATCH] Analyzer: add consensus participant and successes metrics --- internal/analyzer/cmd.go | 2 ++ internal/analyzer/parser/consensus/service.go | 13 ++++++++---- internal/analyzer/report/operator.go | 20 ++++++++++++++----- internal/analyzer/service.go | 4 ++++ 4 files changed, 30 insertions(+), 9 deletions(-) diff --git a/internal/analyzer/cmd.go b/internal/analyzer/cmd.go index 5730d65..8d96d3d 100644 --- a/internal/analyzer/cmd.go +++ b/internal/analyzer/cmd.go @@ -113,6 +113,8 @@ var CMD = &cobra.Command{ PrepareHighestDelay: r.PrepareHighestDelay, PrepareMoreThanSec: strconv.FormatUint(uint64(r.PrepareDelayCount), 10) + "/" + strconv.FormatUint(uint64(r.PrepareCount), 10), ConsensusTimeAvg: r.ConsensusTimeAvg, + ConsensusSuccessfulAttestationSubmissions: r.ConsensusSuccessfulAttestationSubmissions, + ConsensusParticipation: r.ConsensusParticipationCount, }) if !isSet { diff --git a/internal/analyzer/parser/consensus/service.go b/internal/analyzer/parser/consensus/service.go index 143b826..41da7be 100644 --- a/internal/analyzer/parser/consensus/service.go +++ b/internal/analyzer/parser/consensus/service.go @@ -29,7 +29,9 @@ type ( } Stats struct { - OperatorConsensusTimes map[parser.SignerID][]time.Duration + OperatorConsensusTimes map[parser.SignerID][]time.Duration + OperatorConsensusParticipation map[parser.SignerID]uint16 + SuccessfullySubmittedAttestations uint16 } Service struct { @@ -53,7 +55,8 @@ func (s *Service) Analyze() (Stats, error) { var ( stats Stats = Stats{ - OperatorConsensusTimes: make(map[uint32][]time.Duration), + OperatorConsensusTimes: make(map[uint32][]time.Duration), + OperatorConsensusParticipation: make(map[uint32]uint16), } operatorConsensusParticipation = make(map[parser.DutyID]struct { Signers []parser.SignerID @@ -71,8 +74,8 @@ func (s *Service) Analyze() (Stats, error) { if strings.Contains(entry.Message, partialSignatureLogRecord) { /* - since there is no way to verify the round (given log record does not contain roundID filed) in this way we need - to make sure we save signers from the earliest round, meaning round 1 + Since there is no way to verify the round (as the given log record does not contain the roundID field), + we need to ensure that we save signers from the earliest round, meaning round 1. */ if consensusRecord, hasRecordForDuty := operatorConsensusParticipation[entry.DutyID]; hasRecordForDuty { if entry.Timestamp.Before(consensusRecord.Timestamp) { @@ -114,10 +117,12 @@ func (s *Service) Analyze() (Stats, error) { if exist { for _, signerID := range signers.Signers { stats.OperatorConsensusTimes[signerID] = append(stats.OperatorConsensusTimes[signerID], signerConsensusTime) + stats.OperatorConsensusParticipation[signerID]++ } } } + stats.SuccessfullySubmittedAttestations = uint16(len(consensusTimes)) return stats, nil } diff --git a/internal/analyzer/report/operator.go b/internal/analyzer/report/operator.go index b437735..651d489 100644 --- a/internal/analyzer/report/operator.go +++ b/internal/analyzer/report/operator.go @@ -18,17 +18,23 @@ var operatorHeaders = []string{ "Prepare: highest", "Prepare: > 1sec", "Consensus: avg", + "Consensus: \n operator participation", + "Consensus: \n successful attestation submissions", } type OperatorRecord struct { - OperatorID uint64 - IsLogFileOwner bool - Score uint64 - CommitDelayTotal time.Duration + OperatorID uint64 + IsLogFileOwner bool + Score uint64 + CommitDelayTotal time.Duration + PrepareDelayAvg time.Duration PrepareHighestDelay time.Duration PrepareMoreThanSec string - ConsensusTimeAvg time.Duration + + ConsensusTimeAvg time.Duration + ConsensusSuccessfulAttestationSubmissions, + ConsensusParticipation uint16 } type OperatorReport struct { @@ -74,6 +80,8 @@ func (r *OperatorReport) AddRecord(record OperatorRecord) { record.PrepareHighestDelay.String(), record.PrepareMoreThanSec, record.ConsensusTimeAvg.String(), + fmt.Sprint(record.ConsensusParticipation), + fmt.Sprint(record.ConsensusSuccessfulAttestationSubmissions), ) return } @@ -86,6 +94,8 @@ func (r *OperatorReport) AddRecord(record OperatorRecord) { record.PrepareHighestDelay.String(), record.PrepareMoreThanSec, record.ConsensusTimeAvg.String(), + fmt.Sprint(record.ConsensusParticipation), + fmt.Sprint(record.ConsensusSuccessfulAttestationSubmissions), ) } diff --git a/internal/analyzer/service.go b/internal/analyzer/service.go index 2fb4544..327fadb 100644 --- a/internal/analyzer/service.go +++ b/internal/analyzer/service.go @@ -51,6 +51,8 @@ type ( PrepareCount uint16 ConsensusTimeAvg time.Duration + ConsensusParticipationCount, + ConsensusSuccessfulAttestationSubmissions uint16 } AnalyzerResult struct { @@ -134,6 +136,8 @@ func (r *Service) Start() (AnalyzerResult, error) { PrepareCount: prepareStats[operatorID].Count, ConsensusTimeAvg: consensusDurationAvg, + ConsensusSuccessfulAttestationSubmissions: consensusStats.SuccessfullySubmittedAttestations, + ConsensusParticipationCount: consensusStats.OperatorConsensusParticipation[operatorID], }) }