Test the application for v1 release. #37

Merged
abdulrabbani00 merged 9 commits from feature/32-test-known_gaps-skipped-slots into develop 2022-05-17 20:05:16 +00:00
4 changed files with 66 additions and 39 deletions
Showing only changes of commit 67f1427c8b - Show all commits

View File

@ -322,7 +322,7 @@ func writeKnownGaps(db sql.Database, tableIncrement int, startSlot int, endSlot
EntryProcess: entryProcess,
}
upsertKnownGaps(db, kgModel)
}
} else {
totalSlots := endSlot - startSlot
var chunks int
chunks = totalSlots / tableIncrement
@ -348,6 +348,7 @@ func writeKnownGaps(db sql.Database, tableIncrement int, startSlot int, endSlot
}
upsertKnownGaps(db, kgModel)
}
}
}

View File

@ -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")
}
}
}

View File

@ -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)
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 {
loghelper.LogSlotError(head.Slot, err).Error("Unable to process a slot")
return err
}
log.WithFields(log.Fields{"head": head}).Debug("Received a new head event.")
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

View File

@ -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,19 +68,29 @@ func processFullSlot(db sql.Database, serverAddress string, slot int, blockRoot
Metrics: metrics,
}
g, _ := errgroup.WithContext(context.Background())
// Get the BeaconState.
g.Go(func() error {
err := ps.getBeaconState(serverAddress)
if err != nil {
writeKnownGaps(ps.Db, 1, ps.Slot, ps.Slot, err, "processSlot")
return err
}
return nil
})
// Get the SignedBeaconBlock.
err = ps.getSignedBeaconBlock(serverAddress)
g.Go(func() error {
err := ps.getSignedBeaconBlock(serverAddress)
if err != nil {
writeKnownGaps(ps.Db, 1, ps.Slot, ps.Slot, err, "processSlot")
return err
}
return nil
})
if err := g.Wait(); err != nil {
writeKnownGaps(ps.Db, 1, ps.Slot, ps.Slot, err, "processSlot")
}
if ps.HeadOrHistoric == "head" && previousSlot == 0 && previousBlockRoot == "" {
writeStartUpGaps(db, knownGapsTableIncrement, ps.Slot)
@ -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"))