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

fix(p2p): disable quic #3937

Merged
merged 2 commits into from
Nov 14, 2024
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
17 changes: 14 additions & 3 deletions nodebuilder/p2p/addrs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package p2p

import (
"fmt"
"slices"

p2pconfig "github.com/libp2p/go-libp2p/config"
hst "github.com/libp2p/go-libp2p/core/host"
Expand All @@ -11,12 +12,22 @@ import (
// Listen returns invoke function that starts listening for inbound connections with libp2p.Host.
func Listen(cfg *Config) func(h hst.Host) (err error) {
return func(h hst.Host) (err error) {
maListen := make([]ma.Multiaddr, len(cfg.ListenAddresses))
for i, addr := range cfg.ListenAddresses {
maListen[i], err = ma.NewMultiaddr(addr)
maListen := make([]ma.Multiaddr, 0, len(cfg.ListenAddresses))
for _, addr := range cfg.ListenAddresses {
maddr, err := ma.NewMultiaddr(addr)
if err != nil {
return fmt.Errorf("failure to parse config.P2P.ListenAddresses: %w", err)
}
if !enableQUIC {
// TODO(@walldiss): Remove this check when QUIC is stable
if slices.ContainsFunc(maddr.Protocols(), func(p ma.Protocol) bool {
return p.Code == ma.P_QUIC_V1 || p.Code == ma.P_WEBTRANSPORT
}) {
continue
}
}

maListen = append(maListen, maddr)
}
return h.Network().Listen(maListen...)
}
Expand Down
24 changes: 17 additions & 7 deletions nodebuilder/p2p/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package p2p
import (
"context"
"fmt"
"os"
"strings"

"github.com/libp2p/go-libp2p"
Expand All @@ -27,6 +28,8 @@ import (
"github.com/celestiaorg/celestia-node/nodebuilder/node"
)

var enableQUIC = os.Getenv("CELESTIA_ENABLE_QUIC") == "1"

// routedHost constructs a wrapped Host that may fallback to address discovery,
// if any top-level operation on the Host is provided with PeerID(Hash(PbK)) only.
func routedHost(base HostBase, r routing.PeerRouting) hst.Host {
Expand Down Expand Up @@ -80,6 +83,19 @@ func host(params hostParams) (HostBase, error) {
params.Cfg.Upgrade()
}

transports := []libp2p.Option{
libp2p.Transport(tcp.NewTCPTransport),
libp2p.Transport(libp2pwebrtc.New),
wsTransport(tlsCfg),
}

// disable quic and webtransport client support until it is stable
if enableQUIC {
transports = append(transports,
libp2p.Transport(quic.NewTransport),
libp2p.Transport(webtransport.New))
}

opts := []libp2p.Option{
libp2p.NoListenAddrs, // do not listen automatically
libp2p.AddrsFactory(params.AddrF),
Expand All @@ -92,13 +108,7 @@ func host(params hostParams) (HostBase, error) {
libp2p.DisableRelay(),
libp2p.BandwidthReporter(params.Bandwidth),
libp2p.ResourceManager(params.ResourceManager),
libp2p.ChainOptions(
libp2p.Transport(tcp.NewTCPTransport),
libp2p.Transport(quic.NewTransport),
libp2p.Transport(webtransport.New),
libp2p.Transport(libp2pwebrtc.New),
wsTransport(tlsCfg),
),
libp2p.ChainOptions(transports...),
// to clearly define what defaults we rely upon
libp2p.DefaultSecurity,
libp2p.DefaultMuxers,
Expand Down