Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove mplex #10094

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 9 additions & 36 deletions core/node/libp2p/smux.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,52 +3,25 @@
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")

Check warning on line 18 in core/node/libp2p/smux.go

View check run for this annotation

Codecov / codecov/patch

core/node/libp2p/smux.go#L15-L18

Added lines #L15 - L18 were not covered by tests
}
if tptConfig.Multiplexers.Yamux < 0 {
return nil, fmt.Errorf("running libp2p with Swarm.Transports.Multiplexers.Yamux disabled is not supported")
}

Check warning on line 22 in core/node/libp2p/smux.go

View check run for this annotation

Codecov / codecov/patch

core/node/libp2p/smux.go#L20-L22

Added lines #L20 - L22 were not covered by tests

return libp2p.Muxer(yamux.ID, yamux.DefaultTransport), nil

Check warning on line 24 in core/node/libp2p/smux.go

View check run for this annotation

Codecov / codecov/patch

core/node/libp2p/smux.go#L24

Added line #L24 was not covered by tests
}

func SmuxTransport(tptConfig config.Transports) func() (opts Libp2pOpts, err error) {
Expand Down
19 changes: 5 additions & 14 deletions docs/changelogs/v0.23.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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

Expand Down
16 changes: 2 additions & 14 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand Down
36 changes: 17 additions & 19 deletions docs/examples/kubo-as-a-library/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ go 1.20
replace github.com/ipfs/kubo => ./../../..

require (
github.com/ipfs/boxo v0.12.0
github.com/ipfs/boxo v0.12.1-0.20230822135301-303595bcdba7
github.com/ipfs/kubo v0.0.0-00010101000000-000000000000
github.com/libp2p/go-libp2p v0.29.2
github.com/multiformats/go-multiaddr v0.10.1
github.com/libp2p/go-libp2p v0.30.0
github.com/multiformats/go-multiaddr v0.11.0
)

require (
Expand Down Expand Up @@ -50,7 +50,7 @@ require (
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/gopacket v1.1.19 // indirect
github.com/google/pprof v0.0.0-20230705174524-200ffdc848b8 // indirect
github.com/google/pprof v0.0.0-20230821062121-407c9e7a662f // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/gorilla/mux v1.8.0 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
Expand All @@ -59,7 +59,7 @@ require (
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.2 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.5 // indirect
github.com/huin/goupnp v1.2.0 // indirect
github.com/ipfs/bbloom v0.0.4 // indirect
github.com/ipfs/go-bitfield v1.1.0 // indirect
Expand Down Expand Up @@ -110,11 +110,10 @@ 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
github.com/libp2p/go-reuseport v0.3.0 // indirect
github.com/libp2p/go-reuseport v0.4.0 // indirect
github.com/libp2p/go-yamux/v4 v4.0.1 // indirect
github.com/libp2p/zeroconf/v2 v2.2.0 // indirect
github.com/marten-seemann/tcp v0.0.0-20210406111302-dfbc87cc63fd // indirect
Expand All @@ -136,7 +135,7 @@ require (
github.com/multiformats/go-multistream v0.4.1 // indirect
github.com/multiformats/go-varint v0.0.7 // indirect
github.com/onsi/ginkgo/v2 v2.11.0 // indirect
github.com/opencontainers/runtime-spec v1.0.2 // indirect
github.com/opencontainers/runtime-spec v1.1.0 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/openzipkin/zipkin-go v0.4.1 // indirect
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect
Expand All @@ -146,11 +145,10 @@ require (
github.com/prometheus/client_golang v1.16.0 // indirect
github.com/prometheus/client_model v0.4.0 // indirect
github.com/prometheus/common v0.44.0 // indirect
github.com/prometheus/procfs v0.11.0 // indirect
github.com/prometheus/procfs v0.11.1 // indirect
github.com/quic-go/qpack v0.4.0 // indirect
github.com/quic-go/qtls-go1-19 v0.3.3 // indirect
github.com/quic-go/qtls-go1-20 v0.2.3 // indirect
github.com/quic-go/quic-go v0.36.4 // indirect
github.com/quic-go/qtls-go1-20 v0.3.2 // indirect
github.com/quic-go/quic-go v0.38.0 // indirect
github.com/quic-go/webtransport-go v0.5.3 // indirect
github.com/raulk/go-watchdog v1.3.0 // indirect
github.com/samber/lo v1.36.0 // indirect
Expand Down Expand Up @@ -180,16 +178,16 @@ require (
go.uber.org/dig v1.17.0 // indirect
go.uber.org/fx v1.20.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.24.0 // indirect
go.uber.org/zap v1.25.0 // indirect
go4.org v0.0.0-20230225012048-214862532bf5 // indirect
golang.org/x/crypto v0.11.0 // indirect
golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1 // indirect
golang.org/x/crypto v0.12.0 // indirect
golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 // indirect
golang.org/x/mod v0.12.0 // indirect
golang.org/x/net v0.12.0 // indirect
golang.org/x/net v0.14.0 // indirect
golang.org/x/sync v0.3.0 // indirect
golang.org/x/sys v0.10.0 // indirect
golang.org/x/text v0.11.0 // indirect
golang.org/x/tools v0.11.0 // indirect
golang.org/x/sys v0.11.0 // indirect
golang.org/x/text v0.12.0 // indirect
golang.org/x/tools v0.12.1-0.20230815132531-74c255bcf846 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
gonum.org/v1/gonum v0.13.0 // indirect
google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4 // indirect
Expand Down
Loading
Loading