diff --git a/beacon-chain/rpc/eth/validator/BUILD.bazel b/beacon-chain/rpc/eth/validator/BUILD.bazel index d0a0e9d044..31ea92adb5 100644 --- a/beacon-chain/rpc/eth/validator/BUILD.bazel +++ b/beacon-chain/rpc/eth/validator/BUILD.bazel @@ -99,6 +99,7 @@ go_test( "@com_github_ethereum_go_ethereum//common/hexutil:go_default_library", "@com_github_pkg_errors//:go_default_library", "@com_github_prysmaticlabs_go_bitfield//:go_default_library", + "@com_github_sirupsen_logrus//:go_default_library", "@com_github_sirupsen_logrus//hooks/test:go_default_library", "@org_uber_go_mock//gomock:go_default_library", ], diff --git a/beacon-chain/rpc/eth/validator/handlers.go b/beacon-chain/rpc/eth/validator/handlers.go index 2377a5fe9e..a382c7d386 100644 --- a/beacon-chain/rpc/eth/validator/handlers.go +++ b/beacon-chain/rpc/eth/validator/handlers.go @@ -835,12 +835,17 @@ func (s *Server) PrepareBeaconProposer(w http.ResponseWriter, r *http.Request) { s.TrackedValidatorsCache.Set(val) validatorIndices = append(validatorIndices, primitives.ValidatorIndex(validatorIndex)) } + if len(validatorIndices) == 0 { return } - log.WithFields(logrus.Fields{ - "validatorIndices": validatorIndices, - }).Info("Updated fee recipient addresses") + + log := log.WithField("validatorCount", len(validatorIndices)) + if logrus.GetLevel() >= logrus.TraceLevel { + log = log.WithField("validatorIndices", validatorIndices) + } + + log.Debug("Updated fee recipient addresses") } // GetAttesterDuties requests the beacon node to provide a set of attestation duties, diff --git a/beacon-chain/rpc/eth/validator/handlers_test.go b/beacon-chain/rpc/eth/validator/handlers_test.go index 51498b0c62..a0e3def4fa 100644 --- a/beacon-chain/rpc/eth/validator/handlers_test.go +++ b/beacon-chain/rpc/eth/validator/handlers_test.go @@ -44,6 +44,7 @@ import ( "github.com/OffchainLabs/prysm/v7/time/slots" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/pkg/errors" + "github.com/sirupsen/logrus" logTest "github.com/sirupsen/logrus/hooks/test" ) @@ -2854,6 +2855,8 @@ func TestPrepareBeaconProposer(t *testing.T) { func TestProposer_PrepareBeaconProposerOverlapping(t *testing.T) { hook := logTest.NewGlobal() + logrus.SetLevel(logrus.DebugLevel) + db := dbutil.SetupDB(t) // New validator diff --git a/beacon-chain/rpc/prysm/v1alpha1/validator/proposer.go b/beacon-chain/rpc/prysm/v1alpha1/validator/proposer.go index d3bb406952..764d80b0aa 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/validator/proposer.go +++ b/beacon-chain/rpc/prysm/v1alpha1/validator/proposer.go @@ -547,11 +547,19 @@ func (vs *Server) PrepareBeaconProposer( vs.TrackedValidatorsCache.Set(val) validatorIndices = append(validatorIndices, r.ValidatorIndex) } - if len(validatorIndices) != 0 { - log.WithFields(logrus.Fields{ - "validatorCount": len(validatorIndices), - }).Debug("Updated fee recipient addresses for validator indices") + + if len(validatorIndices) == 0 { + return &emptypb.Empty{}, nil + } + + log := log.WithField("validatorCount", len(validatorIndices)) + if logrus.GetLevel() >= logrus.TraceLevel { + log = log.WithField("validatorIndices", validatorIndices) + } + + log.Debug("Updated fee recipient addresses") + return &emptypb.Empty{}, nil } diff --git a/beacon-chain/rpc/prysm/v1alpha1/validator/proposer_test.go b/beacon-chain/rpc/prysm/v1alpha1/validator/proposer_test.go index 11681e5ef8..6455882424 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/validator/proposer_test.go +++ b/beacon-chain/rpc/prysm/v1alpha1/validator/proposer_test.go @@ -53,6 +53,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/pkg/errors" + "github.com/sirupsen/logrus" logTest "github.com/sirupsen/logrus/hooks/test" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -3162,6 +3163,8 @@ func TestProposer_PrepareBeaconProposer(t *testing.T) { func TestProposer_PrepareBeaconProposerOverlapping(t *testing.T) { hook := logTest.NewGlobal() + logrus.SetLevel(logrus.DebugLevel) + db := dbutil.SetupDB(t) ctx := t.Context() proposerServer := &Server{ @@ -3178,13 +3181,13 @@ func TestProposer_PrepareBeaconProposerOverlapping(t *testing.T) { } _, err := proposerServer.PrepareBeaconProposer(ctx, req) require.NoError(t, err) - require.LogsContain(t, hook, "Updated fee recipient addresses for validator indices") + require.LogsContain(t, hook, "Updated fee recipient addresses") // Same validator hook.Reset() _, err = proposerServer.PrepareBeaconProposer(ctx, req) require.NoError(t, err) - require.LogsContain(t, hook, "Updated fee recipient addresses for validator indices") + require.LogsContain(t, hook, "Updated fee recipient addresses") // Same validator with different fee recipient hook.Reset() @@ -3196,7 +3199,7 @@ func TestProposer_PrepareBeaconProposerOverlapping(t *testing.T) { } _, err = proposerServer.PrepareBeaconProposer(ctx, req) require.NoError(t, err) - require.LogsContain(t, hook, "Updated fee recipient addresses for validator indices") + require.LogsContain(t, hook, "Updated fee recipient addresses") // More than one validator hook.Reset() @@ -3209,13 +3212,13 @@ func TestProposer_PrepareBeaconProposerOverlapping(t *testing.T) { } _, err = proposerServer.PrepareBeaconProposer(ctx, req) require.NoError(t, err) - require.LogsContain(t, hook, "Updated fee recipient addresses for validator indices") + require.LogsContain(t, hook, "Updated fee recipient addresses") // Same validators hook.Reset() _, err = proposerServer.PrepareBeaconProposer(ctx, req) require.NoError(t, err) - require.LogsContain(t, hook, "Updated fee recipient addresses for validator indices") + require.LogsContain(t, hook, "Updated fee recipient addresses") } func BenchmarkServer_PrepareBeaconProposer(b *testing.B) { diff --git a/changelog/chris-downgrade-log-level.md b/changelog/chris-downgrade-log-level.md new file mode 100644 index 0000000000..8b3ad7f271 --- /dev/null +++ b/changelog/chris-downgrade-log-level.md @@ -0,0 +1,4 @@ +### Changed + +- Downgraded log level from INFO to DEBUG on PrepareBeaconProposer updated fee recipients. +- Change the logging behaviour of Updated fee recipients to only log count of validators at Debug level and all validator indices at Trace level. \ No newline at end of file