Skip to content

Commit

Permalink
fix(sync): fix syncing validation race condition (#1340)
Browse files Browse the repository at this point in the history
  • Loading branch information
srene authored Jan 20, 2025
1 parent 6e15db0 commit f66ee1c
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions block/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,15 @@ func (m *Manager) Start(ctx context.Context) error {
return fmt.Errorf("sync block manager from settlement: %w", err)
}

// send signal to syncing loop with last settlement state update
m.triggerSettlementSyncing()
// send signal to validation loop with last settlement state update
m.triggerSettlementValidation()
// we only trigger validation if no syncing is required (otherwise it may cause race condition).
// syncing loop will trigger validation after each batch synced.
if m.LastSettlementHeight.Load() > m.State.Height() {
// send signal to syncing loop with last settlement state update
m.triggerSettlementSyncing()
} else {
// send signal to validation loop with last settlement state update
m.triggerSettlementValidation()
}

// This error group is used to control the lifetime of the block manager.
// when one of the loops exits with error, the block manager exits
Expand Down

0 comments on commit f66ee1c

Please sign in to comment.