Test the application for v1 release. #37
@ -322,31 +322,32 @@ func writeKnownGaps(db sql.Database, tableIncrement int, startSlot int, endSlot
|
||||
EntryProcess: entryProcess,
|
||||
}
|
||||
upsertKnownGaps(db, kgModel)
|
||||
}
|
||||
totalSlots := endSlot - startSlot
|
||||
var chunks int
|
||||
chunks = totalSlots / tableIncrement
|
||||
if totalSlots%tableIncrement != 0 {
|
||||
chunks = chunks + 1
|
||||
}
|
||||
} else {
|
||||
totalSlots := endSlot - startSlot
|
||||
var chunks int
|
||||
chunks = totalSlots / tableIncrement
|
||||
if totalSlots%tableIncrement != 0 {
|
||||
chunks = chunks + 1
|
||||
}
|
||||
|
||||
for i := 0; i < chunks; i++ {
|
||||
var tempStart, tempEnd int
|
||||
tempStart = startSlot + (i * tableIncrement)
|
||||
if i+1 == chunks {
|
||||
tempEnd = endSlot
|
||||
} else {
|
||||
tempEnd = startSlot + ((i + 1) * tableIncrement)
|
||||
for i := 0; i < chunks; i++ {
|
||||
var tempStart, tempEnd int
|
||||
tempStart = startSlot + (i * tableIncrement)
|
||||
if i+1 == chunks {
|
||||
tempEnd = endSlot
|
||||
} else {
|
||||
tempEnd = startSlot + ((i + 1) * tableIncrement)
|
||||
}
|
||||
kgModel := DbKnownGaps{
|
||||
StartSlot: strconv.Itoa(tempStart),
|
||||
EndSlot: strconv.Itoa(tempEnd),
|
||||
CheckedOut: false,
|
||||
ReprocessingError: "",
|
||||
EntryError: entryError.Error(),
|
||||
EntryProcess: entryProcess,
|
||||
}
|
||||
upsertKnownGaps(db, kgModel)
|
||||
}
|
||||
kgModel := DbKnownGaps{
|
||||
StartSlot: strconv.Itoa(tempStart),
|
||||
EndSlot: strconv.Itoa(tempEnd),
|
||||
CheckedOut: false,
|
||||
ReprocessingError: "",
|
||||
EntryError: entryError.Error(),
|
||||
EntryProcess: entryProcess,
|
||||
}
|
||||
upsertKnownGaps(db, kgModel)
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -44,6 +44,7 @@ func handleIncomingSseEvent[P ProcessedEvents](eventHandler *SseEvents[P]) {
|
||||
case message := <-eventHandler.MessagesCh:
|
||||
// Message can be nil if its a keep-alive message
|
||||
if len(message.Data) != 0 {
|
||||
log.WithFields(log.Fields{"msg": string(message.Data)}).Debug("We are going to send the following message to be processed.")
|
||||
go processMsg(message.Data, eventHandler.ProcessCh, eventHandler.ErrorCh)
|
||||
}
|
||||
|
||||
@ -54,9 +55,6 @@ func handleIncomingSseEvent[P ProcessedEvents](eventHandler *SseEvents[P]) {
|
||||
"msg": headErr.msg,
|
||||
},
|
||||
).Error("Unable to handle event.")
|
||||
|
||||
case process := <-eventHandler.ProcessCh:
|
||||
log.WithFields(log.Fields{"processed": process}).Debug("Processesing a Message")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,9 @@ import (
|
||||
"strconv"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/vulcanize/ipld-ethcl-indexer/pkg/database/sql"
|
||||
"github.com/vulcanize/ipld-ethcl-indexer/pkg/loghelper"
|
||||
"golang.org/x/sync/errgroup"
|
||||
)
|
||||
|
||||
// This function will perform the necessary steps to handle a reorg.
|
||||
@ -44,11 +46,23 @@ func (bc *BeaconClient) handleHead() {
|
||||
writeKnownGaps(bc.Db, bc.KnownGapTableIncrement, bc.PreviousSlot, bcSlotsPerEpoch+errorSlots, fmt.Errorf("Bad Head Messages"), "headProcessing")
|
||||
}
|
||||
|
||||
err = processHeadSlot(bc.Db, bc.ServerEndpoint, slot, head.Block, head.State, bc.PreviousSlot, bc.PreviousBlockRoot, bc.Metrics, bc.KnownGapTableIncrement)
|
||||
if err != nil {
|
||||
loghelper.LogSlotError(head.Slot, err).Error("Unable to process a slot")
|
||||
}
|
||||
log.WithFields(log.Fields{"head": head}).Debug("Received a new head event.")
|
||||
log.WithFields(log.Fields{"head": head}).Debug("We are going to start processing the slot.")
|
||||
|
||||
go func(db sql.Database, serverAddress string, slot int, blockRoot string, stateRoot string, previousSlot int, previousBlockRoot string, metrics *BeaconClientMetrics, knownGapsTableIncrement int) {
|
||||
errG := new(errgroup.Group)
|
||||
errG.Go(func() error {
|
||||
err = processHeadSlot(db, serverAddress, slot, blockRoot, stateRoot, previousSlot, previousBlockRoot, metrics, knownGapsTableIncrement)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err := errG.Wait(); err != nil {
|
||||
loghelper.LogSlotError(strconv.Itoa(slot), err).Error("Unable to process a slot")
|
||||
}
|
||||
}(bc.Db, bc.ServerEndpoint, slot, head.Block, head.State, bc.PreviousSlot, bc.PreviousBlockRoot, bc.Metrics, bc.KnownGapTableIncrement)
|
||||
|
||||
log.WithFields(log.Fields{"head": head.Slot}).Debug("We finished calling processHeadSlot.")
|
||||
|
||||
// Update the previous block
|
||||
bc.PreviousSlot = slot
|
||||
|
@ -5,6 +5,7 @@
|
||||
package beaconclient
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"strconv"
|
||||
@ -17,6 +18,7 @@ import (
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/vulcanize/ipld-ethcl-indexer/pkg/database/sql"
|
||||
"github.com/vulcanize/ipld-ethcl-indexer/pkg/loghelper"
|
||||
"golang.org/x/sync/errgroup"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -66,18 +68,28 @@ func processFullSlot(db sql.Database, serverAddress string, slot int, blockRoot
|
||||
Metrics: metrics,
|
||||
}
|
||||
|
||||
g, _ := errgroup.WithContext(context.Background())
|
||||
|
||||
// Get the BeaconState.
|
||||
err := ps.getBeaconState(serverAddress)
|
||||
if err != nil {
|
||||
writeKnownGaps(ps.Db, 1, ps.Slot, ps.Slot, err, "processSlot")
|
||||
return err
|
||||
}
|
||||
g.Go(func() error {
|
||||
err := ps.getBeaconState(serverAddress)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
// Get the SignedBeaconBlock.
|
||||
err = ps.getSignedBeaconBlock(serverAddress)
|
||||
if err != nil {
|
||||
g.Go(func() error {
|
||||
err := ps.getSignedBeaconBlock(serverAddress)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
if err := g.Wait(); err != nil {
|
||||
writeKnownGaps(ps.Db, 1, ps.Slot, ps.Slot, err, "processSlot")
|
||||
return err
|
||||
}
|
||||
|
||||
if ps.HeadOrHistoric == "head" && previousSlot == 0 && previousBlockRoot == "" {
|
||||
@ -151,6 +163,7 @@ func (ps *ProcessSlot) getSignedBeaconBlock(serverAddress string) error {
|
||||
err = ps.FullSignedBeaconBlock.UnmarshalSSZ(ps.SszSignedBeaconBlock)
|
||||
|
||||
if err != nil {
|
||||
loghelper.LogError(err).Debug("We are getting an error message when unmarshalling the SignedBeaconBlock.")
|
||||
if ps.FullSignedBeaconBlock.Block.Slot == 0 {
|
||||
loghelper.LogSlotError(strconv.Itoa(ps.Slot), err).Error(SlotUnmarshalError("SignedBeaconBlock"))
|
||||
return fmt.Errorf(SlotUnmarshalError("SignedBeaconBlock"))
|
||||
@ -185,6 +198,7 @@ func (ps *ProcessSlot) getBeaconState(serverEndpoint string) error {
|
||||
err := ps.FullBeaconState.UnmarshalSSZ(ps.SszBeaconState)
|
||||
|
||||
if err != nil {
|
||||
loghelper.LogError(err).Debug("We are getting an error message when unmarshalling the BeaconState")
|
||||
if ps.FullBeaconState.Slot == 0 {
|
||||
loghelper.LogSlotError(strconv.Itoa(ps.Slot), err).Error(SlotUnmarshalError("BeaconState"))
|
||||
return fmt.Errorf(SlotUnmarshalError("BeaconState"))
|
||||
|
Loading…
Reference in New Issue
Block a user