Skip to content

Conversation

@momoshell
Copy link

@momoshell momoshell commented Oct 23, 2025

Description

For quite some time, I've observed that behaviors used in production were deteriorating over time. Specifically, KAD queries started failing, nodes remained stuck in kad::Mode::Client, and Autonat repeatedly failed to confirm external addresses, often stuck with a single check per PeerID.

Inspection revealed that the Identify protocol was returning addresses with ephemeral ports. As a result, all behaviors attempted to dial discovered peers on these ephemeral ports, leading to failed outbound connections.

This was happening because the Transport::Dial future lacked a way to notify NetworkBehaviour implementations about which PortUse policy was ultimately applied while creating outbound connections.

This PR aims to address this by enabling this promise to yield this data, allowing behaviors to respond appropriately based on the PortUse policy in use.

Fixes #5820
Should help with related paritytech/polkadot-sdk#7207

Notes & open questions

Huge thanks and shoutout to @dmitry-markin —without his insights into the problem, I wouldn't have been able to start on this.

This PR is large and contains many changes, but I've done my best to organize it. Since each commit addresses a separate crate, I suggest reviewing it commit-by-commit for the clearest path through the changes. 🙏

I'd appreciate an extra set of eyes on all changes, but I'm specifically looking for a thorough review of the modifications to priv_client within the Relay crate, as I have some unease about them.

I will keep this as a draft until I add some additional tests in the following days.

Change checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • A changelog entry has been made in the appropriate crates

@momoshell momoshell changed the title feat(Trasnport::Dial): Yielding actual PortUse policy used while creating Outbound Connections feat(Trasnport::Dial): PortUse policy yielded while creating Outbound Connections Oct 23, 2025
@momoshell momoshell changed the title feat(Trasnport::Dial): PortUse policy yielded while creating Outbound Connections feat(Transport::Dial): PortUse policy yielded for Outbound Connections Oct 23, 2025
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.

Address translation doesn't work correctly with non-reused ephemeral ports

1 participant