From 9049c3c0266b9685eb9ee3cf82ba9f5050b8fbb8 Mon Sep 17 00:00:00 2001 From: Lucca Dukic <109136188+LuccaBitfly@users.noreply.github.com> Date: Wed, 15 Jan 2025 14:23:29 +0100 Subject: [PATCH] fix: don't panic on empty sync assignments --- backend/pkg/api/services/service_slot_viz.go | 3 +++ backend/pkg/commons/utils/utils.go | 3 +++ 2 files changed, 6 insertions(+) diff --git a/backend/pkg/api/services/service_slot_viz.go b/backend/pkg/api/services/service_slot_viz.go index 95fad1b69..2ebf68437 100644 --- a/backend/pkg/api/services/service_slot_viz.go +++ b/backend/pkg/api/services/service_slot_viz.go @@ -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 } diff --git a/backend/pkg/commons/utils/utils.go b/backend/pkg/commons/utils/utils.go index 73844a5de..20c45e829 100644 --- a/backend/pkg/commons/utils/utils.go +++ b/backend/pkg/commons/utils/utils.go @@ -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]