Skip to content

Modularize go-libp2p — Libp2p/2025 #27

@cewood

Description

@cewood

Modularize go-libp2p

Type: Refactor (Stability & Security)

Prysm, Anytype, Celestia, etc. want to have greater control on the set of dependencies and modules they import while using go-libp2p. Currently go-libp2p introduces a large number of compile time dependencies.

Therefore, through pruning the dependency tree, refactoring, making configuration options more ergonomic, etc. we want to create a very low-cost abstraction for p2p networks to build on go-libp2p (vs custom protocols over QUIC).

This can be achieved by providing a new, smaller go-libp2p library which imports a minimal set of dependencies and through better config options, enables users to build and configure the host with only what they need.

Prototype solution:
https://gist.github.com/sukunrt/8a09ed8e2959dfb033ee9d17fc1d7049

An alternative is a simpler, no defaults, go-libp2p constructor: libp2p/go-libp2p#2962
This keeps the existing Host interface. The main difference is in how the Host is constructed. Instead of the existing constructor a new constructor that uses Fx directly will be exposed. This constructor will let users opt-in to all behaviors explicitly. Nothing will be provided by default to opt-out of.

This should also similarly surface in gossipsub and kad-dht.

ETA

Q4 2025

Expected impact

More satisfied power users, with lower costs of maintenance / audits.

Fewer occurrences of non-adoption to barriers to entry of the “kitchen-sink” approach.

Easier adoption curve based on developers adopting the components they need (e.g. adding in hole punching, UPnP, etc. only if they need it), and building / contributing alternative / missing components.

Key users

Prysmatic Labs (Prysm — Go implementation of Ethereum Consensus client) has requested this project.
This project will help with adoption and maintainability of go-libp2p. We expect that users who want a more modular libp2p with fewer dependencies will adopt this change.

Upstream tracking issue

libp2p/go-libp2p#3294

Metadata

Metadata

Assignees

Projects

Status

Cancelled

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions