libp2p / libp2p/go-libp2p

Allow using go-ibp2p with fewer mandatory dependencies

Open
#3,495 1 comment 2 reactions 0 assignees View on GitHub

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:

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.