Skip to content

Commit

Permalink
op-proposer, op-batcher: Wait for sync in Start rather than loop. (et…
Browse files Browse the repository at this point in the history
…hereum-optimism#11192)

Ensures that if it fails, the process exits with an error, rather than just exiting the runloop and continuing on in a zombie mode that doesn't do anything but doesn't exit.
  • Loading branch information
ajsutton authored Aug 7, 2024
1 parent 96b9e70 commit cc67d34
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
14 changes: 7 additions & 7 deletions op-batcher/batcher/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,13 @@ func (l *BatchSubmitter) StartBatchSubmitting() error {
l.clearState(l.shutdownCtx)
l.lastStoredBlock = eth.BlockID{}

if l.Config.WaitNodeSync {
err := l.waitNodeSync()
if err != nil {
return fmt.Errorf("error waiting for node sync: %w", err)
}
}

l.wg.Add(1)
go l.loop()

Expand Down Expand Up @@ -289,13 +296,6 @@ const (

func (l *BatchSubmitter) loop() {
defer l.wg.Done()
if l.Config.WaitNodeSync {
err := l.waitNodeSync()
if err != nil {
l.Log.Error("Error waiting for node sync", "err", err)
return
}
}

receiptsCh := make(chan txmgr.TxReceipt[txRef])
queue := txmgr.NewQueue[txRef](l.killCtx, l.Txmgr, l.Config.MaxPendingTransactions)
Expand Down
15 changes: 7 additions & 8 deletions op-proposer/proposer/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,13 @@ func (l *L2OutputSubmitter) StartL2OutputSubmitting() error {
}
l.running = true

if l.Cfg.WaitNodeSync {
err := l.waitNodeSync()
if err != nil {
return fmt.Errorf("error waiting for node sync: %w", err)
}
}

l.wg.Add(1)
go l.loop()

Expand Down Expand Up @@ -429,14 +436,6 @@ func (l *L2OutputSubmitter) loop() {
defer l.wg.Done()
ctx := l.ctx

if l.Cfg.WaitNodeSync {
err := l.waitNodeSync()
if err != nil {
l.Log.Error("Error waiting for node sync", "err", err)
return
}
}

if l.dgfContract == nil {
l.loopL2OO(ctx)
} else {
Expand Down

0 comments on commit cc67d34

Please sign in to comment.