Skip to content

Commit 7ae763c

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

File tree

12 files changed

+23
-265
lines changed

12 files changed

+23
-265
lines changed

core/node/libp2p/internal/mplex/conn.go

-49
This file was deleted.

core/node/libp2p/internal/mplex/stream.go

-65
This file was deleted.

core/node/libp2p/internal/mplex/transport.go

-29
This file was deleted.

core/node/libp2p/internal/mplex/transport_test.go

-53
This file was deleted.

core/node/libp2p/smux.go

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

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

10-
"github.com/ipfs/kubo/core/node/libp2p/internal/mplex"
119
"github.com/libp2p/go-libp2p"
1210
"github.com/libp2p/go-libp2p/p2p/muxer/yamux"
1311
)
1412

1513
func makeSmuxTransportOption(tptConfig config.Transports) (libp2p.Option, error) {
1614
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
15+
return nil, fmt.Errorf("configuring muxers with LIBP2P_MUX_PREFS is no longer supported, use Swarm.Transports.Multiplexers")
16+
}
17+
if tptConfig.Multiplexers.Mplex != 0 {
18+
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")
4119
}
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
20+
if tptConfig.Multiplexers.Yamux < 0 {
21+
return nil, fmt.Errorf("running libp2p with Swarm.Transports.Multiplexers.Yamux disabled is not supported")
22+
}
23+
24+
return libp2p.Muxer(yamux.ID, yamux.DefaultTransport), nil
5125
}
5226

5327
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

docs/examples/kubo-as-a-library/go.mod

-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ require (
108108
github.com/libp2p/go-libp2p-record v0.2.0 // indirect
109109
github.com/libp2p/go-libp2p-routing-helpers v0.7.3 // indirect
110110
github.com/libp2p/go-libp2p-xor v0.1.0 // indirect
111-
github.com/libp2p/go-mplex v0.7.0 // indirect
112111
github.com/libp2p/go-msgio v0.3.0 // indirect
113112
github.com/libp2p/go-nat v0.2.0 // indirect
114113
github.com/libp2p/go-netroute v0.2.1 // indirect

docs/examples/kubo-as-a-library/go.sum

-2
Original file line numberDiff line numberDiff line change
@@ -476,8 +476,6 @@ github.com/libp2p/go-libp2p-routing-helpers v0.7.3/go.mod h1:cN4mJAD/7zfPKXBcs9z
476476
github.com/libp2p/go-libp2p-testing v0.12.0 h1:EPvBb4kKMWO29qP4mZGyhVzUyR25dvfUIK5WDu6iPUA=
477477
github.com/libp2p/go-libp2p-xor v0.1.0 h1:hhQwT4uGrBcuAkUGXADuPltalOdpf9aag9kaYNT2tLA=
478478
github.com/libp2p/go-libp2p-xor v0.1.0/go.mod h1:LSTM5yRnjGZbWNTA/hRwq2gGFrvRIbQJscoIL/u6InY=
479-
github.com/libp2p/go-mplex v0.7.0 h1:BDhFZdlk5tbr0oyFq/xv/NPGfjbnrsDam1EvutpBDbY=
480-
github.com/libp2p/go-mplex v0.7.0/go.mod h1:rW8ThnRcYWft/Jb2jeORBmPd6xuG3dGxWN/W168L9EU=
481479
github.com/libp2p/go-msgio v0.0.4/go.mod h1:63lBBgOTDKQL6EWazRMCwXsEeEeK9O2Cd+0+6OOuipQ=
482480
github.com/libp2p/go-msgio v0.3.0 h1:mf3Z8B1xcFN314sWX+2vOTShIE0Mmn2TXn3YCUQGNj0=
483481
github.com/libp2p/go-msgio v0.3.0/go.mod h1:nyRM819GmVaF9LX3l03RMh10QdOroF++NBbxAb0mmDM=

go.mod

-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ require (
5555
github.com/libp2p/go-libp2p-record v0.2.0
5656
github.com/libp2p/go-libp2p-routing-helpers v0.7.3
5757
github.com/libp2p/go-libp2p-testing v0.12.0
58-
github.com/libp2p/go-mplex v0.7.0
5958
github.com/libp2p/go-socket-activation v0.1.0
6059
github.com/mitchellh/go-homedir v1.1.0
6160
github.com/multiformats/go-multiaddr v0.12.0

go.sum

-2
Original file line numberDiff line numberDiff line change
@@ -539,8 +539,6 @@ github.com/libp2p/go-libp2p-testing v0.12.0 h1:EPvBb4kKMWO29qP4mZGyhVzUyR25dvfUI
539539
github.com/libp2p/go-libp2p-testing v0.12.0/go.mod h1:KcGDRXyN7sQCllucn1cOOS+Dmm7ujhfEyXQL5lvkcPg=
540540
github.com/libp2p/go-libp2p-xor v0.1.0 h1:hhQwT4uGrBcuAkUGXADuPltalOdpf9aag9kaYNT2tLA=
541541
github.com/libp2p/go-libp2p-xor v0.1.0/go.mod h1:LSTM5yRnjGZbWNTA/hRwq2gGFrvRIbQJscoIL/u6InY=
542-
github.com/libp2p/go-mplex v0.7.0 h1:BDhFZdlk5tbr0oyFq/xv/NPGfjbnrsDam1EvutpBDbY=
543-
github.com/libp2p/go-mplex v0.7.0/go.mod h1:rW8ThnRcYWft/Jb2jeORBmPd6xuG3dGxWN/W168L9EU=
544542
github.com/libp2p/go-msgio v0.0.4/go.mod h1:63lBBgOTDKQL6EWazRMCwXsEeEeK9O2Cd+0+6OOuipQ=
545543
github.com/libp2p/go-msgio v0.3.0 h1:mf3Z8B1xcFN314sWX+2vOTShIE0Mmn2TXn3YCUQGNj0=
546544
github.com/libp2p/go-msgio v0.3.0/go.mod h1:nyRM819GmVaF9LX3l03RMh10QdOroF++NBbxAb0mmDM=

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)