Validator client - Improve readability - NO FUNCTIONAL CHANGE (#13468)

* Improve `NewServiceRegistry` documentation.

* Improve `README.md`.

* Improve readability of `registerValidatorService`.

* Move `log` in `main.go`.

Since `log` is only used in `main.go`.

* Clean Tos.

* `DefaultDataDir`: Use `switch` instead of `if/elif`.

* `ReadPassword`: Remove unused receiver.

* `validator/main.go`: Clean.

* `WarnIfPlatformNotSupported`: Add Mac OSX ARM64.

* `runner.go`: Use idiomatic `err` handling.

* `waitForChainStart`: Avoid `chainStartResponse`mutation.

* `WaitForChainStart`: Reduce cognitive complexity.

* Logs: `powchain` ==> `execution`.
This commit is contained in:
Manu NALEPA
2024-01-15 15:46:54 +01:00
committed by GitHub
parent b585ff77f5
commit 99a8d0bac6
15 changed files with 150 additions and 109 deletions

View File

@@ -2,4 +2,4 @@ package execution
import "github.com/sirupsen/logrus" import "github.com/sirupsen/logrus"
var log = logrus.WithField("prefix", "powchain") var log = logrus.WithField("prefix", "execution")

View File

@@ -31,11 +31,12 @@ func DefaultDataDir() string {
// Try to place the data folder in the user's home dir // Try to place the data folder in the user's home dir
home := file.HomeDir() home := file.HomeDir()
if home != "" { if home != "" {
if runtime.GOOS == "darwin" { switch runtime.GOOS {
case "darwin":
return filepath.Join(home, "Library", "Eth2") return filepath.Join(home, "Library", "Eth2")
} else if runtime.GOOS == "windows" { case "windows":
return filepath.Join(home, "AppData", "Local", "Eth2") return filepath.Join(home, "AppData", "Local", "Eth2")
} else { default:
return filepath.Join(home, ".eth2") return filepath.Join(home, ".eth2")
} }
} }

View File

@@ -16,7 +16,7 @@ type StdInPasswordReader struct {
} }
// ReadPassword reads a password from stdin. // ReadPassword reads a password from stdin.
func (_ StdInPasswordReader) ReadPassword() (string, error) { func (StdInPasswordReader) ReadPassword() (string, error) {
pwd, err := terminal.ReadPassword(int(os.Stdin.Fd())) pwd, err := terminal.ReadPassword(int(os.Stdin.Fd()))
return string(pwd), err return string(pwd), err
} }

View File

@@ -5,7 +5,6 @@ load("//tools:prysm_image.bzl", "prysm_image_upload")
go_library( go_library(
name = "go_default_library", name = "go_default_library",
srcs = [ srcs = [
"log.go",
"main.go", "main.go",
"usage.go", "usage.go",
], ],
@@ -30,6 +29,7 @@ go_library(
"//runtime/version:go_default_library", "//runtime/version:go_default_library",
"//validator/node:go_default_library", "//validator/node:go_default_library",
"@com_github_joonix_log//:go_default_library", "@com_github_joonix_log//:go_default_library",
"@com_github_pkg_errors//:go_default_library",
"@com_github_sirupsen_logrus//:go_default_library", "@com_github_sirupsen_logrus//:go_default_library",
"@com_github_urfave_cli_v2//:go_default_library", "@com_github_urfave_cli_v2//:go_default_library",
], ],

View File

@@ -1,5 +0,0 @@
package main
import "github.com/sirupsen/logrus"
var log = logrus.WithField("prefix", "main")

View File

@@ -10,6 +10,7 @@ import (
runtimeDebug "runtime/debug" runtimeDebug "runtime/debug"
joonix "github.com/joonix/log" joonix "github.com/joonix/log"
"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/v4/cmd" "github.com/prysmaticlabs/prysm/v4/cmd"
accountcommands "github.com/prysmaticlabs/prysm/v4/cmd/validator/accounts" accountcommands "github.com/prysmaticlabs/prysm/v4/cmd/validator/accounts"
dbcommands "github.com/prysmaticlabs/prysm/v4/cmd/validator/db" dbcommands "github.com/prysmaticlabs/prysm/v4/cmd/validator/db"
@@ -31,8 +32,10 @@ import (
"github.com/urfave/cli/v2" "github.com/urfave/cli/v2"
) )
var log = logrus.WithField("prefix", "main")
func startNode(ctx *cli.Context) error { func startNode(ctx *cli.Context) error {
// verify if ToS accepted // Verify if ToS is accepted.
if err := tos.VerifyTosAcceptedOrPrompt(ctx); err != nil { if err := tos.VerifyTosAcceptedOrPrompt(ctx); err != nil {
return err return err
} }
@@ -141,6 +144,8 @@ func main() {
return err return err
} }
logFileName := ctx.String(cmd.LogFileName.Name)
format := ctx.String(cmd.LogFormat.Name) format := ctx.String(cmd.LogFormat.Name)
switch format { switch format {
case "text": case "text":
@@ -148,8 +153,8 @@ func main() {
formatter.TimestampFormat = "2006-01-02 15:04:05" formatter.TimestampFormat = "2006-01-02 15:04:05"
formatter.FullTimestamp = true formatter.FullTimestamp = true
// If persistent log files are written - we disable the log messages coloring because // If persistent log files are written - we disable the log messages coloring because
// the colors are ANSI codes and seen as Gibberish in the log files. // the colors are ANSI codes and seen as gibberish in the log files.
formatter.DisableColors = ctx.String(cmd.LogFileName.Name) != "" formatter.DisableColors = logFileName != ""
logrus.SetFormatter(formatter) logrus.SetFormatter(formatter)
case "fluentd": case "fluentd":
f := joonix.NewFormatter() f := joonix.NewFormatter()
@@ -167,7 +172,6 @@ func main() {
return fmt.Errorf("unknown log format %s", format) return fmt.Errorf("unknown log format %s", format)
} }
logFileName := ctx.String(cmd.LogFileName.Name)
if logFileName != "" { if logFileName != "" {
if err := logs.ConfigurePersistentLogging(logFileName); err != nil { if err := logs.ConfigurePersistentLogging(logFileName); err != nil {
log.WithError(err).Error("Failed to configuring logging to disk.") log.WithError(err).Error("Failed to configuring logging to disk.")
@@ -182,8 +186,9 @@ func main() {
} }
if err := debug.Setup(ctx); err != nil { if err := debug.Setup(ctx); err != nil {
return err return errors.Wrap(err, "failed to setup debug")
} }
return cmd.ValidateNoArgs(ctx) return cmd.ValidateNoArgs(ctx)
}, },
After: func(ctx *cli.Context) error { After: func(ctx *cli.Context) error {

View File

@@ -29,7 +29,7 @@ Examples of when not to use a feature flag:
Once it has been decided that you should use a feature flag. Follow these steps to safely Once it has been decided that you should use a feature flag. Follow these steps to safely
releasing your feature. In general, try to create a single PR for each step of this process. releasing your feature. In general, try to create a single PR for each step of this process.
1. Add your feature flag to shared/featureconfig/flags.go, use the flag to toggle a boolean in the 1. Add your feature flag to `shared/featureconfig/flags.go`, use the flag to toggle a boolean in the
feature config in shared/featureconfig/config.go. It is a good idea to use the `enable` prefix for feature config in shared/featureconfig/config.go. It is a good idea to use the `enable` prefix for
your flag since you're going to invert the flag in a later step. i.e you will use `disable` prefix your flag since you're going to invert the flag in a later step. i.e you will use `disable` prefix
later. For example, `--enable-my-feature`. Additionally, [create a feature flag tracking issue](https://github.com/prysmaticlabs/prysm/issues/new?template=feature_flag.md) later. For example, `--enable-my-feature`. Additionally, [create a feature flag tracking issue](https://github.com/prysmaticlabs/prysm/issues/new?template=feature_flag.md)
@@ -48,7 +48,7 @@ func someExistingMethod(ctx context.Context) error {
3. Add the flag to the end to end tests. This set of flags can also be found in shared/featureconfig/flags.go. 3. Add the flag to the end to end tests. This set of flags can also be found in shared/featureconfig/flags.go.
4. Test the functionality locally and safely in production. Once you have enough confidence that 4. Test the functionality locally and safely in production. Once you have enough confidence that
your new function works and is safe to release then move onto the next step. your new function works and is safe to release then move onto the next step.
5. Move your existing flag to the deprecated section of shared/featureconfig/flags.go. It is 5. Move your existing flag to the deprecated section of `shared/featureconfig/flags.go`. It is
important NOT to delete your existing flag outright. Deleting a flag can be extremely frustrating important NOT to delete your existing flag outright. Deleting a flag can be extremely frustrating
to users as it may break their existing workflow! Marking a flag as deprecated gives users time to to users as it may break their existing workflow! Marking a flag as deprecated gives users time to
adjust their start scripts and workflow. Add another feature flag to represent the inverse of your adjust their start scripts and workflow. Add another feature flag to represent the inverse of your

View File

@@ -103,7 +103,12 @@ func WarnIfPlatformNotSupported(ctx context.Context) {
return return
} }
if !supported { if !supported {
log.Warn("This platform is not supported. The following platforms are supported: Linux/AMD64," + log.Warn(`This platform is not supported. The following platforms are supported:
" Linux/ARM64, Mac OS X/AMD64 (10.14+ only), and Windows/AMD64") - Linux/AMD64
- Linux/ARM64
- Mac OS X/AMD64 (from 10.14+)
- Mac OS X/ARM64 (from 12.5+)
- Windows/AMD64`,
)
} }
} }

View File

@@ -31,7 +31,7 @@ type ServiceRegistry struct {
serviceTypes []reflect.Type // keep an ordered slice of registered service types. serviceTypes []reflect.Type // keep an ordered slice of registered service types.
} }
// NewServiceRegistry starts a registry instance for convenience // NewServiceRegistry starts a registry instance for convenience.
func NewServiceRegistry() *ServiceRegistry { func NewServiceRegistry() *ServiceRegistry {
return &ServiceRegistry{ return &ServiceRegistry{
services: make(map[reflect.Type]Service), services: make(map[reflect.Type]Service),

View File

@@ -35,11 +35,13 @@ var (
log = logrus.WithField("prefix", "tos") log = logrus.WithField("prefix", "tos")
) )
// VerifyTosAcceptedOrPrompt check if Tos was accepted before or asks to accept. // VerifyTosAcceptedOrPrompt checks if Tos was accepted before or asks to accept.
func VerifyTosAcceptedOrPrompt(ctx *cli.Context) error { func VerifyTosAcceptedOrPrompt(ctx *cli.Context) error {
if file.Exists(filepath.Join(ctx.String(cmd.DataDirFlag.Name), acceptTosFilename)) { tosFilePath := filepath.Join(ctx.String(cmd.DataDirFlag.Name), acceptTosFilename)
if file.Exists(tosFilePath) {
return nil return nil
} }
if ctx.Bool(cmd.AcceptTosFlag.Name) { if ctx.Bool(cmd.AcceptTosFlag.Name) {
saveTosAccepted(ctx) saveTosAccepted(ctx)
return nil return nil
@@ -49,6 +51,7 @@ func VerifyTosAcceptedOrPrompt(ctx *cli.Context) error {
if err != nil { if err != nil {
return errors.New(acceptTosPromptErrText) return errors.New(acceptTosPromptErrText)
} }
if !strings.EqualFold(input, "accept") { if !strings.EqualFold(input, "accept") {
return errors.New("you have to accept Terms and Conditions in order to continue") return errors.New("you have to accept Terms and Conditions in order to continue")
} }

View File

@@ -32,6 +32,7 @@ go_library(
"//beacon-chain/core/altair:go_default_library", "//beacon-chain/core/altair:go_default_library",
"//beacon-chain/core/signing:go_default_library", "//beacon-chain/core/signing:go_default_library",
"//cache/lru:go_default_library", "//cache/lru:go_default_library",
"//cmd:go_default_library",
"//config/features:go_default_library", "//config/features:go_default_library",
"//config/fieldparams:go_default_library", "//config/fieldparams:go_default_library",
"//config/params:go_default_library", "//config/params:go_default_library",

View File

@@ -45,10 +45,6 @@ func (c beaconApiValidatorClient) waitForChainStart(ctx context.Context) (*ethpb
return nil, errors.Wrapf(err, "failed to parse genesis time: %s", genesis.GenesisTime) return nil, errors.Wrapf(err, "failed to parse genesis time: %s", genesis.GenesisTime)
} }
chainStartResponse := &ethpb.ChainStartResponse{}
chainStartResponse.Started = true
chainStartResponse.GenesisTime = genesisTime
if !validRoot(genesis.GenesisValidatorsRoot) { if !validRoot(genesis.GenesisValidatorsRoot) {
return nil, errors.Errorf("invalid genesis validators root: %s", genesis.GenesisValidatorsRoot) return nil, errors.Errorf("invalid genesis validators root: %s", genesis.GenesisValidatorsRoot)
} }
@@ -57,7 +53,12 @@ func (c beaconApiValidatorClient) waitForChainStart(ctx context.Context) (*ethpb
if err != nil { if err != nil {
return nil, errors.Wrap(err, "failed to decode genesis validators root") return nil, errors.Wrap(err, "failed to decode genesis validators root")
} }
chainStartResponse.GenesisValidatorsRoot = genesisValidatorRoot
chainStartResponse := &ethpb.ChainStartResponse{
Started: true,
GenesisTime: genesisTime,
GenesisValidatorsRoot: genesisValidatorRoot,
}
return chainStartResponse, nil return chainStartResponse, nil
} }

View File

@@ -18,7 +18,7 @@ import (
"google.golang.org/grpc/status" "google.golang.org/grpc/status"
) )
// time to wait before trying to reconnect with beacon node. // Time to wait before trying to reconnect with beacon node.
var backOffPeriod = 10 * time.Second var backOffPeriod = 10 * time.Second
// Run the main validator routine. This routine exits if the context is // Run the main validator routine. This routine exits if the context is
@@ -149,8 +149,13 @@ func initializeValidatorAndGetHeadSlot(ctx context.Context, v iface.Validator) (
ticker := time.NewTicker(backOffPeriod) ticker := time.NewTicker(backOffPeriod)
defer ticker.Stop() defer ticker.Stop()
var headSlot primitives.Slot
firstTime := true firstTime := true
var (
headSlot primitives.Slot
err error
)
for { for {
if !firstTime { if !firstTime {
if ctx.Err() != nil { if ctx.Err() != nil {
@@ -158,35 +163,35 @@ func initializeValidatorAndGetHeadSlot(ctx context.Context, v iface.Validator) (
return headSlot, errors.New("context canceled") return headSlot, errors.New("context canceled")
} }
<-ticker.C <-ticker.C
} else {
firstTime = false
} }
err := v.WaitForChainStart(ctx)
firstTime = false
if err := v.WaitForChainStart(ctx); err != nil {
if isConnectionError(err) { if isConnectionError(err) {
log.WithError(err).Warn("Could not determine if beacon chain started") log.WithError(err).Warn("Could not determine if beacon chain started")
continue continue
} }
if err != nil {
log.WithError(err).Fatal("Could not determine if beacon chain started") log.WithError(err).Fatal("Could not determine if beacon chain started")
} }
err = v.WaitForKeymanagerInitialization(ctx) if err := v.WaitForKeymanagerInitialization(ctx); err != nil {
if err != nil {
// log.Fatal will prevent defer from being called // log.Fatal will prevent defer from being called
v.Done() v.Done()
log.WithError(err).Fatal("Wallet is not ready") log.WithError(err).Fatal("Wallet is not ready")
} }
err = v.WaitForSync(ctx) if err := v.WaitForSync(ctx); err != nil {
if isConnectionError(err) { if isConnectionError(err) {
log.WithError(err).Warn("Could not determine if beacon chain started") log.WithError(err).Warn("Could not determine if beacon chain started")
continue continue
} }
if err != nil {
log.WithError(err).Fatal("Could not determine if beacon node synced") log.WithError(err).Fatal("Could not determine if beacon node synced")
} }
err = v.WaitForActivation(ctx, nil /* accountsChangedChan */)
if err != nil { if err := v.WaitForActivation(ctx, nil /* accountsChangedChan */); err != nil {
log.WithError(err).Fatal("Could not wait for validator activation") log.WithError(err).Fatal("Could not wait for validator activation")
} }
@@ -195,15 +200,17 @@ func initializeValidatorAndGetHeadSlot(ctx context.Context, v iface.Validator) (
log.WithError(err).Warn("Could not get current canonical head slot") log.WithError(err).Warn("Could not get current canonical head slot")
continue continue
} }
if err != nil { if err != nil {
log.WithError(err).Fatal("Could not get current canonical head slot") log.WithError(err).Fatal("Could not get current canonical head slot")
} }
err = v.CheckDoppelGanger(ctx)
if err := v.CheckDoppelGanger(ctx); err != nil {
if isConnectionError(err) { if isConnectionError(err) {
log.WithError(err).Warn("Could not wait for checking doppelganger") log.WithError(err).Warn("Could not wait for checking doppelganger")
continue continue
} }
if err != nil {
log.WithError(err).Fatal("Could not succeed with doppelganger check") log.WithError(err).Fatal("Could not succeed with doppelganger check")
} }
break break

View File

@@ -22,6 +22,7 @@ import (
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/v4/async/event" "github.com/prysmaticlabs/prysm/v4/async/event"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/core/altair" "github.com/prysmaticlabs/prysm/v4/beacon-chain/core/altair"
"github.com/prysmaticlabs/prysm/v4/cmd"
"github.com/prysmaticlabs/prysm/v4/config/features" "github.com/prysmaticlabs/prysm/v4/config/features"
fieldparams "github.com/prysmaticlabs/prysm/v4/config/fieldparams" fieldparams "github.com/prysmaticlabs/prysm/v4/config/fieldparams"
"github.com/prysmaticlabs/prysm/v4/config/params" "github.com/prysmaticlabs/prysm/v4/config/params"
@@ -238,50 +239,65 @@ func recheckValidatingKeysBucket(ctx context.Context, valDB vdb.Database, km key
func (v *validator) WaitForChainStart(ctx context.Context) error { func (v *validator) WaitForChainStart(ctx context.Context) error {
ctx, span := trace.StartSpan(ctx, "validator.WaitForChainStart") ctx, span := trace.StartSpan(ctx, "validator.WaitForChainStart")
defer span.End() defer span.End()
// First, check if the beacon chain has started. // First, check if the beacon chain has started.
log.Info("Syncing with beacon node to align on chain genesis info") log.Info("Syncing with beacon node to align on chain genesis info")
chainStartRes, err := v.validatorClient.WaitForChainStart(ctx, &emptypb.Empty{}) chainStartRes, err := v.validatorClient.WaitForChainStart(ctx, &emptypb.Empty{})
if err != io.EOF { if err == io.EOF {
return iface.ErrConnectionIssue
}
if ctx.Err() == context.Canceled { if ctx.Err() == context.Canceled {
return errors.Wrap(ctx.Err(), "context has been canceled so shutting down the loop") return errors.Wrap(ctx.Err(), "context has been canceled so shutting down the loop")
} }
if err != nil { if err != nil {
return errors.Wrap( return errors.Wrap(
iface.ErrConnectionIssue, iface.ErrConnectionIssue,
errors.Wrap(err, "could not receive ChainStart from stream").Error(), errors.Wrap(err, "could not receive ChainStart from stream").Error(),
) )
} }
v.genesisTime = chainStartRes.GenesisTime v.genesisTime = chainStartRes.GenesisTime
curGenValRoot, err := v.db.GenesisValidatorsRoot(ctx) curGenValRoot, err := v.db.GenesisValidatorsRoot(ctx)
if err != nil { if err != nil {
return errors.Wrap(err, "could not get current genesis validators root") return errors.Wrap(err, "could not get current genesis validators root")
} }
if len(curGenValRoot) == 0 { if len(curGenValRoot) == 0 {
if err := v.db.SaveGenesisValidatorsRoot(ctx, chainStartRes.GenesisValidatorsRoot); err != nil { if err := v.db.SaveGenesisValidatorsRoot(ctx, chainStartRes.GenesisValidatorsRoot); err != nil {
return errors.Wrap(err, "could not save genesis validators root") return errors.Wrap(err, "could not save genesis validators root")
} }
} else {
v.setTicker()
return nil
}
if !bytes.Equal(curGenValRoot, chainStartRes.GenesisValidatorsRoot) { if !bytes.Equal(curGenValRoot, chainStartRes.GenesisValidatorsRoot) {
log.Errorf("The genesis validators root received from the beacon node does not match what is in " + log.Errorf(`The genesis validators root received from the beacon node does not match what is in
"your validator database. This could indicate that this is a database meant for another network. If " + your validator database. This could indicate that this is a database meant for another network. If
"you were previously running this validator database on another network, please run --clear-db to " + you were previously running this validator database on another network, please run --%s to
"clear the database. If not, please file an issue at https://github.com/prysmaticlabs/prysm/issues") clear the database. If not, please file an issue at https://github.com/prysmaticlabs/prysm/issues`,
cmd.ClearDB.Name,
)
return fmt.Errorf( return fmt.Errorf(
"genesis validators root from beacon node (%#x) does not match root saved in validator db (%#x)", "genesis validators root from beacon node (%#x) does not match root saved in validator db (%#x)",
chainStartRes.GenesisValidatorsRoot, chainStartRes.GenesisValidatorsRoot,
curGenValRoot, curGenValRoot,
) )
} }
}
} else {
return iface.ErrConnectionIssue
}
v.setTicker()
return nil
}
func (v *validator) setTicker() {
// Once the ChainStart log is received, we update the genesis time of the validator client // Once the ChainStart log is received, we update the genesis time of the validator client
// and begin a slot ticker used to track the current slot the beacon node is in. // and begin a slot ticker used to track the current slot the beacon node is in.
v.ticker = slots.NewSlotTicker(time.Unix(int64(v.genesisTime), 0), params.BeaconConfig().SecondsPerSlot) v.ticker = slots.NewSlotTicker(time.Unix(int64(v.genesisTime), 0), params.BeaconConfig().SecondsPerSlot)
log.WithField("genesisTime", time.Unix(int64(v.genesisTime), 0)).Info("Beacon chain started") log.WithField("genesisTime", time.Unix(int64(v.genesisTime), 0)).Info("Beacon chain started")
return nil
} }
// WaitForSync checks whether the beacon node has sync to the latest head. // WaitForSync checks whether the beacon node has sync to the latest head.

View File

@@ -423,16 +423,22 @@ func (c *ValidatorClient) registerPrometheusService(cliCtx *cli.Context) error {
} }
func (c *ValidatorClient) registerValidatorService(cliCtx *cli.Context) error { func (c *ValidatorClient) registerValidatorService(cliCtx *cli.Context) error {
endpoint := c.cliCtx.String(flags.BeaconRPCProviderFlag.Name) var (
dataDir := c.cliCtx.String(cmd.DataDirFlag.Name) endpoint string = c.cliCtx.String(flags.BeaconRPCProviderFlag.Name)
logValidatorBalances := !c.cliCtx.Bool(flags.DisablePenaltyRewardLogFlag.Name) dataDir string = c.cliCtx.String(cmd.DataDirFlag.Name)
emitAccountMetrics := !c.cliCtx.Bool(flags.DisableAccountMetricsFlag.Name) logValidatorBalances bool = !c.cliCtx.Bool(flags.DisablePenaltyRewardLogFlag.Name)
cert := c.cliCtx.String(flags.CertFlag.Name) emitAccountMetrics bool = !c.cliCtx.Bool(flags.DisableAccountMetricsFlag.Name)
graffiti := c.cliCtx.String(flags.GraffitiFlag.Name) cert string = c.cliCtx.String(flags.CertFlag.Name)
maxCallRecvMsgSize := c.cliCtx.Int(cmd.GrpcMaxCallRecvMsgSizeFlag.Name) graffiti string = c.cliCtx.String(flags.GraffitiFlag.Name)
grpcRetries := c.cliCtx.Uint(flags.GrpcRetriesFlag.Name) maxCallRecvMsgSize int = c.cliCtx.Int(cmd.GrpcMaxCallRecvMsgSizeFlag.Name)
grpcRetryDelay := c.cliCtx.Duration(flags.GrpcRetryDelayFlag.Name) grpcRetries uint = c.cliCtx.Uint(flags.GrpcRetriesFlag.Name)
var interopKeysConfig *local.InteropKeymanagerConfig grpcRetryDelay time.Duration = c.cliCtx.Duration(flags.GrpcRetryDelayFlag.Name)
interopKeysConfig *local.InteropKeymanagerConfig
err error
)
// Configure interop.
if c.cliCtx.IsSet(flags.InteropNumValidators.Name) { if c.cliCtx.IsSet(flags.InteropNumValidators.Name) {
interopKeysConfig = &local.InteropKeymanagerConfig{ interopKeysConfig = &local.InteropKeymanagerConfig{
Offset: cliCtx.Uint64(flags.InteropStartIndex.Name), Offset: cliCtx.Uint64(flags.InteropStartIndex.Name),
@@ -440,27 +446,28 @@ func (c *ValidatorClient) registerValidatorService(cliCtx *cli.Context) error {
} }
} }
gStruct := &g.Graffiti{} // Configure graffiti.
var err error graffitiStruct := &g.Graffiti{}
if c.cliCtx.IsSet(flags.GraffitiFileFlag.Name) { if c.cliCtx.IsSet(flags.GraffitiFileFlag.Name) {
n := c.cliCtx.String(flags.GraffitiFileFlag.Name) graffitiFilePath := c.cliCtx.String(flags.GraffitiFileFlag.Name)
gStruct, err = g.ParseGraffitiFile(n)
graffitiStruct, err = g.ParseGraffitiFile(graffitiFilePath)
if err != nil { if err != nil {
log.WithError(err).Warn("Could not parse graffiti file") log.WithError(err).Warn("Could not parse graffiti file")
} }
} }
wsc, err := Web3SignerConfig(c.cliCtx) web3signerConfig, err := Web3SignerConfig(c.cliCtx)
if err != nil { if err != nil {
return err return err
} }
bpc, err := proposerSettings(c.cliCtx, c.db) proposerSettings, err := proposerSettings(c.cliCtx, c.db)
if err != nil { if err != nil {
return err return err
} }
v, err := client.NewValidatorService(c.cliCtx.Context, &client.Config{ validatorService, err := client.NewValidatorService(c.cliCtx.Context, &client.Config{
Endpoint: endpoint, Endpoint: endpoint,
DataDir: dataDir, DataDir: dataDir,
LogValidatorBalances: logValidatorBalances, LogValidatorBalances: logValidatorBalances,
@@ -476,9 +483,9 @@ func (c *ValidatorClient) registerValidatorService(cliCtx *cli.Context) error {
InteropKeysConfig: interopKeysConfig, InteropKeysConfig: interopKeysConfig,
Wallet: c.wallet, Wallet: c.wallet,
WalletInitializedFeed: c.walletInitialized, WalletInitializedFeed: c.walletInitialized,
GraffitiStruct: gStruct, GraffitiStruct: graffitiStruct,
Web3SignerConfig: wsc, Web3SignerConfig: web3signerConfig,
ProposerSettings: bpc, ProposerSettings: proposerSettings,
BeaconApiTimeout: time.Second * 30, BeaconApiTimeout: time.Second * 30,
BeaconApiEndpoint: c.cliCtx.String(flags.BeaconRESTApiProviderFlag.Name), BeaconApiEndpoint: c.cliCtx.String(flags.BeaconRESTApiProviderFlag.Name),
ValidatorsRegBatchSize: c.cliCtx.Int(flags.ValidatorsRegistrationBatchSizeFlag.Name), ValidatorsRegBatchSize: c.cliCtx.Int(flags.ValidatorsRegistrationBatchSizeFlag.Name),
@@ -487,7 +494,7 @@ func (c *ValidatorClient) registerValidatorService(cliCtx *cli.Context) error {
return errors.Wrap(err, "could not initialize validator service") return errors.Wrap(err, "could not initialize validator service")
} }
return c.services.RegisterService(v) return c.services.RegisterService(validatorService)
} }
func Web3SignerConfig(cliCtx *cli.Context) (*remoteweb3signer.SetupConfig, error) { func Web3SignerConfig(cliCtx *cli.Context) (*remoteweb3signer.SetupConfig, error) {