Skip to content
This repository was archived by the owner on Feb 17, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions synchronizer/synchronizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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
}
}
}
}
}
Expand Down