Skip to content

Commit

Permalink
beacon/log: improve info logging
Browse files Browse the repository at this point in the history
  • Loading branch information
q9f committed Apr 29, 2020
1 parent 3054e2c commit 5d4d69f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
5 changes: 2 additions & 3 deletions beacon-chain/blockchain/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ var log = logrus.WithField("prefix", "blockchain")
// logs state transition related data every slot.
func logStateTransitionData(b *ethpb.BeaconBlock) {
log.WithFields(logrus.Fields{
"slot": b.Slot,
"attestations": len(b.Body.Attestations),
"deposits": len(b.Body.Deposits),
"attesterSlashings": len(b.Body.AttesterSlashings),
Expand All @@ -25,14 +24,14 @@ func logStateTransitionData(b *ethpb.BeaconBlock) {
}).Info("Finished applying state transition")
}

func logSyncStatus(block *ethpb.BeaconBlock, blockRoot [32]byte, finalized *ethpb.Checkpoint) {
func logBlockSyncStatus(block *ethpb.BeaconBlock, blockRoot [32]byte, finalized *ethpb.Checkpoint) {
log.WithFields(logrus.Fields{
"slot": block.Slot,
"block": fmt.Sprintf("0x%s...", hex.EncodeToString(blockRoot[:])[:8]),
"epoch": helpers.SlotToEpoch(block.Slot),
"finalizedEpoch": finalized.Epoch,
"finalizedRoot": fmt.Sprintf("0x%s...", hex.EncodeToString(finalized.Root[:])[:8]),
}).Info("Synced")
}).Info("Synced new block")
}

func logEpochData(beaconState *stateTrie.BeaconState) {
Expand Down
12 changes: 6 additions & 6 deletions beacon-chain/blockchain/receive_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,12 @@ func (s *Service) ReceiveBlockNoPubsub(ctx context.Context, block *ethpb.SignedB
// Reports on block and fork choice metrics.
reportSlotMetrics(blockCopy.Block.Slot, s.headSlot(), s.CurrentSlot(), s.finalizedCheckpt)

// Log block sync status.
logBlockSyncStatus(blockCopy.Block, root, s.finalizedCheckpt)

// Log state transition data.
logStateTransitionData(blockCopy.Block)

// Log sync status.
logSyncStatus(blockCopy.Block, root, s.finalizedCheckpt)

return nil
}

Expand Down Expand Up @@ -171,12 +171,12 @@ func (s *Service) ReceiveBlockNoPubsubForkchoice(ctx context.Context, block *eth
// Reports on block and fork choice metrics.
reportSlotMetrics(blockCopy.Block.Slot, s.headSlot(), s.CurrentSlot(), s.finalizedCheckpt)

// Log block sync status.
logBlockSyncStatus(blockCopy.Block, root, s.finalizedCheckpt)

// Log state transition data.
logStateTransitionData(blockCopy.Block)

// Log sync status.
logSyncStatus(blockCopy.Block, root, s.finalizedCheckpt)

s.epochParticipationLock.Lock()
defer s.epochParticipationLock.Unlock()
s.epochParticipation[helpers.SlotToEpoch(blockCopy.Block.Slot)] = precompute.Balances
Expand Down

0 comments on commit 5d4d69f

Please sign in to comment.