litep2p/peerset: Reject non-reserved peers in the reserved-only mode#8650
Merged
litep2p/peerset: Reject non-reserved peers in the reserved-only mode#8650
Conversation
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
rejected Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Contributor
Author
|
/cmd prdoc --audience node_operator --bump patch |
…e_operator --bump patch'
dmitry-markin
approved these changes
May 26, 2025
substrate/client/network/src/litep2p/shim/notification/peerset.rs
Outdated
Show resolved
Hide resolved
substrate/client/network/src/litep2p/shim/notification/peerset.rs
Outdated
Show resolved
Hide resolved
Co-authored-by: Dmitry Markin <dmitry@markin.tech>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
|
All GitHub workflows were cancelled due to failure one of the required jobs. |
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
ordian
added a commit
that referenced
this pull request
May 27, 2025
* master: (99 commits) Snowbridge: Remove asset location check for compatibility (#8473) add poke_deposit extrinsic to pallet-bounties (#8382) litep2p/peerset: Reject non-reserved peers in the reserved-only mode (#8650) Charge deposit based on key length (#8648) [pallet-revive] make subscription task panic on error (#8587) tx/metrics: Add metrics for the RPC v2 `transactionWatch_v1_submitAndWatch` (#8345) Bridges: Fix - Improve try-state for pallet-xcm-bridge-hub (#8615) Introduce CreateBare, deprecated CreateInherent (#7597) Use hashbrown hashmap/hashset in validation context (#8606) ci: rm gitlab config (#8622) 🔪 flaky and Zombienet tests (#8600) cumulus: adjust unincluded segment size metric buckets (#8617) Benchmark storage access on block validation (#8069) Revert 7934 es/remove tj changes (#8611) collator-protocol: add more collation observability (#8230) `fatxpool`: add fallback for ready at light (#8533) txpool: fix tx removal from unlocks set (#8500) XCMP weight metering: account for the MQ page position (#8344) fix epmb solution duplicate issue + add remote mining apparatus to epm (#8585) Fix generated address returned by Substrate RPC runtime call (#8504) ...
github-merge-queue bot
pushed a commit
that referenced
this pull request
Jun 3, 2025
# Litep2p Becomes the Default Network Backend This PR finalizes the [litep2p](https://github.com/paritytech/litep2p) integration and makes it the default network backend for substrate-based chains. ## Litep2p Improvements After the stabilization, a forum post will follow with up to date information and more accurate measurements of the live impact of litep2p. ### CPU Usage Reduction **Litep2p consumes roughly 2x less CPU than the libp2p alternative**. This frees up resources for other usecases (subsystems) and enables running nodes on more cost-efficient hardware. This metric has been collected by the `networking::libp2p-node` metric of a live Kusama validator. This represents the CPU time spent on polling the networking task. Litep2p CPU consumption is on the left, using roughtly 1.3x CPUs, while libp2p on the right uses roughly 2.9-3x CPUs:  This metric has been collected by the NodeExporter of a live Kusama validator. Litep2p CPU consumption is on the left, using roughtly 230 CPU units, while libp2p on the right uses roughly 350 CPU units. This makes litep2p ~1.52 times more effiecient:  ### DHT Improvements and Authority Discovery Litep2p is able to discover peers faster via the Kademlia protocol than libp2p. This behavior manifests in faster discovery times for validators. For context, libp2p discovers 1K DHT records (authority records) in approximately 10 minutes, while litep2p discovers them in just 2.5 minutes (for more info see #7077 (comment)). This will improve issues we've seen with libp2p that causes validators to not receive rewards: - #8548 ### Stable Sync Peers Litep2p presents a more stable peer count in comparison with the libp2p backend. This ensures we can sync up faster than libp2p to the tip of the chain. In an older experiment, litep2p syncs to the tip of the chain in 526s, compared to 803s for libp2p. The stability of connections shows improvements for other protocols as well:  The previous image shows on the left the litep2p version and on the right the libp2p version. ### Revert Kusama Enablement This PR reverts #7866. Litep2p is now enabled by default, we don't need to selectively enable it on different chains. ### Litep2p 0.9.5 This release primarily focuses on strengthening the stability of the websocket transport. We've resolved an issue where higher-level buffering was causing the Noise protocol to fail when decoding messages. We've also significantly improved connectivity between litep2p and Smoldot (the Substrate-based light client). Empty frames are now handled correctly, preventing handshake timeouts and ensuring smoother communication. Finally, we've carried out several dependency updates to keep the library current with the latest versions of its underlying components. Fixed: - substream/fix: Allow empty payloads with 0-length frame ([#395](paritytech/litep2p#395)) - websocket: Fix connection stability on decrypt messages ([#393](paritytech/litep2p#393)) Changed: - crypto/noise: Show peerIDs that fail to decode ([#392](paritytech/litep2p#392)) - cargo: Bump yamux to 0.13.5 and tokio to 1.45.0 ([#396](paritytech/litep2p#396)) - ci: Enforce and apply clippy rules ([#388](paritytech/litep2p#388)) - build(deps): bump ring from 0.16.20 to 0.17.14 ([#389](paritytech/litep2p#389)) - Update hickory-resolver 0.24.2 -> 0.25.2 ([#386](paritytech/litep2p#386)) ### Fix peerset reserve only mode This has been move in PR: #8650 for ease of reviewing. The PR rejects non-reserved peers in the reserved-only mode of the litep2p notification peerset. --------- Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
paritytech-release-backport-bot bot
pushed a commit
that referenced
this pull request
Jun 4, 2025
…8650) This PR rejects non-reserved peers in the reserved-only mode of the litep2p notification peerset. Previously, litep2p ignored completely the reserved-only state while accepting inbound connections. However, it handled it properly during the slot allocation phase. - the main changes are in the `report_inbound_substream` function, which now propagated a `Rejected` response to litep2p on the reserved-only state - in response, litep2p should never open an inbound substream after receiving the rejected response - the state of peers is not advanced while in `Disconnected` or `Backoff` states - the opening state is moved to `Cancelled` - for consistency purposes (and fuzzing purposes), the `report_substream_opened` is more robustly handling the `Disconnected` state - while at it have replaced a panic with `debug_assert` and an instant reject ## Testing Done - started 2 nodes in Kusama and Polkadot with litep2p - added the `reserved_only_rejects_non_reserved_peers` test to ensure litep2p handles peers properly from different states This PR has been extracted from #8461 to ease the review process cc @paritytech/networking --------- Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Dmitry Markin <dmitry@markin.tech> (cherry picked from commit e82b4db)
|
Successfully created backport PR for |
|
Git push to origin failed for stable2412 with exitcode 1 |
|
Git push to origin failed for stable2503 with exitcode 1 |
paritytech-release-backport-bot bot
pushed a commit
that referenced
this pull request
Jun 4, 2025
…8650) This PR rejects non-reserved peers in the reserved-only mode of the litep2p notification peerset. Previously, litep2p ignored completely the reserved-only state while accepting inbound connections. However, it handled it properly during the slot allocation phase. - the main changes are in the `report_inbound_substream` function, which now propagated a `Rejected` response to litep2p on the reserved-only state - in response, litep2p should never open an inbound substream after receiving the rejected response - the state of peers is not advanced while in `Disconnected` or `Backoff` states - the opening state is moved to `Cancelled` - for consistency purposes (and fuzzing purposes), the `report_substream_opened` is more robustly handling the `Disconnected` state - while at it have replaced a panic with `debug_assert` and an instant reject ## Testing Done - started 2 nodes in Kusama and Polkadot with litep2p - added the `reserved_only_rejects_non_reserved_peers` test to ensure litep2p handles peers properly from different states This PR has been extracted from #8461 to ease the review process cc @paritytech/networking --------- Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Dmitry Markin <dmitry@markin.tech> (cherry picked from commit e82b4db)
|
Successfully created backport PR for |
EgorPopelyaev
pushed a commit
that referenced
this pull request
Jun 5, 2025
…rs in the reserved-only mode (#8744) Backport #8650 into `stable2503` 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 <alexandru.vasile@parity.io> Co-authored-by: Alexandru Vasile <60601340+lexnv@users.noreply.github.com> Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Dmitry Markin <dmitry@markin.tech>
EgorPopelyaev
pushed a commit
that referenced
this pull request
Jun 10, 2025
…rs in the reserved-only mode (#8743) Backport #8650 into `stable2412` 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 <alexandru.vasile@parity.io> Co-authored-by: Alexandru Vasile <60601340+lexnv@users.noreply.github.com> Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Dmitry Markin <dmitry@markin.tech>
pgherveou
pushed a commit
that referenced
this pull request
Jun 11, 2025
…8650) This PR rejects non-reserved peers in the reserved-only mode of the litep2p notification peerset. Previously, litep2p ignored completely the reserved-only state while accepting inbound connections. However, it handled it properly during the slot allocation phase. - the main changes are in the `report_inbound_substream` function, which now propagated a `Rejected` response to litep2p on the reserved-only state - in response, litep2p should never open an inbound substream after receiving the rejected response - the state of peers is not advanced while in `Disconnected` or `Backoff` states - the opening state is moved to `Cancelled` - for consistency purposes (and fuzzing purposes), the `report_substream_opened` is more robustly handling the `Disconnected` state - while at it have replaced a panic with `debug_assert` and an instant reject ## Testing Done - started 2 nodes in Kusama and Polkadot with litep2p - added the `reserved_only_rejects_non_reserved_peers` test to ensure litep2p handles peers properly from different states This PR has been extracted from #8461 to ease the review process cc @paritytech/networking --------- Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Dmitry Markin <dmitry@markin.tech>
pgherveou
pushed a commit
that referenced
this pull request
Jun 11, 2025
# Litep2p Becomes the Default Network Backend This PR finalizes the [litep2p](https://github.com/paritytech/litep2p) integration and makes it the default network backend for substrate-based chains. ## Litep2p Improvements After the stabilization, a forum post will follow with up to date information and more accurate measurements of the live impact of litep2p. ### CPU Usage Reduction **Litep2p consumes roughly 2x less CPU than the libp2p alternative**. This frees up resources for other usecases (subsystems) and enables running nodes on more cost-efficient hardware. This metric has been collected by the `networking::libp2p-node` metric of a live Kusama validator. This represents the CPU time spent on polling the networking task. Litep2p CPU consumption is on the left, using roughtly 1.3x CPUs, while libp2p on the right uses roughly 2.9-3x CPUs:  This metric has been collected by the NodeExporter of a live Kusama validator. Litep2p CPU consumption is on the left, using roughtly 230 CPU units, while libp2p on the right uses roughly 350 CPU units. This makes litep2p ~1.52 times more effiecient:  ### DHT Improvements and Authority Discovery Litep2p is able to discover peers faster via the Kademlia protocol than libp2p. This behavior manifests in faster discovery times for validators. For context, libp2p discovers 1K DHT records (authority records) in approximately 10 minutes, while litep2p discovers them in just 2.5 minutes (for more info see #7077 (comment)). This will improve issues we've seen with libp2p that causes validators to not receive rewards: - #8548 ### Stable Sync Peers Litep2p presents a more stable peer count in comparison with the libp2p backend. This ensures we can sync up faster than libp2p to the tip of the chain. In an older experiment, litep2p syncs to the tip of the chain in 526s, compared to 803s for libp2p. The stability of connections shows improvements for other protocols as well:  The previous image shows on the left the litep2p version and on the right the libp2p version. ### Revert Kusama Enablement This PR reverts #7866. Litep2p is now enabled by default, we don't need to selectively enable it on different chains. ### Litep2p 0.9.5 This release primarily focuses on strengthening the stability of the websocket transport. We've resolved an issue where higher-level buffering was causing the Noise protocol to fail when decoding messages. We've also significantly improved connectivity between litep2p and Smoldot (the Substrate-based light client). Empty frames are now handled correctly, preventing handshake timeouts and ensuring smoother communication. Finally, we've carried out several dependency updates to keep the library current with the latest versions of its underlying components. Fixed: - substream/fix: Allow empty payloads with 0-length frame ([#395](paritytech/litep2p#395)) - websocket: Fix connection stability on decrypt messages ([#393](paritytech/litep2p#393)) Changed: - crypto/noise: Show peerIDs that fail to decode ([#392](paritytech/litep2p#392)) - cargo: Bump yamux to 0.13.5 and tokio to 1.45.0 ([#396](paritytech/litep2p#396)) - ci: Enforce and apply clippy rules ([#388](paritytech/litep2p#388)) - build(deps): bump ring from 0.16.20 to 0.17.14 ([#389](paritytech/litep2p#389)) - Update hickory-resolver 0.24.2 -> 0.25.2 ([#386](paritytech/litep2p#386)) ### Fix peerset reserve only mode This has been move in PR: #8650 for ease of reviewing. The PR rejects non-reserved peers in the reserved-only mode of the litep2p notification peerset. --------- Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
alvicsam
pushed a commit
that referenced
this pull request
Oct 17, 2025
…8650) This PR rejects non-reserved peers in the reserved-only mode of the litep2p notification peerset. Previously, litep2p ignored completely the reserved-only state while accepting inbound connections. However, it handled it properly during the slot allocation phase. - the main changes are in the `report_inbound_substream` function, which now propagated a `Rejected` response to litep2p on the reserved-only state - in response, litep2p should never open an inbound substream after receiving the rejected response - the state of peers is not advanced while in `Disconnected` or `Backoff` states - the opening state is moved to `Cancelled` - for consistency purposes (and fuzzing purposes), the `report_substream_opened` is more robustly handling the `Disconnected` state - while at it have replaced a panic with `debug_assert` and an instant reject ## Testing Done - started 2 nodes in Kusama and Polkadot with litep2p - added the `reserved_only_rejects_non_reserved_peers` test to ensure litep2p handles peers properly from different states This PR has been extracted from #8461 to ease the review process cc @paritytech/networking --------- Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Dmitry Markin <dmitry@markin.tech>
alvicsam
pushed a commit
that referenced
this pull request
Oct 17, 2025
# Litep2p Becomes the Default Network Backend This PR finalizes the [litep2p](https://github.com/paritytech/litep2p) integration and makes it the default network backend for substrate-based chains. ## Litep2p Improvements After the stabilization, a forum post will follow with up to date information and more accurate measurements of the live impact of litep2p. ### CPU Usage Reduction **Litep2p consumes roughly 2x less CPU than the libp2p alternative**. This frees up resources for other usecases (subsystems) and enables running nodes on more cost-efficient hardware. This metric has been collected by the `networking::libp2p-node` metric of a live Kusama validator. This represents the CPU time spent on polling the networking task. Litep2p CPU consumption is on the left, using roughtly 1.3x CPUs, while libp2p on the right uses roughly 2.9-3x CPUs:  This metric has been collected by the NodeExporter of a live Kusama validator. Litep2p CPU consumption is on the left, using roughtly 230 CPU units, while libp2p on the right uses roughly 350 CPU units. This makes litep2p ~1.52 times more effiecient:  ### DHT Improvements and Authority Discovery Litep2p is able to discover peers faster via the Kademlia protocol than libp2p. This behavior manifests in faster discovery times for validators. For context, libp2p discovers 1K DHT records (authority records) in approximately 10 minutes, while litep2p discovers them in just 2.5 minutes (for more info see #7077 (comment)). This will improve issues we've seen with libp2p that causes validators to not receive rewards: - #8548 ### Stable Sync Peers Litep2p presents a more stable peer count in comparison with the libp2p backend. This ensures we can sync up faster than libp2p to the tip of the chain. In an older experiment, litep2p syncs to the tip of the chain in 526s, compared to 803s for libp2p. The stability of connections shows improvements for other protocols as well:  The previous image shows on the left the litep2p version and on the right the libp2p version. ### Revert Kusama Enablement This PR reverts #7866. Litep2p is now enabled by default, we don't need to selectively enable it on different chains. ### Litep2p 0.9.5 This release primarily focuses on strengthening the stability of the websocket transport. We've resolved an issue where higher-level buffering was causing the Noise protocol to fail when decoding messages. We've also significantly improved connectivity between litep2p and Smoldot (the Substrate-based light client). Empty frames are now handled correctly, preventing handshake timeouts and ensuring smoother communication. Finally, we've carried out several dependency updates to keep the library current with the latest versions of its underlying components. Fixed: - substream/fix: Allow empty payloads with 0-length frame ([#395](paritytech/litep2p#395)) - websocket: Fix connection stability on decrypt messages ([#393](paritytech/litep2p#393)) Changed: - crypto/noise: Show peerIDs that fail to decode ([#392](paritytech/litep2p#392)) - cargo: Bump yamux to 0.13.5 and tokio to 1.45.0 ([#396](paritytech/litep2p#396)) - ci: Enforce and apply clippy rules ([#388](paritytech/litep2p#388)) - build(deps): bump ring from 0.16.20 to 0.17.14 ([#389](paritytech/litep2p#389)) - Update hickory-resolver 0.24.2 -> 0.25.2 ([#386](paritytech/litep2p#386)) ### Fix peerset reserve only mode This has been move in PR: #8650 for ease of reviewing. The PR rejects non-reserved peers in the reserved-only mode of the litep2p notification peerset. --------- Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
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 rejects non-reserved peers in the reserved-only mode of the litep2p notification peerset.
Previously, litep2p ignored completely the reserved-only state while accepting inbound connections. However, it handled it properly during the slot allocation phase.
report_inbound_substreamfunction, which now propagated aRejectedresponse to litep2p on the reserved-only stateDisconnectedorBackoffstatesCancelledreport_substream_openedis more robustly handling theDisconnectedstatedebug_assertand an instant rejectTesting Done
reserved_only_rejects_non_reserved_peerstest to ensure litep2p handles peers properly from different statesThis PR has been extracted from #8461 to ease the review process
cc @paritytech/networking