Skip to content

Commit

Permalink
Consider missing validator count for performance metric (#4928)
Browse files Browse the repository at this point in the history
* Consider missing validator count
* Use validator count reported
* Merge branch 'master' into missing-validators
* Merge refs/heads/master into missing-validators
  • Loading branch information
terencechain committed Feb 24, 2020
1 parent 15b649d commit 0470d37
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions validator/client/validator_metrics.go
Expand Up @@ -61,6 +61,7 @@ func (v *validator) LogValidatorGainsAndLosses(ctx context.Context, slot uint64)
votedTarget := 0
votedHead := 0

reported := 0
for i, pkey := range pubKeys {
pubKey := fmt.Sprintf("%#x", pkey[:8])
log := log.WithField("pubKey", pubKey)
Expand Down Expand Up @@ -95,21 +96,23 @@ func (v *validator) LogValidatorGainsAndLosses(ctx context.Context, slot uint64)
}
}

if i < len(resp.InclusionSlots) && resp.InclusionSlots[i] != ^uint64(0) {
if reported < len(resp.InclusionSlots) && resp.InclusionSlots[i] != ^uint64(0) {
included++
}
if i < len(resp.CorrectlyVotedSource) && resp.CorrectlyVotedSource[i] {
if reported < len(resp.CorrectlyVotedSource) && resp.CorrectlyVotedSource[i] {
votedSource++
}
if i < len(resp.CorrectlyVotedTarget) && resp.CorrectlyVotedTarget[i] {
if reported < len(resp.CorrectlyVotedTarget) && resp.CorrectlyVotedTarget[i] {
votedTarget++
}
if i < len(resp.CorrectlyVotedHead) && resp.CorrectlyVotedHead[i] {
if reported < len(resp.CorrectlyVotedHead) && resp.CorrectlyVotedHead[i] {
votedHead++
}
if i < len(resp.BalancesAfterEpochTransition) {
if reported < len(resp.BalancesAfterEpochTransition) {
v.prevBalance[bytesutil.ToBytes48(pkey)] = resp.BalancesBeforeEpochTransition[i]
}

reported++
}

log.WithFields(logrus.Fields{
Expand Down

0 comments on commit 0470d37

Please sign in to comment.