Skip to content

Commit

Permalink
disable quic
Browse files Browse the repository at this point in the history
  • Loading branch information
walldiss committed Nov 14, 2024
1 parent fa01196 commit 40bea0e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 10 deletions.
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

0 comments on commit 40bea0e

Please sign in to comment.