Skip to content

refactor(p2p): brand ingress-validated proposals with a ValidatedProposal type - #25222

Merged
spalladino merged 1 commit into
merge-train/spartan-v5from
spl/validated-proposal-brand
Aug 14, 2026
Merged

refactor(p2p): brand ingress-validated proposals with a ValidatedProposal type#25222
spalladino merged 1 commit into
merge-train/spartan-v5from
spl/validated-proposal-brand

Conversation

@spalladino

Copy link
Copy Markdown
Contributor

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.

  • Adds branded ValidatedBlockProposal and ValidatedCheckpointProposalCore types (plus their minting functions) in stdlib/src/p2p/validated_proposal.ts, following the existing Branded<T, Brand> convention used by BlockNumber and friends.
  • The p2p received-proposal callbacks (P2PBlockReceivedCallback, P2PCheckpointReceivedCallback) and the downstream consumers (ValidatorClient.validateBlockProposal / attestToCheckpointProposal, ProposalHandler.handleBlockProposal / handleCheckpointProposal, and the Validator interface) now take the branded types, so a raw inbound BlockProposal / CheckpointProposalCore cannot reach them.
  • The brands are minted only in libp2p_service.ts, at the three points where the topic validator has already returned Accept: the block-proposal topic path, the checkpoint-embedded block path (processBlock is only set after Accept), and the checkpoint path.
  • Purely a compile-time marker: no runtime validation is added and there is no behavior change. The only non-type edits are in tests, which mint validated proposals from constructed ones.

Related to A-1703.

…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.
@github-actions github-actions Bot added the port-to-next Forward-port this merged PR into next label Aug 14, 2026
@spalladino spalladino removed the port-to-next Forward-port this merged PR into next label Aug 14, 2026
@spalladino
spalladino merged commit 9118206 into merge-train/spartan-v5 Aug 14, 2026
14 checks passed
@spalladino
spalladino deleted the spl/validated-proposal-brand branch August 14, 2026 13:00
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