Skip to content

Make webrtc-specific multistream-select negotiation spec compliant#537

Closed
haikoschol wants to merge 28 commits intoparitytech:masterfrom
ChainSafe:haiko-webrtc-multistream-nego-fix-2
Closed

Make webrtc-specific multistream-select negotiation spec compliant#537
haikoschol wants to merge 28 commits intoparitytech:masterfrom
ChainSafe:haiko-webrtc-multistream-nego-fix-2

Conversation

@haikoschol
Copy link
Copy Markdown
Contributor

@haikoschol haikoschol commented Feb 18, 2026

This PR brings the WebRTC-specific multistream-select implementation in line with the spec. Before this change, the header, the desired protocol and all fallback protocols were sent in a single multistream-select message. The spec mandates that only the desired protocol is to be sent instead. If the peer responds with a na, indicating it does not support this protocol, another multistream-select message should be sent, containing the first fallback protocol. This is to be repeated until the peer accepts a protocol or the dialer runs out of fallbacks.

This fix is required for interop with smoldot. Without this fix, the following happens:

  • The dialer proposes a protocol with fallbacks in a single message (e.g. /multistream/1.0.0\n/c7fd75141ca230c62e99af66d68f9d1f84b0821bcc1e17d2be92aaf5602d1c0e/block-announces/1\n/dot/block-announces/1\n).
  • Smoldot reads from its input buffer until it sees /c7fd75141ca230c62e99af66d68f9d1f84b0821bcc1e17d2be92aaf5602d1c0e/block-announces/1\n and sends back a confirmation.
  • The fallback protocol remains in the input buffer and is misinterpreted by Smoldot as the block announce handshake. Smoldot does not verify the handshake on inbound substreams.
  • The dialer sends the actual block announce handshake (70 byte payload).
  • Smoldot misinterprets this as the first block announce message and fails to decode it and logs this error to the browser console: DecodeBlockAnnounceError(Verify).

This PR builds on ChainSafe/litep2p#6 to incorporate the changes to WebRTC protobuf flag handling.

closes #75

timwu20 and others added 28 commits January 8, 2026 15:42
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@haikoschol
Copy link
Copy Markdown
Contributor Author

I meant to open this in our fork first and get a review from @timwu20. Will convert this to draft because it builds on work that should reviewed first in a PR that hasn't been opened in this repo yet.

@haikoschol haikoschol marked this pull request as draft February 18, 2026 12:27
@haikoschol
Copy link
Copy Markdown
Contributor Author

After syncing with @timwu20 we decided that opening a PR for these changes based off master easier for everyone.

@haikoschol haikoschol closed this Mar 3, 2026
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.

multistream-select implementation used by WebRTC doesn't conform to the spec

2 participants