charon
charon copied to clipboard
Enable libp2p hole punching
Problem to be solved
We currently require nodes to be publicly accessible via a static IP address (determined at startup), otherwise nodes must connect via a bootnode relay (using libp2p circuit relay protocol) which introduces another network hop to all those connections and introduces the complication of relay connections being recycled every few minutes requiring error handling and reconnects.
Libp2p has a set of features called at Hole Punching. Enabling hole punching would result in "some" relay connections being upgraded to "direct connections" when possible. It leverages "circuit-relay", "autonat", "identify" and "dcutr" protocols under the hood.
Direct connections have the following benefits over relay connections:
- They are long lived (not recycled every few minutes)
- They are only only a single hop, which decreases network latency.
- They remove a point of failure (the relay) while they are active.
- This feature can also be used by publicly accessible nodes with dynamic IPs.
Proposed solution
Research and investigate how to enable hole punching and ensure networking remains robust.
Out of Scope
Refactoring ENRs to native LibP2P identity if not required (doesn't seem like it)
Need to setup a meeting with libp2p team @OisinKyne