Skip to content

Commit

Permalink
Remove redundant vote processing of piggybacked vote (#62)
Browse files Browse the repository at this point in the history
Votes from the block proposer are piggybacked by the block message.
The current code verifies them twice, so I removed the redundant processing.

Signed-off-by: Yacov Manevich <[email protected]>
  • Loading branch information
yacovm authored Jan 29, 2025
1 parent aa0584e commit 961ef24
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 3 additions & 4 deletions epoch.go
Original file line number Diff line number Diff line change
Expand Up @@ -996,7 +996,7 @@ func (e *Epoch) createBlockVerificationTask(block Block, from NodeID, vote Vote)
}
round.votes[string(vote.Signature.Signer)] = &vote

if err := e.doProposed(block, vote, from); err != nil {
if err := e.doProposed(block); err != nil {
e.Logger.Warn("Failed voting on block", zap.Error(err))
}

Expand Down Expand Up @@ -1237,7 +1237,7 @@ func (e *Epoch) startRound() error {
return e.handleBlockMessage(msgsForRound.proposal, leaderForCurrentRound)
}

func (e *Epoch) doProposed(block Block, voteFromLeader Vote, from NodeID) error {
func (e *Epoch) doProposed(block Block) error {
vote, err := e.voteOnBlock(block)
if err != nil {
return err
Expand All @@ -1260,8 +1260,7 @@ func (e *Epoch) doProposed(block Block, voteFromLeader Vote, from NodeID) error
if err := e.handleVoteMessage(&vote, e.ID); err != nil {
return err
}

return e.handleVoteMessage(&voteFromLeader, e.ID)
return nil
}

func (e *Epoch) voteOnBlock(block Block) (Vote, error) {
Expand Down
4 changes: 4 additions & 0 deletions epoch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ func notarizeAndFinalizeRound(t *testing.T, nodes []NodeID, round uint64, e *Epo

// start at one since our node has already voted
for i := 1; i < quorum; i++ {
// Skip the vote of the block proposer
if leader.Equals(nodes[i]) {
continue
}
injectTestVote(t, e, block, nodes[i])
}

Expand Down

0 comments on commit 961ef24

Please sign in to comment.