Skip to content

Make late votes not enter consensus peer msg queue #3154

Open

Description

@ValarDragon

Feature Request

Summary

Related to #2927. We should make the consensus reactor, upon seeing a vote message, check if the vote is late and ignore it, outside of consensus state's processing.

This will Save WAL writes, and time under consensus mutex

Problem Definition

On Osmosis RPC nodes, we see 2 million late votes per hour, which I think should mean considerably more work load under the consensus mutex.

Proposal

Add logic right here (https://github.com/cometbft/cometbft/blob/main/internal/consensus/reactor.go#L360-L361 ) of the form:

if vote.Height < height {
// add to late vote metrics
  return
}

Activity

  1. added
    enhancement
    needs-triage
    on May 31, 2024
  2. ValarDragon commented on May 31, 2024

    @ValarDragon
    ContributorAuthor

    We still want precommits for the last block to get into the consensus mutex if they aren't duplicate, so perhaps this should be:

    			// if vote is late, and is not a precommit for the last block, mark it late and return.
    			isLate := msg.Vote.Height < csHeight || (msg.Vote.Height == cs.Height && msg.Vote.Round < csRound)
    			if isLate {
    				isLastBlockPrecommit := msg.Vote.Type != types.PrecommitType || msg.Vote.Height != csHeight-1
    				if isLastBlockPrecommit {
    					cs.metrics.MarkLateVote(msg.Vote.Type)
    					return
    				}
    			}
    
  3. ValarDragon commented on May 31, 2024

    @ValarDragon
    ContributorAuthor

    There is no metric for how many precommits for the last block get in. JUst how many late votes we have.

    We get on average on our RPC nodes, 440 late precommits and 75 late prevotes per second. Saving 75 late prevotes from blocking the consensus mutex / WAL seems worth the change to me

  4. cason commented on Jun 10, 2024

    @cason

    My opinion on that:

    1. Reactor keeps some summary of the consensus protocol state; it is not the latest one, as we don't want lock contention, but it is update enough to figure out old/useless votes
    2. Reactor uses this summary to drop clearly old/useless messages. Some messages are old/useless but the reactor does not know that yet, but we are ok here.

    At the consensus level we can really see whether a message is valid/useful of not. We could anticipate such checks so that to only acquire the consensus lock and write the message to the WAL when this pre-check does not report that the message is super old. We are still paying the synchronization cost of the channel between reactor and state, but at least the logic is simpler to follow, and can even apply to a broader spectrum of scenarios.

  5. added and removed
    needs-triage
    on Jun 11, 2024
  6. cason commented on Jul 1, 2024

    @cason

    Notice that we need votes from previous rounds for some transitions in the state machine. See lines on the archive paper:

    28: upon 〈PROPOSAL, hp , roundp, v, vr〉 from proposer(hp , roundp) AND 2f + 1 〈PREVOTE, hp, vr, id(v)〉 while
    stepp = propose ∧ (vr ≥ 0 ∧ vr < roundp) do
    

    and

    49: upon 〈PROPOSAL, hp , r, v, ∗〉 from proposer(hp , r) AND 2f + 1 〈PRECOMMIT, hp , r, id(v)〉 while decisionp [hp] = nil do
    

    Notice that the round r is not current roundp.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    consensusenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions