Skip to content

refactor(p2p): split InitialBroadcastSource out of ValidatedPoolReader - #11973

Merged
pierugo-dfinity merged 2 commits into
masterfrom
pierugo/p2p/split-initial-broadcast-source
Oct 29, 2026
Merged

pierugo-dfinity merged 2 commits into
masterfrom
pierugo/p2p/split-initial-broadcast-source

Conversation

@pierugo-dfinity

Copy link
Copy Markdown
Contributor

Why

ValidatedPoolReader<T> had two methods with disjoint users:

  • get is used only by P2P lookups: FetchArtifact's RPC handler and the stripped-message Pools (which serve peers and fill in stripped block proposals).
  • get_all_for_initial_broadcast is used only by create_artifact_handler in ic-artifact-manager, when it starts.

Every implementor still had to provide both, so several returned empty iterators or unimplemented!() for the method nobody called on them (the ingress pool, the stripped consensus pool wrapper, the mock and the bench fakes).

What

  • Keep ValidatedPoolReader<T> with only get, and move get_all_for_initial_broadcast into a new InitialBroadcastSource<T> trait in rs/interfaces/src/p2p/consensus.rs.
  • create_artifact_handler now requires InitialBroadcastSource instead of ValidatedPoolReader. create_ingress_handlers used neither method (it passes no initial artifacts), so it drops the bound altogether.
  • The consensus, certification, IDKG, DKG and canister HTTP pools (and TestConsensus) implement both traits, with unchanged method bodies.
  • The ingress pool, ConsensusPoolWrapper, MockValidatedPoolReader and the bench fakes only implement get. The ingress pool test that only asserted the removed method returned nothing is deleted.

No behavior change.

Testing

  • cargo check --all-targets --all-features, cargo fmt, ci/scripts/rust-lint.sh (clippy clean for all affected crates).
  • bazel test of the 118 tests within two rdeps hops of the changed files: all pass.

🤖 Generated with Claude Code

