Skip to content

Commit 9049c3c

Browse files
committed
fix: don't panic on empty sync assignments
1 parent d219720 commit 9049c3c

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

backend/pkg/api/services/service_slot_viz.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,9 @@ func (s *Services) updateSlotVizData() error {
228228
dutiesInfo.SlotSyncParticipated[duty.Slot] = make(map[constypes.ValidatorIndex]bool, 0)
229229

230230
partValidators := utils.GetParticipatingSyncCommitteeValidators(duty.SyncAggregateBits, dutiesInfo.TotalSyncAssignmentsForEpoch[utils.EpochOfSlot(duty.Slot)])
231+
if len(partValidators) == 0 {
232+
log.Error(nil, "no participating sync validators found", 0, map[string]interface{}{"slot": duty.Slot})
233+
}
231234
for _, validator := range partValidators {
232235
dutiesInfo.SlotSyncParticipated[duty.Slot][validator] = true
233236
}

backend/pkg/commons/utils/utils.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,9 @@ func SortedUniqueUint64(arr []uint64) []uint64 {
221221
}
222222

223223
func GetParticipatingSyncCommitteeValidators(syncAggregateBits []byte, validators []uint64) []uint64 {
224+
if len(validators) != len(syncAggregateBits)*8 {
225+
return nil
226+
}
224227
participatingValidators := []uint64{}
225228
for i := 0; i < len(syncAggregateBits)*8; i++ {
226229
val := validators[i]

0 commit comments

Comments
 (0)