Skip to content

Commit fbf0c56

Browse files
committed
libp2p: remove mplex
Fixes: #10069
1 parent ef620aa commit fbf0c56

File tree

4 files changed

+23
-62
lines changed

4 files changed

+23
-62
lines changed

core/node/libp2p/smux.go

+9-34
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package libp2p
33
import (
44
"fmt"
55
"os"
6-
"strings"
76

87
"github.com/ipfs/kubo/config"
98

@@ -14,40 +13,16 @@ import (
1413

1514
func makeSmuxTransportOption(tptConfig config.Transports) (libp2p.Option, error) {
1615
if prefs := os.Getenv("LIBP2P_MUX_PREFS"); prefs != "" {
17-
// Using legacy LIBP2P_MUX_PREFS variable.
18-
log.Error("LIBP2P_MUX_PREFS is now deprecated.")
19-
log.Error("Use the `Swarm.Transports.Multiplexers' config field.")
20-
muxers := strings.Fields(prefs)
21-
enabled := make(map[string]bool, len(muxers))
22-
23-
var opts []libp2p.Option
24-
for _, tpt := range muxers {
25-
if enabled[tpt] {
26-
return nil, fmt.Errorf(
27-
"duplicate muxer found in LIBP2P_MUX_PREFS: %s",
28-
tpt,
29-
)
30-
}
31-
switch tpt {
32-
case yamux.ID:
33-
opts = append(opts, libp2p.Muxer(tpt, yamux.DefaultTransport))
34-
case mplex.ID:
35-
opts = append(opts, libp2p.Muxer(tpt, mplex.DefaultTransport))
36-
default:
37-
return nil, fmt.Errorf("unknown muxer: %s", tpt)
38-
}
39-
}
40-
return libp2p.ChainOptions(opts...), nil
16+
return nil, fmt.Errorf("configuring muxers with LIBP2P_MUX_PREFS is no longer supported, use Swarm.Transports.Multiplexers")
17+
}
18+
if tptConfig.Multiplexers.Mplex != 0 {
19+
return nil, fmt.Errorf("Swarm.Transports.Multiplexers.Mplex is no longer supported, remove it from your config, see https://github.com/libp2p/specs/issues/553")
4120
}
42-
return prioritizeOptions([]priorityOption{{
43-
priority: tptConfig.Multiplexers.Yamux,
44-
defaultPriority: 100,
45-
opt: libp2p.Muxer(yamux.ID, yamux.DefaultTransport),
46-
}, {
47-
priority: tptConfig.Multiplexers.Mplex,
48-
defaultPriority: config.Disabled,
49-
opt: libp2p.Muxer(mplex.ID, mplex.DefaultTransport),
50-
}}), nil
21+
if tptConfig.Multiplexers.Yamux < 0 {
22+
return nil, fmt.Errorf("running libp2p with Swarm.Transports.Multiplexers.Yamux disabled is not supported")
23+
}
24+
25+
return libp2p.Muxer(yamux.ID, yamux.DefaultTransport), nil
5126
}
5227

5328
func SmuxTransport(tptConfig config.Transports) func() (opts Libp2pOpts, err error) {

docs/changelogs/v0.25.md

+11
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- [Overview](#overview)
88
- [🔦 Highlights](#-highlights)
99
- [RPC `API.Authorizations`](#rpc-apiauthorizations)
10+
- [MPLEX removal](#mplex-removal)
1011
- [Graphsync Experiment Removal](#graphsync-experiment-removal)
1112
- [📝 Changelog](#-changelog)
1213
- [👨‍👩‍👧‍👦 Contributors](#-contributors)
@@ -28,6 +29,16 @@ This feature is opt-in. By default, no authorization is set up.
2829
For configuration instructions,
2930
refer to the [documentation](https://github.com/ipfs/kubo/blob/master/docs/config.md#apiauthorizations).
3031

32+
#### MPLEX Removal
33+
34+
After deprecating and removing mplex support by default in [v0.23.0](https://github.com/ipfs/kubo/blob/master/docs/changelogs/v0.23.md#mplex-deprecation).
35+
36+
We now fully removed it. If you still need mplex support to talk with other pieces of software,
37+
please try updating them, and if they don't support yamux or QUIC talk to us about it.
38+
39+
Mplex is unreliable by design, it will drop data and generete errors when sending data *too fast*,
40+
yamux and QUIC support backpressure, that means if we send data faster than the remote machine can process it, we slows down to match the remote's speed.
41+
3142
#### Graphsync Experiment Removal
3243

3344
Currently the Graphsync server is to our knowledge not used

docs/config.md

+3-14
Original file line numberDiff line numberDiff line change
@@ -2253,21 +2253,10 @@ Type: `priority`
22532253

22542254
### `Swarm.Transports.Multiplexers.Mplex`
22552255

2256-
**DEPRECATED**: See https://github.com/ipfs/kubo/issues/9958
2256+
**REMOVED**: See https://github.com/ipfs/kubo/issues/9958
22572257

2258-
Mplex is deprecated, this is because it is unreliable and
2259-
randomly drop streams when sending data *too fast*.
2260-
2261-
New pieces of code rely on backpressure, that means the stream will dynamically
2262-
slow down the sending rate if data is getting backed up.
2263-
Backpressure is provided by **Yamux** and **QUIC**.
2264-
2265-
If you want to turn it back on make sure to have a higher (lower is better)
2266-
priority than `Yamux`, you don't want your Kubo to start defaulting to Mplex.
2267-
2268-
Default: `200`
2269-
2270-
Type: `priority`
2258+
Support for Mplex has been [removed from Kubo and go-libp2p](https://github.com/libp2p/specs/issues/553).
2259+
Please remove this option from your config.
22712260

22722261
## `DNS`
22732262

test/cli/transports_test.go

-14
Original file line numberDiff line numberDiff line change
@@ -72,20 +72,6 @@ func TestTransports(t *testing.T) {
7272
runTests(nodes)
7373
})
7474

75-
t.Run("tcp with mplex", func(t *testing.T) {
76-
// FIXME(#10069): we don't want this to exists anymore
77-
t.Parallel()
78-
nodes := tcpNodes(t)
79-
nodes.ForEachPar(func(n *harness.Node) {
80-
n.UpdateConfig(func(cfg *config.Config) {
81-
cfg.Swarm.Transports.Multiplexers.Yamux = config.Disabled
82-
cfg.Swarm.Transports.Multiplexers.Mplex = 200
83-
})
84-
})
85-
nodes.StartDaemons().Connect()
86-
runTests(nodes)
87-
})
88-
8975
t.Run("tcp with NOISE", func(t *testing.T) {
9076
t.Parallel()
9177
nodes := tcpNodes(t)

0 commit comments

Comments
 (0)