Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP Fail in processSequenceBatches if we don't have the parent batch #82

Closed
wants to merge 1 commit into from
Closed
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
17 changes: 17 additions & 0 deletions synchronizer/synchronizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,23 @@ func (s *ClientSynchronizer) processSequenceBatches(sequencedBatches []etherman.
return nil
}

if lastBatch, err := s.state.GetLastBatchNumber(s.ctx, dbTx); err != nil {
log.Errorf("Error fetching previous batch number: %w", err)
rollbackErr := dbTx.Rollback(s.ctx)
if rollbackErr != nil {
log.Fatalf("error rolling back state. rollbackErr: %s, error : %w", rollbackErr.Error(), err)
}
return err
} else if sequencedBatches[0].BatchNumber != lastBatch + 1 {
err = fmt.Errorf("New batch %d is not successor of last synced batch %d, there may have been a reorg", sequencedBatches[0].BatchNumber, lastBatch)
log.Warnf("Possible reorg detected: %w", err)
rollbackErr := dbTx.Rollback(s.ctx)
if rollbackErr != nil {
log.Fatalf("error rolling back state. rollbackErr: %s, error : %w", rollbackErr.Error(), err)
}
return err
}

for _, sbatch := range sequencedBatches {
// Ensure the L1 origin for this batch is in the database. Since the L1 origin assigned by
// HotShot is not necessarily the same as an L1 block which we added to the database as a
Expand Down