Skip to content

Replace Deprecated mplex with yamux for Improved Interoperability #534

@paschal533

Description

@paschal533

Description

While working on an interoperability test between py-libp2p and rust-libp2p for a simple ping exchange, I discovered that py-libp2p still relies on mplex as its default stream multiplexer (e.g., in libp2p/stream_muxer/mplex/ and used in TransportUpgrader). However, mplex has been deprecated across the libp2p ecosystem, with implementations like rust-libp2p and go-libp2p now using yamux as the standard multiplexer. This mismatch causes compatibility issues, as seen in my ongoing interop tests where py-libp2p fails to mux streams with rust-libp2p after the Noise handshake.

Impact

  • py-libp2p cannot interoperate seamlessly with modern libp2p implementations that use yamux.
  • The continued use of mplex risks falling further behind the libp2p spec and community standards.

Proposed Solution

  • Replace mplex with yamux as the default multiplexer in py-libp2p.
  • Update TransportUpgrader and related components to prioritize /yamux/1.0.0 over /mplex/0.0.1.
  • Deprecate or remove mplex support to align with rust-libp2p and go-libp2p.

Current Work
I’m actively working on implementing yamux support in py-libp2p (see libp2p/stream_muxer/yamux/yamux.py). My current efforts include:

  • Adapting yamux.py to use a 12-byte header per the spec.
  • Integrating it into TransportUpgrader for Noise/Yamux interop with rust-libp2p.
  • Resolving type and linting issues (mypy, flake8, pydocstyle) for a clean PR.

I plan to submit a PR as soon as possible once the interop test succeeds and the implementation is stable.

Request for Feedback

  • Would maintainers prefer mplex deprecated gradually (e.g., dual support) or removed outright?

Related Efforts

Looking forward to collaborating on this to bring py-libp2p up to date with the broader libp2p ecosystem

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions