Skip to content

Conversation

leandernikolaus
Copy link
Contributor

No description provided.

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 PR fixes the leader's voting behavior in the consensus protocol by ensuring the leader sends a vote after broadcasting a proposal. The fix distinguishes between when the current node is the next leader versus when it needs to send its vote to a different next leader.

  • Reordered proposal broadcasting to happen before vote handling
  • Added logic to determine the next leader and conditionally send votes
  • Updated function documentation to reflect the new dual responsibility

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

@leandernikolaus leandernikolaus requested a review from meling October 2, 2025 13:13
}

// Disseminate stores a vote for the proposal and broadcasts the proposal.
// Disseminate broadcasts the proposal and aggregate my vote for this proposal
Copy link
Member

Choose a reason for hiding this comment

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

The doc comment is a bit confusing. What about this:

// Disseminate broadcasts the proposal to the other replicas and records it locally, bypassing the network stack.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no, the point is that the vote is also broadcast or submitted locally, depending on where is the next leader.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now it is:
Disseminate broadcasts the proposal and aggregates vote for this proposal

Copy link
Member

Choose a reason for hiding this comment

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

Hmm. I still think it is unclear. Since we explicitly separated aggregation from dissemination with two methods, I feel a more precise explanation is warranted. There is also no doc comment explaining this in relation to the next leader (could be a new sentence). If we keep the current phrasing, it must be ... aggregates my vote for this proposal. (as in the original).

Nit: Why removed the .?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was not aware of the details. But do you want to explain aggregation in the doc for dissemination?
e.g.

// Disseminate broadcasts the proposal and aggregates my vote for this proposals.
// Aggregating sends the vote or stores it if I am leader in the next view.
func (hs *Clique) Disseminate(proposal *hotstuff.ProposeMsg, pc hotstuff.PartialCert) error {

Copy link
Member

Choose a reason for hiding this comment

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

What about this:

// Disseminate broadcasts the proposal and immediately aggregates my vote for this proposals.

// reusing the previous partial cert
// aggregating for view 2 to change the leader to 2 so clique will aggregate instead
// of storing the vote internally
err = clique.Aggregate(1, nil, pc)
Copy link
Member

Choose a reason for hiding this comment

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

Is this no longer necessary? Then we don't have any tests that involve calls to Aggregate. (I've actually updated this code in #220.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I noticed this as well. Check the new version

@meling meling merged commit e95ae38 into package-restructuring Oct 3, 2025
@meling meling deleted the pr_sendvote branch October 3, 2025 11:40
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