mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-10 07:58:22 -05:00
Added flag to disable rewards/penatlty logging (#2319)
* Added flag to disable rewards/penatlty logging * Added flag disable log info validator function * Added flag to disable rewards/penatlty logging * Changed value to not have it log when it is on and have it logged when it's off * Added flag to disable rewards/penatlty logging * Built for cli & types * fixing flag issue * Added ctxCli to the validator struct * Accepted change * Fixing conditionals and merge conflicts * Added bracket * fixed the return statement to its proper place * Added validator conditional for logging penalties & rewards * Added conditional for logging penality/reward info * Making conditional command line log refactorable * also part of the last commit * Changed value variable to lowercase * Fixed if conditional for penalty reward validation * Synced with master * Fixed bazel build * Syncing with master * Sync with master * Added true values to logValidator Balances * Changed values from true to false * FIX WIP * Added variables to the validators * Added negation for logValidatorBalances variable The name of the flag is DisablePenaltyRewardLogFlag. Since the name of the var is logValidatorBalances. We are assuming that the variable will have a positive. It makes more sense to negate the disable flag as a value rather than keep it positive. Co-Authored-By: frederickalcantara <frederickaalcantara@gmail.com> * fixed password * Remove prevBalance line
This commit is contained in:
committed by
Nishant Das
parent
81c8b130c6
commit
6ddb5fa81a
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -71,6 +71,7 @@ var appHelpFlagGroups = []flagGroup{
|
||||
types.BeaconRPCProviderFlag,
|
||||
types.KeystorePathFlag,
|
||||
types.PasswordFlag,
|
||||
types.DisablePenaltyRewardLogFlag,
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user