Migrate SubmitAggregateAndProof (#4951)

* Remove unused services, mark everything as deprecated, regen pb.go
* remove some code from cluster pk manager, gazelle
* goimports
* remove mocks
* Update WORKSPACE, deprecate old method, stub new method
* Move implementation to ethereumapis definition
* gofmt
* Add TODO for #4952
* Merge branch 'master' into migrate-submitaggregateandproof
* Update validator client to use new submit aggregate and proof method
* Merge branch 'migrate-submitaggregateandproof' of github.com:prysmaticlabs/prysm into migrate-submitaggregateandproof
* gaz
* rename
* rename
* Merge refs/heads/master into migrate-submitaggregateandproof
* Merge refs/heads/master into migrate-submitaggregateandproof
* Merge refs/heads/master into migrate-submitaggregateandproof
* Merge refs/heads/master into migrate-submitaggregateandproof
* Merge refs/heads/master into migrate-submitaggregateandproof
* fix tests
* Merge branch 'migrate-submitaggregateandproof' of github.com:prysmaticlabs/prysm into migrate-submitaggregateandproof
This commit is contained in:
Preston Van Loon
2020-02-27 12:23:35 -08:00
committed by GitHub
parent 2fef9d3e5e
commit 05a5bad476
16 changed files with 871 additions and 504 deletions

View File

@@ -1272,7 +1272,7 @@ go_repository(
go_repository(
name = "com_github_prysmaticlabs_ethereumapis",
commit = "53ccc146f7f488c5c7634530057f4aedf510a9ac",
commit = "fca4d6f69bedb8615c2fc916d1a68f2692285caa",
importpath = "github.com/prysmaticlabs/ethereumapis",
patch_args = ["-p1"],
patches = [

View File

@@ -1,4 +1,4 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "go_default_library",
@@ -6,41 +6,9 @@ go_library(
importpath = "github.com/prysmaticlabs/prysm/beacon-chain/rpc/aggregator",
visibility = ["//beacon-chain:__subpackages__"],
deps = [
"//beacon-chain/blockchain:go_default_library",
"//beacon-chain/core/helpers:go_default_library",
"//beacon-chain/db:go_default_library",
"//beacon-chain/operations/attestations:go_default_library",
"//beacon-chain/p2p:go_default_library",
"//beacon-chain/sync:go_default_library",
"//beacon-chain/rpc/validator:go_default_library",
"//proto/beacon/rpc/v1:go_default_library",
"@com_github_prysmaticlabs_ethereumapis//eth/v1alpha1:go_default_library",
"@com_github_sirupsen_logrus//:go_default_library",
"@io_opencensus_go//trace:go_default_library",
"@org_golang_google_grpc//codes:go_default_library",
"@org_golang_google_grpc//status:go_default_library",
],
)
go_test(
name = "go_default_test",
srcs = ["server_test.go"],
embed = [":go_default_library"],
deps = [
"//beacon-chain/blockchain/testing:go_default_library",
"//beacon-chain/core/helpers:go_default_library",
"//beacon-chain/db/testing:go_default_library",
"//beacon-chain/operations/attestations:go_default_library",
"//beacon-chain/p2p/testing:go_default_library",
"//beacon-chain/state:go_default_library",
"//beacon-chain/sync/initial-sync/testing:go_default_library",
"//proto/beacon/p2p/v1:go_default_library",
"//proto/beacon/rpc/v1:go_default_library",
"//shared/attestationutil:go_default_library",
"//shared/bls:go_default_library",
"//shared/params:go_default_library",
"//shared/testutil:go_default_library",
"@com_github_prysmaticlabs_ethereumapis//eth/v1alpha1:go_default_library",
"@com_github_prysmaticlabs_go_bitfield//:go_default_library",
"@com_github_prysmaticlabs_go_ssz//:go_default_library",
],
)

View File

@@ -4,100 +4,37 @@ import (
"context"
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
"github.com/prysmaticlabs/prysm/beacon-chain/blockchain"
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
"github.com/prysmaticlabs/prysm/beacon-chain/db"
"github.com/prysmaticlabs/prysm/beacon-chain/operations/attestations"
"github.com/prysmaticlabs/prysm/beacon-chain/p2p"
"github.com/prysmaticlabs/prysm/beacon-chain/sync"
"github.com/prysmaticlabs/prysm/beacon-chain/rpc/validator"
pb "github.com/prysmaticlabs/prysm/proto/beacon/rpc/v1"
"github.com/sirupsen/logrus"
"go.opencensus.io/trace"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
var log logrus.FieldLogger
func init() {
log = logrus.WithField("prefix", "rpc/aggregator")
}
// Server defines a server implementation of the gRPC aggregator service.
// Deprecated: Do not use.
type Server struct {
BeaconDB db.ReadOnlyDatabase
HeadFetcher blockchain.HeadFetcher
SyncChecker sync.Checker
AttPool attestations.Pool
P2p p2p.Broadcaster
ValidatorServer *validator.Server
}
// SubmitAggregateAndProof is called by a validator when its assigned to be an aggregator.
// The beacon node will broadcast aggregated attestation and proof on the aggregator's behavior.
// Deprecated: Use github.com/prysmaticlabs/prysm/beacon-chain/rpc/validator.SubmitAggregateAndProof.
// TODO(4952): Delete this method.
func (as *Server) SubmitAggregateAndProof(ctx context.Context, req *pb.AggregationRequest) (*pb.AggregationResponse, error) {
ctx, span := trace.StartSpan(ctx, "AggregatorServer.SubmitAggregation")
defer span.End()
span.AddAttributes(trace.Int64Attribute("slot", int64(req.Slot)))
if as.SyncChecker.Syncing() {
return nil, status.Errorf(codes.Unavailable, "Syncing to latest head, not ready to respond")
request := &ethpb.AggregationRequest{
Slot: req.Slot,
CommitteeIndex: req.CommitteeIndex,
PublicKey: req.PublicKey,
SlotSignature: req.SlotSignature,
}
validatorIndex, exists, err := as.BeaconDB.ValidatorIndex(ctx, req.PublicKey)
if err != nil {
return nil, status.Errorf(codes.Internal, "Could not get validator index from DB: %v", err)
}
if !exists {
return nil, status.Error(codes.Internal, "Could not locate validator index in DB")
}
epoch := helpers.SlotToEpoch(req.Slot)
activeValidatorIndices, err := as.HeadFetcher.HeadValidatorsIndices(epoch)
if err != nil {
return nil, status.Errorf(codes.Internal, "Could not get validators: %v", err)
}
seed, err := as.HeadFetcher.HeadSeed(epoch)
if err != nil {
return nil, status.Errorf(codes.Internal, "Could not get seed: %v", err)
}
committee, err := helpers.BeaconCommittee(activeValidatorIndices, seed, req.Slot, req.CommitteeIndex)
// Passthrough request to non-deprecated method.
res, err := as.ValidatorServer.SubmitAggregateAndProof(ctx, request)
if err != nil {
return nil, err
}
// Check if the validator is an aggregator
isAggregator, err := helpers.IsAggregator(uint64(len(committee)), req.SlotSignature)
if err != nil {
return nil, status.Errorf(codes.Internal, "Could not get aggregator status: %v", err)
}
if !isAggregator {
return nil, status.Errorf(codes.InvalidArgument, "Validator is not an aggregator")
}
// Retrieve the unaggregated attestation from pool.
aggregatedAtts := as.AttPool.AggregatedAttestationsBySlotIndex(req.Slot, req.CommitteeIndex)
for _, aggregatedAtt := range aggregatedAtts {
if ctx.Err() != nil {
return nil, ctx.Err()
}
if helpers.IsAggregated(aggregatedAtt) {
if err := as.P2p.Broadcast(ctx, &ethpb.AggregateAttestationAndProof{
AggregatorIndex: validatorIndex,
SelectionProof: req.SlotSignature,
Aggregate: aggregatedAtt,
}); err != nil {
return nil, status.Errorf(codes.Internal, "Could not broadcast aggregated attestation: %v", err)
}
log.WithFields(logrus.Fields{
"slot": req.Slot,
"committeeIndex": req.CommitteeIndex,
"validatorIndex": validatorIndex,
"aggregatedCount": aggregatedAtt.AggregationBits.Count(),
}).Debug("Broadcasting aggregated attestation and proof")
}
}
return &pb.AggregationResponse{}, nil
return &pb.AggregationResponse{Root: res.AttestationDataRoot}, nil
}

View File

@@ -258,13 +258,7 @@ func (s *Service) Start() {
BlockNotifier: s.blockNotifier,
AttestationNotifier: s.operationNotifier,
}
aggregatorServer := &aggregator.Server{
BeaconDB: s.beaconDB,
HeadFetcher: s.headFetcher,
SyncChecker: s.syncService,
AttPool: s.attestationsPool,
P2p: s.p2p,
}
aggregatorServer := &aggregator.Server{ValidatorServer: validatorServer}
pb.RegisterAggregatorServiceServer(s.grpcServer, aggregatorServer)
ethpb.RegisterNodeServer(s.grpcServer, nodeServer)
ethpb.RegisterBeaconChainServer(s.grpcServer, beaconChainServer)

View File

@@ -3,6 +3,7 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
go_library(
name = "go_default_library",
srcs = [
"aggregator.go",
"assignments.go",
"attester.go",
"exit.go",
@@ -57,6 +58,7 @@ go_library(
go_test(
name = "go_default_test",
srcs = [
"aggregator_test.go",
"assignments_test.go",
"attester_test.go",
"exit_test.go",

View File

@@ -0,0 +1,82 @@
package validator
import (
"context"
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
"github.com/sirupsen/logrus"
"go.opencensus.io/trace"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
// SubmitAggregateAndProof is called by a validator when its assigned to be an aggregator.
// The beacon node will broadcast aggregated attestation and proof on the aggregator's behavior.
func (as *Server) SubmitAggregateAndProof(ctx context.Context, req *ethpb.AggregationRequest) (*ethpb.AggregationResponse, error) {
ctx, span := trace.StartSpan(ctx, "AggregatorServer.SubmitAggregation")
defer span.End()
span.AddAttributes(trace.Int64Attribute("slot", int64(req.Slot)))
if as.SyncChecker.Syncing() {
return nil, status.Errorf(codes.Unavailable, "Syncing to latest head, not ready to respond")
}
validatorIndex, exists, err := as.BeaconDB.ValidatorIndex(ctx, req.PublicKey)
if err != nil {
return nil, status.Errorf(codes.Internal, "Could not get validator index from DB: %v", err)
}
if !exists {
return nil, status.Error(codes.Internal, "Could not locate validator index in DB")
}
epoch := helpers.SlotToEpoch(req.Slot)
activeValidatorIndices, err := as.HeadFetcher.HeadValidatorsIndices(epoch)
if err != nil {
return nil, status.Errorf(codes.Internal, "Could not get validators: %v", err)
}
seed, err := as.HeadFetcher.HeadSeed(epoch)
if err != nil {
return nil, status.Errorf(codes.Internal, "Could not get seed: %v", err)
}
committee, err := helpers.BeaconCommittee(activeValidatorIndices, seed, req.Slot, req.CommitteeIndex)
if err != nil {
return nil, err
}
// Check if the validator is an aggregator
isAggregator, err := helpers.IsAggregator(uint64(len(committee)), req.SlotSignature)
if err != nil {
return nil, status.Errorf(codes.Internal, "Could not get aggregator status: %v", err)
}
if !isAggregator {
return nil, status.Errorf(codes.InvalidArgument, "Validator is not an aggregator")
}
// Retrieve the unaggregated attestation from pool.
aggregatedAtts := as.AttPool.AggregatedAttestationsBySlotIndex(req.Slot, req.CommitteeIndex)
for _, aggregatedAtt := range aggregatedAtts {
if ctx.Err() != nil {
return nil, ctx.Err()
}
if helpers.IsAggregated(aggregatedAtt) {
if err := as.P2P.Broadcast(ctx, &ethpb.AggregateAttestationAndProof{
AggregatorIndex: validatorIndex,
SelectionProof: req.SlotSignature,
Aggregate: aggregatedAtt,
}); err != nil {
return nil, status.Errorf(codes.Internal, "Could not broadcast aggregated attestation: %v", err)
}
log.WithFields(logrus.Fields{
"slot": req.Slot,
"committeeIndex": req.CommitteeIndex,
"validatorIndex": validatorIndex,
"aggregatedCount": aggregatedAtt.AggregationBits.Count(),
}).Debug("Broadcasting aggregated attestation and proof")
}
}
return &ethpb.AggregationResponse{}, nil
}

View File

@@ -1,8 +1,7 @@
package aggregator
package validator
import (
"context"
"encoding/binary"
"reflect"
"strings"
"testing"
@@ -18,7 +17,6 @@ import (
beaconstate "github.com/prysmaticlabs/prysm/beacon-chain/state"
mockSync "github.com/prysmaticlabs/prysm/beacon-chain/sync/initial-sync/testing"
pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
pb "github.com/prysmaticlabs/prysm/proto/beacon/rpc/v1"
"github.com/prysmaticlabs/prysm/shared/attestationutil"
"github.com/prysmaticlabs/prysm/shared/bls"
"github.com/prysmaticlabs/prysm/shared/params"
@@ -30,13 +28,6 @@ func init() {
params.OverrideBeaconConfig(params.MinimalSpecConfig())
}
// pubKey is a helper to generate a well-formed public key.
func pubKey(i uint64) []byte {
pubKey := make([]byte, params.BeaconConfig().BLSPubkeyLength)
binary.LittleEndian.PutUint64(pubKey, uint64(i))
return pubKey
}
func TestSubmitAggregateAndProof_Syncing(t *testing.T) {
db := dbutil.SetupDB(t)
defer dbutil.TeardownDB(t, db)
@@ -50,7 +41,7 @@ func TestSubmitAggregateAndProof_Syncing(t *testing.T) {
BeaconDB: db,
}
req := &pb.AggregationRequest{CommitteeIndex: 1}
req := &ethpb.AggregationRequest{CommitteeIndex: 1}
wanted := "Syncing to latest head, not ready to respond"
if _, err := aggregatorServer.SubmitAggregateAndProof(ctx, req); !strings.Contains(err.Error(), wanted) {
t.Error("Did not receive wanted error")
@@ -66,7 +57,7 @@ func TestSubmitAggregateAndProof_CantFindValidatorIndex(t *testing.T) {
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
})
aggregatorServer := &Server{
server := &Server{
HeadFetcher: &mock.ChainService{State: s},
SyncChecker: &mockSync.Sync{IsSyncing: false},
BeaconDB: db,
@@ -74,9 +65,9 @@ func TestSubmitAggregateAndProof_CantFindValidatorIndex(t *testing.T) {
priv := bls.RandKey()
sig := priv.Sign([]byte{'A'}, 0)
req := &pb.AggregationRequest{CommitteeIndex: 1, SlotSignature: sig.Marshal(), PublicKey: pubKey(3)}
req := &ethpb.AggregationRequest{CommitteeIndex: 1, SlotSignature: sig.Marshal(), PublicKey: pubKey(3)}
wanted := "Could not locate validator index in DB"
if _, err := aggregatorServer.SubmitAggregateAndProof(ctx, req); !strings.Contains(err.Error(), wanted) {
if _, err := server.SubmitAggregateAndProof(ctx, req); !strings.Contains(err.Error(), wanted) {
t.Errorf("Did not receive wanted error: expected %v, received %v", wanted, err.Error())
}
}
@@ -90,7 +81,7 @@ func TestSubmitAggregateAndProof_IsAggregator(t *testing.T) {
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
})
aggregatorServer := &Server{
server := &Server{
HeadFetcher: &mock.ChainService{State: s},
SyncChecker: &mockSync.Sync{IsSyncing: false},
BeaconDB: db,
@@ -100,12 +91,12 @@ func TestSubmitAggregateAndProof_IsAggregator(t *testing.T) {
priv := bls.RandKey()
sig := priv.Sign([]byte{'A'}, 0)
pubKey := pubKey(1)
req := &pb.AggregationRequest{CommitteeIndex: 1, SlotSignature: sig.Marshal(), PublicKey: pubKey}
req := &ethpb.AggregationRequest{CommitteeIndex: 1, SlotSignature: sig.Marshal(), PublicKey: pubKey}
if err := db.SaveValidatorIndex(ctx, pubKey, 100); err != nil {
t.Fatal(err)
}
if _, err := aggregatorServer.SubmitAggregateAndProof(ctx, req); err != nil {
if _, err := server.SubmitAggregateAndProof(ctx, req); err != nil {
t.Fatal(err)
}
}
@@ -115,7 +106,7 @@ func TestSubmitAggregateAndProof_AggregateOk(t *testing.T) {
c := params.MinimalSpecConfig()
c.TargetAggregatorsPerCommittee = 16
params.OverrideBeaconConfig(c)
defer params.UseMainnetConfig()
defer params.UseMinimalConfig()
db := dbutil.SetupDB(t)
defer dbutil.TeardownDB(t, db)
@@ -132,13 +123,13 @@ func TestSubmitAggregateAndProof_AggregateOk(t *testing.T) {
SyncChecker: &mockSync.Sync{IsSyncing: false},
BeaconDB: db,
AttPool: attestations.NewPool(),
P2p: &mockp2p.MockBroadcaster{},
P2P: &mockp2p.MockBroadcaster{},
}
priv := bls.RandKey()
sig := priv.Sign([]byte{'B'}, 0)
pubKey := pubKey(2)
req := &pb.AggregationRequest{CommitteeIndex: 1, SlotSignature: sig.Marshal(), PublicKey: pubKey}
req := &ethpb.AggregationRequest{CommitteeIndex: 1, SlotSignature: sig.Marshal(), PublicKey: pubKey}
if err := db.SaveValidatorIndex(ctx, pubKey, 100); err != nil {
t.Fatal(err)
}
@@ -169,7 +160,7 @@ func TestSubmitAggregateAndProof_AggregateNotOk(t *testing.T) {
c := params.MinimalSpecConfig()
c.TargetAggregatorsPerCommittee = 16
params.OverrideBeaconConfig(c)
defer params.UseMainnetConfig()
defer params.UseMinimalConfig()
db := dbutil.SetupDB(t)
defer dbutil.TeardownDB(t, db)
@@ -185,13 +176,13 @@ func TestSubmitAggregateAndProof_AggregateNotOk(t *testing.T) {
SyncChecker: &mockSync.Sync{IsSyncing: false},
BeaconDB: db,
AttPool: attestations.NewPool(),
P2p: &mockp2p.MockBroadcaster{},
P2P: &mockp2p.MockBroadcaster{},
}
priv := bls.RandKey()
sig := priv.Sign([]byte{'B'}, 0)
pubKey := pubKey(2)
req := &pb.AggregationRequest{CommitteeIndex: 1, SlotSignature: sig.Marshal(), PublicKey: pubKey}
req := &ethpb.AggregationRequest{CommitteeIndex: 1, SlotSignature: sig.Marshal(), PublicKey: pubKey}
if err := db.SaveValidatorIndex(ctx, pubKey, 100); err != nil {
t.Fatal(err)
}

View File

@@ -402,7 +402,7 @@ index 0099328..8b8c6eb 100644
// The epoch for which this set of validator assignments is valid.
diff --git a/eth/v1alpha1/validator.proto b/eth/v1alpha1/validator.proto
index c0ab286..428875b 100644
index 47203c1..9e72b10 100644
--- a/eth/v1alpha1/validator.proto
+++ b/eth/v1alpha1/validator.proto
@@ -15,6 +15,7 @@ syntax = "proto3";
@@ -413,7 +413,7 @@ index c0ab286..428875b 100644
import "google/api/annotations.proto";
import "google/protobuf/empty.proto";
import "eth/v1alpha1/beacon_block.proto";
@@ -180,7 +181,7 @@ message DomainResponse {
@@ -191,7 +192,7 @@ message DomainResponse {
message ValidatorActivationRequest {
// A list of 48 byte validator public keys.
@@ -422,7 +422,7 @@ index c0ab286..428875b 100644
}
message ValidatorActivationResponse {
@@ -206,7 +207,7 @@ message ChainStartResponse {
@@ -217,7 +218,7 @@ message ChainStartResponse {
message ValidatorIndexRequest {
// A 48 byte validator public key.
@@ -431,7 +431,7 @@ index c0ab286..428875b 100644
}
message ValidatorIndexResponse {
@@ -216,7 +217,7 @@ message ValidatorIndexResponse {
@@ -227,7 +228,7 @@ message ValidatorIndexResponse {
message ValidatorStatusRequest {
// A 48 byte validator public key.
@@ -440,7 +440,7 @@ index c0ab286..428875b 100644
}
enum ValidatorStatus {
@@ -254,7 +255,7 @@ message DutiesRequest {
@@ -265,7 +266,7 @@ message DutiesRequest {
uint64 epoch = 1;
// Array of byte encoded BLS public keys.
@@ -449,7 +449,7 @@ index c0ab286..428875b 100644
}
message DutiesResponse {
@@ -273,7 +274,7 @@ message DutiesResponse {
@@ -284,7 +285,7 @@ message DutiesResponse {
uint64 proposer_slot = 4;
// 48 byte BLS public key for the validator who's assigned to perform a duty.
@@ -458,7 +458,7 @@ index c0ab286..428875b 100644
// The current status of the validator assigned to perform the duty.
ValidatorStatus status = 6;
@@ -288,15 +289,16 @@ message BlockRequest {
@@ -299,15 +300,16 @@ message BlockRequest {
uint64 slot = 1;
// Validator's 32 byte randao reveal secret of the current epoch.
@@ -478,7 +478,7 @@ index c0ab286..428875b 100644
}
message AttestationDataRequest {
@@ -309,16 +311,16 @@ message AttestationDataRequest {
@@ -320,7 +322,7 @@ message AttestationDataRequest {
message AttestResponse {
// The root of the attestation data successfully submitted to the beacon node.
@@ -486,6 +486,8 @@ index c0ab286..428875b 100644
+ bytes attestation_data_root = 1 [(gogoproto.moretags) = "ssz-size:\"32\""];
}
message AggregationRequest {
@@ -343,10 +345,10 @@ message AggregationResponse {
// An Ethereum 2.0 validator.
message Validator {
// 48 byte BLS public key used for the validator's activities.

View File

@@ -10,7 +10,6 @@ import (
grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
"github.com/pkg/errors"
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
pb "github.com/prysmaticlabs/prysm/proto/beacon/rpc/v1"
"github.com/prysmaticlabs/prysm/validator/db"
"github.com/prysmaticlabs/prysm/validator/keymanager"
"github.com/sirupsen/logrus"
@@ -147,7 +146,6 @@ func (v *ValidatorService) Start() {
db: valDB,
validatorClient: ethpb.NewBeaconNodeValidatorClient(v.conn),
beaconClient: ethpb.NewBeaconChainClient(v.conn),
aggregatorClient: pb.NewAggregatorServiceClient(v.conn),
node: ethpb.NewNodeClient(v.conn),
keyManager: v.keyManager,
graffiti: v.graffiti,

View File

@@ -38,7 +38,6 @@ type validator struct {
validatorClient ethpb.BeaconNodeValidatorClient
beaconClient ethpb.BeaconChainClient
graffiti []byte
aggregatorClient pb.AggregatorServiceClient
node ethpb.NodeClient
keyManager keymanager.KeyManager
prevBalance map[[48]byte]uint64

View File

@@ -10,7 +10,6 @@ import (
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
"github.com/prysmaticlabs/go-ssz"
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
pb "github.com/prysmaticlabs/prysm/proto/beacon/rpc/v1"
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/prysmaticlabs/prysm/shared/roughtime"
"github.com/prysmaticlabs/prysm/shared/slotutil"
@@ -74,7 +73,7 @@ func (v *validator) SubmitAggregateAndProof(ctx context.Context, slot uint64, pu
// https://github.com/ethereum/eth2.0-specs/blob/v0.9.3/specs/validator/0_beacon-chain-validator.md#broadcast-aggregate
v.waitToSlotTwoThirds(ctx, slot)
_, err = v.aggregatorClient.SubmitAggregateAndProof(ctx, &pb.AggregationRequest{
_, err = v.validatorClient.SubmitAggregateAndProof(ctx, &ethpb.AggregationRequest{
Slot: slot,
CommitteeIndex: duty.CommitteeIndex,
PublicKey: pubKey[:],

View File

@@ -7,7 +7,6 @@ import (
"github.com/golang/mock/gomock"
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
pb "github.com/prysmaticlabs/prysm/proto/beacon/rpc/v1"
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/prysmaticlabs/prysm/shared/testutil"
logTest "github.com/sirupsen/logrus/hooks/test"
@@ -40,10 +39,10 @@ func TestSubmitAggregateAndProof_Ok(t *testing.T) {
gomock.Any(), // epoch
).Return(&ethpb.DomainResponse{}, nil /*err*/)
m.aggregatorClient.EXPECT().SubmitAggregateAndProof(
m.validatorClient.EXPECT().SubmitAggregateAndProof(
gomock.Any(), // ctx
gomock.AssignableToTypeOf(&pb.AggregationRequest{}),
).Return(&pb.AggregationResponse{}, nil)
gomock.AssignableToTypeOf(&ethpb.AggregationRequest{}),
).Return(&ethpb.AggregationResponse{}, nil)
validator.SubmitAggregateAndProof(context.Background(), 0, validatorPubKey)
}

View File

@@ -19,7 +19,6 @@ import (
type mocks struct {
validatorClient *internal.MockBeaconNodeValidatorClient
aggregatorClient *internal.MockAggregatorServiceClient
}
func setup(t *testing.T) (*validator, *mocks, func()) {
@@ -27,12 +26,10 @@ func setup(t *testing.T) (*validator, *mocks, func()) {
ctrl := gomock.NewController(t)
m := &mocks{
validatorClient: internal.NewMockBeaconNodeValidatorClient(ctrl),
aggregatorClient: internal.NewMockAggregatorServiceClient(ctrl),
}
validator := &validator{
db: valDB,
validatorClient: m.validatorClient,
aggregatorClient: m.aggregatorClient,
keyManager: testKeyManager,
graffiti: []byte{},
attLogs: make(map[[32]byte]*attSubmitted),

View File

@@ -4,14 +4,12 @@ go_library(
name = "go_default_library",
testonly = True,
srcs = [
"aggregator_service_mock.go",
"beacon_node_validator_service_mock.go",
"node_mock.go",
],
importpath = "github.com/prysmaticlabs/prysm/validator/internal",
visibility = ["//validator:__subpackages__"],
deps = [
"//proto/beacon/rpc/v1:go_default_library",
"@com_github_gogo_protobuf//types:go_default_library",
"@com_github_golang_mock//gomock:go_default_library",
"@com_github_prysmaticlabs_ethereumapis//eth/v1alpha1:go_default_library",

View File

@@ -1,57 +0,0 @@
// Code generated by MockGen. DO NOT EDIT.
// Source: github.com/prysmaticlabs/prysm/proto/beacon/rpc/v1 (interfaces: AggregatorServiceClient)
// Package internal is a generated GoMock package.
package internal
import (
context "context"
reflect "reflect"
gomock "github.com/golang/mock/gomock"
v1 "github.com/prysmaticlabs/prysm/proto/beacon/rpc/v1"
grpc "google.golang.org/grpc"
)
// MockAggregatorServiceClient is a mock of AggregatorServiceClient interface
type MockAggregatorServiceClient struct {
ctrl *gomock.Controller
recorder *MockAggregatorServiceClientMockRecorder
}
// MockAggregatorServiceClientMockRecorder is the mock recorder for MockAggregatorServiceClient
type MockAggregatorServiceClientMockRecorder struct {
mock *MockAggregatorServiceClient
}
// NewMockAggregatorServiceClient creates a new mock instance
func NewMockAggregatorServiceClient(ctrl *gomock.Controller) *MockAggregatorServiceClient {
mock := &MockAggregatorServiceClient{ctrl: ctrl}
mock.recorder = &MockAggregatorServiceClientMockRecorder{mock}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use
func (m *MockAggregatorServiceClient) EXPECT() *MockAggregatorServiceClientMockRecorder {
return m.recorder
}
// SubmitAggregateAndProof mocks base method
func (m *MockAggregatorServiceClient) SubmitAggregateAndProof(arg0 context.Context, arg1 *v1.AggregationRequest, arg2 ...grpc.CallOption) (*v1.AggregationResponse, error) {
m.ctrl.T.Helper()
varargs := []interface{}{arg0, arg1}
for _, a := range arg2 {
varargs = append(varargs, a)
}
ret := m.ctrl.Call(m, "SubmitAggregateAndProof", varargs...)
ret0, _ := ret[0].(*v1.AggregationResponse)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// SubmitAggregateAndProof indicates an expected call of SubmitAggregateAndProof
func (mr *MockAggregatorServiceClientMockRecorder) SubmitAggregateAndProof(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
varargs := append([]interface{}{arg0, arg1}, arg2...)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SubmitAggregateAndProof", reflect.TypeOf((*MockAggregatorServiceClient)(nil).SubmitAggregateAndProof), varargs...)
}

File diff suppressed because it is too large Load Diff