diff --git a/packages/eventindexer/indexer/filter.go b/packages/eventindexer/indexer/filter.go index d8eef5875dc..d0c2d6a4d51 100644 --- a/packages/eventindexer/indexer/filter.go +++ b/packages/eventindexer/indexer/filter.go @@ -21,44 +21,61 @@ func L1FilterFunc( svc *Service, filterOpts *bind.FilterOpts, ) error { - blockProvenEvents, err := svc.taikol1.FilterBlockProven(filterOpts, nil) - if err != nil { - return errors.Wrap(err, "svc.taikol1.FilterBlockProven") - } + if svc.taikol1 != nil { + blockProvenEvents, err := svc.taikol1.FilterBlockProven(filterOpts, nil) + if err != nil { + return errors.Wrap(err, "svc.taikol1.FilterBlockProven") + } - err = svc.saveBlockProvenEvents(ctx, chainID, blockProvenEvents) - if err != nil { - return errors.Wrap(err, "svc.saveBlockProvenEvents") - } + err = svc.saveBlockProvenEvents(ctx, chainID, blockProvenEvents) + if err != nil { + return errors.Wrap(err, "svc.saveBlockProvenEvents") + } - blockProposedEvents, err := svc.taikol1.FilterBlockProposed(filterOpts, nil) - if err != nil { - return errors.Wrap(err, "svc.taikol1.FilterBlockProposed") - } + blockProposedEvents, err := svc.taikol1.FilterBlockProposed(filterOpts, nil) + if err != nil { + return errors.Wrap(err, "svc.taikol1.FilterBlockProposed") + } - err = svc.saveBlockProposedEvents(ctx, chainID, blockProposedEvents) - if err != nil { - return errors.Wrap(err, "svc.saveBlockProposedEvents") - } + err = svc.saveBlockProposedEvents(ctx, chainID, blockProposedEvents) + if err != nil { + return errors.Wrap(err, "svc.saveBlockProposedEvents") + } - blockVerifiedEvents, err := svc.taikol1.FilterBlockVerified(filterOpts, nil) - if err != nil { - return errors.Wrap(err, "svc.taikol1.FilterBlockVerified") - } + blockVerifiedEvents, err := svc.taikol1.FilterBlockVerified(filterOpts, nil) + if err != nil { + return errors.Wrap(err, "svc.taikol1.FilterBlockVerified") + } - err = svc.saveBlockVerifiedEvents(ctx, chainID, blockVerifiedEvents) - if err != nil { - return errors.Wrap(err, "svc.saveBlockVerifiedEvents") + err = svc.saveBlockVerifiedEvents(ctx, chainID, blockVerifiedEvents) + if err != nil { + return errors.Wrap(err, "svc.saveBlockVerifiedEvents") + } } - messagesSent, err := svc.bridge.FilterMessageSent(filterOpts, nil) - if err != nil { - return errors.Wrap(err, "svc.bridge.FilterMessageSent") + if svc.bridge != nil { + messagesSent, err := svc.bridge.FilterMessageSent(filterOpts, nil) + if err != nil { + return errors.Wrap(err, "svc.bridge.FilterMessageSent") + } + + err = svc.saveMessageSentEvents(ctx, chainID, messagesSent) + if err != nil { + return errors.Wrap(err, "svc.saveMessageSentEvents") + } } - err = svc.saveMessageSentEvents(ctx, chainID, messagesSent) - if err != nil { - return errors.Wrap(err, "svc.saveMessageSentEvents") + if svc.proverPool != nil { + slashedEvents, err := svc.proverPool.FilterSlashed(filterOpts, nil) + if err != nil { + return errors.Wrap(err, "svc.proverPool.FilterSlashed") + } + + err = svc.saveSlashedEvents(ctx, chainID, slashedEvents) + if err != nil { + return errors.Wrap(err, "svc.saveSlashedEvents") + } + } return nil diff --git a/packages/eventindexer/indexer/filter_then_subscribe.go b/packages/eventindexer/indexer/filter_then_subscribe.go index fe0331243b4..1eb27b8b0e2 100644 --- a/packages/eventindexer/indexer/filter_then_subscribe.go +++ b/packages/eventindexer/indexer/filter_then_subscribe.go @@ -73,16 +73,6 @@ func (svc *Service) FilterThenSubscribe( return errors.Wrap(err, "filter") } - slashedEvents, err := svc.proverPool.FilterSlashed(filterOpts, nil) - if err != nil { - return errors.Wrap(err, "svc.proverPool.FilterSlashed") - } - - err = svc.saveSlashedEvents(ctx, chainID, slashedEvents) - if err != nil { - return errors.Wrap(err, "svc.saveSlashedEvents") - } - header, err := svc.ethClient.HeaderByNumber(ctx, big.NewInt(int64(end))) if err != nil { return errors.Wrap(err, "svc.ethClient.HeaderByNumber")