Skip to content

Commit

Permalink
Add Clock-Based Slot to Metrics (#5545)
Browse files Browse the repository at this point in the history
* clock based slot
* Merge refs/heads/master into highest-possible-slot
  • Loading branch information
rauljordan authored Apr 20, 2020
1 parent 61c96f5 commit 9255a2b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
9 changes: 7 additions & 2 deletions beacon-chain/blockchain/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ var (
Name: "beacon_head_slot",
Help: "Slot of the head block of the beacon chain",
})
clockTimeSlot = promauto.NewGauge(prometheus.GaugeOpts{
Name: "beacon_clock_time_slot",
Help: "The current slot based on the genesis time and current clock",
})
competingBlks = promauto.NewCounter(prometheus.CounterOpts{
Name: "competing_blocks",
Help: "The # of blocks received and processed from a competing chain",
Expand Down Expand Up @@ -82,8 +86,9 @@ var (
)

// reportSlotMetrics reports slot related metrics.
func reportSlotMetrics(currentSlot uint64, headSlot uint64, finalizedCheckpoint *ethpb.Checkpoint) {
beaconSlot.Set(float64(currentSlot))
func reportSlotMetrics(stateSlot uint64, headSlot uint64, clockSlot uint64, finalizedCheckpoint *ethpb.Checkpoint) {
clockTimeSlot.Set(float64(clockSlot))
beaconSlot.Set(float64(stateSlot))
beaconHeadSlot.Set(float64(headSlot))
if finalizedCheckpoint != nil {
headFinalizedEpoch.Set(float64(finalizedCheckpoint.Epoch))
Expand Down
6 changes: 3 additions & 3 deletions beacon-chain/blockchain/receive_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func (s *Service) ReceiveBlockNoPubsub(ctx context.Context, block *ethpb.SignedB
})

// Reports on block and fork choice metrics.
reportSlotMetrics(blockCopy.Block.Slot, s.headSlot(), s.finalizedCheckpt)
reportSlotMetrics(blockCopy.Block.Slot, s.headSlot(), s.CurrentSlot(), s.finalizedCheckpt)

// Log state transition data.
logStateTransitionData(blockCopy.Block)
Expand Down Expand Up @@ -166,7 +166,7 @@ func (s *Service) ReceiveBlockNoPubsubForkchoice(ctx context.Context, block *eth
})

// Reports on block and fork choice metrics.
reportSlotMetrics(blockCopy.Block.Slot, s.headSlot(), s.finalizedCheckpt)
reportSlotMetrics(blockCopy.Block.Slot, s.headSlot(), s.CurrentSlot(), s.finalizedCheckpt)

// Log state transition data.
logStateTransitionData(blockCopy.Block)
Expand Down Expand Up @@ -222,7 +222,7 @@ func (s *Service) ReceiveBlockNoVerify(ctx context.Context, block *ethpb.SignedB
})

// Reports on blockCopy and fork choice metrics.
reportSlotMetrics(blockCopy.Block.Slot, s.headSlot(), s.finalizedCheckpt)
reportSlotMetrics(blockCopy.Block.Slot, s.headSlot(), s.CurrentSlot(), s.finalizedCheckpt)

// Log state transition data.
log.WithFields(logrus.Fields{
Expand Down

0 comments on commit 9255a2b

Please sign in to comment.