feat(p2p): add connection logging behaviour and global peer context#202
Merged
Conversation
- Pending `GitCommit` implementation
- Move parse method to `impl` block
- Include Git commit - Include timestamp - Include env version if any
Closed
iamquang95
reviewed
Feb 23, 2026
emlautarom1
requested changes
Feb 23, 2026
Collaborator
emlautarom1
left a comment
There was a problem hiding this comment.
There are multiple points in this PR:
- The move to
Streamfor p2p behaviors. - The refactoring of how we construct nodes and relay servers
- Connection logging
Overall looks good, but it would have been better to have it as stacked PRs.
The only issue that I see is on the refactoring where the code for constructing nodes and relays is quite convoluted and could use some improvements.
Some tests seem excessive (most likely AI generating for the sake of it) and I expect that we can trim them down with some minor changes.
emlautarom1
approved these changes
Feb 24, 2026
Collaborator
emlautarom1
left a comment
There was a problem hiding this comment.
LGTM. We'll revisit the constructor code later, for now no need to worry about it.
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.
This PR implements connection logging behaviour
Summary
This PR introduces connection logging functionality to the P2P module, porting the connection logging behaviour from Charon Go. The implementation tracks and logs libp2p connection lifecycle events while exposing connection metrics.
Key Changes
Connection Logger Behaviour (
conn_logger.rs): A newNetworkBehaviourimplementation that:ConnectionLoggerMetricstrait with default and test implementationsGlobal Context (
global_context.rs): Introduces a sharedGlobalContextwith a thread-safePeerStorefor tracking active/inactive peers across the P2P stackOptional Behaviour Wrapper (
optional.rs): A genericOptionalBehaviour<B>wrapper that allows behaviours to be conditionally enabled, simplifying behaviour compositionPluto Behaviour Refactoring:
PlutoBehaviourto useOptionalBehaviourfor the inner behaviourGlobalContextintegration to the behaviour builderNode API Improvements:
Nodenow implementsStreamfor ergonomic event handlingGlobalContextpropagation through node creationGlobalContextfor inner behaviour constructionUtility Additions: Helper functions for detecting relay addresses (
is_relay_addr) and QUIC addresses (is_quic_addr), plus connection type/protocol classificationTest Plan
p2p.rsexample with multiple nodes to validate mDNS discovery and relay connections