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

disable mplex stream muxer #4668

Merged
merged 1 commit into from
Jan 4, 2022
Merged
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
32 changes: 3 additions & 29 deletions app/submodule/network/network_submodule.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"os"
"path/filepath"
"runtime"
"strings"
"time"

"github.com/ipfs/go-bitswap"
Expand All @@ -27,10 +26,8 @@ import (
"github.com/libp2p/go-libp2p"
"github.com/libp2p/go-libp2p-core/host"
p2pmetrics "github.com/libp2p/go-libp2p-core/metrics"
smux "github.com/libp2p/go-libp2p-core/mux"
"github.com/libp2p/go-libp2p-core/routing"
dht "github.com/libp2p/go-libp2p-kad-dht"
mplex "github.com/libp2p/go-libp2p-mplex"
libp2pps "github.com/libp2p/go-libp2p-pubsub"
yamux "github.com/libp2p/go-libp2p-yamux"
ma "github.com/multiformats/go-multiaddr"
Expand Down Expand Up @@ -112,7 +109,7 @@ type networkConfig interface {
// NewNetworkSubmodule creates a new network submodule.
func NewNetworkSubmodule(ctx context.Context, config networkConfig) (*NetworkSubmodule, error) {
bandwidthTracker := p2pmetrics.NewBandwidthCounter()
libP2pOpts := append(config.Libp2pOpts(), libp2p.BandwidthReporter(bandwidthTracker), makeSmuxTransportOption(true))
libP2pOpts := append(config.Libp2pOpts(), libp2p.BandwidthReporter(bandwidthTracker), makeSmuxTransportOption())

var networkName string
var err error
Expand Down Expand Up @@ -400,9 +397,8 @@ func buildHost(ctx context.Context, config networkConfig, libP2pOpts []libp2p.Op
return libp2p.New(opts...)
}

func makeSmuxTransportOption(mplexExp bool) libp2p.Option {
func makeSmuxTransportOption() libp2p.Option {
const yamuxID = "/yamux/1.0.0"
const mplexID = "/mplex/6.7.0"

ymxtpt := *yamux.DefaultTransport
ymxtpt.AcceptBacklog = 512
Expand All @@ -411,27 +407,5 @@ func makeSmuxTransportOption(mplexExp bool) libp2p.Option {
ymxtpt.LogOutput = os.Stderr
}

muxers := map[string]smux.Multiplexer{yamuxID: &ymxtpt}
if mplexExp {
muxers[mplexID] = mplex.DefaultTransport
}

// Allow muxer preference order overriding
order := []string{yamuxID, mplexID}
if prefs := os.Getenv("LIBP2P_MUX_PREFS"); prefs != "" {
order = strings.Fields(prefs)
}

opts := make([]libp2p.Option, 0, len(order))
for _, id := range order {
tpt, ok := muxers[id]
if !ok {
networkLogger.Warnf("unknown or duplicate muxer in LIBP2P_MUX_PREFS: %s", id)
continue
}
delete(muxers, id)
opts = append(opts, libp2p.Muxer(id, tpt))
}

return libp2p.ChainOptions(opts...)
return libp2p.Muxer(yamuxID, &ymxtpt)
}
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ require (
github.com/libp2p/go-libp2p v0.17.0
github.com/libp2p/go-libp2p-core v0.13.0
github.com/libp2p/go-libp2p-kad-dht v0.15.0
github.com/libp2p/go-libp2p-mplex v0.4.1
github.com/libp2p/go-libp2p-peerstore v0.6.0
github.com/libp2p/go-libp2p-pubsub v0.6.0
github.com/libp2p/go-libp2p-swarm v0.9.0
Expand Down
5 changes: 3 additions & 2 deletions pkg/messagepool/selection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import (
"context"
"encoding/json"
"fmt"
"github.com/stretchr/testify/require"
cbg "github.com/whyrusleeping/cbor-gen"
"io"
"math"
"math/big"
Expand All @@ -15,6 +13,9 @@ import (
"sort"
"testing"

"github.com/stretchr/testify/require"
cbg "github.com/whyrusleeping/cbor-gen"

"github.com/filecoin-project/go-address"
tbig "github.com/filecoin-project/go-state-types/big"
"github.com/filecoin-project/go-state-types/crypto"
Expand Down