diff --git a/packages/relayer/indexer/indexer.go b/packages/relayer/indexer/indexer.go index 31483c9000..02294a5bdb 100644 --- a/packages/relayer/indexer/indexer.go +++ b/packages/relayer/indexer/indexer.go @@ -218,28 +218,38 @@ func (i *Indexer) Start() error { i.wg.Add(1) go func() { - defer func() { - i.wg.Done() - }() - - if err := i.filter(i.ctx); err != nil { - slog.Error("error filtering blocks", "error", err.Error()) + if err := backoff.Retry(func() error { + err := i.filter(i.ctx) + if err != nil { + slog.Error("filter failed, will retry", "error", err) + } + return err + }, backoff.WithContext(backoff.NewConstantBackOff(5*time.Second), i.ctx)); err != nil { + slog.Error("error after retrying filter with backoff", "error", err) } }() go func() { if err := backoff.Retry(func() error { - return scanBlocks(i.ctx, i.srcEthClient, i.srcChainId, i.wg) - }, backoff.NewConstantBackOff(5*time.Second)); err != nil { + err := scanBlocks(i.ctx, i.srcEthClient, i.srcChainId, i.wg) + if err != nil { + slog.Error("scanBlocks failed, will retry", "error", err) + } + return err + }, backoff.WithContext(backoff.NewConstantBackOff(5*time.Second), i.ctx)); err != nil { slog.Error("scan blocks backoff retry", "error", err) } }() go func() { if err := backoff.Retry(func() error { - return i.queue.Notify(i.ctx, i.wg) - }, backoff.NewConstantBackOff(5*time.Second)); err != nil { - slog.Error("queue notify backoff retry", "error", err) + err := i.queue.Notify(i.ctx, i.wg) + if err != nil { + slog.Error("i.queue.Notify failed, will retry", "error", err) + } + return err + }, backoff.WithContext(backoff.NewConstantBackOff(5*time.Second), i.ctx)); err != nil { + slog.Error("i.queue.Notify backoff retry", "error", err) } }() @@ -383,6 +393,9 @@ func (i *Indexer) filter(ctx context.Context) error { if i.watchMode == CrawlPastBlocks { slog.Info("restarting filtering from genesis") + + i.processingBlockHeight = 0 + return i.filter(ctx) } diff --git a/packages/relayer/indexer/set_initial_processing_block_by_mode.go b/packages/relayer/indexer/set_initial_processing_block_by_mode.go index 2df25e038a..bb980711e6 100644 --- a/packages/relayer/indexer/set_initial_processing_block_by_mode.go +++ b/packages/relayer/indexer/set_initial_processing_block_by_mode.go @@ -43,7 +43,12 @@ func (i *Indexer) setInitialProcessingBlockByMode( return nil case Resync: + if i.watchMode == CrawlPastBlocks && i.processingBlockHeight > startingBlock { + return nil + } + i.processingBlockHeight = startingBlock + return nil default: return relayer.ErrInvalidMode