diff --git a/validator/client/validator_metrics.go b/validator/client/validator_metrics.go index 5670487b9..09ddadc8e 100644 --- a/validator/client/validator_metrics.go +++ b/validator/client/validator_metrics.go @@ -75,9 +75,9 @@ func (v *validator) LogValidatorGainsAndLosses(ctx context.Context, slot uint64) if slot < params.BeaconConfig().SlotsPerEpoch { v.prevBalance[bytesutil.ToBytes48(pkey)] = params.BeaconConfig().MaxEffectiveBalance } - newBalance := float64(resp.BalancesAfterEpochTransition[i]) / float64(params.BeaconConfig().GweiPerEth) - if v.prevBalance[bytesutil.ToBytes48(pkey)] > 0 { + if v.prevBalance[bytesutil.ToBytes48(pkey)] > 0 && len(resp.BalancesAfterEpochTransition) > i { + newBalance := float64(resp.BalancesAfterEpochTransition[i]) / float64(params.BeaconConfig().GweiPerEth) prevBalance := float64(resp.BalancesBeforeEpochTransition[i]) / float64(params.BeaconConfig().GweiPerEth) percentNet := (newBalance - prevBalance) / prevBalance log.WithFields(logrus.Fields{