ping: Conform to the spec & exclude from connection keep-alive#416
Conversation
dmitry-markin
left a comment
There was a problem hiding this comment.
Hey, this is going in the right direction, but there should be a way to simplify the implementation by not introducing separate async tasks for inbound/outbound substreams and not adding command channels. It should be possible to implement polling of inbound substreams by putting them into FuturesUnordered or, may be, tokio_stream::StreamMap. The latter should be quite easy as there is maximum one inbound substream allowed from any remote peer as per ping spec: https://github.com/libp2p/specs/blob/master/ping/ping.md
|
@dmitry-markin can you check my current implementation |
There was a problem hiding this comment.
Hey hey, nice use of SplitStream/SplitSink! I think what is missing is a cleaner separation between inbound and outbound substreams. On inbound substreams we should only respond to incoming pings, and on outbound send pings ourself. It would be better than relying on the presence of the time in the map, which can get screwed when we both send pings to a peer and receive pings from it.
i have done this now @dmitry-markin |
|
Out of scope for this PR but I noticed that |
There was a problem hiding this comment.
FWIW, I ran the following tests, using a litep2p listener and webrtc transport:
| Dialer | Listener -> Dialer Pings | Dialer -> Listener Pings |
|---|---|---|
| libp2p | ❌ | ✅ |
| "minimal smoldot env" | ✅ | ✅ |
The failing outbound pings with libp2p is an unrelated issue (#494).
|
@lexnv @haikoschol @dmitry-markin please help review |
LGTM, but my approval doesn't count towards mergeability. |
…mi/repeat-request-periodically
|
@lexnv @haikoschol Can you review the PR one more time, please? I have pushed some fixes and it should be ready for merging now. One thing that makes me worry a bit, is that connection keep-alive is finally working and closing the connections, and we have only request-response protocols keeping the connection open, because no other protocols open new substreams and kick |
| @@ -104,13 +117,19 @@ impl ConfigBuilder { | |||
| self | |||
| } | |||
|
|
|||
There was a problem hiding this comment.
Nit: Is cargo doc check ignoring missings docs on public methods? We should also document this and state the defaults (same for above in public interfaces)
There was a problem hiding this comment.
litep2p doesn't have #![warn(missing_docs)] set. But this is for another PR :)
haikoschol
left a comment
There was a problem hiding this comment.
LGTM, although I feel like I can't really assess the impact of the changes on the keepalive mechanism.
What I can say is that these changes do not seem to cause any issues when connecting from smoldot using webrtc. I've merged them into the branch I've been using for testing and it worked like a charm.
## [0.13.1] - 2026-02-27 This release includes multiple fixes of transports and protocols, fixing connection stability issues with other librariies (specifically, [smoldot](https://github.com/smol-dot/smoldot/)) and increasing success rates of dialing & opening substreams, especially in extreme cases when remote nodes have a lot of private addresses published to the DHT. ### Fixed - ping: Conform to the spec & exclude from connection keep-alive ([#416](#416)) - transport: Make accept async to close the gap on service races ([#525](#525)) - transport: Limit dial concurrency and bound total dialing time ([#538](#538)) - webrtc: Support `FIN`/`FIN_ACK` handshake for substream shutdown ([#513](#513)) - transport: Expose failed addresses to the transport manager ([#529](#529)) ### Changed - manager: Prioritize public addresses for dialing ([#530](#530))
This PR makes ping protocol conform to the spec, specifically:
Tested litep2p-litep2p, litep2p-(pre-PR)litep2p, litep2p-smoldot.
Closes #415