Skip to content

*: improve NAT hole punching#4516

Open
KaloyanTanev wants to merge 1 commit into
mainfrom
kalo/nat-hole-punching
Open

*: improve NAT hole punching#4516
KaloyanTanev wants to merge 1 commit into
mainfrom
kalo/nat-hole-punching

Conversation

@KaloyanTanev
Copy link
Copy Markdown
Collaborator

ForceDirectConnections does require the peers to attempt this at the exact same time, which occurs only when the stars align... libp2p.EnableHolePunching() should attempt direct connection in much more sophisticated and native way.

It is yet to be tested on hoodi.

category: feature
ticket: #4233

@KaloyanTanev KaloyanTanev requested review from Copilot and pinebit May 8, 2026 14:05
@KaloyanTanev KaloyanTanev self-assigned this May 8, 2026
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 8, 2026

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR switches Charon’s NAT traversal strategy from a custom “force direct dial” loop to libp2p’s built-in DCUtR hole punching, aiming to more reliably upgrade relay connections to direct connections.

Changes:

  • Enabled libp2p hole punching via libp2p.EnableHolePunching() when constructing the host.
  • Removed the ForceDirectConnections lifecycle hook and its lifecycle ordering/wiring.
  • Updated lifecycle stringer outputs to reflect the removed start hook.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
p2p/p2p.go Enables libp2p hole punching and removes custom forced-direct connection logic; updates an inline comment in QUIC upgrade path.
app/app.go Stops registering the removed ForceDirectConnections lifecycle start hook.
app/lifecycle/order.go Removes StartForceDirectConns from the global start ordering.
app/lifecycle/orderstart_string.go Regenerated/updated OrderStart stringer mapping after removing StartForceDirectConns.
app/lifecycle/orderstop_string.go Updates OrderStop stringer implementation (consistent with regenerated output).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 8, 2026

Codecov Report

❌ Patch coverage is 50.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 57.07%. Comparing base (764e780) to head (52ffa28).

Files with missing lines Patch % Lines
app/lifecycle/orderstart_string.go 50.00% 0 Missing and 1 partial ⚠️
app/lifecycle/orderstop_string.go 50.00% 0 Missing and 1 partial ⚠️
p2p/p2p.go 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4516      +/-   ##
==========================================
+ Coverage   57.05%   57.07%   +0.02%     
==========================================
  Files         245      245              
  Lines       32964    32934      -30     
==========================================
- Hits        18806    18797       -9     
+ Misses      11782    11759      -23     
- Partials     2376     2378       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants