diff --git a/eth/sync.go b/eth/sync.go index 5e50aa31f6..71585fb017 100644 --- a/eth/sync.go +++ b/eth/sync.go @@ -183,7 +183,20 @@ func (cs *chainSyncer) nextSyncOp() *chainSyncOp { // cs.handler.acceptTxs.Store(false) // log.Info("Disable transaction acceptance randomly for the delay exceeding 10 blocks.") // } + } else if op.td.Cmp(new(big.Int).Add(ourTD, common.Big2)) <= 0 { // common.Big2: difficulty of an in-turn block + // On BSC, blocks are produced much faster than on Ethereum. + // If the node is only slightly behind (e.g., 1 block), syncing is unnecessary. + // It's likely still processing broadcasted blocks or block hash announcements. + // In most cases, the node will catch up within 3 seconds. + time.Sleep(3 * time.Second) + + // Re-check local head to see if it has caught up + if _, latestTD := cs.modeAndLocalHead(); ourTD.Cmp(latestTD) < 0 { + log.Trace("The local head is already caught up; synchronization is not required.") + return nil + } } + return op }