Skip to content

Commit

Permalink
chore: run blocksync on statesync retry failure
Browse files Browse the repository at this point in the history
  • Loading branch information
lklimek committed Jan 28, 2025
1 parent 29fe133 commit 9c7f3a0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion internal/consensus/state_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func (s *StateDataStore) Subscribe(evsw *eventemitter.EventEmitter) {
})
}

// StateData is a copy of the current RoundState nad state.State stored in the store
// StateData is a copy of the current RoundState and state.State stored in the store
// Along with data, StateData provides some methods to check or update data inside
type StateData struct {
config *config.ConsensusConfig
Expand Down
11 changes: 9 additions & 2 deletions internal/statesync/reactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,16 @@ func (r *Reactor) OnStart(ctx context.Context) error {
if r.needsStateSync {
r.logger.Info("starting state sync")
if _, err := r.Sync(ctx); err != nil {
if errors.Is(err, errNoSnapshots) {
if errors.Is(err, errNoSnapshots) && r.postSyncHook != nil {
state, err := r.stateStore.Load()
if err != nil {
return fmt.Errorf("failed to load state: %w", err)
}

r.logger.Warn("no snapshots available; falling back to block sync", "err", err)
return nil
if err := r.postSyncHook(ctx, state); err != nil {
return fmt.Errorf("post sync failed: %w", err)
}
}
r.logger.Error("state sync failed; shutting down this node", "err", err)
return err
Expand Down

0 comments on commit 9c7f3a0

Please sign in to comment.