Skip to content

fix(consensus): treat malformed ProcessProposal responses as terminal, not as call failures - #1662

Draft
Claudius-Maginificent wants to merge 20 commits into
devfrom
fix/consensus-malformed-process-proposal
Draft

Claudius-Maginificent wants to merge 20 commits into
devfrom
fix/consensus-malformed-process-proposal

Conversation

@Claudius-Maginificent

Copy link
Copy Markdown
Collaborator

TL;DR: A validator that falls behind no longer keeps asking the application, every few seconds, to check a block when the application's answer is broken in a way that asking again cannot fix.

User story

As a validator operator, I want my node to stop retrying a request when the application's answer is structurally invalid, to keep logs and application load sane while the network moves on.

Scenario

Base flow

A validator that missed a block the network agreed on gets it late and asks the application to check it. If that check fails for a temporary reason, the validator tries again with a growing delay, up to every five seconds.

Actual behavior

When the application accepts the block but returns a broken answer (for example a result hash of the wrong length, or the wrong number of transaction results), the validator treats it like a temporary failure and keeps retrying for the rest of the round, logging a warning each time. The same broken answer comes back every time.

Expected behavior

A broken answer from the application is treated as final, like an explicit rejection: the validator logs it once and does not retry. Temporary failures are still retried as before.

Detailed discussion

Stacked on #1600 (base: fix/consensus-serve-polka-block), which adds the polka block retry this PR narrows. Follow-up to a review comment on #1600.

What was done

  • internal/state/errors.go: new sentinel ErrMalformedResponse.
  • internal/state/execution.go (BlockExecutor.ProcessProposal): an UNKNOWN status, a failing ResponseProcessProposal.Validate (e.g. wrong app hash size), mismatching tx_results (validateExecTxResults) and the later app hash size check now wrap ErrMalformedResponse, keeping the original message and cause (errors.Is matches both).
  • internal/consensus/block_executor.go (tryPolkaBlock): ErrMalformedResponse is terminal, like ErrBlockRejected and ErrInvalidBlock; the terminal log says the block is not retried.
  • spec/consensus/consensus-transitions.md: the prevote rule names ErrMalformedResponse for these responses.
  • Other callers (ensureProcess, ensureOwnRound, mustEnsureProcess, verifyProcessedCommit, prevoter.handleError, handshake replay, ApplyBlock, blocksync applier) do not branch on the new type, so their behaviour is unchanged; only the error text gains a prefix.

Out of scope

  • PrepareProposal response validation (CreateProposalBlock) keeps its untyped errors: it is not retried.
  • Changeset errors (e.g. invalid consensus parameter updates in an ACCEPT) are not classified and are still retried.

Known limitations

None.

Testing

  • New: TestStatePolkaBlockFailureNotWorthRetryingIsNotRetried/malformed_response (accepted response with a 31-byte app hash: exactly one ProcessProposal call, no retry armed) and TestProcessProposalMalformedResponse in internal/state (wrong app hash size, wrong tx result count, UNKNOWN status, plus a valid baseline). Both fail without the fix.
  • go test -tags deadlock for ./internal/state/ and the polka, process and proposal tests in ./internal/consensus/ pass; the new tests pass repeatedly under -race; golangci-lint on the changed packages reports 0 issues.

Breaking changes

None. Error messages from ProcessProposal for these cases gain the malformed response from abci app: prefix.

Prior work

Attribution

🤖 Generated with Claude Code

🤖 Co-authored by Claudius the Magnificent AI Agent

lklimek and others added 19 commits November 9, 2026 13:26
…t in its round

A validator that saw a polka for a block it never received precommits nil
and, once its peers move to a later round, can no longer obtain the block:
block parts are served only from the proposal part set, which entering a
new round clears, while the valid and locked part sets that still hold the
block are never gossiped. Even when the block does arrive, one completed in
the prevote or precommit step is not processed, so an application that
verifies vote extensions against its last processed proposal, like Drive,
rejects every precommit for the block. Rejected precommits are not stored
and do not count towards the +2/3 of any kind that start the precommit
wait, so the validator stays in its round for good and a network without
spare voting power stalls with it.

Serve a validator peer at this height, in an earlier round, the complete
valid or locked part set whose header it is collecting, from the gossip
snapshot. Process the round's polka block when it completes too late for
the round to vote on it, so that the precommits for it verify; the node
casts no vote again, and a failure is not retried.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
A polka block the application rejects is processed once and not retried
on the precommits for it or on its parts arriving again; a block completing
in the prevote wait is processed there and not again in the precommit step;
one completing in the propose step with its proposal takes the usual path
and is processed once; a block completing without being the round's polka
block is not processed; an incomplete held part set is not served.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
A block completing while the round's polka is for another block is not
processed; a nil polka alone let the identity check go unexercised. The
rejected-block test no longer redelivers parts the part set already holds,
which completes nothing.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
… set is incomplete

heldBlockPartsFor skipped the held-block fallback whenever the round's
ProposalBlockParts carried the peer's part set header, even when that set
was incomplete and had nothing left to send. A complete current set still
suppresses the fallback, which would send nothing new anyway.

