Allow using go-ibp2p with fewer mandatory dependencies
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 6.9k
- Forks
- 1.3k
- Avg merge
- 13d 21h
- Merged PRs (30d)
- 1
Description
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:
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:
- https://github.com/libp2p/go-libp2p/blob/e5b7bf00c16698ae661d3e587a4cc8bfa5738666/options.go#L102
- https://github.com/libp2p/go-libp2p/blob/e5b7bf00c16698ae661d3e587a4cc8bfa5738666/libp2p_test.go#L200-L211
- https://github.com/libp2p/go-libp2p/blob/e5b7bf00c16698ae661d3e587a4cc8bfa5738666/config/config.go#L391-L422
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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing transport references in defaults.go, options.go, config/config.go, and libp2p_test.go, focusing on the linked DefaultTransports and quicreuse paths. Review how the TCP-only configuration reaches these packages and identify the dependency boundaries that need redesign. Done means unused transports, including QUIC when not configured, are no longer mandatory dependencies and the affected tests pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- networking
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100