libp2p / libp2p/rust-libp2p

Make `stream timeout` and `maximum concurrent streams` per connection configurable in the identify protocol.

Open
#5,653 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
5.6k
Forks
1.3k
Avg merge
8h 47m
Merged PRs (30d)
19

Description

Description

I would like to propose the following two constants, namely :-

  1. stream_timeout
  2. max_concurrent_streams_per_connection

defined here be made configurable via Identify Behaviour config defined here.

Motivation

In a large peer-to-peer (p2p) network with a lot of peers attempting to a dial a peer via swarm, some subsequent IdentifyReceived events are never triggered due to the active streams timing out or not having enough concurrent streams configured per connection.

Currently there is no way to increase this timeout or allow more concurrent streams as they are hardcoded to 60s and 10 respectively on identify handlers.

I would love to have these two attributes be made configurable such that the user inheriting the library can choose to set a value from config and the default be set to the original 60s and 10 respectively.

Current Implementation

Current implementation:

/protocol/identify/src/handler.rs

const STREAM_TIMEOUT: Duration = Duration::from_secs(60);
const MAX_CONCURRENT_STREAMS_PER_CONNECTION: usize = 10;
/protocol/identify/src/handler.rs

impl Handler {
    /// Creates a new `Handler`.
    pub fn new(
        interval: Duration,
        remote_peer_id: PeerId,
        public_key: PublicKey,
        protocol_version: String,
        agent_version: String,
        observed_addr: Multiaddr,
        external_addresses: HashSet<Multiaddr>,
    ) -> Self {
        Self {
            remote_peer_id,
            events: SmallVec::new(),
            active_streams: futures_bounded::FuturesSet::new(
                STREAM_TIMEOUT,
                MAX_CONCURRENT_STREAMS_PER_CONNECTION,
            ),
            ...
Are you planning to do it yourself in a pull request ?

Yes

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with protocols/identify/src/handler.rs, where the stream timeout and per-connection concurrency constants are used in Handler::new. Then inspect the Identify Behaviour config in protocols/identify/src/behaviour.rs and trace how configuration reaches the handler. Done means both values are configurable through that config while retaining defaults of 60 seconds and 10 streams.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
networking
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.