feat: add rust-p2p skill#356
Conversation
| **Critical failure mode:** if `conn_logger` writes context A while an inner | ||
| behaviour reads context B, the inner behaviour will treat connected peers as | ||
| disconnected. |
There was a problem hiding this comment.
This paragraph is not very clear (why conn_logger? Write what specifically? Is this a matter of ordering?)
There was a problem hiding this comment.
The conn_logger is a core behaviour in PlutoBehaviour. The peer_store in p2p_context is updated by conn_logger, and other behaviours use that peer_store.
/// Pluto network behaviour.
///
/// Combines multiple libp2p protocols:
/// - **Connection logging**: Tracks connections and updates peer store (first
/// to ensure other behaviours see updated peer state)
/// - **Connection gating**: Controls which connections are allowed
/// - **Identify**: Exchanges peer information and supported protocols
/// - **Ping**: Measures latency and keeps connections alive
/// - **AutoNAT**: Detects NAT status and public reachability
/// - **QUIC upgrade**: Periodically upgrades TCP connections to QUIC
#[derive(NetworkBehaviour)]
pub struct PlutoBehaviour<B: NetworkBehaviour> {
/// Connection logger behaviour - MUST be first so peer store is updated
/// before other behaviours process connection events.
pub conn_logger: ConnectionLoggerBehaviour<DefaultConnectionLoggerMetrics>,
/// Connection gater behaviour.
pub gater: ConnGater,
/// Identify behaviour.
pub identify: identify::Behaviour,
/// Ping behaviour.
pub ping: ping::Behaviour,
/// AutoNAT behaviour for NAT detection.
pub autonat: autonat::Behaviour,
/// QUIC upgrade behaviour for upgrading TCP to QUIC connections.
pub quic_upgrade: QuicUpgradeBehaviour,
/// Inner behaviour.
pub inner: OptionalBehaviour<B>,
}Ordering matters because #[derive(NetworkBehaviour)] delegates each trait method to fields in struct order. For poll(), it polls first field until Pending, then next field. That's why the conn_logger has to be placed on the top in PlutoBehaviour.
| - poll retry/routing timers, | ||
| - translate handler events into feature events. | ||
|
|
||
| `poll` rules: |
There was a problem hiding this comment.
Does libp2p have any skills on the topic? Maybe we could incorporate them if so.
There was a problem hiding this comment.
I couldn't find any skill related to rust-libp2p. Later if we can find some, we can improve our skill.
This add skill to help agents implement and review rust libp2p related package