duties v2 fix no assignment panic (#15466)

* adding fix

* preston's suggestion
This commit is contained in:
james-prysm
2025-07-03 10:44:51 -05:00
committed by GitHub
parent b1ac8209b2
commit fac509a3e6
4 changed files with 10 additions and 2 deletions

View File

@@ -403,7 +403,7 @@ func AssignmentForValidator(
}
}
}
return nil // validator is not scheduled this epoch
return &LiteAssignment{} // validator is not scheduled this epoch
}
// CommitteeAssignments calculates committee assignments for each validator during the specified epoch.

View File

@@ -912,6 +912,7 @@ func TestAssignmentForValidator(t *testing.T) {
{{4, 5, 6}},
}
got = helpers.AssignmentForValidator(bySlot, start, primitives.ValidatorIndex(99))
require.IsNil(t, got)
// should be empty to be safe
require.DeepEqual(t, &helpers.LiteAssignment{}, got)
})
}

View File

@@ -261,6 +261,10 @@ func (vs *Server) buildValidatorDuty(
}
func populateCommitteeFields(duty *ethpb.DutiesV2Response_Duty, la *helpers.LiteAssignment) {
if duty == nil || la == nil {
// should never be the case as previous functions should set
return
}
duty.CommitteeLength = la.CommitteeLength
duty.CommitteeIndex = la.CommitteeIndex
duty.ValidatorCommitteeIndex = la.ValidatorCommitteeIndex

View File

@@ -0,0 +1,3 @@
### Fixed
- Fix panic on dutiesv2 when there is no committee assignment on the epoch