diff --git a/beacon-chain/rpc/service.go b/beacon-chain/rpc/service.go index d69fbb1a8..a44feed35 100644 --- a/beacon-chain/rpc/service.go +++ b/beacon-chain/rpc/service.go @@ -447,6 +447,9 @@ func assignmentsForPublicKeys(keys []*pb.PublicKey, beaconState *pbp2p.BeaconSta assignments := []*pb.Assignment{} for _, val := range keys { + if len(val.PublicKey) == 0 { + continue + } // For the corresponding public key and current crystallized state, // we determine the assigned slot for the validator and whether it // should act as a proposer or attester. diff --git a/beacon-chain/rpc/service_test.go b/beacon-chain/rpc/service_test.go index 492728815..be946e831 100644 --- a/beacon-chain/rpc/service_test.go +++ b/beacon-chain/rpc/service_test.go @@ -656,3 +656,16 @@ func TestValidatorAssignments(t *testing.T) { exitRoutine <- true testutil.AssertLogsContain(t, hook, "Sending new cycle assignments to validator clients") } + +func TestAssignmentsForPublicKeys_emptyPubKey(t *testing.T) { + pks := []*pb.PublicKey{&pb.PublicKey{}} + + a, err := assignmentsForPublicKeys(pks, nil) + if err != nil { + t.Error(err) + } + + if len(a) > 0 { + t.Errorf("Expected no assignments, but got %v", a) + } +}