`ValidatedPoolReader` had two methods with disjoint users: P2P lookups
(`FetchArtifact`'s RPC handler and the stripped-message pools) only call
`get`, while `create_artifact_handler` only calls
`get_all_for_initial_broadcast`. Every implementor had to provide both,
so several returned empty iterators or `unimplemented!()` for the method
nobody called on them.

Move `get_all_for_initial_broadcast` into a new `InitialBroadcastSource`
trait and require it only in `create_artifact_handler`.
`create_ingress_handlers` used neither method, so it drops the bound
altogether, and the ingress pool, the stripped consensus pool wrapper,
the mock and the bench fakes no longer implement the unused method.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@pierugo-dfinity
pierugo-dfinity requested a balanced review from Copilot October 28, 2026 15:24
@pierugo-dfinity pierugo-dfinity changed the title refactor(p2p): split InitialBroadcastSource out of ValidatedPoolReader refactor(p2p): split InitialBroadcastSource out of ValidatedPoolReader` Oct 28, 2026
@pierugo-dfinity pierugo-dfinity changed the title refactor(p2p): split InitialBroadcastSource out of ValidatedPoolReader` refactor(p2p): split InitialBroadcastSource out of ValidatedPoolReader Oct 28, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues block the separation of startup broadcasting from artifact lookup.

No open issues 🎉

What changed in this PR

Separates startup broadcasting from artifact lookup in the P2P interfaces, allowing pools and test helpers to implement only the capabilities they use. Existing lookup and broadcast behavior is preserved.

Changes:

  • Extracts InitialBroadcastSource from ValidatedPoolReader and updates artifact-manager bounds.
  • Moves existing startup-broadcast implementations into the new trait.
  • Removes unused broadcast stubs and the obsolete ingress test.
File Description
rs/​p2p/​test_utils/​src/​mocks.rs Removes the broadcast method from the lookup mock.
rs/​p2p/​test_utils/​src/​consensus.rs Implements the new broadcast trait for TestConsensus.
rs/​p2p/​artifact_manager/​src/​lib.rs Requires the broadcast trait where needed and drops the unused ingress lookup bound.
rs/​p2p/​artifact_downloader/​src/​fetch_stripped_artifact/​assembler.rs Removes the unused broadcast stub from the consensus wrapper.
rs/​p2p/​artifact_downloader/​benches/​assembler.rs Removes unused broadcast stubs from benchmark pools.
rs/​interfaces/​src/​p2p/​consensus.rs Defines separate lookup and startup-broadcast traits.
rs/​artifact_pool/​src/​ingress_pool.rs Removes the empty broadcast implementation and its test.
rs/​artifact_pool/​src/​idkg_pool.rs Moves startup broadcasting into the new trait.
rs/​artifact_pool/​src/​dkg_pool.rs Moves startup broadcasting into the new trait.
rs/​artifact_pool/​src/​consensus_pool.rs Moves startup broadcasting into the new trait.
rs/​artifact_pool/​src/​certification_pool.rs Moves startup broadcasting into the new trait.
rs/​artifact_pool/​src/​canister_http_pool.rs Moves startup broadcasting into the new trait.

Review effort: Balanced

@pierugo-dfinity
pierugo-dfinity marked this pull request as ready for review October 28, 2026 15:37
@pierugo-dfinity
pierugo-dfinity requested a review from a team as a code owner October 28, 2026 15:37
@zeropath-ai

zeropath-ai Bot commented Oct 28, 2026

Copy link
Copy Markdown

✅ No security or compliance issues detected. Reviewed everything up to 7deab30.

Security Overview
Detected Code Changes
Change Type Relevant files
Enhancement ► rs/artifact_pool/src/canister_http_pool.rs
    Implement InitialBroadcastSource for CanisterHttpPoolImpl
► rs/artifact_pool/src/certification_pool.rs
    Implement InitialBroadcastSource for CertificationPoolImpl
Enhancement ► rs/artifact_pool/src/consensus_pool.rs
    Add InitialBroadcastSource trait implementation for ConsensusMessage in ConsensusPoolImpl
Enhancement ► rs/artifact_pool/src/dkg_pool.rs
    Implement InitialBroadcastSource for dkg::Message in DkgPoolImpl
Enhancement ► rs/artifact_pool/src/idkg_pool.rs
    Implement InitialBroadcastSource for IDkgMessage in IDkgPoolImpl
Enhancement ► rs/artifact_pool/src/ingress_pool.rs
    Add (or preserve) InitialBroadcastSource-related behavior for Ingress artifacts (context: initial broadcast source alignment)
Enhancement ► rs/interfaces/src/p2p/consensus.rs
    Introduce InitialBroadcastSource trait definition for artifacts
Enhancement ► rs/p2p/artifact_manager/src/lib.rs
    Update trait bounds to include InitialBroadcastSource on Pool types used for artifact handling
Enhancement ► rs/p2p/artifact_manager/src/lib.rs
    Adjust create_ingress_handlers signature and related code to accommodate InitialBroadcastSource dependency; adjust artifact handler creation to require InitialBroadcastSource
Enhancement ► rs/p2p/test_utils/src/consensus.rs
    Implement InitialBroadcastSource for U64Artifact in TestConsensus
Enhancement ► rs/p2p/artifact_downloader/benches/assembler.rs
    Remove get_all_for_initial_broadcast stub implementations in Fake pools
Enhancement ► rs/p2p/artifact_downloader/src/fetch_stripped_artifact/assembler.rs
    Remove get_all_for_initial_broadcast implementation for MaybeStrippedConsensusMessage

@pierugo-dfinity
pierugo-dfinity added this pull request to the merge queue Oct 29, 2026
Merged via the queue into master with commit 39c32ea Oct 29, 2026
41 checks passed
@pierugo-dfinity
pierugo-dfinity deleted the pierugo/p2p/split-initial-broadcast-source branch October 29, 2026 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants