Update rules_go and fix proto conflicts (#8596)

* Update rules_go and fix proto conflicts

* gaz

* Update generated code

* more emptypb fixes

* gaz

Co-authored-by: Victor Farazdagi <simple.square@gmail.com>
This commit is contained in:
Preston Van Loon
2021-03-11 18:03:19 -06:00
committed by GitHub
parent fa2084330b
commit eb694ab5d5
57 changed files with 344 additions and 220 deletions

View File

@@ -51,6 +51,7 @@ go_library(
"@com_github_prysmaticlabs_ethereumapis//eth/v1alpha1:go_default_library",
"@com_github_sirupsen_logrus//:go_default_library",
"@com_github_tyler_smith_go_bip39//:go_default_library",
"@io_bazel_rules_go//proto/wkt:empty_go_proto",
"@io_opencensus_go//plugin/ocgrpc:go_default_library",
"@org_golang_google_grpc//:go_default_library",
"@org_golang_google_grpc//codes:go_default_library",
@@ -101,6 +102,7 @@ go_test(
"@com_github_pkg_errors//:go_default_library",
"@com_github_prysmaticlabs_ethereumapis//eth/v1alpha1:go_default_library",
"@com_github_wealdtech_go_eth2_wallet_encryptor_keystorev4//:go_default_library",
"@io_bazel_rules_go//proto/wkt:empty_go_proto",
"@org_golang_google_grpc//:go_default_library",
"@org_golang_google_grpc//metadata:go_default_library",
],

View File

@@ -6,7 +6,7 @@ import (
"time"
"github.com/dgrijalva/jwt-go"
ptypes "github.com/gogo/protobuf/types"
"github.com/golang/protobuf/ptypes/empty"
"github.com/pkg/errors"
pb "github.com/prysmaticlabs/prysm/proto/validator/accounts/v2"
"github.com/prysmaticlabs/prysm/shared/fileutil"
@@ -86,7 +86,7 @@ func (s *Server) Login(ctx context.Context, req *pb.AuthRequest) (*pb.AuthRespon
}
// HasUsedWeb checks if the user has authenticated via the web interface.
func (s *Server) HasUsedWeb(ctx context.Context, _ *ptypes.Empty) (*pb.HasUsedWebResponse, error) {
func (s *Server) HasUsedWeb(ctx context.Context, _ *empty.Empty) (*pb.HasUsedWebResponse, error) {
walletExists, err := wallet.Exists(s.walletDir)
if err != nil {
return nil, status.Error(codes.Internal, "Could not check if wallet exists")
@@ -99,14 +99,14 @@ func (s *Server) HasUsedWeb(ctx context.Context, _ *ptypes.Empty) (*pb.HasUsedWe
}
// Logout a user by invalidating their JWT key.
func (s *Server) Logout(ctx context.Context, _ *ptypes.Empty) (*ptypes.Empty, error) {
func (s *Server) Logout(ctx context.Context, _ *empty.Empty) (*empty.Empty, error) {
// Invalidate the old JWT key, making all requests done with its token fail.
jwtKey, err := createRandomJWTKey()
if err != nil {
return nil, status.Error(codes.Internal, "Could not invalidate JWT key")
}
s.jwtKey = jwtKey
return &ptypes.Empty{}, nil
return &empty.Empty{}, nil
}
// Sends an auth response via gRPC containing a new JWT token.
@@ -123,7 +123,7 @@ func (s *Server) sendAuthResponse() (*pb.AuthResponse, error) {
}
// ChangePassword allows changing the RPC password via the API as an authenticated method.
func (s *Server) ChangePassword(ctx context.Context, req *pb.ChangePasswordRequest) (*ptypes.Empty, error) {
func (s *Server) ChangePassword(ctx context.Context, req *pb.ChangePasswordRequest) (*empty.Empty, error) {
if req.CurrentPassword == "" {
return nil, status.Error(codes.InvalidArgument, "Current password cannot be empty")
}
@@ -148,7 +148,7 @@ func (s *Server) ChangePassword(ctx context.Context, req *pb.ChangePasswordReque
if err := s.SaveHashedPassword(req.Password); err != nil {
return nil, status.Errorf(codes.Internal, "could not write hashed password to disk: %v", err)
}
return &ptypes.Empty{}, nil
return &empty.Empty{}, nil
}
// SaveHashedPassword to disk for the validator RPC.

View File

@@ -7,7 +7,7 @@ import (
"testing"
"github.com/dgrijalva/jwt-go"
ptypes "github.com/gogo/protobuf/types"
"github.com/golang/protobuf/ptypes/empty"
pb "github.com/prysmaticlabs/prysm/proto/validator/accounts/v2"
"github.com/prysmaticlabs/prysm/shared/event"
"github.com/prysmaticlabs/prysm/shared/fileutil"
@@ -87,7 +87,7 @@ func TestServer_Logout(t *testing.T) {
_, err = jwt.Parse(tokenString, checkParsedKey)
assert.NoError(t, err)
_, err = ss.Logout(context.Background(), &ptypes.Empty{})
_, err = ss.Logout(context.Background(), &empty.Empty{})
require.NoError(t, err)
// Attempting to validate the same token string after logout should fail.

View File

@@ -5,6 +5,7 @@ import (
"time"
ptypes "github.com/gogo/protobuf/types"
"github.com/golang/protobuf/ptypes/empty"
middleware "github.com/grpc-ecosystem/go-grpc-middleware"
grpc_retry "github.com/grpc-ecosystem/go-grpc-middleware/retry"
grpc_opentracing "github.com/grpc-ecosystem/go-grpc-middleware/tracing/opentracing"
@@ -54,7 +55,7 @@ func (s *Server) registerBeaconClient() error {
// GetBeaconStatus retrieves information about the beacon node gRPC connection
// and certain chain metadata, such as the genesis time, the chain head, and the
// deposit contract address.
func (s *Server) GetBeaconStatus(ctx context.Context, _ *ptypes.Empty) (*pb.BeaconStatusResponse, error) {
func (s *Server) GetBeaconStatus(ctx context.Context, _ *empty.Empty) (*pb.BeaconStatusResponse, error) {
syncStatus, err := s.beaconNodeClient.GetSyncStatus(ctx, &ptypes.Empty{})
if err != nil {
return &pb.BeaconStatusResponse{
@@ -113,14 +114,14 @@ func (s *Server) GetValidators(
// GetValidatorQueue is a wrapper around the /eth/v1alpha1 endpoint of the same name.
func (s *Server) GetValidatorQueue(
ctx context.Context, req *ptypes.Empty,
ctx context.Context, _ *empty.Empty,
) (*ethpb.ValidatorQueue, error) {
return s.beaconChainClient.GetValidatorQueue(ctx, req)
return s.beaconChainClient.GetValidatorQueue(ctx, &ptypes.Empty{})
}
// GetPeers is a wrapper around the /eth/v1alpha1 endpoint of the same name.
func (s *Server) GetPeers(
ctx context.Context, req *ptypes.Empty,
ctx context.Context, _ *empty.Empty,
) (*ethpb.Peers, error) {
return s.beaconNodeClient.ListPeers(ctx, req)
return s.beaconNodeClient.ListPeers(ctx, &ptypes.Empty{})
}

View File

@@ -7,6 +7,7 @@ import (
ptypes "github.com/gogo/protobuf/types"
"github.com/golang/mock/gomock"
"github.com/golang/protobuf/ptypes/empty"
"github.com/pkg/errors"
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
pb "github.com/prysmaticlabs/prysm/proto/validator/accounts/v2"
@@ -27,7 +28,7 @@ func TestGetBeaconStatus_NotConnected(t *testing.T) {
beaconNodeClient: nodeClient,
}
ctx := context.Background()
resp, err := srv.GetBeaconStatus(ctx, &ptypes.Empty{})
resp, err := srv.GetBeaconStatus(ctx, &empty.Empty{})
require.NoError(t, err)
want := &pb.BeaconStatusResponse{
BeaconNodeEndpoint: "",
@@ -65,7 +66,7 @@ func TestGetBeaconStatus_OK(t *testing.T) {
beaconChainClient: beaconChainClient,
}
ctx := context.Background()
resp, err := srv.GetBeaconStatus(ctx, &ptypes.Empty{})
resp, err := srv.GetBeaconStatus(ctx, &empty.Empty{})
require.NoError(t, err)
want := &pb.BeaconStatusResponse{
BeaconNodeEndpoint: "",

View File

@@ -5,6 +5,7 @@ import (
"time"
ptypes "github.com/gogo/protobuf/types"
"github.com/golang/protobuf/ptypes/empty"
"github.com/pkg/errors"
pb "github.com/prysmaticlabs/prysm/proto/validator/accounts/v2"
"github.com/prysmaticlabs/prysm/shared/version"
@@ -14,7 +15,7 @@ import (
// GetBeaconNodeConnection retrieves the current beacon node connection
// information, as well as its sync status.
func (s *Server) GetBeaconNodeConnection(ctx context.Context, _ *ptypes.Empty) (*pb.NodeConnectionResponse, error) {
func (s *Server) GetBeaconNodeConnection(ctx context.Context, _ *empty.Empty) (*pb.NodeConnectionResponse, error) {
syncStatus, err := s.syncChecker.Syncing(ctx)
if err != nil || s.validatorService.Status() != nil {
return &pb.NodeConnectionResponse{
@@ -38,12 +39,12 @@ func (s *Server) GetBeaconNodeConnection(ctx context.Context, _ *ptypes.Empty) (
}
// GetLogsEndpoints for the beacon and validator client.
func (s *Server) GetLogsEndpoints(ctx context.Context, _ *ptypes.Empty) (*pb.LogsEndpointResponse, error) {
func (s *Server) GetLogsEndpoints(ctx context.Context, _ *empty.Empty) (*pb.LogsEndpointResponse, error) {
return nil, status.Error(codes.Unimplemented, "unimplemented")
}
// GetVersion --
func (s *Server) GetVersion(ctx context.Context, _ *ptypes.Empty) (*pb.VersionResponse, error) {
func (s *Server) GetVersion(ctx context.Context, _ *empty.Empty) (*pb.VersionResponse, error) {
beacon, err := s.beaconNodeClient.GetVersion(ctx, &ptypes.Empty{})
if err != nil {
return nil, err
@@ -56,7 +57,7 @@ func (s *Server) GetVersion(ctx context.Context, _ *ptypes.Empty) (*pb.VersionRe
}
// StreamBeaconLogs from the beacon node via a gRPC server-side stream.
func (s *Server) StreamBeaconLogs(req *ptypes.Empty, stream pb.Health_StreamBeaconLogsServer) error {
func (s *Server) StreamBeaconLogs(req *empty.Empty, stream pb.Health_StreamBeaconLogsServer) error {
// Wrap service context with a cancel in order to propagate the exiting of
// this method properly to the beacon node server.
ctx, cancel := context.WithCancel(s.ctx)
@@ -87,7 +88,7 @@ func (s *Server) StreamBeaconLogs(req *ptypes.Empty, stream pb.Health_StreamBeac
}
// StreamValidatorLogs from the validator client via a gRPC server-side stream.
func (s *Server) StreamValidatorLogs(_ *ptypes.Empty, stream pb.Health_StreamValidatorLogsServer) error {
func (s *Server) StreamValidatorLogs(_ *empty.Empty, stream pb.Health_StreamValidatorLogsServer) error {
ch := make(chan []byte, s.streamLogsBufferSize)
sub := s.logsStreamer.LogsFeed().Subscribe(ch)
defer func() {

View File

@@ -6,6 +6,7 @@ import (
"time"
ptypes "github.com/gogo/protobuf/types"
"github.com/golang/protobuf/ptypes/empty"
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
pb "github.com/prysmaticlabs/prysm/proto/validator/accounts/v2"
"github.com/prysmaticlabs/prysm/shared/testutil/require"
@@ -45,7 +46,7 @@ func TestServer_GetBeaconNodeConnection(t *testing.T) {
genesisFetcher: &mockGenesisFetcher{},
nodeGatewayEndpoint: endpoint,
}
got, err := s.GetBeaconNodeConnection(ctx, &ptypes.Empty{})
got, err := s.GetBeaconNodeConnection(ctx, &empty.Empty{})
require.NoError(t, err)
want := &pb.NodeConnectionResponse{
BeaconNodeEndpoint: endpoint,

View File

@@ -7,7 +7,7 @@ import (
"fmt"
"path/filepath"
ptypes "github.com/gogo/protobuf/types"
"github.com/golang/protobuf/ptypes/empty"
"github.com/pkg/errors"
pb "github.com/prysmaticlabs/prysm/proto/validator/accounts/v2"
"github.com/prysmaticlabs/prysm/shared/featureconfig"
@@ -126,7 +126,7 @@ func (s *Server) CreateWallet(ctx context.Context, req *pb.CreateWalletRequest)
}
// WalletConfig returns the wallet's configuration. If no wallet exists, we return an empty response.
func (s *Server) WalletConfig(ctx context.Context, _ *ptypes.Empty) (*pb.WalletResponse, error) {
func (s *Server) WalletConfig(ctx context.Context, _ *empty.Empty) (*pb.WalletResponse, error) {
exists, err := wallet.Exists(s.walletDir)
if err != nil {
return nil, status.Errorf(codes.Internal, checkExistsErrMsg)
@@ -166,7 +166,7 @@ func (s *Server) WalletConfig(ctx context.Context, _ *ptypes.Empty) (*pb.WalletR
}
// GenerateMnemonic creates a new, random bip39 mnemonic phrase.
func (s *Server) GenerateMnemonic(_ context.Context, _ *ptypes.Empty) (*pb.GenerateMnemonicResponse, error) {
func (s *Server) GenerateMnemonic(_ context.Context, _ *empty.Empty) (*pb.GenerateMnemonicResponse, error) {
mnemonicRandomness := make([]byte, 32)
if _, err := rand.NewGenerator().Read(mnemonicRandomness); err != nil {
return nil, status.Errorf(

View File

@@ -8,7 +8,7 @@ import (
"path/filepath"
"testing"
ptypes "github.com/gogo/protobuf/types"
"github.com/golang/protobuf/ptypes/empty"
"github.com/google/uuid"
pb "github.com/prysmaticlabs/prysm/proto/validator/accounts/v2"
"github.com/prysmaticlabs/prysm/shared/bls"
@@ -106,7 +106,7 @@ func TestServer_CreateWallet_Derived(t *testing.T) {
_, err = s.CreateWallet(ctx, req)
require.ErrorContains(t, "Must include mnemonic", err)
mnemonicResp, err := s.GenerateMnemonic(ctx, &ptypes.Empty{})
mnemonicResp, err := s.GenerateMnemonic(ctx, &empty.Empty{})
require.NoError(t, err)
req.Mnemonic = mnemonicResp.Mnemonic
@@ -116,7 +116,7 @@ func TestServer_CreateWallet_Derived(t *testing.T) {
func TestServer_WalletConfig_NoWalletFound(t *testing.T) {
s := &Server{}
resp, err := s.WalletConfig(context.Background(), &ptypes.Empty{})
resp, err := s.WalletConfig(context.Background(), &empty.Empty{})
require.NoError(t, err)
assert.DeepEqual(t, resp, &pb.WalletResponse{})
}
@@ -143,7 +143,7 @@ func TestServer_WalletConfig(t *testing.T) {
require.NoError(t, err)
s.wallet = w
s.keymanager = km
resp, err := s.WalletConfig(ctx, &ptypes.Empty{})
resp, err := s.WalletConfig(ctx, &empty.Empty{})
require.NoError(t, err)
assert.DeepEqual(t, resp, &pb.WalletResponse{