Skip to content

Update litep2p with WebRTC Transport Support#10

Draft
timwu20 wants to merge 1 commit intomasterfrom
tim/webrtc-integration
Draft

Update litep2p with WebRTC Transport Support#10
timwu20 wants to merge 1 commit intomasterfrom
tim/webrtc-integration

Conversation

@timwu20
Copy link

@timwu20 timwu20 commented Feb 10, 2026

Summary

  • Updates litep2p from crates.io v0.13.0 to a git revision (27b110d1) that includes WebRTC transport support, and enables the new webrtc feature flag
  • Adds WebRTC address parsing to the litep2p network backend so that /ip4/.../udp/.../webrtc listen addresses are recognized and routed to the WebRTC transport
  • Extends known-address handling to recognize WebRTC and Certhash multiaddr protocols when appending /p2p/<peer_id> to addresses

Details

Dependency change (Cargo.toml)

The litep2p dependency is switched from a crates.io release to a pinned git commit from the chainsafe/litep2p repository, with the webrtc feature added alongside the existing rsa and websocket features. This also pulls in str0m (a WebRTC media/data library) as a new transitive dependency.

Listen address parsing (substrate/client/network/src/litep2p/mod.rs)

The previous implementation used an iterator-based filter_map + unzip pattern to split listen addresses into TCP and WebSocket buckets. This is refactored into an explicit for loop that classifies addresses into three categories:

Address pattern Transport
/ip{4,6}/.../tcp/.../ws or /wss WebSocket
/ip{4,6}/.../tcp/... TCP
/ip{4,6}/.../udp/.../webrtc WebRTC (new)

The WebRTC transport is conditionally configured — it is only added to the litep2p config when at least one WebRTC listen address is provided.

Known-address protocol matching

The address-matching logic in NetworkBackend::new is updated to also recognize Protocol::WebRTC and Protocol::Certhash(_) as valid terminal protocols before appending /p2p/<peer_id>, ensuring WebRTC addresses from the DHT or other discovery mechanisms are correctly handled.

Test plan

  • Verify that existing TCP and WebSocket listen addresses continue to work as before
  • Configure a node with a WebRTC listen address (e.g., /ip4/0.0.0.0/udp/30333/webrtc) and confirm it starts listening on WebRTC
  • Confirm that WebRTC peer addresses discovered via DHT are properly formatted with the /p2p suffix
  • Run cargo build -p polkadot --release to confirm successful compilation
  • Run network-related tests: cargo test -p sc-network

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.

1 participant