From 93ebba6dcaf9907cce121023296449bd5aa08892 Mon Sep 17 00:00:00 2001 From: terencechain Date: Thu, 11 Aug 2022 07:33:30 -0700 Subject: [PATCH] Remove duty countdown flag (#11121) --- cmd/validator/flags/flags.go | 7 -- cmd/validator/main.go | 1 - cmd/validator/usage.go | 1 - validator/accounts/testing/mock.go | 4 -- validator/client/BUILD.bazel | 1 - validator/client/iface/validator.go | 1 - validator/client/log.go | 56 --------------- validator/client/log_test.go | 75 --------------------- validator/client/runner.go | 3 - validator/client/service.go | 4 -- validator/client/testutil/mock_validator.go | 5 -- validator/client/validator.go | 1 - validator/node/node.go | 1 - 13 files changed, 160 deletions(-) delete mode 100644 validator/client/log_test.go diff --git a/cmd/validator/flags/flags.go b/cmd/validator/flags/flags.go index d2409a647b..2ecdb0328c 100644 --- a/cmd/validator/flags/flags.go +++ b/cmd/validator/flags/flags.go @@ -316,13 +316,6 @@ var ( Name: "graffiti-file", Usage: "The path to a YAML file with graffiti values", } - // EnableDutyCountDown enables more verbose logging for counting down to duty. - EnableDutyCountDown = &cli.BoolFlag{ - Name: "enable-duty-count-down", - Usage: "Enables more verbose logging for counting down to duty", - Value: false, - } - // ProposerSettingsFlag defines the path or URL to a file with proposer config. ProposerSettingsFlag = &cli.StringFlag{ Name: "proposer-settings-file", diff --git a/cmd/validator/main.go b/cmd/validator/main.go index fe2e358a87..ff1668f85b 100644 --- a/cmd/validator/main.go +++ b/cmd/validator/main.go @@ -71,7 +71,6 @@ var appFlags = []cli.Flag{ flags.WalletDirFlag, flags.EnableWebFlag, flags.GraffitiFileFlag, - flags.EnableDutyCountDown, // Consensys' Web3Signer flags flags.Web3SignerURLFlag, flags.Web3SignerPublicValidatorKeysFlag, diff --git a/cmd/validator/usage.go b/cmd/validator/usage.go index c7b50db51a..ecd050da78 100644 --- a/cmd/validator/usage.go +++ b/cmd/validator/usage.go @@ -106,7 +106,6 @@ var appHelpFlagGroups = []flagGroup{ flags.WalletDirFlag, flags.WalletPasswordFileFlag, flags.GraffitiFileFlag, - flags.EnableDutyCountDown, flags.Web3SignerURLFlag, flags.Web3SignerPublicValidatorKeysFlag, flags.ProposerSettingsFlag, diff --git a/validator/accounts/testing/mock.go b/validator/accounts/testing/mock.go index 5ccff88f99..85219e6f21 100644 --- a/validator/accounts/testing/mock.go +++ b/validator/accounts/testing/mock.go @@ -150,10 +150,6 @@ func (_ MockValidator) LogAttestationsSubmitted() { panic("implement me") } -func (_ MockValidator) LogNextDutyTimeLeft(_ types.Slot) error { - panic("implement me") -} - func (_ MockValidator) UpdateDomainDataCaches(_ context.Context, _ types.Slot) { panic("implement me") } diff --git a/validator/client/BUILD.bazel b/validator/client/BUILD.bazel index 37662d39f7..69da945c56 100644 --- a/validator/client/BUILD.bazel +++ b/validator/client/BUILD.bazel @@ -94,7 +94,6 @@ go_test( "attest_protect_test.go", "attest_test.go", "key_reload_test.go", - "log_test.go", "metrics_test.go", "propose_protect_test.go", "propose_test.go", diff --git a/validator/client/iface/validator.go b/validator/client/iface/validator.go index a224679769..755f208410 100644 --- a/validator/client/iface/validator.go +++ b/validator/client/iface/validator.go @@ -53,7 +53,6 @@ type Validator interface { SubmitSignedContributionAndProof(ctx context.Context, slot types.Slot, pubKey [fieldparams.BLSPubkeyLength]byte) LogAttestationsSubmitted() LogSyncCommitteeMessagesSubmitted() - LogNextDutyTimeLeft(slot types.Slot) error UpdateDomainDataCaches(ctx context.Context, slot types.Slot) WaitForKeymanagerInitialization(ctx context.Context) error AllValidatorsAreExited(ctx context.Context) (bool, error) diff --git a/validator/client/log.go b/validator/client/log.go index ddf957e924..2966da2f79 100644 --- a/validator/client/log.go +++ b/validator/client/log.go @@ -3,14 +3,10 @@ package client import ( "fmt" "sync/atomic" - "time" - "github.com/prysmaticlabs/prysm/config/params" types "github.com/prysmaticlabs/prysm/consensus-types/primitives" "github.com/prysmaticlabs/prysm/encoding/bytesutil" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - prysmTime "github.com/prysmaticlabs/prysm/time" - "github.com/prysmaticlabs/prysm/time/slots" "github.com/sirupsen/logrus" ) @@ -50,55 +46,3 @@ func (v *validator) LogSyncCommitteeMessagesSubmitted() { // Reset the amount. atomic.StoreUint64(&v.syncCommitteeStats.totalMessagesSubmitted, 0) } - -// LogNextDutyTimeLeft logs the next duty info. -func (v *validator) LogNextDutyTimeLeft(slot types.Slot) error { - if !v.logDutyCountDown { - return nil - } - if v.duties == nil { - return nil - } - - var nextDutySlot types.Slot - attestingCounts := make(map[types.Slot]uint64) - proposingCounts := make(map[types.Slot]uint64) - for _, duty := range v.duties.CurrentEpochDuties { - attestingCounts[duty.AttesterSlot]++ - - if duty.AttesterSlot > slot && (nextDutySlot > duty.AttesterSlot || nextDutySlot == 0) { - nextDutySlot = duty.AttesterSlot - } - for _, proposerSlot := range duty.ProposerSlots { - proposingCounts[proposerSlot]++ - - if proposerSlot > slot && (nextDutySlot > proposerSlot || nextDutySlot == 0) { - nextDutySlot = proposerSlot - } - } - } - - if nextDutySlot == 0 { - log.WithField("slotInEpoch", slot%params.BeaconConfig().SlotsPerEpoch).Info("No duty until next epoch") - } else { - nextDutyTime, err := slots.ToTime(v.genesisTime, nextDutySlot) - if err != nil { - return err - } - timeLeft := time.Duration(nextDutyTime.Unix() - prysmTime.Now().Unix()).Nanoseconds() - // There is not much value to log if time left is less than one slot. - if uint64(timeLeft) >= params.BeaconConfig().SecondsPerSlot { - log.WithFields( - logrus.Fields{ - "currentSlot": slot, - "dutySlot": nextDutySlot, - "attesting": attestingCounts[nextDutySlot], - "proposing": proposingCounts[nextDutySlot], - "slotInEpoch": slot % params.BeaconConfig().SlotsPerEpoch, - "secondsLeft": timeLeft, - }).Info("Next duty") - } - } - - return nil -} diff --git a/validator/client/log_test.go b/validator/client/log_test.go deleted file mode 100644 index 362aeee9d3..0000000000 --- a/validator/client/log_test.go +++ /dev/null @@ -1,75 +0,0 @@ -package client - -import ( - "testing" - - types "github.com/prysmaticlabs/prysm/consensus-types/primitives" - ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - "github.com/prysmaticlabs/prysm/testing/require" - logTest "github.com/sirupsen/logrus/hooks/test" -) - -func TestLogNextDutyCountDown_NoDuty(t *testing.T) { - hook := logTest.NewGlobal() - v := &validator{ - logDutyCountDown: true, - duties: ðpb.DutiesResponse{CurrentEpochDuties: []*ethpb.DutiesResponse_Duty{ - {AttesterSlot: 100, ProposerSlots: []types.Slot{105}}, - {AttesterSlot: 110}, - {AttesterSlot: 120}, - }}, - } - require.NoError(t, v.LogNextDutyTimeLeft(121)) - require.LogsContain(t, hook, "No duty until next epoch") -} - -func TestLogNextDutyCountDown_HasDutyAttester(t *testing.T) { - hook := logTest.NewGlobal() - v := &validator{ - logDutyCountDown: true, - duties: ðpb.DutiesResponse{CurrentEpochDuties: []*ethpb.DutiesResponse_Duty{ - {AttesterSlot: 100, ProposerSlots: []types.Slot{105}}, - {AttesterSlot: 110}, - {AttesterSlot: 120}, - }}, - } - require.NoError(t, v.LogNextDutyTimeLeft(115)) - require.LogsContain(t, hook, "\"Next duty\" attesting=1 currentSlot=115 dutySlot=120 prefix=validator proposing=0") -} - -func TestLogNextDutyCountDown_HasDutyProposer(t *testing.T) { - hook := logTest.NewGlobal() - v := &validator{ - logDutyCountDown: true, - duties: ðpb.DutiesResponse{CurrentEpochDuties: []*ethpb.DutiesResponse_Duty{ - {AttesterSlot: 100, ProposerSlots: []types.Slot{105}}, - {AttesterSlot: 110}, - {AttesterSlot: 120}, - }}, - } - require.NoError(t, v.LogNextDutyTimeLeft(101)) - require.LogsContain(t, hook, "\"Next duty\" attesting=0 currentSlot=101 dutySlot=105 prefix=validator proposing=1") -} - -func TestLogNextDutyCountDown_HasMultipleDuties(t *testing.T) { - hook := logTest.NewGlobal() - v := &validator{ - logDutyCountDown: true, - duties: ðpb.DutiesResponse{CurrentEpochDuties: []*ethpb.DutiesResponse_Duty{ - {AttesterSlot: 120}, - {AttesterSlot: 110}, - {AttesterSlot: 105}, - {AttesterSlot: 105}, - {AttesterSlot: 100, ProposerSlots: []types.Slot{105}}, - }}, - } - require.NoError(t, v.LogNextDutyTimeLeft(101)) - require.LogsContain(t, hook, "\"Next duty\" attesting=2 currentSlot=101 dutySlot=105 prefix=validator proposing=1") -} - -func TestLogNextDutyCountDown_NilDuty(t *testing.T) { - v := &validator{ - logDutyCountDown: true, - } - require.NoError(t, v.LogNextDutyTimeLeft(101)) -} diff --git a/validator/client/runner.go b/validator/client/runner.go index 3792fdfb20..e91169d427 100644 --- a/validator/client/runner.go +++ b/validator/client/runner.go @@ -268,9 +268,6 @@ func performRoles(slotCtx context.Context, allRoles map[[48]byte][]iface.Validat if err := v.LogValidatorGainsAndLosses(slotCtx, slot); err != nil { log.WithError(err).Error("Could not report validator's rewards/penalties") } - if err := v.LogNextDutyTimeLeft(slot); err != nil { - log.WithError(err).Error("Could not report next count down") - } }() } diff --git a/validator/client/service.go b/validator/client/service.go index 207ed1446c..76fed99ef1 100644 --- a/validator/client/service.go +++ b/validator/client/service.go @@ -51,7 +51,6 @@ type ValidatorService struct { useWeb bool emitAccountMetrics bool logValidatorBalances bool - logDutyCountDown bool interopKeysConfig *local.InteropKeymanagerConfig conn *grpc.ClientConn grpcRetryDelay time.Duration @@ -78,7 +77,6 @@ type Config struct { UseWeb bool LogValidatorBalances bool EmitAccountMetrics bool - LogDutyCountDown bool InteropKeysConfig *local.InteropKeymanagerConfig Wallet *wallet.Wallet WalletInitializedFeed *event.Feed @@ -121,7 +119,6 @@ func NewValidatorService(ctx context.Context, cfg *Config) (*ValidatorService, e useWeb: cfg.UseWeb, interopKeysConfig: cfg.InteropKeysConfig, graffitiStruct: cfg.GraffitiStruct, - logDutyCountDown: cfg.LogDutyCountDown, Web3SignerConfig: cfg.Web3SignerConfig, ProposerSettings: cfg.ProposerSettings, } @@ -206,7 +203,6 @@ func (v *ValidatorService) Start() { graffitiStruct: v.graffitiStruct, graffitiOrderedIndex: graffitiOrderedIndex, eipImportBlacklistedPublicKeys: slashablePublicKeys, - logDutyCountDown: v.logDutyCountDown, Web3SignerConfig: v.Web3SignerConfig, ProposerSettings: v.ProposerSettings, walletInitializedChannel: make(chan *wallet.Wallet, 1), diff --git a/validator/client/testutil/mock_validator.go b/validator/client/testutil/mock_validator.go index 2c05685bca..b6928d8e63 100644 --- a/validator/client/testutil/mock_validator.go +++ b/validator/client/testutil/mock_validator.go @@ -183,11 +183,6 @@ func (_ *FakeValidator) SubmitSyncCommitteeMessage(_ context.Context, _ types.Sl // LogAttestationsSubmitted for mocking. func (_ *FakeValidator) LogAttestationsSubmitted() {} -// LogNextDutyTimeLeft for mocking. -func (_ *FakeValidator) LogNextDutyTimeLeft(_ types.Slot) error { - return nil -} - // UpdateDomainDataCaches for mocking. func (_ *FakeValidator) UpdateDomainDataCaches(context.Context, types.Slot) {} diff --git a/validator/client/validator.go b/validator/client/validator.go index 6c8aa39c25..dc1bf2e8f3 100644 --- a/validator/client/validator.go +++ b/validator/client/validator.go @@ -66,7 +66,6 @@ type validator struct { logValidatorBalances bool useWeb bool emitAccountMetrics bool - logDutyCountDown bool domainDataLock sync.Mutex attLogsLock sync.Mutex aggregatedSlotCommitteeIDCacheLock sync.Mutex diff --git a/validator/node/node.go b/validator/node/node.go index 51c14c0f9f..229542e9b0 100644 --- a/validator/node/node.go +++ b/validator/node/node.go @@ -428,7 +428,6 @@ func (c *ValidatorClient) registerValidatorService(cliCtx *cli.Context) error { Wallet: c.wallet, WalletInitializedFeed: c.walletInitialized, GraffitiStruct: gStruct, - LogDutyCountDown: c.cliCtx.Bool(flags.EnableDutyCountDown.Name), Web3SignerConfig: wsc, ProposerSettings: bpc, })