Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Substantial VC cleanup #13593

Merged
merged 13 commits into from
May 21, 2024
4 changes: 1 addition & 3 deletions testing/validator-mock/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@ go_library(
"//api/client/beacon:go_default_library",
"//api/client/event:go_default_library",
"//consensus-types/primitives:go_default_library",
"//consensus-types/validator:go_default_library",
"//proto/prysm/v1alpha1:go_default_library",
"//validator/client/iface:go_default_library",
"@com_github_golang_mock//gomock:go_default_library",
"@com_github_prysmaticlabs_prysm_v4//consensus-types/validator:go_default_library",
"@com_github_prysmaticlabs_prysm_v4//validator/client/iface:go_default_library",
"@org_golang_google_protobuf//types/known/emptypb:go_default_library",
"@org_uber_go_mock//gomock:go_default_library",
],
Expand Down
6 changes: 3 additions & 3 deletions testing/validator-mock/prysm_chain_client_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type beaconApiValidatorClient struct {
stateValidatorsProvider StateValidatorsProvider
jsonRestHandler JsonRestHandler
beaconBlockConverter BeaconBlockConverter
prysmChainClient iface.PrysmBeaconChainClient
prysmChainClient iface.PrysmChainClient
isEventStreamRunning bool
}

Expand Down
4 changes: 2 additions & 2 deletions validator/client/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ type ValidatorService struct {
graffitiStruct *graffiti.Graffiti
interopKeysConfig *local.InteropKeymanagerConfig
web3SignerConfig *remoteweb3signer.SetupConfig
proposerSettings *validatorserviceconfig.ProposerSettings
proposerSettings *proposer.Settings
validatorsRegBatchSize int
useWeb bool
emitAccountMetrics bool
Expand All @@ -76,7 +76,7 @@ type Config struct {
GraffitiStruct *graffiti.Graffiti
InteropKmConfig *local.InteropKeymanagerConfig
Web3SignerConfig *remoteweb3signer.SetupConfig
ProposerSettings *validatorserviceconfig.ProposerSettings
ProposerSettings *proposer.Settings
ValidatorsRegBatchSize int
UseWeb bool
LogValidatorPerformance bool
Expand Down
4 changes: 2 additions & 2 deletions validator/client/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import (
"github.com/prysmaticlabs/prysm/v5/validator/accounts/wallet"
beacon_api "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api"
"github.com/prysmaticlabs/prysm/v5/validator/client/iface"
vdb "github.com/prysmaticlabs/prysm/v5/validator/db"
"github.com/prysmaticlabs/prysm/v5/validator/db"
dbCommon "github.com/prysmaticlabs/prysm/v5/validator/db/common"
"github.com/prysmaticlabs/prysm/v5/validator/graffiti"
"github.com/prysmaticlabs/prysm/v5/validator/keymanager"
Expand Down Expand Up @@ -91,7 +91,7 @@ type validator struct {
db db.Database
km keymanager.IKeymanager
web3SignerConfig *remoteweb3signer.SetupConfig
proposerSettings *validatorserviceconfig.ProposerSettings
proposerSettings *proposer.Settings
signedValidatorRegistrations map[[fieldparams.BLSPubkeyLength]byte]*ethpb.SignedValidatorRegistrationV1
validatorsRegBatchSize int
interopKeysConfig *local.InteropKeymanagerConfig
Expand Down
20 changes: 10 additions & 10 deletions validator/client/validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -997,7 +997,7 @@ func TestValidator_CheckDoppelGanger(t *testing.T) {
}
v := &validator{
validatorClient: client,
km: km,
km: km,
db: db,
}
client.EXPECT().CheckDoppelGanger(
Expand Down Expand Up @@ -1038,7 +1038,7 @@ func TestValidator_CheckDoppelGanger(t *testing.T) {
}
v := &validator{
validatorClient: client,
km: km,
km: km,
db: db,
}
client.EXPECT().CheckDoppelGanger(
Expand Down Expand Up @@ -1077,7 +1077,7 @@ func TestValidator_CheckDoppelGanger(t *testing.T) {
}
v := &validator{
validatorClient: client,
km: km,
km: km,
db: db,
}
client.EXPECT().CheckDoppelGanger(
Expand Down Expand Up @@ -1122,7 +1122,7 @@ func TestValidator_CheckDoppelGanger(t *testing.T) {
}
v := &validator{
validatorClient: client,
km: km,
km: km,
db: db,
}
client.EXPECT().CheckDoppelGanger(
Expand Down Expand Up @@ -1150,7 +1150,7 @@ func TestValidator_CheckDoppelGanger(t *testing.T) {
}
v := &validator{
validatorClient: client,
km: km,
km: km,
db: db,
}
client.EXPECT().CheckDoppelGanger(
Expand Down Expand Up @@ -1366,7 +1366,7 @@ func TestValidator_WaitForKeymanagerInitialization_web3Signer(t *testing.T) {
db: db,
useWeb: false,
wallet: w,
Web3SignerConfig: &remoteweb3signer.SetupConfig{
web3SignerConfig: &remoteweb3signer.SetupConfig{
BaseEndpoint: "http://localhost:8545",
ProvidedPublicKeys: keys,
},
Expand All @@ -1391,9 +1391,9 @@ func TestValidator_WaitForKeymanagerInitialization_Web(t *testing.T) {
require.NoError(t, err)
walletChan := make(chan *wallet.Wallet, 1)
v := validator{
db: db,
useWeb: true,
walletInitializedFeed: &event.Feed{},
db: db,
useWeb: true,
walletInitializedFeed: &event.Feed{},
walletInitializedChan: walletChan,
}
wait := make(chan struct{})
Expand Down Expand Up @@ -1992,7 +1992,7 @@ func TestValidator_PushSettings(t *testing.T) {
pubkeys, err := km.FetchValidatingPublicKeys(ctx)
require.NoError(t, err)
if tt.feeRecipientMap != nil {
feeRecipients, err := v.buildPrepProposerReqs(ctx, pubkeys)
feeRecipients, err := v.buildPrepProposerReqs(pubkeys)
require.NoError(t, err)
signedRegisterValidatorRequests := v.buildSignedRegReqs(ctx, pubkeys, km.Sign)
for _, recipient := range feeRecipients {
Expand Down
18 changes: 9 additions & 9 deletions validator/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ import (
// ValidatorClient defines an instance of an Ethereum validator that manages
// the entire lifecycle of services attached to it participating in proof of stake.
type ValidatorClient struct {
cliCtx *cli.Context
ctx context.Context
cancel context.CancelFunc
db iface.ValidatorDB
services *runtime.ServiceRegistry // Lifecycle and service store.
lock sync.RWMutex
wallet *wallet.Wallet
cliCtx *cli.Context
ctx context.Context
cancel context.CancelFunc
db iface.ValidatorDB
services *runtime.ServiceRegistry // Lifecycle and service store.
lock sync.RWMutex
wallet *wallet.Wallet
walletInitializedFeed *event.Feed
stop chan struct{} // Channel to wait for termination notifications.
stop chan struct{} // Channel to wait for termination notifications.
}

// NewValidatorClient creates a new instance of the Prysm validator client.
Expand Down Expand Up @@ -534,7 +534,7 @@ func (c *ValidatorClient) registerValidatorService(cliCtx *cli.Context) error {
GraffitiStruct: graffitiStruct,
InteropKmConfig: interopKmConfig,
Web3SignerConfig: web3signerConfig,
ProposerSettings: proposerSettings,
ProposerSettings: ps,
ValidatorsRegBatchSize: c.cliCtx.Int(flags.ValidatorsRegistrationBatchSizeFlag.Name),
UseWeb: c.cliCtx.Bool(flags.EnableWebFlag.Name),
LogValidatorPerformance: !c.cliCtx.Bool(flags.DisablePenaltyRewardLogFlag.Name),
Expand Down
4 changes: 2 additions & 2 deletions validator/rpc/beacon.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ func (s *Server) registerBeaconClient() error {

restHandler := beaconApi.NewBeaconApiJsonRestHandler(http.Client{Timeout: s.beaconApiTimeout}, s.beaconApiEndpoint)

s.ChainClient = beaconChainClientFactory.NewChainClient(conn, restHandler)
s.NodeClient = nodeClientFactory.NewNodeClient(conn, restHandler)
s.chainClient = beaconChainClientFactory.NewChainClient(conn, restHandler)
s.nodeClient = nodeClientFactory.NewNodeClient(conn, restHandler)
s.beaconNodeValidatorClient = validatorClientFactory.NewValidatorClient(conn, restHandler)

return nil
Expand Down
4 changes: 2 additions & 2 deletions validator/rpc/handlers_beacon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,15 +228,15 @@ func TestServer_GetValidators(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ctrl := gomock.NewController(t)
beaconChainClient := validatormock.NewMockBeaconChainClient(ctrl)
beaconChainClient := validatormock.NewMockChainClient(ctrl)
if tt.wantErr == "" {
beaconChainClient.EXPECT().ListValidators(
gomock.Any(), // ctx
tt.expectedReq,
).Return(tt.chainResp, nil)
}
s := &Server{
beaconChainClient: beaconChainClient,
chainClient: beaconChainClient,
}
req := httptest.NewRequest(http.MethodGet, fmt.Sprintf("/v2/validator/beacon/validators?%s", tt.query), http.NoBody)
wr := httptest.NewRecorder()
Expand Down
16 changes: 8 additions & 8 deletions validator/rpc/handlers_keymanager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1091,14 +1091,14 @@ func TestServer_SetGasLimit(t *testing.T) {
validatorDB := dbtest.SetupDB(t, [][fieldparams.BLSPubkeyLength]byte{}, isSlashingProtectionMinimal)
vs, err := client.NewValidatorService(ctx, &client.Config{
Validator: m,
ValDB: validatorDB,
DB: validatorDB,
})
require.NoError(t, err)

s := &Server{
validatorService: vs,
beaconNodeValidatorClient: beaconClient,
db: validatorDB,
db: validatorDB,
}

if tt.beaconReturn != nil {
Expand Down Expand Up @@ -1280,12 +1280,12 @@ func TestServer_DeleteGasLimit(t *testing.T) {
validatorDB := dbtest.SetupDB(t, [][fieldparams.BLSPubkeyLength]byte{}, isSlashingProtectionMinimal)
vs, err := client.NewValidatorService(ctx, &client.Config{
Validator: m,
DB: validatorDB,
DB: validatorDB,
})
require.NoError(t, err)
s := &Server{
validatorService: vs,
db: validatorDB,
db: validatorDB,
}
// Set up global default value for builder gas limit.
params.BeaconConfig().DefaultBuilderGasLimit = uint64(globalDefaultGasLimit)
Expand Down Expand Up @@ -1744,13 +1744,13 @@ func TestServer_FeeRecipientByPubkey(t *testing.T) {
// save a default here
vs, err := client.NewValidatorService(ctx, &client.Config{
Validator: m,
DB: validatorDB,
DB: validatorDB,
})
require.NoError(t, err)
s := &Server{
validatorService: vs,
beaconNodeValidatorClient: beaconClient,
db: validatorDB,
db: validatorDB,
}
request := &SetFeeRecipientByPubkeyRequest{
Ethaddress: tt.args,
Expand Down Expand Up @@ -1854,12 +1854,12 @@ func TestServer_DeleteFeeRecipientByPubkey(t *testing.T) {
validatorDB := dbtest.SetupDB(t, [][fieldparams.BLSPubkeyLength]byte{}, isSlashingProtectionMinimal)
vs, err := client.NewValidatorService(ctx, &client.Config{
Validator: m,
DB: validatorDB,
DB: validatorDB,
})
require.NoError(t, err)
s := &Server{
validatorService: vs,
db: validatorDB,
db: validatorDB,
}
req := httptest.NewRequest(http.MethodDelete, fmt.Sprintf("/eth/v1/validator/{pubkey}/feerecipient"), nil)
req = mux.SetURLVars(req, map[string]string{"pubkey": pubkey})
Expand Down
7 changes: 4 additions & 3 deletions validator/rpc/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"github.com/prysmaticlabs/prysm/v5/validator/client"
iface "github.com/prysmaticlabs/prysm/v5/validator/client/iface"
"github.com/prysmaticlabs/prysm/v5/validator/db"
"github.com/sirupsen/logrus"
"go.opencensus.io/plugin/ocgrpc"
"google.golang.org/grpc"
"google.golang.org/grpc/reflection"
Expand Down Expand Up @@ -65,7 +64,6 @@ type Server struct {
grpcRetryDelay time.Duration
grpcHeaders []string
grpcServer *grpc.Server
jwtSecret []byte
beaconNodeValidatorClient iface.ValidatorClient
chainClient iface.ChainClient
nodeClient iface.NodeClient
Expand All @@ -74,6 +72,9 @@ type Server struct {
beaconApiEndpoint string
beaconApiTimeout time.Duration
beaconNodeCert string
jwtSecret []byte
authTokenPath string
authToken string
db db.Database
walletDir string
wallet *wallet.Wallet
Expand Down Expand Up @@ -109,7 +110,7 @@ func NewServer(ctx context.Context, cfg *Config) *Server {
if err := server.initializeAuthToken(); err != nil {
log.WithError(err).Error("Could not initialize web auth token")
}
validatorWebAddr := fmt.Sprintf("%s:%d", server.validatorGatewayHost, server.validatorGatewayPort)
validatorWebAddr := fmt.Sprintf("%s:%d", server.grpcGatewayHost, server.grpcGatewayPort)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should look at changing this naming again in the future. we want to get rid of gateway asap

logValidatorWebAuth(validatorWebAddr, server.authToken, server.authTokenPath)
go server.refreshAuthTokenFromFileChanges(server.ctx, server.authTokenPath)
}
Expand Down
Loading