From 1eff00fb33ff0efc40c328e25d34960704971f57 Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Tue, 7 Dec 2021 09:38:19 -0500 Subject: [PATCH] Display Num Pruned Items in Slasher Only When Actually Prunes (#9989) Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com> --- beacon-chain/slasher/receive.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/beacon-chain/slasher/receive.go b/beacon-chain/slasher/receive.go index 8c1fb969b..4a864cca7 100644 --- a/beacon-chain/slasher/receive.go +++ b/beacon-chain/slasher/receive.go @@ -216,10 +216,14 @@ func (s *Service) pruneSlasherDataWithinSlidingWindow(ctx context.Context, curre if err != nil { return errors.Wrap(err, "Could not prune proposals") } - log.WithFields(logrus.Fields{ - "prunedAttestationRecords": numPrunedAtts, - "prunedProposalRecords": numPrunedProposals, - "elapsed": time.Since(start), - }).Info("Successfully ran slasher data pruning") + fields := logrus.Fields{} + if numPrunedAtts > 0 { + fields["numPrunedAtts"] = numPrunedAtts + } + if numPrunedProposals > 0 { + fields["numPrunedProposals"] = numPrunedProposals + } + fields["elapsed"] = time.Since(start) + log.WithFields(fields).Info("Done pruning old attestations and proposals for slasher") return nil }