From 2de2000eb7dd6a2b39eaccce2e717378a1492a1d Mon Sep 17 00:00:00 2001 From: terencechain Date: Tue, 31 May 2022 10:44:36 -0700 Subject: [PATCH] Add back finalized info in new block log (#10792) * Add back finalized info in new block log * Better refactor Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com> --- beacon-chain/blockchain/log.go | 36 +++++++++++++++------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/beacon-chain/blockchain/log.go b/beacon-chain/blockchain/log.go index bd7a06f4e..9b0086e32 100644 --- a/beacon-chain/blockchain/log.go +++ b/beacon-chain/blockchain/log.go @@ -60,27 +60,23 @@ func logBlockSyncStatus(block interfaces.BeaconBlock, blockRoot [32]byte, justif return err } level := log.Logger.GetLevel() + + log = log.WithField("slot", block.Slot()) if level >= logrus.DebugLevel { - log.WithFields(logrus.Fields{ - "slot": block.Slot(), - "slotInEpoch": block.Slot() % params.BeaconConfig().SlotsPerEpoch, - "block": fmt.Sprintf("0x%s...", hex.EncodeToString(blockRoot[:])[:8]), - "epoch": slots.ToEpoch(block.Slot()), - "justifiedEpoch": justified.Epoch, - "justifiedRoot": fmt.Sprintf("0x%s...", hex.EncodeToString(justified.Root)[:8]), - "finalizedEpoch": finalized.Epoch, - "finalizedRoot": fmt.Sprintf("0x%s...", hex.EncodeToString(finalized.Root)[:8]), - "parentRoot": fmt.Sprintf("0x%s...", hex.EncodeToString(block.ParentRoot())[:8]), - "version": version.String(block.Version()), - "sinceSlotStartTime": prysmTime.Now().Sub(startTime), - "chainServiceProcessedTime": prysmTime.Now().Sub(receivedTime), - }).Debug("Synced new block") - } else { - log.WithFields(logrus.Fields{ - "slot": block.Slot(), - "block": fmt.Sprintf("0x%s...", hex.EncodeToString(blockRoot[:])[:8]), - "epoch": slots.ToEpoch(block.Slot()), - }).Info("Synced new block") + log = log.WithField("slotInEpoch", block.Slot()%params.BeaconConfig().SlotsPerEpoch) + log = log.WithField("justifiedEpoch", justified.Epoch) + log = log.WithField("justifiedRoot", fmt.Sprintf("0x%s...", hex.EncodeToString(justified.Root)[:8])) + log = log.WithField("parentRoot", fmt.Sprintf("0x%s...", hex.EncodeToString(block.ParentRoot())[:8])) + log = log.WithField("version", version.String(block.Version())) + log = log.WithField("sinceSlotStartTime", prysmTime.Now().Sub(startTime)) + log = log.WithField("chainServiceProcessedTime", prysmTime.Now().Sub(receivedTime)) } + + log.WithFields(logrus.Fields{ + "block": fmt.Sprintf("0x%s...", hex.EncodeToString(blockRoot[:])[:8]), + "epoch": slots.ToEpoch(block.Slot()), + "finalizedEpoch": finalized.Epoch, + "finalizedRoot": fmt.Sprintf("0x%s...", hex.EncodeToString(finalized.Root)[:8]), + }).Info("Synced new block") return nil }