Skip to content

Conversation

@meling
Copy link
Member

@meling meling commented Nov 3, 2025

Fixes #262

  • feat: add HighestView and HighestViewAggQC methods to SyncInfo
  • refactor: simplify VerifySyncInfo in Aggregate and Simple timeout rules

@meling meling requested a review from Copilot November 3, 2025 22:47
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors duplicate logic for determining the highest view in SyncInfo by extracting it into reusable methods. The changes reduce code duplication and improve maintainability by centralizing the view comparison logic.

  • Adds HighestView() and HighestViewAggQC() methods to SyncInfo that encapsulate the logic for determining the highest view and timeout status
  • Refactors Simple.VerifySyncInfo() to use the new HighestView() method
  • Refactors Aggregate.VerifySyncInfo() to use the new HighestViewAggQC() method

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
types.go Added two new methods HighestView() and HighestViewAggQC() to encapsulate view comparison logic for different certificate types
protocol/synchronizer/timeoutrule_simple.go Replaced inline view comparison logic with call to syncInfo.HighestView()
protocol/synchronizer/timeoutrule_aggregate.go Replaced inline view comparison logic with call to syncInfo.HighestViewAggQC()

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +204 to +208
return si.aggQC.View(), true // aggQC is always from timeouts
}
return si.tc.View(), true
case si.aggQC != nil:
return si.aggQC.View(), true
Copy link

Copilot AI Nov 3, 2025

Choose a reason for hiding this comment

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

The inline comment 'aggQC is always from timeouts' is misleading. According to the HotStuff protocol and Fast-HotStuff extension, an AggregateQC is a collection of QCs from timeout messages, but it represents the highest QC among those timeouts, not a timeout certificate itself. The timeout return value should indicate whether the highest view came from a timeout certificate (TC) or not. When aggQC has a higher view than TC, the timeout flag should be false since the highest view comes from the aggregated QCs (which represent successful proposals), not from a timeout.

Suggested change
return si.aggQC.View(), true // aggQC is always from timeouts
}
return si.tc.View(), true
case si.aggQC != nil:
return si.aggQC.View(), true
// aggQC represents the highest QC among timeouts, not a timeout certificate itself
return si.aggQC.View(), false
}
return si.tc.View(), true
case si.aggQC != nil:
// aggQC present, no TC; highest view comes from QC
return si.aggQC.View(), false

Copilot uses AI. Check for mistakes.
This adds two helper methods for view comparison between QC and TC
and AggQC and TC. These can be used by VerifySyncInfo.
This uses the new HighestView() methods to determine if the QC or
TC has the highest view, and thus if timeout should be true.

Note: Moving the initialization of view and timeout before the
signature verification should be fine, since a signature failure
will return err != nil, and users of the VerifySyncInfo must always
check for err before using any other output.
@meling meling force-pushed the meling/262/simplify-verify-syncinfo branch from b8e3aee to eec647e Compare November 14, 2025 16:02
If the SyncInfo is missing the AggregateQC, we now check if the
SyncInfo has a quorum certificate and returns that instead.
This corresponds to the existing logic on the master branch.
@meling
Copy link
Member Author

meling commented Nov 14, 2025

Superceded by #269

@meling meling closed this Nov 14, 2025
@meling meling deleted the meling/262/simplify-verify-syncinfo branch November 14, 2025 23:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: timeoutrule_aggregate.go:VerifySyncInfo() always returns timeout = true (unless SyncInfo is empty)

2 participants