Skip to content

refactor(state): replace commit-verification memo with typed VerifiedCommit token - #1456

Merged
lklimek merged 6 commits into
perf/verify-commit-oncefrom
feat/commit-verification-token
Sep 11, 2026
Merged

lklimek merged 6 commits into
perf/verify-commit-oncefrom
feat/commit-verification-token

Conversation

@lklimek

@lklimek lklimek commented Sep 11, 2026 •

Copy link
Copy Markdown
Collaborator

Issue being fixed or feature implemented

PR #1427 speeds up block sync by not re-verifying a commit's BLS threshold
signature three times over — once when it arrives, then twice more one
height later as the next block's LastCommit. It does this with a
throwaway "memo": a private, mutex-guarded cache inside BlockExecutor that
remembers the last couple of verified commits by height.

This PR replaces that memo with a typed proof of verification,
types.VerifiedCommit, so the guarantee is enforced by the type system
instead of living in ambient, shared, mutable state. The codebase already
uses this exact pattern for votes (types.VoteVerification) — this makes
Commit consistent with it.

What was done?

  • New types.VerifiedCommit (types/verified_commit.go): a commit paired
    with, optionally, proof that its threshold signatures were verified —
    VerifiedCommit{commit *Commit; proof *commitProof}. A nil proof is the
    "without proof" variant (Go's shape for the Rust-enum-style
    Unverified(Commit) | Verified{Commit, Proof} this models); the zero value
    and NewUnverifiedCommit(commit) both produce it. Commit() returns the
    held commit but is explicitly documented as not evidence — a caller must
    never validate this in place of the commit it actually received. Only
    VerifyCommitSignatures(vals, chainID, blockID, height, commit, budget)
    attaches a proof, and only on success, recording owned copies of everything
    a re-verification would check (chain ID, height, block ID, quorum
    type/hash, threshold key, signed digests and signatures).
  • The only way to use a proof is
    (*ValidatorSet).VerifyCommitUnlessVerified(...). It skips the real
    verification only on an exact match (checked by an unexported
    (*commitProof).checkMatches, nil-receiver-safe, which re-derives the
    digests and compares them by content — no BLS pairing, and deliberately no
    pointer-identity check against the commit the proof was minted with).
    Anything else, including a proof-less VerifiedCommit, falls through to
    the unchanged verifyCommit. Unlike the vote token, a mismatch is not
    rejected — it's a hint that may be absent, not a claim that must hold.
    This is what lets consensus and the replayer pass an unverified commit and
    keep verifying every commit in full, exactly as they do today.
  • verifyCommit is split into commitSignData + verifyCommitReportingSigns,
    with every existing typed-error path (budget exhaustion, the untyped
    vote-extension-count mismatch, the typed invalid-signature error) kept
    byte-identical — internal/statesync depends on this distinction to
    decide whether to disconnect a peer.
  • Executor.VerifyCommit returns the VerifiedCommit instead of writing
    into a private cache. ValidateBlock, ValidateBlockWithRoundState,
    FinalizeBlock and ApplyBlock each take the verification of
    block.LastCommit as an explicit parameter instead of consulting hidden
    state.
  • internal/blocksync/applier.go's blockApplier threads each commit's
    VerifiedCommit one block forward explicitly (guarded by its existing
    mutex, advanced only after a successful apply, reset on UpdateState) —
    this replaces the cross-height half of perf(blocksync): verify a commit once, not again as the next block's LastCommit #1427's memo with an explicit value
    instead of an ambient one.
  • perf(blocksync): verify a commit once, not again as the next block's LastCommit #1427's verifiedCommits/verifiedCommit/newVerifiedCommit/
    lastCommitVerified memo and its mutex are deleted entirely.
    internal/state/execution.go nets smaller (~140 lines removed, ~40
    added) despite the new capability.
  • state_last_commit_verification_skipped keeps its existing meaning: two
    skips per block during block sync, flat during consensus.

Minor behavior changes (found while replacing the memo, not by design)