<sub>🤖 Co-authored by [Claudius the Magnificent](https://github.com/lklimek/claudius) AI Agent</sub>

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ommit step

A block that completed in the precommit step before its polka was never
processed: ProposalCompletedAction found no polka, and the prevote that
formed it later only updated the valid block, as the node had already
precommitted. The application then rejected every precommit for the block
and the node never started its precommit wait.

blockExecutor.processPolkaBlock now owns the condition (current-round
non-nil polka, matching proposal block, not yet processed) and is called
both on block completion and when the current round's polka forms in the
Precommit or PrecommitWait step. The polka path runs once per round, as
the valid round is set there, so a failed ProcessProposal is not retried.

<sub>🤖 Co-authored by [Claudius the Magnificent](https://github.com/lklimek/claudius) AI Agent</sub>

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s nil for it

When the polka formed in the prevote steps and enterPrecommit precommitted
nil because the round's proposal was missing or its timestamp differed from
the block's, the held polka block was never processed: the valid round was
already set and the block had completed earlier. The application then
rejected every precommit for it and the node never started its precommit
wait. Both nil branches now call processPolkaBlock before signing; it is a
no-op unless the held block is the unprocessed polka block, and
enterPrecommit runs once per round.

<sub>🤖 Co-authored by [Claudius the Magnificent](https://github.com/lklimek/claudius) AI Agent</sub>

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…h nil precommit

With no proposal held, a polka block can only be held unprocessed after
ProposalCompletedAction already tried and failed to process it, so the call in
that branch was a silent retry that contradicted the no-retry contract and was
not covered by any test. The timestamp-mismatch branch alone closes the stall.

<sub>🤖 Co-authored by [Claudius the Magnificent](https://github.com/lklimek/claudius) AI Agent</sub>

Co-Authored-By: Claude Opus 5.5 <[email protected]>
PartSet.IsComplete read count without the part set mutex that AddPart
writes it under. Consensus gossip checks the completeness of the
proposal part set the consensus state is filling, so the read raced
with AddPart.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A block that completed before its polka must be processed when the
polka forms after +2/3 precommits started the precommit wait, so that
the precommits for it verify. The valid-block middleware test passes a
real block executor rather than nil to the polka processing it calls.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
processPolkaBlock also runs before the node votes, and on the nil
precommit over a mismatched proposal timestamp, so its doc and log
messages no longer say the block arrived too late to vote on. The debug
log drops the step, which on the timestamp path is the step before
precommit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The node's own step never becomes RoundStepPrecommitWait: entering the
precommit wait only sets TriggeredTimeoutPrecommit and leaves the step
at RoundStepPrecommit, which the polka-block hook already checks.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…o a block

Drive verifies a vote extension against the block it accepted in the
precommit's round or, failing that, the same block accepted in another
round of the height; the polka-block recovery matters when it accepted
the block in neither. Other applications may require the same round.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…hout a proposal

A node whose signed proposal was dropped (its BlockID did not describe the
completed block) keeps the block but precommits nil without a proposal.
When +2/3 prevoted that block, the application never processed it in the
round, so peer precommits carrying extensions for it failed verification
and the precommit wait never started. Process the held polka block before
the nil precommit, as the timestamp-mismatch branch already does.

The test application's comment now describes the strict same-round
contract it enforces, which Drive relaxes to the same block accepted in
another round of the height.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ocessProposal error

A validator that precommitted nil and then completes the round's polka
block processes it once so peer precommit extensions verify. When that
ProcessProposal failed recoverably, nothing processed the block again:
ensureOwnRound restores only an already processed proposal, so every
peer precommit stayed rejected and precommit wait never started.

Schedule one pending retry per height, round and block ID on a dedicated
timer read by the consensus loop, with the delay doubling from 100ms up
to 5s. Duplicate triggers are coalesced. A due retry is dropped when the
node moved to another height, round or polka block, lost the complete
block, or has it processed already; no retry is scheduled after a
rejection, an invalid block, a stopped ABCI client or a canceled context.
The step timeout ticker is not used, so step timeouts are unaffected.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Add clearPolkaRetry and call it when a retry is replaced or dropped as
stale, when the receive routine exits, when OnStart fails, and before
the WAL catchup replay runs again after a repair, so no timer outlives
the state that armed it.

Treat an error wrapping context.Canceled as not worth retrying, and
state in ensureOwnRound's comment that only processPolkaBlock failures
are retried.

Test that an invalid block, a stopped ABCI client, a canceled context
or a canceled ctx schedule no retry, and that the delay stops growing
at polkaRetryMaxDelay.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
OnStart cleared the pending polka block retry before replaying a repaired
WAL. The repaired WAL holds only the records the first replay already
applied, so the second replay cannot arm the retry again: duplicate block
parts complete no proposal and duplicate prevotes form no new polka. A
retry armed by a transient ProcessProposal failure during the first
replay was lost, and the node kept rejecting precommits for the block.

Keep the retry; a failed start still clears it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…, not as call failures

ProcessProposal returned plain wrapped errors for an accepted response
with an app hash of the wrong size, a tx result count that does not
match the block, or an UNKNOWN status. The polka block retry could not
tell these from a failed call and retried them every few seconds for the
rest of the round, though the application answers the same way each time.

Wrap them in the new sm.ErrMalformedResponse and let tryPolkaBlock drop
them like a rejected or invalid block. Other callers do not check the
error type and behave as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Name the checks that wrap ErrMalformedResponse, update the prevote spec to
match, and stop the terminal polka log from claiming that precommits will be
rejected: the application still decides each vote extension.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@thepastaclaw

thepastaclaw commented Nov 27, 2026 •

Copy link
Copy Markdown

🕓 Review not started yet because this PR is a draft.

  • Request normal review — click when the PR is ready for review.
  • Request priority review — click to move this review to the front of the queue.

Commit 2d0dd0b. Normal review starts when eligible; priority review starts as soon as a slot is available.

Base automatically changed from fix/consensus-serve-polka-block to dev November 27, 2026 12:42

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants