Skip to content

Conversation

@paritytech-release-backport-bot

Backport #10362 into stable2509 from lexnv.

See the documentation on how to use this bot.

…s` (#10362)

While triaging the Versi-net, I've discovered that the connection
between collators and validators sometimes takes less than 20ms, while
at other times it takes more than 500ms.

In both cases, the validators are already connected to a different
protocol. Therefore, opening and negotiating substreams must be almost
instant.

The slot timer of the peerset artificially introduces the delay:
- The `SetReservedPeers` is received by the peerset. At this step, the
peerset propagated the `closedSubstream` to signal that it wants to
disconnect previously reserved peers.
- At the next slot allocation timer tick (after 1s), the newly added
reserved peers are requested to be connected

This can introduce an artificial delay of up to 1s, which is
unnecessary.

To mitigate this behavior, this PR:
- Transforms the ` enum PeersetNotificationCommand` into a structure.
Effectively, the peerset can specify directly to close some substreams
and open other substreams
- Upon receiving the `SetReservedPeers` command, peers are moved into
the `Opening` state and the request is propagated to the litep2p to open
substreams.
- The behavior of the slot allocation timer remains identical. This is
needed to capture the following edge cases:
- The reserved peer of the `SetReservedPeers` is not disconnected, but
backoff / pending closing.
  - The reserved peer is banned

cc @paritytech/networking

Detected during versi-net triaging of elastic scaling:
#10310 (comment)

---------

Signed-off-by: Alexandru Vasile <[email protected]>
Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Bastian Köcher <[email protected]>
(cherry picked from commit 8a034ca)
@github-actions
Copy link
Contributor

This pull request is amending an existing release. Please proceed with extreme caution,
as to not impact downstream teams that rely on the stability of it. Some things to consider:

  • Backports are only for 'patch' or 'minor' changes. No 'major' or other breaking change.
  • Should be a legit fix for some bug, not adding tons of new features.
  • Must either be already audited or not need an audit.
Emergency Bypass

If you really need to bypass this check: add validate: false to each crate
in the Prdoc where a breaking change is introduced. This will release a new major
version of that crate and all its reverse dependencies and basically break the release.

@lexnv lexnv changed the title [stable2509] Backport #10362 [stable2509] Backport #10362: net/peerset: Optimize substream opening duration for SetReservedPeers Nov 25, 2025
@EgorPopelyaev EgorPopelyaev enabled auto-merge (squash) November 25, 2025 13:28
@EgorPopelyaev EgorPopelyaev merged commit dd95a52 into stable2509 Nov 25, 2025
271 of 277 checks passed
@EgorPopelyaev EgorPopelyaev deleted the backport-10362-to-stable2509 branch November 25, 2025 16:05
smohan-dw pushed a commit to dhiway/sdk that referenced this pull request Nov 28, 2025
…am opening duration for `SetReservedPeers` (paritytech#10408)

Backport paritytech#10362 into `stable2509` from lexnv.

See the
[documentation](https://github.com/paritytech/polkadot-sdk/blob/master/docs/BACKPORT.md)
on how to use this bot.

<!--
  # To be used by other automation, do not modify:
  original-pr-number: #${pull_number}
-->

---------

Signed-off-by: Alexandru Vasile <[email protected]>
Co-authored-by: Alexandru Vasile <[email protected]>
Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Bastian Köcher <[email protected]>
Co-authored-by: Egor_P <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A3-backport Pull request is already reviewed well in another branch.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants