Repository navigation
Conversation
…cast (cometbft#5204) If the application's ExtendVote produces data that its own VerifyVoteExtension rejects, the chain deadlocks: the proposer happily advances to the next height while every other validator loops verifying the same invalid extension and never reaches 2/3 precommits. Per the maintainer-blessed Option A in the issue thread, run VerifyVoteExtension on the proposer's own extension immediately after ExtendVote returns. On self-rejection panic with a clear error pointing at the inconsistency between the application's ExtendVote and VerifyVoteExtension handlers — better operator signal than a silent network-wide stall. Skip self-verify when the extension is empty: an absent-but-required extension is caught downstream by SignAndCheckVote and produces a recoverable error, which is the existing behavior we want to preserve (TestVoteExtensionEnableHeight/'extension absent but required' still passes unchanged). Test mock for VerifyVoteExtension in TestVoteExtensionEnableHeight is relaxed from Times(numValidators - 1) to unbounded — the new self-verify call makes the exact count timing-dependent; what matters is that the round completes correctly. Closes cometbft#5204
aljo242
left a comment
There was a problem hiding this comment.
Reviewed and validated locally:
go test ./consensus -run 'TestStateVoteExtension|TestVoteExtensionEnableHeight|TestVerifyVoteExtensionNotCalledOnAbsentPrecommit' -count=1
LGTM. Self-verifying proposer extensions closes the deadlock scenario and the test updates match the new behavior.
|
@greptile review |
|
hey @satyakwok we require signed commits for contributors. could you reopen this pr with signed commits enabled? |
Greptile SummaryThis PR fixes a chain-deadlock bug (#5204) where an application whose
Confidence Score: 4/5Safe to merge — the new code path only fires when an application's handlers are already broken, leaving all correct deployments unaffected. The production logic change is small and well-reasoned: it intercepts an extension immediately after ExtendVote and re-validates it before signing, turning a silent network stall into an explicit panic with context. The main rough edges are a misleading 'proposer' label in the panic message (the code runs for any validator, not just the proposer) and a test suite that doesn't actually exercise the new self-verify call or the panic-on-rejection branch, since the mock returns an empty extension and the guard len(vote.Extension) > 0 is never satisfied. consensus/state_test.go deserves a second look — the new behavior (self-verify fires on non-empty extension, panic fires on rejection) has no test coverage. Important Files Changed
|
| panic(fmt.Errorf( | ||
| "proposer's own vote extension failed VerifyVoteExtension at height %d: %w; "+ | ||
| "application ExtendVote and VerifyVoteExtension handlers are inconsistent", | ||
| vote.Height, err, | ||
| )) |
There was a problem hiding this comment.
Misleading "proposer" label in panic message
signVote is invoked by every validator for their own precommit, not exclusively by the block proposer. If a non-proposer validator's extension fails self-verification, the panic will say "proposer's own vote extension" — which will send an operator hunting for a proposer misconfiguration when the real culprit is a different node. Using the validator's address in the message would make the trace actionable regardless of which node hits the panic.
| if testCase.expectVerifyCalled { | ||
| // Calls include numValidators-1 verifications of incoming | ||
| // precommits plus one self-verify on the proposer's own | ||
| // extension (#5204). The exact count depends on scheduling; | ||
| // we only care that the round completes. | ||
| m.On("VerifyVoteExtension", mock.Anything, mock.Anything).Return(&abci.ResponseVerifyVoteExtension{ | ||
| Status: abci.ResponseVerifyVoteExtension_ACCEPT, | ||
| }, nil).Times(numValidators - 1) | ||
| }, nil) | ||
| } |
There was a problem hiding this comment.
New self-verify path is never exercised by the existing tests
The ExtendVote mock is configured to return &abci.ResponseExtendVote{} (empty VoteExtension), so len(vote.Extension) == 0 is always true and the self-verify branch is never entered. The comment about "scheduling-dependent count" is therefore not the actual reason the .Times(numValidators - 1) constraint was dropped — the count remains exactly numValidators - 1 in practice. More importantly, there is no test that (a) returns a non-empty extension from ExtendVote and confirms VerifyVoteExtension is called once extra for the self-verify, and (b) returns a non-empty extension that VerifyVoteExtension rejects and confirms the panic fires. These two cases are the core of the new feature.
|
Replaced by #5890 — rebased onto current The replacement PR also folds in Greptile's two findings on this PR:
Closing this in favor of #5890. Thanks @aljo242 for the earlier review and @mattac21 for the signed-commits flag. |
…cast (cometbft#5204) [v2] (cometbft#5890) Supersedes cometbft#5864. ## Why a new PR cometbft#5864 was opened with one unsigned base commit (`d184ae5`) plus five `Merge branch 'main'` commits. Per @mattac21's request, this PR rebases the work onto current `main` as **a single signed commit** with no merge noise. ## What changed since cometbft#5864 Greptile flagged two valid issues on the previous PR; both addressed here: 1. **Panic message no longer says "proposer's"** (`consensus/state.go`) `signVote` runs on every validator, not just the proposer, so the old wording would mislead operators when a non-proposer hit the panic. The message now leads with `validator %X failed self-verification of its own vote extension at height %d` so the trace identifies the offending node regardless of role. 2. **Self-verify path now has dedicated test coverage** (`consensus/state_test.go`) New `TestSelfVerifyVoteExtensionRejectPanics` drives `signVote` directly from the test goroutine (bypassing `receiveRoutine`'s `defer recover()`), with a mock app whose `ExtendVote` returns a non-empty extension that `VerifyVoteExtension` rejects. Asserts the panic fires with the expected message and that both ABCI methods were called. The `TestVoteExtensionEnableHeight` `VerifyVoteExtension` mock is **restored** to `Times(numValidators - 1)` — that test's `ExtendVote` mock returns an empty extension, so the self-verify guard is never entered there and the exact count holds. The misleading `// scheduling-dependent count` comment from cometbft#5864 is gone. ## Original bug (unchanged from cometbft#5864) If the application's `ExtendVote` produces data its own `VerifyVoteExtension` rejects, the chain deadlocks: the issuing validator advances locally while every peer loops rejecting the invalid extension and 2/3 precommits are never reached. This PR adds an immediate self-verification in `signVote`: after `ExtendVote` returns a non-empty extension, `VerifyVoteExtension` is called on it before broadcasting. On rejection, the node panics with a clear handler-inconsistency message. Empty extensions are skipped — the absent-but-required case is caught downstream by `SignAndCheckVote` with a recoverable error, preserving existing behavior. ## Validation ``` go test ./consensus -run 'TestSelfVerifyVoteExtensionRejectPanics|TestStateVoteExtension|TestVoteExtensionEnableHeight|TestVerifyVoteExtensionNotCalledOnAbsentPrecommit|TestExtendVoteCalledWhenEnabled' -count=1 ok github.com/cometbft/cometbft/consensus 1.042s ``` Closes cometbft#5204 --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
…cast (cometbft#5204) [v2] (cometbft#5890) Supersedes cometbft#5864. ## Why a new PR cometbft#5864 was opened with one unsigned base commit (`d184ae5`) plus five `Merge branch 'main'` commits. Per @mattac21's request, this PR rebases the work onto current `main` as **a single signed commit** with no merge noise. ## What changed since cometbft#5864 Greptile flagged two valid issues on the previous PR; both addressed here: 1. **Panic message no longer says "proposer's"** (`consensus/state.go`) `signVote` runs on every validator, not just the proposer, so the old wording would mislead operators when a non-proposer hit the panic. The message now leads with `validator %X failed self-verification of its own vote extension at height %d` so the trace identifies the offending node regardless of role. 2. **Self-verify path now has dedicated test coverage** (`consensus/state_test.go`) New `TestSelfVerifyVoteExtensionRejectPanics` drives `signVote` directly from the test goroutine (bypassing `receiveRoutine`'s `defer recover()`), with a mock app whose `ExtendVote` returns a non-empty extension that `VerifyVoteExtension` rejects. Asserts the panic fires with the expected message and that both ABCI methods were called. The `TestVoteExtensionEnableHeight` `VerifyVoteExtension` mock is **restored** to `Times(numValidators - 1)` — that test's `ExtendVote` mock returns an empty extension, so the self-verify guard is never entered there and the exact count holds. The misleading `// scheduling-dependent count` comment from cometbft#5864 is gone. ## Original bug (unchanged from cometbft#5864) If the application's `ExtendVote` produces data its own `VerifyVoteExtension` rejects, the chain deadlocks: the issuing validator advances locally while every peer loops rejecting the invalid extension and 2/3 precommits are never reached. This PR adds an immediate self-verification in `signVote`: after `ExtendVote` returns a non-empty extension, `VerifyVoteExtension` is called on it before broadcasting. On rejection, the node panics with a clear handler-inconsistency message. Empty extensions are skipped — the absent-but-required case is caught downstream by `SignAndCheckVote` with a recoverable error, preserving existing behavior. ## Validation ``` go test ./consensus -run 'TestSelfVerifyVoteExtensionRejectPanics|TestStateVoteExtension|TestVoteExtensionEnableHeight|TestVerifyVoteExtensionNotCalledOnAbsentPrecommit|TestExtendVoteCalledWhenEnabled' -count=1 ok github.com/cometbft/cometbft/consensus 1.042s ``` Closes cometbft#5204 --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Closes #5204.
Bug
If the application's
ExtendVoteproduces data that its ownVerifyVoteExtensionrejects, the chain deadlocks: the proposer happily advances to the next height while every other validator loops verifying the same invalid extension and never reaches 2/3 precommits. Issue reporter 's log trace shows exactly this — proposer at height 12, peers stuck at height 11 with repeatedVerifyVoteExtensionHandler Price=0errors.Fix
Per the maintainer-blessed Option A (@liangping in the issue thread): immediately after
ExtendVotereturns on the proposer, callVerifyVoteExtensionon the resulting extension. On self-rejection, panic with a clear error pointing at the inconsistency between the application'sExtendVoteandVerifyVoteExtensionhandlers — better operator signal than a silent network-wide stall.The
len(vote.Extension) > 0guard preserves existing behavior for the "absent but required" case — that path is caught downstream bySignAndCheckVoteand produces a recoverable error (theTestVoteExtensionEnableHeight/extension_absent_but_requiredsubtest passes unchanged).Tests
All five
TestVoteExtensionEnableHeightsubtests pass:extension_present_but_not_enabledextension_absent_but_not_requiredextension_present_and_requiredextension_absent_but_requiredextension_absent_but_required_in_future_heightOne adjustment in the test file:
TestVoteExtensionEnableHeightpreviously setm.On("VerifyVoteExtension", ...).Times(numValidators - 1)(assuming the proposer never self-verifies). With the new self-verify call, the exact count is timing-dependent (the proposer self-verifies once, thennumValidators - 1peers verify the proposer's precommit). Relaxed to an unbounded mock expectation — the test asserts round completion (expectSuccessfulRound), which is the property we care about.Why panic and not log-and-continue
The proposer's
ExtendVoteandVerifyVoteExtensionhandlers disagreeing is a non-recoverable application logic bug, not a network condition. If we silently log and broadcast anyway, every peer will reject the precommit (existing behavior, deadlock). If we silently log and broadcast a nil extension, peers reject for "extension required but absent". Panicking with a clear message gives the operator a stack trace pointing at the application bug rather than chasing a network-level mystery. Mirrors the existing pattern atstate/execution.go:413where unrecoverable VerifyVoteExtension errors panic.Race / claim history
Compatibility
SignAndCheckVoterecoverable-error path (no behavioral change)