From 5814b563d3ae59872576a3e06d21fcfab9653dcc Mon Sep 17 00:00:00 2001 From: Adin Schmahmann Date: Mon, 23 Jan 2023 23:12:35 -0500 Subject: [PATCH 1/4] docs: remove documentation indicating that mplex is enabled by default --- libp2p.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libp2p.go b/libp2p.go index d77c3b9b2e..0e5746faee 100644 --- a/libp2p.go +++ b/libp2p.go @@ -37,8 +37,7 @@ func ChainOptions(opts ...Option) Option { // transport protocols; // // - If no multiplexer configuration is provided, the node is configured by -// default to use the "yamux/1.0.0" and "mplux/6.7.0" stream connection -// multiplexers; +// default to use the "yamux/1.0.0" stream connection multiplexer; // // - If no security transport is provided, the host uses the go-libp2p's noise // and/or tls encrypted transport to encrypt all traffic; From 34fca15515055241259506c0a05a070933b355a7 Mon Sep 17 00:00:00 2001 From: Adin Schmahmann Date: Mon, 23 Jan 2023 23:19:48 -0500 Subject: [PATCH 2/4] feat: expose yamux ID as a constant --- defaults.go | 2 +- p2p/muxer/yamux/transport.go | 2 ++ p2p/net/swarm/dial_worker_test.go | 2 +- p2p/net/swarm/testing/testing.go | 2 +- test-plans/cmd/ping/main.go | 2 +- 5 files changed, 6 insertions(+), 4 deletions(-) diff --git a/defaults.go b/defaults.go index 1eebd68f63..72f618a773 100644 --- a/defaults.go +++ b/defaults.go @@ -34,7 +34,7 @@ var DefaultSecurity = ChainOptions( // // Use this option when you want to *extend* the set of multiplexers used by // libp2p instead of replacing them. -var DefaultMuxers = Muxer("/yamux/1.0.0", yamux.DefaultTransport) +var DefaultMuxers = Muxer(yamux.ID, yamux.DefaultTransport) // DefaultTransports are the default libp2p transports. // diff --git a/p2p/muxer/yamux/transport.go b/p2p/muxer/yamux/transport.go index df4ff1be3b..3273836331 100644 --- a/p2p/muxer/yamux/transport.go +++ b/p2p/muxer/yamux/transport.go @@ -12,6 +12,8 @@ import ( var DefaultTransport *Transport +const ID = "/yamux/1.0.0" + func init() { config := yamux.DefaultConfig() // We've bumped this to 16MiB as this critically limits throughput. diff --git a/p2p/net/swarm/dial_worker_test.go b/p2p/net/swarm/dial_worker_test.go index 3ec0d9cee5..88af08d226 100644 --- a/p2p/net/swarm/dial_worker_test.go +++ b/p2p/net/swarm/dial_worker_test.go @@ -82,7 +82,7 @@ func makeUpgrader(t *testing.T, n *Swarm) transport.Upgrader { pk := n.Peerstore().PrivKey(id) st := insecure.NewWithIdentity(insecure.ID, id, pk) - u, err := tptu.New([]sec.SecureTransport{st}, []tptu.StreamMuxer{{ID: "/yamux/1.0.0", Muxer: yamux.DefaultTransport}}, nil, nil, nil) + u, err := tptu.New([]sec.SecureTransport{st}, []tptu.StreamMuxer{{ID: yamux.ID, Muxer: yamux.DefaultTransport}}, nil, nil, nil) require.NoError(t, err) return u } diff --git a/p2p/net/swarm/testing/testing.go b/p2p/net/swarm/testing/testing.go index ea062cfd68..0f6824c4db 100644 --- a/p2p/net/swarm/testing/testing.go +++ b/p2p/net/swarm/testing/testing.go @@ -105,7 +105,7 @@ func GenUpgrader(t *testing.T, n *swarm.Swarm, connGater connmgr.ConnectionGater pk := n.Peerstore().PrivKey(id) st := insecure.NewWithIdentity(insecure.ID, id, pk) - u, err := tptu.New([]sec.SecureTransport{st}, []tptu.StreamMuxer{{ID: "/yamux/1.0.0", Muxer: yamux.DefaultTransport}}, nil, nil, connGater, opts...) + u, err := tptu.New([]sec.SecureTransport{st}, []tptu.StreamMuxer{{ID: yamux.ID, Muxer: yamux.DefaultTransport}}, nil, nil, connGater, opts...) require.NoError(t, err) return u } diff --git a/test-plans/cmd/ping/main.go b/test-plans/cmd/ping/main.go index acedee4f08..d00d04d7cd 100644 --- a/test-plans/cmd/ping/main.go +++ b/test-plans/cmd/ping/main.go @@ -92,7 +92,7 @@ func main() { switch muxer { case "yamux": - options = append(options, libp2p.Muxer("/yamux/1.0.0", yamux.DefaultTransport)) + options = append(options, libp2p.Muxer(yamux.ID, yamux.DefaultTransport)) case "mplex": options = append(options, libp2p.Muxer("/mplex/6.7.0", mplex.DefaultTransport)) case "quic": From d4c596693ca76145d2efffb503c5a43ee08cd5bd Mon Sep 17 00:00:00 2001 From: Adin Schmahmann Date: Mon, 23 Jan 2023 23:20:57 -0500 Subject: [PATCH 3/4] feat: expose mplex ID as a constant --- p2p/muxer/mplex/transport.go | 2 ++ test-plans/cmd/ping/main.go | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/p2p/muxer/mplex/transport.go b/p2p/muxer/mplex/transport.go index b7fbe84c7f..10d54d1536 100644 --- a/p2p/muxer/mplex/transport.go +++ b/p2p/muxer/mplex/transport.go @@ -11,6 +11,8 @@ import ( // DefaultTransport has default settings for Transport var DefaultTransport = &Transport{} +const ID = "/mplex/6.7.0" + var _ network.Multiplexer = &Transport{} // Transport implements mux.Multiplexer that constructs diff --git a/test-plans/cmd/ping/main.go b/test-plans/cmd/ping/main.go index d00d04d7cd..af9fee422c 100644 --- a/test-plans/cmd/ping/main.go +++ b/test-plans/cmd/ping/main.go @@ -94,7 +94,7 @@ func main() { case "yamux": options = append(options, libp2p.Muxer(yamux.ID, yamux.DefaultTransport)) case "mplex": - options = append(options, libp2p.Muxer("/mplex/6.7.0", mplex.DefaultTransport)) + options = append(options, libp2p.Muxer(mplex.ID, mplex.DefaultTransport)) case "quic": default: log.Fatalf("Unsupported muxer: %s", muxer) From 31e6f39ec09c038682b61af09926f9ca2c32afc7 Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Mon, 23 Jan 2023 21:24:52 -0800 Subject: [PATCH 4/4] reword muxer config documentation --- libp2p.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libp2p.go b/libp2p.go index 0e5746faee..db23253b14 100644 --- a/libp2p.go +++ b/libp2p.go @@ -37,7 +37,7 @@ func ChainOptions(opts ...Option) Option { // transport protocols; // // - If no multiplexer configuration is provided, the node is configured by -// default to use the "yamux/1.0.0" stream connection multiplexer; +// default to use yamux; // // - If no security transport is provided, the host uses the go-libp2p's noise // and/or tls encrypted transport to encrypt all traffic;