Skip to content

Conversation

@aschmahmann
Copy link
Contributor

No description provided.

Copy link

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

This PR adds support for libp2p private networks (pnet) by implementing swarm key functionality. The key change enables users to specify a private network swarm key file via a --pnet flag, which is then used to configure libp2p hosts for secure, isolated network operations.

  • Introduces pnet swarm key loading and context management
  • Updates all libp2p host creation points to accept and use context-based pnet configuration
  • Adds comprehensive test coverage for pnet functionality

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
main.go Adds global --pnet flag and Before hook to load swarm key into context; updates GetBitswapCID call signature
lib/pnet.go Implements pnet PSK loading from file and context storage/retrieval functions
lib/pnet_test.go Tests pnet PSK loading, validation, and network isolation behavior
lib/libp2p.go Updates libp2pHost to accept context and conditionally apply pnet configuration
lib/ping.go Passes context to libp2pHost call
lib/only_connect.go Passes context to libp2pHost call
lib/identify.go Passes context to libp2pHost call
lib/dht.go Passes context to libp2pHost call
lib/bitswap.go Updates CheckBitswapCID and GetBitswapCID to pass context to libp2pHost

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

@codecov
Copy link

codecov bot commented Dec 15, 2025

Codecov Report

❌ Patch coverage is 59.52381% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 27.16%. Comparing base (6f29ae7) to head (0375a4d).

Files with missing lines Patch % Lines
main.go 0.00% 10 Missing ⚠️
lib/pnet.go 80.00% 2 Missing and 2 partials ⚠️
lib/bitswap.go 33.33% 2 Missing ⚠️
lib/only_connect.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #60      +/-   ##
==========================================
+ Coverage   24.47%   27.16%   +2.69%     
==========================================
  Files           7        8       +1     
  Lines         568      578      +10     
==========================================
+ Hits          139      157      +18     
+ Misses        390      380      -10     
- Partials       39       41       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.


type pnetPSKContextKey struct{}

func WithPnetPSK(ctx context.Context, psk pnet.PSK) context.Context {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note: I went with the context plumbing approach mostly for ease. I'm also happy to swap this to something else (e.g. passing around libp2p options or switching to passing a host explicitly and then exposing a default constructor).

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