Skip to content

enterPrecommit is almost always double verifying the block #2854

@ValarDragon

Description

@ValarDragon

Feature Request

Summary

enterPrecommit almost always runs ValidateBlock, however in most cases this is duplicate logic as we have already prevoted the block. We only enter a lock after this line! This is the line where we run validate block: https://github.com/cometbft/cometbft/blob/main/internal/consensus/state.go#L1667

I suggest that we change this line here, to be one of two things:

  • Only validate the block after checking some cache for whether we have already validated this block.
  • Check "did we prevote this block", and only ran ValidateBlock if we did not.

Problem Definition

We see we have duplicate VerifyBlock logic on synced full nodes:
image

This operation is expensive, especially in consensus critical contexts!

Proposal

I think that making a cache for checking if we've already validated a block is better, as it seems easier to also avoid extra redundant validations for finalizeCommit. I haven't read that logic, but guessing by how all 3 of these validate block calls are pretty similar in the amount of time spent, I'm guessing its a redundant ValidateBlock as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions