go-libp2p icon indicating copy to clipboard operation
go-libp2p copied to clipboard

Reflect go-libp2p's modularity in dependency tree/ Reduce binary size

Open Wondertan opened this issue 7 months ago • 0 comments
trafficstars

Problem

Let's say I configure libp2p to use TCP + yamux + TLS. This is doable and libp2p allows me to construct such a node. However, the go-libp2p is still gonna make me import pion/quic/wt/noise/etc and put them in binary.

The core issue here is how libp2p Host gets constructed. Even though go-libp2p has all the lower-level pkgs cleanly separated from one-another, the config pkg pulls it all in a single place.

Solution

Golang since quite sometime introduced graph pruning and lazy loading. By leveraging this feature, go-libp2p could provide a way to construct your Host in a way that picks only carefully selected pkgs, pruning those that are simply not used by the application.

The best part here is that go-libp2p did everything right bottom-up to achieve this. All the components are ready to be used in such a way and its only a matter of providing right recipe for library users on how to compose their host of whats absolutely necessary for their usecase.

Wondertan avatar Mar 24 '25 20:03 Wondertan