From 31e1ef0082d803a8dfef31ab6e4ca8b39ecdd99a Mon Sep 17 00:00:00 2001 From: Abdul Rabbani Date: Mon, 6 Jun 2022 12:12:31 -0400 Subject: [PATCH] Set starting slot and improve error gap capturing --- pkg/beaconclient/beaconclient.go | 1 - pkg/beaconclient/processevents.go | 10 ++++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/pkg/beaconclient/beaconclient.go b/pkg/beaconclient/beaconclient.go index 8f24207..ee56b39 100644 --- a/pkg/beaconclient/beaconclient.go +++ b/pkg/beaconclient/beaconclient.go @@ -59,7 +59,6 @@ type BeaconClient struct { StartingSlot int // If we're performing head tracking. What is the first slot we processed. PreviousSlot int // Whats the previous slot we processed PreviousBlockRoot string // Whats the previous block root, used to check the next blocks parent. - CheckKnownGaps bool // Should we check for gaps at start up. HeadTracking *SseEvents[Head] // Track the head block ReOrgTracking *SseEvents[ChainReorg] // Track all Reorgs //FinalizationTracking *SseEvents[FinalizedCheckpoint] // Track all finalization checkpoints diff --git a/pkg/beaconclient/processevents.go b/pkg/beaconclient/processevents.go index 457a116..8dd5520 100644 --- a/pkg/beaconclient/processevents.go +++ b/pkg/beaconclient/processevents.go @@ -53,13 +53,19 @@ func (bc *BeaconClient) handleHead() { if errorSlots != 0 && bc.PreviousSlot != 0 { log.WithFields(log.Fields{ "lastProcessedSlot": bc.PreviousSlot, - "errorMessages": errorSlots, + "errorSlots": errorSlots, }).Warn("We added slots to the knownGaps table because we got bad head messages.") - writeKnownGaps(bc.Db, bc.KnownGapTableIncrement, bc.PreviousSlot, bcSlotsPerEpoch+errorSlots, fmt.Errorf("Bad Head Messages"), "headProcessing", bc.Metrics) + writeKnownGaps(bc.Db, bc.KnownGapTableIncrement, bc.PreviousSlot+1, slot, fmt.Errorf("Bad Head Messages"), "headProcessing", bc.Metrics) + errorSlots = 0 } log.WithFields(log.Fields{"head": head}).Debug("We are going to start processing the slot.") + // Not used anywhere yet but might be useful to have. + if bc.PreviousSlot == 0 && bc.PreviousBlockRoot == "" { + bc.StartingSlot = slot + } + go processHeadSlot(bc.Db, bc.ServerEndpoint, slot, head.Block, head.State, bc.PreviousSlot, bc.PreviousBlockRoot, bc.Metrics, bc.KnownGapTableIncrement, bc.CheckDb) log.WithFields(log.Fields{"head": head.Slot}).Debug("We finished calling processHeadSlot.")