Skip to content

Conversation

@lexnv
Copy link
Collaborator

@lexnv lexnv commented Dec 9, 2025

This PR fixes the bandwidth metering for TCP and websocket substreams.

Thepoll_read implementation was reporting too many bytes for metering:

  • We are incrementing the self.bandwidth_sink.increase_inbound(buf.filled().len()) not only with the bytes that we have extracted from the socket, but with the whole buffer length
  • This PR saves the prior length before incrementing the bandwidth sink

Closes: #490

@lexnv lexnv self-assigned this Dec 9, 2025
@lexnv lexnv merged commit 08311db into master Dec 11, 2025
8 checks passed
@lexnv lexnv deleted the lexnv/metering-bndw branch December 11, 2025 10:21
lexnv added a commit that referenced this pull request Dec 16, 2025
## [0.12.3] - 2025-12-16

This release improves the robustness of the multistream-select
negotiation over WebRTC transport and fixes inbound bandwidth metering
on substreams. It also enhances the dialing success rate by improving
the transport dialing logic. Additionally, it re-exports CID's multihash
to facilitate the construction of CID V1.

### Changed

- transports: Improves the robustness and success rate of connection
dialing ([#495](#495))
- types: Re-export cid's multihash to construct CID V1
([#491](#491))

### Fixed

- fix: multistream-select negotiation on outbound substream over webrtc
([#465](#465))
- substream: Fix inbound bandwidth metering
([#499](#499))

---------

Signed-off-by: Alexandru Vasile <[email protected]>
github-merge-queue bot pushed a commit to paritytech/polkadot-sdk that referenced this pull request Dec 17, 2025
## [0.12.3] - 2025-12-16

This release improves the robustness of the multistream-select
negotiation over WebRTC transport and fixes inbound bandwidth metering
on substreams. It also enhances the dialing success rate by improving
the transport dialing logic. Additionally, it re-exports CID's multihash
to facilitate the construction of CID V1.

### Changed

- transports: Improves the robustness and success rate of connection
dialing ([#495](paritytech/litep2p#495))
- types: Re-export cid's multihash to construct CID V1
([#491](paritytech/litep2p#491))

### Fixed

- fix: multistream-select negotiation on outbound substream over webrtc
([#465](paritytech/litep2p#465))
- substream: Fix inbound bandwidth metering
([#499](paritytech/litep2p#499))

cc @paritytech/sdk-node

---------

Signed-off-by: Alexandru Vasile <[email protected]>
Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
paritytech-release-backport-bot bot pushed a commit to paritytech/polkadot-sdk that referenced this pull request Dec 17, 2025
## [0.12.3] - 2025-12-16

This release improves the robustness of the multistream-select
negotiation over WebRTC transport and fixes inbound bandwidth metering
on substreams. It also enhances the dialing success rate by improving
the transport dialing logic. Additionally, it re-exports CID's multihash
to facilitate the construction of CID V1.

### Changed

- transports: Improves the robustness and success rate of connection
dialing ([#495](paritytech/litep2p#495))
- types: Re-export cid's multihash to construct CID V1
([#491](paritytech/litep2p#491))

### Fixed

- fix: multistream-select negotiation on outbound substream over webrtc
([#465](paritytech/litep2p#465))
- substream: Fix inbound bandwidth metering
([#499](paritytech/litep2p#499))

cc @paritytech/sdk-node

---------

Signed-off-by: Alexandru Vasile <[email protected]>
Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
(cherry picked from commit a12ec9c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

substream: Incorrect metering of bandwidth

3 participants