Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
xenowits committed Sep 13, 2022
1 parent b8d1e86 commit 22ef729
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
1 change: 1 addition & 0 deletions core/fetcher/fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
19 changes: 2 additions & 17 deletions core/fetcher/fetcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package fetcher_test

import (
"context"
"math/rand"
"testing"

eth2v1 "github.com/attestantio/go-eth2-client/api/v1"
Expand All @@ -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"
)
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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 (
Expand Down
1 change: 1 addition & 0 deletions core/unsigneddata.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (

var (
_ UnsignedData = AttestationData{}
_ UnsignedData = AggregatedAttestation{}
_ UnsignedData = VersionedBeaconBlock{}
_ UnsignedData = VersionedBlindedBeaconBlock{}
)
Expand Down
13 changes: 13 additions & 0 deletions testutil/random.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down

0 comments on commit 22ef729

Please sign in to comment.