How Has This Been Tested?

  • New types/verified_commit_test.go: the proof matches only an exact
    commit/chain/height/blockID/quorum-type/quorum-hash/key, rejects/falls
    through on distinct kinds of mismatch, survives mutation of its inputs
    after construction (TestVerifiedCommitProofSurvivesMutationOfItsInputs,
    now also pinning require.Same(t, minted.commit, verified.Commit()) —
    the embedded pointer is the caller's own, not a copy), a proof-less
    VerifiedCommit never skips even when it holds the exact commit being
    verified (TestUnverifiedCommitMatchesNothing), and the fall-through path
    returns exactly the same error VerifyCommit would
    (TestVerifiedCommitKeepsTheVerifyCommitErrors across forged signature,
    wrong block ID, wrong quorum hash, wrong height, and
    vote-extension-count mismatch).
  • internal/blocksync/applier_test.go:
    TestBlockApplierSkipsTheLastCommitItVerified drives three real blocks
    through sm.BlockExecutor and asserts LastCommitVerificationSkipped
    reaches 0/2/4 after heights 1/2/3 — mutation-tested by temporarily
    swapping the applier's forwarded value for an unverified one, which turns
    the assertion red (2 expected vs 0 actual) before being reverted.
  • Mocks (internal/state/mocks/executor.go) regenerated via mockery
    (go:generate), not hand-edited; every mock expectation on the four
    call sites now using NewUnverifiedCommit was audited — none is pinned to
    the old zero-value literal.
  • go build ./...: clean. gofmt: clean. make lint
    (golangci-lint --new-from-rev=origin/perf/verify-commit-once):
    0 issues. go test -count=1 ./types/... ./internal/state/...: all
    green. go test -tags=deadlock ./types/... ./internal/state/... ./internal/blocksync/... ./dash/quorum/...: all green.
    go test -mod=readonly -timeout=5m -race ./internal/consensus/...
    (full, unfiltered): ok, 127.8s.
  • go test -race ./internal/blocksync/... hits two known, pre-existing
    timing flakes unrelated to this change
    (TestReactor_NoBlockResponse, TestSynchronizer/TestClientTimeoutUnwedgesAFullWindow).
    Confirmed pre-existing by a same-load A/B against the pre-rework baseline:
    both flake at the same rate (11/12 and 10/12 pass) on both sides, and
    the rework side passed 12/12 in the same run. All of the above
    independently re-verified by the coordinator, not just taken from the
    implementer's report.
  • Not reproduced here (out of scope for this PR): perf(blocksync): verify a commit once, not again as the next block's LastCommit #1427's 3000-block replay
    throughput benchmark.

Breaking Changes

None externally. state.Executor (internal interface) changes signature —
internal only, all implementations/mocks updated in this PR.

Detailed discussion

Stacked on #1427 (perf/verify-commit-once) — this PR's base is that
branch, not v1.8-dev; #1427's own commits are untouched.

The type was originally implemented as types.CommitVerification (a
proof-only token, checked against a separately-held commit) and then
reworked, in a follow-up commit on this same branch, into
types.VerifiedCommit as described above — the commit is now embedded in
the value itself rather than threaded alongside it. This branch also
carries an unrelated test-only fix for the pre-existing TestWALRoundsSkipper
flake (also shipped standalone against v1.8-dev as #1457).

A third commit removed NewUnverifiedCommit, the exported constructor the
rework initially added for the "commit held, no proof" case: it let any
caller build a value named VerifiedCommit that named a real commit while
attaching no proof, and nothing outside tests ever called .Commit() on
one. The four call sites that used it (consensus's finalize/validate,
ProcessProposal, the replayer) never read the commit back off the value
either — they only pass it into VerifyCommitUnlessVerified, which already
falls through to a full verification on any proof-less value. All four now
pass the zero VerifiedCommit{}, the only proof-less value code outside
types can produce.

Deliberately out of scope for this PR (left as follow-up candidates):

  • blockExec.cache (block-hash-keyed, unlocked, ignores state/lastCommit)
    is a separate, pre-existing shortcut with its own correctness questions —
    noted, not touched.
  • Minting a VerifiedCommit on the consensus side
    (StateData.verifyCommit, TryAddCommitAction) so consensus can also
    skip redundant re-verification — the explicit-parameter shape here makes
    that a drop-in change later, but it's excluded from this PR's scope.
  • A broader follow-up is being scoped separately: checking, at every use
    site of Vote/Commit (not just the redundant-BLS-verify hot spots
    addressed here), that the value in hand still applies to the current
    block/state/height context.

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have made corresponding changes to the documentation

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

🤖 Generated with Claude Code

lklimek and others added 2 commits September 11, 2026 09:34
…tion

VerifyCommitSignatures verifies a commit exactly as ValidatorSet.VerifyCommit
does and, on success, returns a CommitVerification recording the chain,
height, block ID, quorum, threshold key and the signed digests and signatures
it checked. ValidatorSet.VerifyCommitUnlessVerified skips the threshold
verification only when a verification covers exactly those inputs. Anything
else, including the zero value, falls through to the unchanged verifyCommit,
so its typed errors (ErrInvalidCommitSignature versus the untyped
vote-extension count mismatch and budget exhaustion) are preserved.

verifyCommit is split into commitSignData and verifyCommitReportingSigns with
every error path unchanged.

Co-Authored-By: Claude Opus 5 <[email protected]>
…rification token

BlockExecutor.VerifyCommit returns a types.CommitVerification instead of
recording it in a private two-slot memo. ValidateBlock,
ValidateBlockWithRoundState, FinalizeBlock and ApplyBlock take the
verification of block.LastCommit explicitly. Block sync's applier threads the
verification of each commit one block forward; consensus and the replayer pass
the zero value and verify in full as before. The
state_last_commit_verification_skipped metric keeps its meaning.

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

coderabbitai Bot commented Sep 11, 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

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 9da1b025-460d-4561-897f-dc6f45b6d6b3

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

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

Comment @coderabbitai help to get the list of available commands.

The WAL generator node is the only validator, so it proposes every round,
and replayPrevoter makes heights 3 to 5 commit only at round 10. The test
genesis gives round 10 a 30.5ms propose timeout. On a loaded runner (-race,
-coverprofile, several packages at once) that timer fires before the node's
own proposal is complete, so it prevotes nil and moves to round 11:
- at height 5, stopConsensusAtHeight(5, 11) halts consensus and the test
  times out after 60s ("waited too long for tendermint to produce 5
  blocks"), which is the failure seen on #1391, #1393 and #1410;
- at height 3 or 4, the commit lands past maxRound and the round assertion
  fails.

Give the generator a 10s propose timeout. With a single proposer, a round
moves on as soon as the proposal is complete, so a longer timeout only
removes the race. UnsafeProposeTimeoutOverride is node-local and not a
consensus parameter, so the blocks are unchanged.

TestWALRoundsSkipperSlowProposer pins this. Its app holds PrepareProposal at
round 10 for three times the genesis propose timeout. Without the override
it fails every run; with it, it passes every run.

Once the test survives load, a second pre-existing flake surfaces. The
replaying State and its WAL keep running after Stop/Wait: receiveRoutine
exits only when it sees its context cancelled, and the services' ctx
watchers log asynchronously. Their logs through NewTestingLogger then land
after the test completes and panic the binary ("Log in goroutine after
TestWALRoundsSkipper has completed"). The test now logs through a writer
that is muted, under a lock, by its first-registered cleanup.

Co-Authored-By: Claude Opus 5 <[email protected]>
@lklimek
lklimek changed the base branch from perf/verify-commit-once to v1.8-dev September 11, 2026 11:21
types.CommitVerification only carried proof metadata, checked against a
commit passed alongside it. It becomes types.VerifiedCommit: the commit
itself plus an optional proof.

    type VerifiedCommit struct {
        commit *Commit       // the caller's pointer, the subject only
        proof  *commitProof  // nil: no proof
    }

commitProof keeps the nine fields CommitVerification recorded, with their
doc comments.
- VerifyCommitSignatures keeps its signature, checks and errors. It returns
  the commit with a proof on success, and the zero VerifiedCommit on failure.
- NewUnverifiedCommit(commit) builds the no-proof variant. The zero value is
  NewUnverifiedCommit(nil).
- Commit() returns the embedded pointer. Its doc spells out that it is not
  evidence and must never be validated in place of the commit actually
  received.
- checkMatches moves to *commitProof and treats a nil receiver as "nothing
  was verified". It compares commit content only, never pointer identity.
- errCommitVerificationMismatch becomes errCommitProofMismatch.

Only the parameter types change at the call sites. block.LastCommit is
still read from the block, and the current-height commit parameter of
ApplyBlock/FinalizeBlock is untouched. Consensus (finalize, validate),
ProcessProposal and the replayer pass NewUnverifiedCommit(block.LastCommit);
the block-sync applier keeps the zero value where it holds no commit. Mocks
are regenerated with mockery v3.7.4.

Tests:
- the types tests are renamed to VerifiedCommit;
- the proof-mutation test pins with require.Same that the embedded commit
  aliases the caller's pointer;
- a new case shows that a VerifiedCommit without proof, even one holding
  the very commit being verified, never skips verification;
- the new TestBlockApplierSkipsTheLastCommitItVerified drives three blocks
  through a real executor and asserts LastCommitVerificationSkipped reaches
  0, 2 and 4. It fails if the applier hands the next block the commit
  without its proof;
- metricspy gains a Counter for it.

Co-Authored-By: Claude Opus 5 <[email protected]>
@lklimek lklimek changed the title refactor(state): replace commit-verification memo with typed CommitVerification token refactor(state): replace commit-verification memo with typed VerifiedCommit token Sep 11, 2026
@lklimek
lklimek changed the base branch from v1.8-dev to perf/verify-commit-once September 11, 2026 12:37
@lklimek
lklimek marked this pull request as ready for review September 11, 2026 12:38
GitHub Actions never picked up 0eccc06 (no check-suite created for it
after 45+ minutes, unlike every prior push on this branch) — pushing an
empty commit to force a fresh push event.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@thepastaclaw

thepastaclaw commented Sep 11, 2026 •

Copy link
Copy Markdown

🕓 Queued for automated review — 15th in line, estimated start in ~3.0 h (commit dacaefb)
Estimated review time once started: ~25 min (two-phase automated review; median of recent runs).

  • Request priority review — tick this box and the review moves to the front of the queue.

…ifiedCommit

NewUnverifiedCommit let any caller wrap an arbitrary commit into a value of
a type named VerifiedCommit while attaching no proof at all -- a naming
trap, and unused by anything that reads Commit(): nothing outside tests
ever called it. The four call sites that used it to signal "no proof held"
never read the commit back off the value either; they only pass it into
VerifyCommitUnlessVerified, which already falls through to a full
verification on any proof-less value, zero value included.

Remove the constructor. The zero value is now the only proof-less
VerifiedCommit that code outside types can produce, and it is the only one
that matters in practice: consensus, the replayer and block sync's
ProcessProposal path all switch to it. The still-exported Commit() and the
commit field stay -- VerifyCommitSignatures is still the only way to end up
with a VerifiedCommit that names a real commit, and it always pairs one
with its proof.

TestUnverifiedCommitMatchesNothing keeps its "holds the exact commit but no
proof" case as an in-package struct literal: a white-box test proving the
mismatch check would still refuse to skip verification even in that
stronger, no-longer-reachable-from-outside scenario.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@lklimek
lklimek merged commit e7d505f into perf/verify-commit-once Sep 11, 2026
18 checks passed
@lklimek
lklimek deleted the feat/commit-verification-token branch September 11, 2026 13:22
lklimek added a commit that referenced this pull request Sep 11, 2026
…LastCommit (#1427)

* perf(blocksync): verify a commit once, not again as the next block's LastCommit

Block sync threshold-verifies the commit for block N in blockApplier.verify, and
one height later the same commit comes back as block N+1's LastCommit and is
verified a second time inside validateBlock. Every commit was verified twice, a
block apart, at roughly 1.9 ms each.

The applier now records what it verified through a new Executor.NoteVerifiedCommit
and validateBlock takes a lastCommitVerified hint. The skip fires only on an exact
match of every input ValidatorSet.verifyCommit reads: chain ID, height, block ID,
quorum type, quorum hash, threshold public key, and a byte-identical marshalled
commit. Marshalling rather than using Commit.Hash() matters, because that hash
only covers ThresholdBlockSignature and would miss Round and the vote extensions.
Anything short of a full match falls through to a real verification.

The note is stored after ApplyBlock returns, not before: both places that would
re-verify this commit run while the *next* block is applied, so writing it earlier
would overwrite the entry they are still reading for the current block and the
skip would never fire. The validator set is captured before ApplyBlock, which
reassigns e.state.

The consensus path never calls NoteVerifiedCommit, so the memo stays nil there and
nothing changes. It is an atomic.Pointer written and read whole, never
read-modify-write, and blockApplier.Apply is serialised under its own mutex.

Replaying mainnet, the applier's verify stage goes from 3.61 ms to 1.84 ms a block.

* perf(state): skip the second LastCommit verification when the memo proves it ran (#1428)

ValidateBlockWithRoundState verifies block.LastCommit even though the ValidateBlock
call at the top of the same function normally does it. That second verification is
load-bearing rather than redundant: ValidateBlock short-circuits on blockExec.cache,
which is keyed on the block hash alone and carries no promise about the state the
earlier validation ran against. Removing it outright breaks TestStateProposalTime.

So gate it on the memo added in the previous change instead of on the cache. The
skip happens only when this exact commit was already verified against identical
inputs — same chain ID, height, block ID, quorum type, quorum hash, threshold
public key and byte-identical marshalled commit. That is a property of the data,
not of the cache, so it holds no matter which path populated the cache.

Replaying mainnet, this stage goes from 1.81 ms a block to 0.007 ms. Together with
the previous change block sync performs one threshold verification per block
instead of three.

* test(state): cover the verified-commit memo directly

TestLastCommitAlreadyVerified checks the memo matches only on a full match of every input VerifyCommit reads, and falls through when the chain ID, height, block ID, quorum type, quorum hash, threshold key or any commit field differs. TestApplyBlockSkipsVerifiedLastCommit drives a real BlockExecutor with genuine BLS commits through ApplyBlock: a noted commit is not threshold-verified again, a forged commit that was never noted is rejected, and a memo for a different commit does not cover a forged one.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* test(state): fold the ApplyBlock drive into the memo fixture

Replace the blockAndID closure with a fixture method so each subtest reads as note-then-assert, use slices.Clone for the vote extensions, and move the cache comment above the call it explains.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* refactor(state): verify commits through the executor so the memo cannot be fed unverified ones

NoteVerifiedCommit took the caller's word that a commit had been verified. Replace it with Executor.VerifyCommit, which runs the threshold verification itself and remembers the result only on success. The block sync applier now verifies through it; nothing else can write the memo.

The memo keeps the two most recent commits instead of one: VerifyCommit for commit N runs before block N is validated, and block N's LastCommit is commit N-1, so both must be present. This also removes the ordering constraint that forced the applier to record the note only after ApplyBlock returned.

Every slice-backed field in the memo is now an owned copy, so mutation of the validator set, block ID or commit after verification cannot change what it matches. validateBlock takes the hint as a closure, so the memo is consulted only after ValidateBasic and the cheaper header checks. A new state_last_commit_verification_skipped counter makes the skip observable, and a marshal failure on the memo path is logged instead of swallowed.

* refactor(state): replace commit-verification memo with typed VerifiedCommit token (#1456)

* feat(types): add CommitVerification, a typed proof of commit verification

VerifyCommitSignatures verifies a commit exactly as ValidatorSet.VerifyCommit
does and, on success, returns a CommitVerification recording the chain,
height, block ID, quorum, threshold key and the signed digests and signatures
it checked. ValidatorSet.VerifyCommitUnlessVerified skips the threshold
verification only when a verification covers exactly those inputs. Anything
else, including the zero value, falls through to the unchanged verifyCommit,
so its typed errors (ErrInvalidCommitSignature versus the untyped
vote-extension count mismatch and budget exhaustion) are preserved.

verifyCommit is split into commitSignData and verifyCommitReportingSigns with
every error path unchanged.

Co-Authored-By: Claude Opus 5 <[email protected]>

* refactor(state): replace commit-verification memo with typed CommitVerification token

BlockExecutor.VerifyCommit returns a types.CommitVerification instead of
recording it in a private two-slot memo. ValidateBlock,
ValidateBlockWithRoundState, FinalizeBlock and ApplyBlock take the
verification of block.LastCommit explicitly. Block sync's applier threads the
verification of each commit one block forward; consensus and the replayer pass
the zero value and verify in full as before. The
state_last_commit_verification_skipped metric keeps its meaning.

Co-Authored-By: Claude Opus 5 <[email protected]>

* test(consensus): deflake TestWALRoundsSkipper

The WAL generator node is the only validator, so it proposes every round,
and replayPrevoter makes heights 3 to 5 commit only at round 10. The test
genesis gives round 10 a 30.5ms propose timeout. On a loaded runner (-race,
-coverprofile, several packages at once) that timer fires before the node's
own proposal is complete, so it prevotes nil and moves to round 11:
- at height 5, stopConsensusAtHeight(5, 11) halts consensus and the test
  times out after 60s ("waited too long for tendermint to produce 5
  blocks"), which is the failure seen on #1391, #1393 and #1410;
- at height 3 or 4, the commit lands past maxRound and the round assertion
  fails.

Give the generator a 10s propose timeout. With a single proposer, a round
moves on as soon as the proposal is complete, so a longer timeout only
removes the race. UnsafeProposeTimeoutOverride is node-local and not a
consensus parameter, so the blocks are unchanged.

TestWALRoundsSkipperSlowProposer pins this. Its app holds PrepareProposal at
round 10 for three times the genesis propose timeout. Without the override
it fails every run; with it, it passes every run.

Once the test survives load, a second pre-existing flake surfaces. The
replaying State and its WAL keep running after Stop/Wait: receiveRoutine
exits only when it sees its context cancelled, and the services' ctx
watchers log asynchronously. Their logs through NewTestingLogger then land
after the test completes and panic the binary ("Log in goroutine after
TestWALRoundsSkipper has completed"). The test now logs through a writer
that is muted, under a lock, by its first-registered cleanup.

Co-Authored-By: Claude Opus 5 <[email protected]>

* refactor(types): turn CommitVerification into VerifiedCommit

types.CommitVerification only carried proof metadata, checked against a
commit passed alongside it. It becomes types.VerifiedCommit: the commit
itself plus an optional proof.

    type VerifiedCommit struct {
        commit *Commit       // the caller's pointer, the subject only
        proof  *commitProof  // nil: no proof
    }

commitProof keeps the nine fields CommitVerification recorded, with their
doc comments.
- VerifyCommitSignatures keeps its signature, checks and errors. It returns
  the commit with a proof on success, and the zero VerifiedCommit on failure.
- NewUnverifiedCommit(commit) builds the no-proof variant. The zero value is
  NewUnverifiedCommit(nil).
- Commit() returns the embedded pointer. Its doc spells out that it is not
  evidence and must never be validated in place of the commit actually
  received.
- checkMatches moves to *commitProof and treats a nil receiver as "nothing
  was verified". It compares commit content only, never pointer identity.
- errCommitVerificationMismatch becomes errCommitProofMismatch.

Only the parameter types change at the call sites. block.LastCommit is
still read from the block, and the current-height commit parameter of
ApplyBlock/FinalizeBlock is untouched. Consensus (finalize, validate),
ProcessProposal and the replayer pass NewUnverifiedCommit(block.LastCommit);
the block-sync applier keeps the zero value where it holds no commit. Mocks
are regenerated with mockery v3.7.4.

Tests:
- the types tests are renamed to VerifiedCommit;
- the proof-mutation test pins with require.Same that the embedded commit
  aliases the caller's pointer;
- a new case shows that a VerifiedCommit without proof, even one holding
  the very commit being verified, never skips verification;
- the new TestBlockApplierSkipsTheLastCommitItVerified drives three blocks
  through a real executor and asserts LastCommitVerificationSkipped reaches
  0, 2 and 4. It fails if the applier hands the next block the commit
  without its proof;
- metricspy gains a Counter for it.

Co-Authored-By: Claude Opus 5 <[email protected]>

* chore: retrigger CI

GitHub Actions never picked up 0eccc06 (no check-suite created for it
after 45+ minutes, unlike every prior push on this branch) — pushing an
empty commit to force a fresh push event.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* refactor(types): drop NewUnverifiedCommit, the only way to fake a VerifiedCommit

NewUnverifiedCommit let any caller wrap an arbitrary commit into a value of
a type named VerifiedCommit while attaching no proof at all -- a naming
trap, and unused by anything that reads Commit(): nothing outside tests
ever called it. The four call sites that used it to signal "no proof held"
never read the commit back off the value either; they only pass it into
VerifyCommitUnlessVerified, which already falls through to a full
verification on any proof-less value, zero value included.

Remove the constructor. The zero value is now the only proof-less
VerifiedCommit that code outside types can produce, and it is the only one
that matters in practice: consensus, the replayer and block sync's
ProcessProposal path all switch to it. The still-exported Commit() and the
commit field stay -- VerifyCommitSignatures is still the only way to end up
with a VerifiedCommit that names a real commit, and it always pairs one
with its proof.

TestUnverifiedCommitMatchesNothing keeps its "holds the exact commit but no
proof" case as an in-package struct literal: a white-box test proving the
mismatch check would still refuse to skip verification even in that
stronger, no-longer-reachable-from-outside scenario.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

---------

Co-authored-by: Claude Opus 5 <[email protected]>

* perf(state): offer the verified LastCommit to ProcessProposal

Since block sync validates the app response through
ProcessProposal(verify=true), ValidateBlockWithRoundState runs there with
a hard-coded zero proof, so every synced block threshold-verified its
LastCommit once more even though the applier already held the proof.

ProcessProposal takes lastCommit and forwards it to the verify branch.
The block applier hands it the proof it carries forward; consensus and
the replayer hold none and pass the zero value. ApplyBlock passes its own
lastCommit through for uniformity; it is unread with verify unset.

TestBlockApplierSkipsTheLastCommitItVerified now expects three skips per
height after the first, and fails against the previous commit.

Co-Authored-By: Claude Opus 5 <[email protected]>

* test(state): trim the ApplyBlock LastCommit verification tests

- Count skipped verifications with metricspy.Counter instead of a local
  duplicate of it.
- Drop the subtest applying a forged commit with the verification
  VerifyCommit returned on rejecting it: that verification is the zero
  value, already pinned by "rejected commit yields no verification" and
  TestVerifiedCommitKeepsTheVerifyCommitErrors, and a forged LastCommit
  without proof is pinned by "unverified forged commit is rejected".
- TestApplyBlockSkipsVerifiedLastCommit covers ApplyBlock only; block sync
  no longer calls it, so point to the block sync pin instead.

Co-Authored-By: Claude Opus 5 <[email protected]>

---------

Co-authored-by: lklimek <[email protected]>
Co-authored-by: Claude Fable 5.1 <[email protected]>
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.

2 participants