diff --git a/.github/workflows/on-pr.yml b/.github/workflows/on-pr.yml index 1c988f7..2f48b54 100644 --- a/.github/workflows/on-pr.yml +++ b/.github/workflows/on-pr.yml @@ -206,4 +206,5 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v3 with: - args: --timeout 90s --disable deadcode + args: --timeout 90s --disable deadcode, +# args: --timeout 90s --disable deadcode,unused diff --git a/pkg/beaconclient/capturehistoric.go b/pkg/beaconclient/capturehistoric.go index 422ebd2..3c4d29b 100644 --- a/pkg/beaconclient/capturehistoric.go +++ b/pkg/beaconclient/capturehistoric.go @@ -18,6 +18,8 @@ package beaconclient import ( + "fmt" + log "github.com/sirupsen/logrus" "github.com/vulcanize/ipld-ethcl-indexer/pkg/database/sql" "golang.org/x/sync/errgroup" @@ -85,10 +87,24 @@ func handleBatchProcess(maxWorkers int, bp BatchProcessing, db sql.Database, ser // Process all ranges and send each individual slot to the worker. go func() { for slots := range slotsCh { - for i := slots.startSlot; i <= slots.endSlot; i++ { - workCh <- i + if slots.startSlot > slots.endSlot { + log.Error("We received a batch process request where the startSlot is greater than the end slot.") + errCh <- batchHistoricError{ + err: fmt.Errorf("We received a startSlot where the start was greater than the end."), + errProcess: "RangeOrder", + slot: slots.startSlot, + } + errCh <- batchHistoricError{ + err: fmt.Errorf("We received a endSlot where the start was greater than the end."), + errProcess: "RangeOrder", + slot: slots.endSlot, + } + } else { + for i := slots.startSlot; i <= slots.endSlot; i++ { + workCh <- i + } + processedCh <- slots } - processedCh <- slots } }() diff --git a/pkg/beaconclient/processslot.go b/pkg/beaconclient/processslot.go index a046dc8..e4c15b1 100644 --- a/pkg/beaconclient/processslot.go +++ b/pkg/beaconclient/processslot.go @@ -45,7 +45,6 @@ var ( return fmt.Sprintf("Unable to properly unmarshal the Slot field in the %s.", obj) } ParentRootUnmarshalError = "Unable to properly unmarshal the ParentRoot field in the SignedBeaconBlock." - MissingIdentifiedError = "Can't query state without a set slot or block_root" MissingEth1Data = "Can't get the Eth1 block_hash" VersionedUnmarshalerError = "Unable to create a versioned unmarshaler" ) @@ -160,11 +159,8 @@ func (ps *ProcessSlot) getSignedBeaconBlock(serverAddress string, vmCh <-chan *d var blockIdentifier string // Used to query the block if ps.BlockRoot != "" { blockIdentifier = ps.BlockRoot - } else if ps.Slot != 0 { - blockIdentifier = strconv.Itoa(ps.Slot) } else { - log.Error(MissingIdentifiedError) - return fmt.Errorf(MissingIdentifiedError) + blockIdentifier = strconv.Itoa(ps.Slot) } blockEndpoint := serverAddress + BcBlockQueryEndpoint + blockIdentifier var err error @@ -209,11 +205,8 @@ func (ps *ProcessSlot) getBeaconState(serverEndpoint string, vmCh chan<- *dt.Ver var stateIdentifier string // Used to query the state if ps.StateRoot != "" { stateIdentifier = ps.StateRoot - } else if ps.Slot != 0 { - stateIdentifier = strconv.Itoa(ps.Slot) } else { - log.Error(MissingIdentifiedError) - return fmt.Errorf(MissingIdentifiedError) + stateIdentifier = strconv.Itoa(ps.Slot) } stateEndpoint := serverEndpoint + BcStateQueryEndpoint + stateIdentifier ps.SszBeaconState, _, _ = querySsz(stateEndpoint, strconv.Itoa(ps.Slot))