Skip to content

consensus: PickVoteToSend assumes peer has vote before checking result of Send #2615

@ebuchman

Description

@ebuchman

In PickVoteToSend, we mark the peer as having the vote we're going to send:

	if index, ok := votes.BitArray().Sub(psVotes).PickRandom(); ok {
		ps.setHasVote(height, round, type_, index)
		return votes.GetByIndex(index), true
	}

But this happens before we actually try to send it. If sending fails, we will have incorrectly marked the peer as having the vote:

	if vote, ok := ps.PickVoteToSend(votes); ok {
		msg := &VoteMessage{vote}
		ps.logger.Debug("Sending vote message", "ps", ps, "vote", vote)
		return ps.peer.Send(VoteChannel, cdc.MustMarshalBinaryBare(msg))
	}

We should check the result of ps.peer.Send before calling ps.setHasVote

Metadata

Metadata

Assignees

No one assigned

    Labels

    C:consensusComponent: ConsensusT:bugType Bug (Confirmed)

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions