From ddf454a04d9ceca2fdd38506893c6e55c8d6b967 Mon Sep 17 00:00:00 2001 From: Preston Van Loon Date: Sat, 12 Jan 2019 23:44:28 -0500 Subject: [PATCH] Ignore empty public keys in gRPC request (#1309) * Ignore empty public keys in gRPC request * Remove log --- beacon-chain/rpc/service.go | 3 +++ beacon-chain/rpc/service_test.go | 13 +++++++++++++ 2 files changed, 16 insertions(+) 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) + } +}