From 7899dc115e5c93c2671493744b4ab7dce201ff99 Mon Sep 17 00:00:00 2001 From: SuburbanDad <61096102+SuburbanDad@users.noreply.github.com> Date: Sat, 15 Feb 2020 14:47:45 -0800 Subject: [PATCH] prevent additional array OOB errors for validator balances (#4872) Co-authored-by: garyschulte --- validator/client/validator_metrics.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/validator/client/validator_metrics.go b/validator/client/validator_metrics.go index 165518b629..a58a93a908 100644 --- a/validator/client/validator_metrics.go +++ b/validator/client/validator_metrics.go @@ -95,19 +95,21 @@ func (v *validator) LogValidatorGainsAndLosses(ctx context.Context, slot uint64) } } - if resp.InclusionSlots[i] != ^uint64(0) { + if i < len(resp.InclusionSlots) && resp.InclusionSlots[i] != ^uint64(0) { included++ } - if resp.CorrectlyVotedSource[i] { + if i < len(resp.CorrectlyVotedSource) && resp.CorrectlyVotedSource[i] { votedSource++ } - if resp.CorrectlyVotedTarget[i] { + if i < len(resp.CorrectlyVotedTarget) && resp.CorrectlyVotedTarget[i] { votedTarget++ } - if resp.CorrectlyVotedHead[i] { + if i < len(resp.CorrectlyVotedHead) && resp.CorrectlyVotedHead[i] { votedHead++ } - v.prevBalance[bytesutil.ToBytes48(pkey)] = resp.BalancesBeforeEpochTransition[i] + if i < len(resp.BalancesAfterEpochTransition) { + v.prevBalance[bytesutil.ToBytes48(pkey)] = resp.BalancesBeforeEpochTransition[i] + } } log.WithFields(logrus.Fields{