Add support for building a Beacon API validator client versus a gRPC one (#11612)

This commit is contained in:
Patrice Vignola
2022-11-07 02:29:27 -08:00
committed by GitHub
parent 53d4659654
commit d33af46c90
39 changed files with 946 additions and 86 deletions

View File

@@ -43,6 +43,8 @@ go_library(
"//validator/accounts/petnames:go_default_library",
"//validator/accounts/wallet:go_default_library",
"//validator/client:go_default_library",
"//validator/client/iface:go_default_library",
"//validator/client/validator-client-factory:go_default_library",
"//validator/db:go_default_library",
"//validator/keymanager:go_default_library",
"//validator/keymanager/derived:go_default_library",

View File

@@ -187,7 +187,7 @@ func TestServer_VoluntaryExit(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
ctx := context.Background()
mockValidatorClient := mock2.NewMockBeaconNodeValidatorClient(ctrl)
mockValidatorClient := mock2.NewMockValidatorClient(ctrl)
mockNodeClient := mock2.NewMockNodeClient(ctrl)
mockValidatorClient.EXPECT().

View File

@@ -14,6 +14,7 @@ import (
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
validatorpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1/validator-client"
"github.com/prysmaticlabs/prysm/v3/validator/client"
validatorClientFactory "github.com/prysmaticlabs/prysm/v3/validator/client/validator-client-factory"
"google.golang.org/grpc"
"google.golang.org/protobuf/types/known/emptypb"
)
@@ -48,7 +49,7 @@ func (s *Server) registerBeaconClient() error {
s.beaconChainClient = ethpb.NewBeaconChainClient(conn)
s.beaconNodeClient = ethpb.NewNodeClient(conn)
s.beaconNodeHealthClient = ethpb.NewHealthClient(conn)
s.beaconNodeValidatorClient = ethpb.NewBeaconNodeValidatorClient(conn)
s.beaconNodeValidatorClient = validatorClientFactory.NewValidatorClient(conn)
return nil
}

View File

@@ -19,6 +19,7 @@ import (
validatorpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1/validator-client"
"github.com/prysmaticlabs/prysm/v3/validator/accounts/wallet"
"github.com/prysmaticlabs/prysm/v3/validator/client"
iface "github.com/prysmaticlabs/prysm/v3/validator/client/iface"
"github.com/prysmaticlabs/prysm/v3/validator/db"
"github.com/sirupsen/logrus"
"go.opencensus.io/plugin/ocgrpc"
@@ -59,7 +60,7 @@ type Server struct {
streamLogsBufferSize int
beaconChainClient ethpb.BeaconChainClient
beaconNodeClient ethpb.NodeClient
beaconNodeValidatorClient ethpb.BeaconNodeValidatorClient
beaconNodeValidatorClient iface.ValidatorClient
beaconNodeHealthClient ethpb.HealthClient
valDB db.Database
ctx context.Context

View File

@@ -770,7 +770,7 @@ func TestServer_ListFeeRecipientByPubkey(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ctrl := gomock.NewController(t)
mockValidatorClient := mock2.NewMockBeaconNodeValidatorClient(ctrl)
mockValidatorClient := mock2.NewMockValidatorClient(ctrl)
m := &mock.MockValidator{}
m.SetProposerSettings(tt.args)
vs, err := client.NewValidatorService(ctx, &client.Config{
@@ -793,7 +793,7 @@ func TestServer_ListFeeRecipientByPubkey(t *testing.T) {
func TestServer_SetFeeRecipientByPubkey(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
beaconClient := mock2.NewMockBeaconNodeValidatorClient(ctrl)
beaconClient := mock2.NewMockValidatorClient(ctrl)
ctx := grpc.NewContextWithServerTransportStream(context.Background(), &runtime.ServerTransportStream{})
byteval, err := hexutil.Decode("0xaf2e7ba294e03438ea819bd4033c6c1bf6b04320ee2075b77273c08d02f8a61bcc303c2c06bd3713cb442072ae591493")
wantAddress := "0x055Fb65722e7b2455012Bfebf6177f1d2e9738d7"
@@ -1024,7 +1024,7 @@ func TestServer_GetGasLimit(t *testing.T) {
func TestServer_SetGasLimit(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
beaconClient := mock2.NewMockBeaconNodeValidatorClient(ctrl)
beaconClient := mock2.NewMockValidatorClient(ctrl)
ctx := grpc.NewContextWithServerTransportStream(context.Background(), &runtime.ServerTransportStream{})
pubkey1, err := hexutil.Decode("0xaf2e7ba294e03438ea819bd4033c6c1bf6b04320ee2075b77273c08d02f8a61bcc303c2c06bd3713cb442072ae591493")
pubkey2, err2 := hexutil.Decode("0xbedefeaa94e03438ea819bd4033c6c1bf6b04320ee2075b77273c08d02f8a61bcc303c2cdddddddddddddddddddddddd")