From 22ef729ec6ba0e68a6689363a1f9a86f47f6b38e Mon Sep 17 00:00:00 2001 From: xenowits Date: Tue, 13 Sep 2022 12:49:38 +0530 Subject: [PATCH] address review comments --- core/fetcher/fetcher.go | 1 + core/fetcher/fetcher_test.go | 19 ++----------------- core/unsigneddata.go | 1 + testutil/random.go | 13 +++++++++++++ 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/core/fetcher/fetcher.go b/core/fetcher/fetcher.go index 76c7b10f4..e81a66ee1 100644 --- a/core/fetcher/fetcher.go +++ b/core/fetcher/fetcher.go @@ -157,6 +157,7 @@ func (f *Fetcher) fetchAggregatorData(ctx context.Context, slot int64, defSet co return core.UnsignedDataSet{}, err } + // This validator isn't an aggregator for this slot. if !res.IsAggregator { continue } diff --git a/core/fetcher/fetcher_test.go b/core/fetcher/fetcher_test.go index 80cccc5e3..ff96a8a4f 100644 --- a/core/fetcher/fetcher_test.go +++ b/core/fetcher/fetcher_test.go @@ -17,7 +17,6 @@ package fetcher_test import ( "context" - "math/rand" "testing" eth2v1 "github.com/attestantio/go-eth2-client/api/v1" @@ -27,7 +26,6 @@ import ( "github.com/obolnetwork/charon/core" "github.com/obolnetwork/charon/core/fetcher" - "github.com/obolnetwork/charon/eth2util/eth2exp" "github.com/obolnetwork/charon/testutil" "github.com/obolnetwork/charon/testutil/beaconmock" ) @@ -119,8 +117,8 @@ func TestFetchAggregator(t *testing.T) { } signedCommSubByPubKey := map[core.PubKey]core.SignedData{ - pubkeysByIdx[vIdxA]: randomSignedBeaconCommitteeSubscription(vIdxA, slot, commIdxA), - pubkeysByIdx[vIdxB]: randomSignedBeaconCommitteeSubscription(vIdxB, slot, commIdxB), + pubkeysByIdx[vIdxA]: testutil.RandomSignedBeaconCommitteeSubscription(vIdxA, slot, commIdxA), + pubkeysByIdx[vIdxB]: testutil.RandomSignedBeaconCommitteeSubscription(vIdxB, slot, commIdxB), } attByPubKey := map[core.PubKey]core.SignedData{ @@ -345,19 +343,6 @@ func assertRandaoBlindedBlock(t *testing.T, randao eth2p0.BLSSignature, block co } } -// randomSignedBeaconCommitteeSubscription returns a SignedBeaconCommitteeSubscription with the inputs and a random slot signature. -func randomSignedBeaconCommitteeSubscription(vIdx, slot, commIdx int) core.SignedBeaconCommitteeSubscription { - return core.SignedBeaconCommitteeSubscription{ - BeaconCommitteeSubscription: eth2exp.BeaconCommitteeSubscription{ - ValidatorIndex: eth2p0.ValidatorIndex(vIdx), - Slot: eth2p0.Slot(slot), - CommitteeIndex: eth2p0.CommitteeIndex(commIdx), - CommitteesAtSlot: rand.Uint64(), - SlotSignature: testutil.RandomEth2Signature(), - }, - } -} - // beaconCommittee returns a BeaconCommittee with the given committee index and a list of commLen validator indexes. func beaconCommittee(commIdx, commLen int) *eth2v1.BeaconCommittee { var ( diff --git a/core/unsigneddata.go b/core/unsigneddata.go index 8a5fe53c2..c7075c979 100644 --- a/core/unsigneddata.go +++ b/core/unsigneddata.go @@ -30,6 +30,7 @@ import ( var ( _ UnsignedData = AttestationData{} + _ UnsignedData = AggregatedAttestation{} _ UnsignedData = VersionedBeaconBlock{} _ UnsignedData = VersionedBlindedBeaconBlock{} ) diff --git a/testutil/random.go b/testutil/random.go index 7b79c347f..7f20940d5 100644 --- a/testutil/random.go +++ b/testutil/random.go @@ -347,6 +347,19 @@ func RandomBeaconCommitteeSubscription() *eth2exp.BeaconCommitteeSubscription { } } +// RandomSignedBeaconCommitteeSubscription returns a SignedBeaconCommitteeSubscription with the inputs and a random slot signature. +func RandomSignedBeaconCommitteeSubscription(vIdx, slot, commIdx int) core.SignedBeaconCommitteeSubscription { + return core.SignedBeaconCommitteeSubscription{ + BeaconCommitteeSubscription: eth2exp.BeaconCommitteeSubscription{ + ValidatorIndex: eth2p0.ValidatorIndex(vIdx), + Slot: eth2p0.Slot(slot), + CommitteeIndex: eth2p0.CommitteeIndex(commIdx), + CommitteesAtSlot: rand.Uint64(), + SlotSignature: RandomEth2Signature(), + }, + } +} + func RandomSyncAggregate(t *testing.T) *altair.SyncAggregate { t.Helper()