Skip to content

Commit

Permalink
reorg detactor errors
Browse files Browse the repository at this point in the history
  • Loading branch information
rachit77 committed Sep 11, 2024
1 parent 1ac7b63 commit 8029fbd
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,20 @@ func start(cliCtx *cli.Context) error {
components := cliCtx.StringSlice(config.FlagComponents)
l1Client := runL1ClientIfNeeded(components, c.Etherman.URL)
l2Client := runL2ClientIfNeeded(components, c.AggOracle.EVMSender.URLRPCL2)
reorgDetectorL1 := runReorgDetectorL1IfNeeded(cliCtx.Context, components, l1Client, &c.ReorgDetectorL1)
reorgDetectorL2 := runReorgDetectorL2IfNeeded(cliCtx.Context, components, l2Client, &c.ReorgDetectorL2)
reorgDetectorL1, errChanL1 := runReorgDetectorL1IfNeeded(cliCtx.Context, components, l1Client, &c.ReorgDetectorL1)
go func() {
if err := <-errChanL1; err != nil {
log.Fatal("Error from ReorgDetectorL1: ", err)
}
}()

reorgDetectorL2, errChanL2 := runReorgDetectorL2IfNeeded(cliCtx.Context, components, l2Client, &c.ReorgDetectorL2)
go func() {
if err := <-errChanL2; err != nil {
log.Fatal("Error from ReorgDetectorL2: ", err)
}
}()

l1InfoTreeSync := runL1InfoTreeSyncerIfNeeded(cliCtx.Context, components, *c, l1Client, reorgDetectorL1)
claimSponsor := runClaimSponsorIfNeeded(cliCtx.Context, components, l2Client, c.ClaimSponsor)
l1BridgeSync := runBridgeSyncL1IfNeeded(cliCtx.Context, components, c.BridgeL1Sync, reorgDetectorL1, l1Client)
Expand Down Expand Up @@ -514,9 +526,9 @@ func runReorgDetectorL1IfNeeded(
components []string,
l1Client *ethclient.Client,
cfg *reorgdetector.Config,
) *reorgdetector.ReorgDetector {
) (*reorgdetector.ReorgDetector, chan error) {
if !isNeeded([]string{SEQUENCE_SENDER, AGGREGATOR, AGGORACLE, RPC}, components) {
return nil
return nil, nil
}
rd := newReorgDetector(cfg, l1Client)

Expand All @@ -527,23 +539,18 @@ func runReorgDetectorL1IfNeeded(
}
close(errChan)
}()
go func() {
if err := <-errChan; err != nil {
log.Errorf("Failed to start ReorgDetector: %v", err)
}
}()

return rd
return rd, errChan
}

func runReorgDetectorL2IfNeeded(
ctx context.Context,
components []string,
l2Client *ethclient.Client,
cfg *reorgdetector.Config,
) *reorgdetector.ReorgDetector {
) (*reorgdetector.ReorgDetector, chan error) {
if !isNeeded([]string{AGGORACLE, RPC}, components) {
return nil
return nil, nil
}
rd := newReorgDetector(cfg, l2Client)

Expand All @@ -554,13 +561,8 @@ func runReorgDetectorL2IfNeeded(
}
close(errChan)
}()
go func() {
if err := <-errChan; err != nil {
log.Errorf("Failed to start ReorgDetector: %v", err)
}
}()

return rd
return rd, errChan
}

func runClaimSponsorIfNeeded(
Expand Down

0 comments on commit 8029fbd

Please sign in to comment.