From b668b85d07a0d5315e617206fd5d511ab803bbae Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Tue, 22 Aug 2023 14:21:20 +0200 Subject: [PATCH] feat: remove mplex Co-Authored-By: Jorropo --- core/node/libp2p/smux.go | 45 ++++++-------------------- docs/changelogs/v0.23.md | 19 +++-------- docs/config.md | 16 ++------- docs/examples/kubo-as-a-library/go.mod | 1 - docs/examples/kubo-as-a-library/go.sum | 2 -- go.mod | 1 - go.sum | 2 -- test/cli/transports_test.go | 14 -------- 8 files changed, 16 insertions(+), 84 deletions(-) diff --git a/core/node/libp2p/smux.go b/core/node/libp2p/smux.go index 0777928a8152..a276b5ddc163 100644 --- a/core/node/libp2p/smux.go +++ b/core/node/libp2p/smux.go @@ -3,52 +3,25 @@ package libp2p import ( "fmt" "os" - "strings" "github.com/ipfs/kubo/config" "github.com/libp2p/go-libp2p" - "github.com/libp2p/go-libp2p/p2p/muxer/mplex" "github.com/libp2p/go-libp2p/p2p/muxer/yamux" ) func makeSmuxTransportOption(tptConfig config.Transports) (libp2p.Option, error) { if prefs := os.Getenv("LIBP2P_MUX_PREFS"); prefs != "" { - // Using legacy LIBP2P_MUX_PREFS variable. - log.Error("LIBP2P_MUX_PREFS is now deprecated.") - log.Error("Use the `Swarm.Transports.Multiplexers' config field.") - muxers := strings.Fields(prefs) - enabled := make(map[string]bool, len(muxers)) - - var opts []libp2p.Option - for _, tpt := range muxers { - if enabled[tpt] { - return nil, fmt.Errorf( - "duplicate muxer found in LIBP2P_MUX_PREFS: %s", - tpt, - ) - } - switch tpt { - case yamux.ID: - opts = append(opts, libp2p.Muxer(tpt, yamux.DefaultTransport)) - case mplex.ID: - opts = append(opts, libp2p.Muxer(tpt, mplex.DefaultTransport)) - default: - return nil, fmt.Errorf("unknown muxer: %s", tpt) - } - } - return libp2p.ChainOptions(opts...), nil - } else { - return prioritizeOptions([]priorityOption{{ - priority: tptConfig.Multiplexers.Yamux, - defaultPriority: 100, - opt: libp2p.Muxer(yamux.ID, yamux.DefaultTransport), - }, { - priority: tptConfig.Multiplexers.Mplex, - defaultPriority: config.Disabled, - opt: libp2p.Muxer(mplex.ID, mplex.DefaultTransport), - }}), nil + return nil, fmt.Errorf("configuring muxers with LIBP2P_MUX_PREFS is no longer supported, use Swarm.Transports.Multiplexers") + } + if tptConfig.Multiplexers.Mplex != 0 { + 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") } + if tptConfig.Multiplexers.Yamux < 0 { + return nil, fmt.Errorf("running libp2p with Swarm.Transports.Multiplexers.Yamux disabled is not supported") + } + + return libp2p.Muxer(yamux.ID, yamux.DefaultTransport), nil } func SmuxTransport(tptConfig config.Transports) func() (opts Libp2pOpts, err error) { diff --git a/docs/changelogs/v0.23.md b/docs/changelogs/v0.23.md index c2267a8e1987..93847f6500c2 100644 --- a/docs/changelogs/v0.23.md +++ b/docs/changelogs/v0.23.md @@ -6,7 +6,7 @@ - [Overview](#overview) - [🔦 Highlights](#-highlights) - - [Mplex deprecation](#mplex-deprecation) + - [Mplex removal](#mplex-removal) - [Gateway: meaningful CAR responses on Not Found errors](#gateway-meaningful-car-responses-on-not-found-errors) - [Binary characters in file names: no longer works with old clients and new Kubo servers](#binary-characters-in-file-names-no-longer-works-with-old-clients-and-new-kubo-servers) - [📝 Changelog](#-changelog) @@ -16,23 +16,14 @@ ### 🔦 Highlights -#### Mplex deprecation +#### Mplex removal -Mplex is being deprecated, this is because it is unreliable and -randomly drop streams when sending data *too fast*. +[Support for Mplex was removed from Kubo and go-libp2p](https://github.com/libp2p/specs/issues/553). It was unreliable and known to +randomly drop streams when sending data too fast. New pieces of code rely on backpressure, that means the stream will dynamicaly slow down the sending rate if data is getting backed up. -Backpressure is provided by **Yamux** and **QUIC**. - -In case you need compatibility with older implementations that do not ship with -Yamux (like default's JS-IPFS) you can turned it back ON in the config with: -```console -$ ipfs config --json Swarm.Transports.Multiplexers.Mplex 200 -``` - -We will completely remove Mplex in v0.24 as it makes protocols very bad to implement, -if you are in this situation you need to add yamux support to your other implementation. +Backpressure is now provided by [Yamux](https://github.com/ipfs/kubo/blob/master/docs/config.md#swarmtransportsmultiplexersyamux) (enabled by default) and QUIC. #### Gateway: meaningful CAR responses on Not Found errors diff --git a/docs/config.md b/docs/config.md index 6b8b271b7303..e38319cd03a0 100644 --- a/docs/config.md +++ b/docs/config.md @@ -2116,21 +2116,9 @@ Type: `priority` ### `Swarm.Transports.Multiplexers.Mplex` -**DEPRECATED**: See https://github.com/ipfs/kubo/issues/9958 +**REMOVED**: See https://github.com/ipfs/kubo/issues/9958 -Mplex is deprecated, this is because it is unreliable and -randomly drop streams when sending data *too fast*. - -New pieces of code rely on backpressure, that means the stream will dynamicaly -slow down the sending rate if data is getting backed up. -Backpressure is provided by **Yamux** and **QUIC**. - -If you want to turn it back on make sure to have a higher (lower is better) -priority than `Yamux`, you don't want your Kubo to start defaulting to Mplex. - -Default: `200` - -Type: `priority` +[Support for Mplex has been removed from Kubo and go-libp2p](https://github.com/libp2p/specs/issues/553). Please remove this option from your config. ## `DNS` diff --git a/docs/examples/kubo-as-a-library/go.mod b/docs/examples/kubo-as-a-library/go.mod index 1539680770d9..43f2c0e9f75b 100644 --- a/docs/examples/kubo-as-a-library/go.mod +++ b/docs/examples/kubo-as-a-library/go.mod @@ -110,7 +110,6 @@ require ( github.com/libp2p/go-libp2p-record v0.2.0 // indirect github.com/libp2p/go-libp2p-routing-helpers v0.7.1 // indirect github.com/libp2p/go-libp2p-xor v0.1.0 // indirect - github.com/libp2p/go-mplex v0.7.0 // indirect github.com/libp2p/go-msgio v0.3.0 // indirect github.com/libp2p/go-nat v0.2.0 // indirect github.com/libp2p/go-netroute v0.2.1 // indirect diff --git a/docs/examples/kubo-as-a-library/go.sum b/docs/examples/kubo-as-a-library/go.sum index 2f877d6043ab..89422288c8f4 100644 --- a/docs/examples/kubo-as-a-library/go.sum +++ b/docs/examples/kubo-as-a-library/go.sum @@ -482,8 +482,6 @@ github.com/libp2p/go-libp2p-routing-helpers v0.7.1/go.mod h1:cHStPSRC/wgbfpb5jYd github.com/libp2p/go-libp2p-testing v0.12.0 h1:EPvBb4kKMWO29qP4mZGyhVzUyR25dvfUIK5WDu6iPUA= github.com/libp2p/go-libp2p-xor v0.1.0 h1:hhQwT4uGrBcuAkUGXADuPltalOdpf9aag9kaYNT2tLA= github.com/libp2p/go-libp2p-xor v0.1.0/go.mod h1:LSTM5yRnjGZbWNTA/hRwq2gGFrvRIbQJscoIL/u6InY= -github.com/libp2p/go-mplex v0.7.0 h1:BDhFZdlk5tbr0oyFq/xv/NPGfjbnrsDam1EvutpBDbY= -github.com/libp2p/go-mplex v0.7.0/go.mod h1:rW8ThnRcYWft/Jb2jeORBmPd6xuG3dGxWN/W168L9EU= github.com/libp2p/go-msgio v0.0.4/go.mod h1:63lBBgOTDKQL6EWazRMCwXsEeEeK9O2Cd+0+6OOuipQ= github.com/libp2p/go-msgio v0.3.0 h1:mf3Z8B1xcFN314sWX+2vOTShIE0Mmn2TXn3YCUQGNj0= github.com/libp2p/go-msgio v0.3.0/go.mod h1:nyRM819GmVaF9LX3l03RMh10QdOroF++NBbxAb0mmDM= diff --git a/go.mod b/go.mod index b0dded118451..4d27b33b9c4a 100644 --- a/go.mod +++ b/go.mod @@ -157,7 +157,6 @@ require ( github.com/libp2p/go-libp2p-asn-util v0.3.0 // indirect github.com/libp2p/go-libp2p-gostream v0.6.0 // indirect github.com/libp2p/go-libp2p-xor v0.1.0 // indirect - github.com/libp2p/go-mplex v0.7.0 // indirect github.com/libp2p/go-msgio v0.3.0 // indirect github.com/libp2p/go-nat v0.2.0 // indirect github.com/libp2p/go-netroute v0.2.1 // indirect diff --git a/go.sum b/go.sum index 6e4845f99069..b64b3384e8ac 100644 --- a/go.sum +++ b/go.sum @@ -543,8 +543,6 @@ github.com/libp2p/go-libp2p-testing v0.12.0 h1:EPvBb4kKMWO29qP4mZGyhVzUyR25dvfUI github.com/libp2p/go-libp2p-testing v0.12.0/go.mod h1:KcGDRXyN7sQCllucn1cOOS+Dmm7ujhfEyXQL5lvkcPg= github.com/libp2p/go-libp2p-xor v0.1.0 h1:hhQwT4uGrBcuAkUGXADuPltalOdpf9aag9kaYNT2tLA= github.com/libp2p/go-libp2p-xor v0.1.0/go.mod h1:LSTM5yRnjGZbWNTA/hRwq2gGFrvRIbQJscoIL/u6InY= -github.com/libp2p/go-mplex v0.7.0 h1:BDhFZdlk5tbr0oyFq/xv/NPGfjbnrsDam1EvutpBDbY= -github.com/libp2p/go-mplex v0.7.0/go.mod h1:rW8ThnRcYWft/Jb2jeORBmPd6xuG3dGxWN/W168L9EU= github.com/libp2p/go-msgio v0.0.4/go.mod h1:63lBBgOTDKQL6EWazRMCwXsEeEeK9O2Cd+0+6OOuipQ= github.com/libp2p/go-msgio v0.3.0 h1:mf3Z8B1xcFN314sWX+2vOTShIE0Mmn2TXn3YCUQGNj0= github.com/libp2p/go-msgio v0.3.0/go.mod h1:nyRM819GmVaF9LX3l03RMh10QdOroF++NBbxAb0mmDM= diff --git a/test/cli/transports_test.go b/test/cli/transports_test.go index d37c78aad1ae..5a849f1e2700 100644 --- a/test/cli/transports_test.go +++ b/test/cli/transports_test.go @@ -71,20 +71,6 @@ func TestTransports(t *testing.T) { runTests(nodes) }) - t.Run("tcp with mplex", func(t *testing.T) { - // FIXME(#10069): we don't want this to exists anymore - t.Parallel() - nodes := tcpNodes(t) - nodes.ForEachPar(func(n *harness.Node) { - n.UpdateConfig(func(cfg *config.Config) { - cfg.Swarm.Transports.Multiplexers.Yamux = config.Disabled - cfg.Swarm.Transports.Multiplexers.Mplex = 200 - }) - }) - nodes.StartDaemons().Connect() - runTests(nodes) - }) - t.Run("tcp with NOISE", func(t *testing.T) { t.Parallel() nodes := tcpNodes(t)