diff --git a/validator/client/service.go b/validator/client/service.go index 5d467763c6..685b275312 100644 --- a/validator/client/service.go +++ b/validator/client/service.go @@ -19,22 +19,24 @@ var log = logrus.WithField("prefix", "validator") // ValidatorService represents a service to manage the validator client // routine. type ValidatorService struct { - ctx context.Context - cancel context.CancelFunc - validator Validator - conn *grpc.ClientConn - endpoint string - withCert string - key *keystore.Key - keys map[string]*keystore.Key + ctx context.Context + cancel context.CancelFunc + validator Validator + conn *grpc.ClientConn + endpoint string + withCert string + key *keystore.Key + keys map[string]*keystore.Key + logValidatorBalances bool } // Config for the validator service. type Config struct { - Endpoint string - CertFlag string - KeystorePath string - Password string + Endpoint string + CertFlag string + KeystorePath string + Password string + LogValidatorBalances bool } // NewValidatorService creates a new validator service for the service @@ -55,12 +57,13 @@ func NewValidatorService(ctx context.Context, cfg *Config) (*ValidatorService, e break } return &ValidatorService{ - ctx: ctx, - cancel: cancel, - endpoint: cfg.Endpoint, - withCert: cfg.CertFlag, - keys: keys, - key: key, + ctx: ctx, + cancel: cancel, + endpoint: cfg.Endpoint, + withCert: cfg.CertFlag, + keys: keys, + key: key, + logValidatorBalances: cfg.LogValidatorBalances, }, nil } @@ -93,12 +96,13 @@ func (v *ValidatorService) Start() { log.Info("Successfully started gRPC connection") v.conn = conn v.validator = &validator{ - beaconClient: pb.NewBeaconServiceClient(v.conn), - validatorClient: pb.NewValidatorServiceClient(v.conn), - attesterClient: pb.NewAttesterServiceClient(v.conn), - proposerClient: pb.NewProposerServiceClient(v.conn), - keys: v.keys, - pubkeys: pubkeys, + beaconClient: pb.NewBeaconServiceClient(v.conn), + validatorClient: pb.NewValidatorServiceClient(v.conn), + attesterClient: pb.NewAttesterServiceClient(v.conn), + proposerClient: pb.NewProposerServiceClient(v.conn), + keys: v.keys, + pubkeys: pubkeys, + logValidatorBalances: v.logValidatorBalances, } go run(v.ctx, v.validator) } diff --git a/validator/client/validator.go b/validator/client/validator.go index 54de53308a..b936baa8ae 100644 --- a/validator/client/validator.go +++ b/validator/client/validator.go @@ -18,16 +18,17 @@ import ( ) type validator struct { - genesisTime uint64 - ticker *slotutil.SlotTicker - assignments *pb.CommitteeAssignmentResponse - proposerClient pb.ProposerServiceClient - validatorClient pb.ValidatorServiceClient - beaconClient pb.BeaconServiceClient - attesterClient pb.AttesterServiceClient - keys map[string]*keystore.Key - pubkeys [][]byte - prevBalance uint64 + genesisTime uint64 + ticker *slotutil.SlotTicker + assignments *pb.CommitteeAssignmentResponse + proposerClient pb.ProposerServiceClient + validatorClient pb.ValidatorServiceClient + beaconClient pb.BeaconServiceClient + attesterClient pb.AttesterServiceClient + keys map[string]*keystore.Key + pubkeys [][]byte + prevBalance uint64 + logValidatorBalances bool } // Done cleans up the validator. diff --git a/validator/client/validator_metrics.go b/validator/client/validator_metrics.go index 9eee658c2b..356854c8c1 100644 --- a/validator/client/validator_metrics.go +++ b/validator/client/validator_metrics.go @@ -60,13 +60,15 @@ func (v *validator) LogValidatorGainsAndLosses(ctx context.Context, slot uint64) if v.prevBalance > 0 { prevBalance := float64(v.prevBalance) / float64(params.BeaconConfig().GweiPerEth) percentNet := (newBalance - prevBalance) / prevBalance - log.WithFields(logrus.Fields{ - "prevBalance": prevBalance, - "newBalance": newBalance, - "delta": fmt.Sprintf("%f", newBalance-prevBalance), - "percentChange": fmt.Sprintf("%.2f%%", percentNet*100), - "pubKey": tpk, - }).Info("Net gains/losses in eth") + if v.logValidatorBalances { + log.WithFields(logrus.Fields{ + "prevBalance": prevBalance, + "newBalance": newBalance, + "delta": fmt.Sprintf("%f", newBalance-prevBalance), + "percentChange": fmt.Sprintf("%.2f%%", percentNet*100), + "pubKey": tpk, + }).Info("Net gains/losses in eth") + } } totalPrevBalance += resp.Balance } diff --git a/validator/main.go b/validator/main.go index cacc0d4ca7..fb3a8389c7 100644 --- a/validator/main.go +++ b/validator/main.go @@ -138,6 +138,7 @@ contract in order to activate the validator client`, types.BeaconRPCProviderFlag, types.KeystorePathFlag, types.PasswordFlag, + types.DisablePenaltyRewardLogFlag, cmd.VerbosityFlag, cmd.DataDirFlag, cmd.EnableTracingFlag, diff --git a/validator/node/node.go b/validator/node/node.go index 249df05b53..233416dc06 100644 --- a/validator/node/node.go +++ b/validator/node/node.go @@ -129,10 +129,12 @@ func (s *ValidatorClient) registerPrometheusService(ctx *cli.Context) error { func (s *ValidatorClient) registerClientService(ctx *cli.Context, password string) error { endpoint := ctx.GlobalString(types.BeaconRPCProviderFlag.Name) keystoreDirectory := ctx.GlobalString(types.KeystorePathFlag.Name) + logValidatorBalances := !ctx.GlobalBool(types.DisablePenaltyRewardLogFlag.Name) v, err := client.NewValidatorService(context.Background(), &client.Config{ - Endpoint: endpoint, - KeystorePath: keystoreDirectory, - Password: password, + Endpoint: endpoint, + KeystorePath: keystoreDirectory, + Password: password, + LogValidatorBalances: logValidatorBalances, }) if err != nil { return fmt.Errorf("could not initialize client service: %v", err) diff --git a/validator/types/flags.go b/validator/types/flags.go index 6763041227..84c868b7ba 100644 --- a/validator/types/flags.go +++ b/validator/types/flags.go @@ -38,6 +38,11 @@ var ( Name: "password", Usage: "string value of the password for your validator private keys", } + // DisablePenaltyRewardLogFlag defines the ability to not log reward/penalty information during deployment + DisablePenaltyRewardLogFlag = cli.BoolFlag{ + Name: "disable-rewards-penalties-logging", + Usage: "Disable reward/penalty logging during cluster deployment", + } ) func homeDir() string { diff --git a/validator/usage.go b/validator/usage.go index b6adda79fe..7e86a1d8fa 100644 --- a/validator/usage.go +++ b/validator/usage.go @@ -71,6 +71,7 @@ var appHelpFlagGroups = []flagGroup{ types.BeaconRPCProviderFlag, types.KeystorePathFlag, types.PasswordFlag, + types.DisablePenaltyRewardLogFlag, }, }, {