Skip to content

Conversation

meling
Copy link
Member

@meling meling commented Oct 3, 2025

This adds a bool value to the StopVoting method so that we can avoid accessing the LastVote value only for checking if the prev and current view are different outside the voter.

This adds a bool value to the StopVoting method so that we can
avoid accessing the LastVote value only for checking if the prev
and current view are different outside the voter.
@meling meling changed the title Replace LastVote with expanded StopVoting method feat: replace LastVote with expanded StopVoting method Oct 3, 2025
Copy link

@Copilot 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 pull request refactors the voting mechanism by removing the LastVote method and extending StopVoting to return a boolean indicating whether the view was advanced. This allows callers to determine if a view change occurred without needing to access the previous vote state externally.

  • Replaced LastVote() method with a boolean return value from StopVoting()
  • Simplified the logging logic in the synchronizer by using the return value
  • Added comprehensive test coverage for the new StopVoting behavior

Reviewed Changes

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

File Description
protocol/synchronizer/synchronizer.go Simplified timeout handling by using StopVoting's return value for conditional logging
protocol/consensus/voter.go Modified StopVoting to return boolean and removed LastVote method
protocol/consensus/voter_test.go Added comprehensive tests for StopVoting behavior and updated existing test

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@meling meling requested a review from Copilot October 3, 2025 18:00
Copy link

@Copilot 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

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

s.logger.Debugf("Stopped voting in view %d and changed to view %d", prev, view)

if s.voter.StopVoting(view) {
s.logger.Debugf("Stopped voting for view %d", view)
Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe this should be: Advanced to view %d?

Copy link
Contributor

Choose a reason for hiding this comment

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

No, at this point, the replica is actually in between views.
It stopped voting in one view but did not start the next view.
It will only start the next view once it has sufficient timeouts.
We should create an issue to examine this further. I remember a related discussion on PBFT, where PBFT stopped voting once a view timed out but later work only stopped voting once a viewChange message is sent.
Does the synchronizer algorithm implemented here specify that we have to stop voting on a local timeout?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't know the answer to that question, but that's what it does.

Copy link
Contributor

@leandernikolaus leandernikolaus left a comment

Choose a reason for hiding this comment

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

Mostly good, there is an issue about stopping to vote

s.logger.Debugf("Stopped voting in view %d and changed to view %d", prev, view)

if s.voter.StopVoting(view) {
s.logger.Debugf("Stopped voting for view %d", view)
Copy link
Contributor

Choose a reason for hiding this comment

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

No, at this point, the replica is actually in between views.
It stopped voting in one view but did not start the next view.
It will only start the next view once it has sufficient timeouts.
We should create an issue to examine this further. I remember a related discussion on PBFT, where PBFT stopped voting once a view timed out but later work only stopped voting once a viewChange message is sent.
Does the synchronizer algorithm implemented here specify that we have to stop voting on a local timeout?

@meling meling merged commit 05f4988 into package-restructuring Oct 4, 2025
@meling meling deleted the pr_remove-last-vote branch October 4, 2025 13:34
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.

2 participants