Skip to content

Commit

Permalink
Add a small sleep (1/10 average block time) when chain is behind (#726)
Browse files Browse the repository at this point in the history
  • Loading branch information
eljobe authored Jan 29, 2025
1 parent 80915fb commit 06459d1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions assertions/poster.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ func (m *Manager) PostAssertionBasedOnParent(
"latestStakedAssertionBatchCount", batchCount,
"latestStakedAssertionBlockHash", containers.Trunc(parentBlockHash[:]),
)
// If the chain is catching up, we wait for a bit and try again.
time.Sleep(m.times.avgBlockTime / 10)
return none, nil
}
return none, errors.Wrapf(err, "could not get execution state at batch count %d with parent block hash %v", batchCount, parentBlockHash)
Expand Down
2 changes: 2 additions & 0 deletions assertions/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,8 @@ func (m *Manager) findCanonicalAssertionBranch(
chainCatchingUpCounter.Inc(1)
log.Info("Chain still syncing "+
"will reattempt processing when caught up", "err", err)
// If the chain is catching up, we wait for a bit and try again.
time.Sleep(m.times.avgBlockTime / 10)
return false, l2stateprovider.ErrChainCatchingUp
case err != nil:
return false, err
Expand Down

0 comments on commit 06459d1

Please sign in to comment.