Skip to content

Commit

Permalink
fix: return error for out of range position in GetValidatorIndex (#167)
Browse files Browse the repository at this point in the history
  • Loading branch information
samcm authored Aug 31, 2023
1 parent 32bd250 commit 6cc4dbc
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 6cc4dbc

Please sign in to comment.