diff --git a/beacon-chain/blockchain/log.go b/beacon-chain/blockchain/log.go index 078991982..bd7a06f4e 100644 --- a/beacon-chain/blockchain/log.go +++ b/beacon-chain/blockchain/log.go @@ -54,25 +54,33 @@ func logStateTransitionData(b interfaces.BeaconBlock) error { return nil } -func logBlockSyncStatus(block interfaces.BeaconBlock, blockRoot [32]byte, finalized *ethpb.Checkpoint, receivedTime time.Time, genesisTime uint64) error { +func logBlockSyncStatus(block interfaces.BeaconBlock, blockRoot [32]byte, justified, finalized *ethpb.Checkpoint, receivedTime time.Time, genesisTime uint64) error { startTime, err := slots.ToTime(genesisTime, block.Slot()) if err != nil { return err } - 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()), - "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()), - }).Info("Synced new block") - log.WithFields(logrus.Fields{ - "slot": block.Slot, - "sinceSlotStartTime": prysmTime.Now().Sub(startTime), - "chainServiceProcessedTime": prysmTime.Now().Sub(receivedTime), - }).Debug("Sync new block times") + level := log.Logger.GetLevel() + 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") + } return nil } diff --git a/beacon-chain/blockchain/receive_block.go b/beacon-chain/blockchain/receive_block.go index 4dc62493a..620141731 100644 --- a/beacon-chain/blockchain/receive_block.go +++ b/beacon-chain/blockchain/receive_block.go @@ -59,14 +59,18 @@ func (s *Service) ReceiveBlock(ctx context.Context, block interfaces.SignedBeaco } // Reports on block and fork choice metrics. + justified, err := s.store.JustifiedCheckpt() + if err != nil { + return err + } finalized, err := s.store.FinalizedCheckpt() if err != nil { - return errors.Wrap(err, "could not get finalized checkpoint") + return errNilFinalizedInStore } reportSlotMetrics(blockCopy.Block().Slot(), s.HeadSlot(), s.CurrentSlot(), finalized) // Log block sync status. - if err := logBlockSyncStatus(blockCopy.Block(), blockRoot, finalized, receivedTime, uint64(s.genesisTime.Unix())); err != nil { + if err := logBlockSyncStatus(blockCopy.Block(), blockRoot, justified, finalized, receivedTime, uint64(s.genesisTime.Unix())); err != nil { return err } // Log state transition data.