Skip to content

Commit

Permalink
fix: return error for out of range position in GetValidatorIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
samcm committed Aug 31, 2023
1 parent 42f122f commit a0e9aea
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/sentry/ethereum/services/duties.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit a0e9aea

Please sign in to comment.