diff --git a/block/internal/syncing/syncer.go b/block/internal/syncing/syncer.go index 848ae9825..69c7fef1b 100644 --- a/block/internal/syncing/syncer.go +++ b/block/internal/syncing/syncer.go @@ -467,6 +467,11 @@ func (s *Syncer) fetchDAUntilCaughtUp(ctx context.Context) error { } } +// PendingCount returns the number of unprocessed height events in the pipeline. +func (s *Syncer) PendingCount() int { + return len(s.heightInCh) +} + func (s *Syncer) pendingWorkerLoop(ctx context.Context) { defer s.wg.Done() diff --git a/node/failover.go b/node/failover.go index f6e0c8d9f..f6fd09a3a 100644 --- a/node/failover.go +++ b/node/failover.go @@ -315,7 +315,8 @@ func (f *failoverState) waitForCatchup(ctx context.Context) (bool, error) { p2pCaughtUp = true } - if daCaughtUp && p2pCaughtUp { + pipelineDrained := f.bc.Syncer == nil || f.bc.Syncer.PendingCount() == 0 + if daCaughtUp && p2pCaughtUp && pipelineDrained { f.logger.Info(). Uint64("store_height", storeHeight). Uint64("max_p2p_height", maxP2PHeight).