diff --git a/synchronizer/synchronizer.go b/synchronizer/synchronizer.go index e453d3f93b..ad7a90306c 100644 --- a/synchronizer/synchronizer.go +++ b/synchronizer/synchronizer.go @@ -129,17 +129,6 @@ func (s *ClientSynchronizer) Sync() error { case <-s.ctx.Done(): return nil case <-time.After(waitDuration): - //Sync L1Blocks - if lastEthBlockSynced, err = s.syncBlocks(lastEthBlockSynced); err != nil { - log.Warn("error syncing blocks: ", err) - lastEthBlockSynced, err = s.state.GetLastBlock(s.ctx, nil) - if err != nil { - log.Fatal("error getting lastEthBlockSynced to resume the synchronization... Error: ", err) - } - if s.ctx.Err() != nil { - continue - } - } latestSequencedBatchNumber, err := s.etherMan.GetLatestBatchNumber() if err != nil { log.Warn("error getting latest sequenced batch in the rollup. Error: ", err) @@ -150,6 +139,7 @@ func (s *ClientSynchronizer) Sync() error { log.Warn("error getting latest batch synced. Error: ", err) continue } + // Sync trusted state if latestSyncedBatch >= latestSequencedBatchNumber { log.Info("L1 state fully synchronized") err = s.syncTrustedState(latestSyncedBatch) @@ -159,6 +149,17 @@ func (s *ClientSynchronizer) Sync() error { } waitDuration = s.cfg.SyncInterval.Duration } + //Sync L1Blocks + if lastEthBlockSynced, err = s.syncBlocks(lastEthBlockSynced); err != nil { + log.Warn("error syncing blocks: ", err) + lastEthBlockSynced, err = s.state.GetLastBlock(s.ctx, nil) + if err != nil { + log.Fatal("error getting lastEthBlockSynced to resume the synchronization... Error: ", err) + } + if s.ctx.Err() != nil { + continue + } + } } } }