#3495·go-libp2p

Allow using go-ibp2p with fewer mandatory dependencies

Author: brandondCreated Apr 28, 2026Updated Jun 14, 2026

At the moment, simply importing go-libp2p (or a project that uses it, such as spegel) pulls in a VERY large set of indirect dependencies. These dependencies are all used even if only a single transport is enabled with libp2p.ChainOptions(libp2p.NoTransports, libp2p.Transport(tcp.NewTCPTransport))

For example, even if only tcp is used, dependencies for all available transports are pulled in due to all transports being referenced in DefaultTransports variable:

https://github.com/libp2p/go-libp2p/blob/2f158627d8599d90c1c8fd33d8b414308ae3c61f/defaults.go#L45-L51

Even if DefaultPrivateTransports and DefaultTransports are modified to avoid importing unwanted transports, it is impossible to avoid pulling in github.com/quic-go/quic-go as the quicreuse transport is baked deeply into the base and config packages:

Eliminating unused transports (other than quic) saves ~8MB off the size of a simple binary that uses go-libp2p. Eliminating quic when not used would further reduce the size by ~1.6MB.

Ideally the transport abstractions would not leak into the Options and Configs (and tests for same), and the base package would not pull in all transports by default.