From a0e9aeaae52e1735f640c2d34d542a98b9b1f6fc Mon Sep 17 00:00:00 2001 From: Sam Calder-Mason Date: Thu, 31 Aug 2023 10:38:25 +1000 Subject: [PATCH] fix: return error for out of range position in GetValidatorIndex --- pkg/sentry/ethereum/services/duties.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/sentry/ethereum/services/duties.go b/pkg/sentry/ethereum/services/duties.go index f7da0421..e739b2be 100644 --- a/pkg/sentry/ethereum/services/duties.go +++ b/pkg/sentry/ethereum/services/duties.go @@ -242,7 +242,11 @@ func (m *DutiesService) GetValidatorIndex(epoch phase0.Epoch, slot phase0.Slot, continue } - return committee.Validators[position], nil + if position < uint64(len(committee.Validators)) { + return committee.Validators[position], nil + } else { + return 0, fmt.Errorf("position %d is out of range for slot %d in epoch %d in committee %d", position, slot, epoch, committeeIndex) + } } return 0, fmt.Errorf("validator index not found")