refactor(p2p): brand ingress-validated proposals with a ValidatedProposal type - #25222
Merged
Merged
Conversation
…osal type Block and checkpoint proposals are validated once, at p2p ingress, and the downstream validator-client handlers deliberately do not repeat those checks. Encode that precondition in the type system with branded ValidatedBlockProposal / ValidatedCheckpointProposalCore types, minted only where the gossipsub topic validator has accepted the proposal, so a raw inbound proposal can no longer reach the handlers. Compile-time only: no runtime behavior change.
alexghr
approved these changes
Aug 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #25207. That PR removed the duplicate downstream re-validation of inbound block and checkpoint proposals, leaving p2p ingress (gossipsub topic validation) as the single place proposals are validated. The downstream handlers document that precondition in prose; this PR enforces it with the type system.
ValidatedBlockProposalandValidatedCheckpointProposalCoretypes (plus their minting functions) instdlib/src/p2p/validated_proposal.ts, following the existingBranded<T, Brand>convention used byBlockNumberand friends.P2PBlockReceivedCallback,P2PCheckpointReceivedCallback) and the downstream consumers (ValidatorClient.validateBlockProposal/attestToCheckpointProposal,ProposalHandler.handleBlockProposal/handleCheckpointProposal, and theValidatorinterface) now take the branded types, so a raw inboundBlockProposal/CheckpointProposalCorecannot reach them.libp2p_service.ts, at the three points where the topic validator has already returnedAccept: the block-proposal topic path, the checkpoint-embedded block path (processBlockis only set after Accept), and the checkpoint path.Related to A-1703.