helia
helia copied to clipboard
Remove DHT and bootstrapping from browser defaults
Background
Using the Amino DHT from browsers is currently problematic and expensive:
- <1/3 of the Amino DHT supports transports accessible from a browser https://probelab.io/ipfsdht/#dht-transport-distribution
- Almost all of those are WebTransport, which is currently only supported in Chromium (although Firefox support is close)
- However, Chromium has artificial throttling of WebTransport connections which makes using them en-mass quite painful, particularly in p2p networks like the Amino DHT where peers may come and go since the throttling over-punishes dials to absent peers. https://issues.chromium.org/issues/40069954
- The net result is that we currently spin up many connections in the browser that are themselves not useful which is a tremendous waste of resources and harms the overall experience
Because Helia is used for a variety of tasks spinning up expensive network calls that are unlikely to be useful is a problematic default. For instance, this helia example for working with a CAR spins up over 200 connections despite not needing the network at all. https://github.com/ipfs-examples/helia-examples/blob/c900274c2819ae320262009974d9a770e5a72955/examples/helia-create-car/src/provider/HeliaProvider.jsx#L38. While perhaps the example could change, I think it's worth considering that it's likely others will create examples in a similar way and it'd be better to give them a good onboarding experience by default.
Proposal
Let's remove the DHT and bootstrap-based peer discovery from the browser defaults. Such as: https://github.com/ipfs/helia/blob/6c88ee1530861357d23ea49d20aac3c1b5aa0bd9/packages/helia/src/utils/libp2p-defaults.browser.ts#L65-L73
https://github.com/ipfs/helia/blob/6c88ee1530861357d23ea49d20aac3c1b5aa0bd9/packages/helia/src/utils/libp2p-defaults.browser.ts#L58-L60
What's Next?
As things like WebRTC-direct are rolled out by default in kubo and become more present in the Amino DHT and if/when the Chromium bugs are fixed it would be reasonable to evaluate re-enabling the Amino DHT by default, but IMO we should keep the defaults at what works best now rather than what we hope will be best later.