Skip to content

blocksync: verify extended commits before storing them and stay in sync without a servable peer - #67

Merged
tqin7 merged 2 commits into
dydx-fork-v0.38.5from
tq/blocksync-sync-hardening
Oct 29, 2026
Merged

tqin7 merged 2 commits into
dydx-fork-v0.38.5from
tq/blocksync-sync-hardening

Conversation

@tqin7

@tqin7 tqin7 commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

Two block-sync hardening changes, each its own commit.

Verify a peer's extended commit before persisting it. Block sync verified the next block's LastCommit with VerifyCommitLight and checked the extended commit only for shape with EnsureExtensions, then stored it. Consensus later rebuilds LastCommit from that stored extended commit through ToExtendedVoteSet, which panics on a bad signature, so a peer could leave a node unable to switch to consensus. ValidatorSet.VerifyExtendedCommit now checks every precommit and extension signature plus the +2/3 threshold and returns an error, and the reactor runs it before SaveBlockWithExtendedCommit. A missing extended commit at a vote-extension height goes through the same peer-error path instead of the old "possible node store corruption" panic, since the block comes from a peer, not the store.

Stay in block sync when no peer can serve the next height. Since #57, updateMaxPeerHeight skips peers whose base is past pool.height. When every peer is skipped, maxPeerHeight is 0, which IsCaughtUp read as being at the tip, so a node could switch to consensus at a stale height. The pool now counts servable peers and reports not caught up when there are none. Peers at genesis still count, so a fresh network starts as before.

@tqin7
tqin7 force-pushed the tq/blocksync-sync-hardening branch from 6a1b996 to f35aac0 Compare October 29, 2026 16:17
tqin7 added 2 commits October 29, 2026 12:32
- ValidatorSet.VerifyExtendedCommit checks every precommit and extension signature and the +2/3 threshold, returning an error where ToExtendedVoteSet panics
- the reactor runs it before SaveBlockWithExtendedCommit and treats a missing extended commit at a vote-extension height as a peer error instead of panicking
- updateMaxPeerHeight counts the peers whose base is at or below pool.height
- IsCaughtUp returns false when that count is zero, so an all-pruned peer set no longer reads as being at the tip
@tqin7
tqin7 force-pushed the tq/blocksync-sync-hardening branch from f35aac0 to 3c54ad7 Compare October 29, 2026 16:32
@tqin7
tqin7 merged commit 00f56e5 into dydx-fork-v0.38.5 Oct 29, 2026
14 of 15 checks passed
@tqin7
tqin7 deleted the tq/blocksync-sync-hardening branch October 29, 2026 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants