Skip to content

Basic p2 p peer client#789

Draft
ChrisPaprocki wants to merge 6 commits into780-Basic-P2P-Peer-Client-Specfrom
780-Basic-P2P-Peer-Client
Draft

Basic p2 p peer client#789
ChrisPaprocki wants to merge 6 commits into780-Basic-P2P-Peer-Client-Specfrom
780-Basic-P2P-Peer-Client

Conversation

@ChrisPaprocki
Copy link
Collaborator

Description

Describe what this PR does and why. Keep it concise but include enough context
for reviewers who are not familiar with the area.

Related Issue(s)

Link any related issues, e.g. Fixes #123 or Relates to #456.

How was this tested?

Describe the tests that you ran to verify your changes. Include instructions
so reviewers can reproduce. Examples:

  • unit tests (command)
  • integration tests (how to run)
  • manual steps

Checklist

  • My code builds and passes local tests
  • I added/updated tests for my changes, where applicable
  • I updated documentation (if applicable)
  • branch has ≤ 5 commits (honor system)
  • commit messages tell a coherent story
  • branch is up to date with main (rebased on main; fast-forward possible)
  • CI/CD passes on the merged-with-main result

Impact / Side effects

Describe any potential side effects, e.g. performance, compatibility, or security concerns.
If the PR introduces a breaking change, explain migration steps for users.

Reviewer notes / Areas to focus

If you want specific feedback, list files/functions to review or aspects you are unsure about.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a basic P2P peer client to the Peer Network Interface (PNI) module, introducing peer-sharing based discovery plus cold/hot peer set management to improve resilience and decentralisation.

Changes:

  • Implement peer-sharing mini-protocol client (peer_sharing) and cold peer set management with cooldown/churn logic (peer_manager).
  • Extend NetworkManager to seed cold peers from config, maintain min_hot_peers, run periodic discovery + churn tickers, and add connect timeouts.
  • Add configuration keys + defaults, and introduce unit/integration tests for peer management and address validation.

Reviewed changes

Copilot reviewed 17 out of 18 changed files in this pull request and generated 15 comments.

Show a summary per file
File Description
specs/780-Basic-P2P-Peer-Client/spec.md Adds new functional requirements and traceability for multi-peer connection lifecycle.
modules/peer_network_interface/src/peer_sharing.rs Implements peer-sharing client, CBOR encoding/decoding, handshake gating, and address validation.
modules/peer_network_interface/src/peer_manager.rs Adds cold/failed peer sets, cooldown tracking, and cap/eviction mechanics.
modules/peer_network_interface/src/network.rs Integrates peer_manager/peer_sharing into NetworkManager with discovery + churn tickers and disconnect handling.
modules/peer_network_interface/src/connection.rs Adds TCP connect timeout to peer connections.
modules/peer_network_interface/src/configuration.rs Adds new config fields and defaults for peer discovery/churn/timeouts.
modules/peer_network_interface/config.default.toml Documents and provides defaults for new peer discovery settings.
modules/peer_network_interface/src/peer_network_interface.rs Exposes new modules and threads config through NetworkManager construction.
modules/peer_network_interface/src/chain_state.rs Extracts intersect-point selection into a shared helper for reuse.
modules/peer_network_interface/src/block_flow.rs Uses chain-state intersect-point sampling in consensus mode; keeps recent published points capped.
modules/peer_network_interface/src/block_flow_consensus_scenarios_tests.rs Updates test harness config to include new fields.
modules/peer_network_interface/tests/peer_sharing_tests.rs Adds tests for address validation and peer-sharing timeout behaviour.
modules/peer_network_interface/tests/peer_manager_tests.rs Adds tests for cold set, cap/eviction, cooldown, demotion behaviour, and churn gating.
modules/peer_network_interface/tests/configuration_tests.rs Verifies PeerManagerConfig defaults.
modules/peer_network_interface/Cargo.toml Adds dependencies required for new peer-sharing/peer-manager code.
modules/consensus/src/consensus.rs Lowers parent-missing log level from info to debug.
Cargo.toml / Cargo.lock Adds workspace dependency on rand and locks new crate versions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ChrisPaprocki ChrisPaprocki changed the title 780 basic p2 p peer client Basic p2 p peer client Mar 16, 2026
@ChrisPaprocki ChrisPaprocki force-pushed the 780-Basic-P2P-Peer-Client-Spec branch from 4d57a75 to 478eae0 Compare March 20, 2026 13:55
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