Skip to content
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
18 changes: 16 additions & 2 deletions core/qbft/qbft.go
Original file line number Diff line number Diff line change
Expand Up @@ -459,8 +459,22 @@ func compare[I any, V comparable, C any](ctx context.Context, d Definition[I, V,
return inputValueSource, nil
case inputValueSource = <-compareValue:
case <-timerChan:
log.Warn(ctx, "", errors.New("timeout waiting for local data, used for comparing with leader's proposed data"))
return inputValueSource, errTimeout
// When the eager timer fires at an absolute deadline, d.Compare may have
// already completed (e.g. instantly when compareAttestations is disabled).
// Go's select picks randomly among ready channels, so check compareErr
// before declaring a timeout to avoid spurious round changes.
select {
case err := <-compareErr:
if err != nil {
log.Warn(ctx, errCompare.Error(), err)
return inputValueSource, errCompare
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe to preserve errors chain: return inputValueSource, errors.Wrap(err, errCompare.Error()).

}

return inputValueSource, nil
default:
log.Warn(ctx, "", errors.New("timeout waiting for local data, used for comparing with leader's proposed data"))
return inputValueSource, errTimeout
}
}
}
}
Expand Down