From 3b2c514c0628de008d76657e04ac3065d7ef87bc Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Tue, 28 Apr 2020 21:44:51 -0500 Subject: [PATCH] Empty Committee Check in Submit Attestation (#5672) * empty committee check * Merge refs/heads/master into validator-id-errs --- validator/client/validator_attest.go | 4 ++++ validator/client/validator_attest_test.go | 18 +++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/validator/client/validator_attest.go b/validator/client/validator_attest.go index e5046a4b5..4dd8d249e 100644 --- a/validator/client/validator_attest.go +++ b/validator/client/validator_attest.go @@ -67,6 +67,10 @@ func (v *validator) SubmitAttestation(ctx context.Context, slot uint64, pubKey [ } return } + if len(duty.Committee) == 0 { + log.Debug("Empty committee for validator duty, not attesting") + return + } v.waitToSlotOneThird(ctx, slot) diff --git a/validator/client/validator_attest_test.go b/validator/client/validator_attest_test.go index 8c160f84a..19e117974 100644 --- a/validator/client/validator_attest_test.go +++ b/validator/client/validator_attest_test.go @@ -31,7 +31,23 @@ func TestRequestAttestation_ValidatorDutiesRequestFailure(t *testing.T) { testutil.AssertLogsContain(t, hook, "Could not fetch validator assignment") } -func TestAttestToBlockHead_SubmitAttestationRequestFailure(t *testing.T) { +func TestAttestToBlockHead_SubmitAttestation_EmptyCommittee(t *testing.T) { + hook := logTest.NewGlobal() + + validator, _, finish := setup(t) + defer finish() + validator.duties = ðpb.DutiesResponse{Duties: []*ethpb.DutiesResponse_Duty{ + { + PublicKey: validatorKey.PublicKey.Marshal(), + CommitteeIndex: 0, + Committee: make([]uint64, 0), + ValidatorIndex: 0, + }}} + validator.SubmitAttestation(context.Background(), 0, validatorPubKey) + testutil.AssertLogsContain(t, hook, "Empty committee") +} + +func TestAttestToBlockHead_SubmitAttestation_RequestFailure(t *testing.T) { hook := logTest.NewGlobal() validator, m, finish := setup(t)