Skip to content

Commit

Permalink
fix: don't panic on empty sync assignments
Browse files Browse the repository at this point in the history
  • Loading branch information
LuccaBitfly committed Jan 15, 2025
1 parent d219720 commit 9049c3c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions backend/pkg/api/services/service_slot_viz.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,9 @@ func (s *Services) updateSlotVizData() error {
dutiesInfo.SlotSyncParticipated[duty.Slot] = make(map[constypes.ValidatorIndex]bool, 0)

partValidators := utils.GetParticipatingSyncCommitteeValidators(duty.SyncAggregateBits, dutiesInfo.TotalSyncAssignmentsForEpoch[utils.EpochOfSlot(duty.Slot)])
if len(partValidators) == 0 {
log.Error(nil, "no participating sync validators found", 0, map[string]interface{}{"slot": duty.Slot})
}
for _, validator := range partValidators {
dutiesInfo.SlotSyncParticipated[duty.Slot][validator] = true
}
Expand Down
3 changes: 3 additions & 0 deletions backend/pkg/commons/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,9 @@ func SortedUniqueUint64(arr []uint64) []uint64 {
}

func GetParticipatingSyncCommitteeValidators(syncAggregateBits []byte, validators []uint64) []uint64 {
if len(validators) != len(syncAggregateBits)*8 {
return nil
}
participatingValidators := []uint64{}
for i := 0; i < len(syncAggregateBits)*8; i++ {
val := validators[i]
Expand Down

0 comments on commit 9049c3c

Please sign in to comment.