From 80f656d8d750a548b6e024dfd988b3c46ee64e2a Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Wed, 19 Jan 2022 13:16:03 -0500 Subject: [PATCH] consensus: check proposal non-nil in prevote message delay metric (backport #7625) (#7631) * consensus: check proposal non-nil in prevote message delay metric (#7625) (cherry picked from commit b6307c42e095c6f8e9e7c2518fb1004cc8f201a1) # Conflicts: # consensus/state.go * fix merge conflicts Co-authored-by: William Banfield <4561443+williambanfield@users.noreply.github.com> Co-authored-by: William Banfield --- consensus/state.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/consensus/state.go b/consensus/state.go index befb4bf0d..9ca9f1d57 100644 --- a/consensus/state.go +++ b/consensus/state.go @@ -2278,11 +2278,17 @@ func (cs *State) checkDoubleSigningRisk(height int64) error { } func (cs *State) calculatePrevoteMessageDelayMetrics() { + if cs.Proposal == nil { + return + } + ps := cs.Votes.Prevotes(cs.Round) pl := ps.List() + sort.Slice(pl, func(i, j int) bool { return pl[i].Timestamp.Before(pl[j].Timestamp) }) + var votingPowerSeen int64 for _, v := range pl { _, val := cs.Validators.GetByAddress(v.ValidatorAddress)