Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(iroh-net): Make a single direct address in NodeAddr instant #2580

Merged
merged 13 commits into from
Aug 5, 2024

Conversation

flub
Copy link
Contributor

@flub flub commented Aug 2, 2024

Description

In #2509 (c1c3539) we removed chosing
a random unconfirmed direct address and through both it and the relay
if we did not yet have any confirmed direct address. This required
any direct address passed in via a NodeAddr to do a DISCO Ping-Pong
round trip before it would be used.

It turns out this is used a lot in the sense that a common socket
address is used: when you know an IP is reachable. Requiring a ping
would mean the first QUIC packets would be dropped, Quinn would wait
to detect this before retrying and connections are delayed by an
observable second by the end of it all. Not great for this scenario,
even if it can be argued that outside of tests this is not a common
scenario.

So this brings back the random selection of unconfirmed addresses.

It tries to do this without adding more complexity to the NodeState.
Instead it consolidates the path information and best address into the
NodeUdpState struct. But without any logic changes. It then adds
just this extra caching of the chosen address to this struct.

This is a huge simplification of a much larger refactor I was trying
to do first. I believe that was the right track but resulted in too
many changes to do in one large PR. So the long-term goal here is to
continue removing state manipulation outside of NodeUdpState struct so
that it gains more control of how to manage the UDP paths. This will
help the logic of how UDP paths are chosen to be based entirely on the
PathState - which is the right model for this.

Breaking Changes

None

Notes & open questions

Fixed #2546

Change checklist

  • Self-review.
  • Documentation updates following the style guide, if relevant.
  • Tests if relevant.
  • All breaking changes documented.

Copy link

github-actions bot commented Aug 2, 2024

Documentation for this PR has been generated and is available at: https://n0-computer.github.io/iroh/pr/2580/docs/iroh/

Last updated: 2024-08-05T14:50:20Z

@dignifiedquire
Copy link
Contributor

doc comments are sad


// The highest acceptable latency for an endpoint path. If the latency is higher
// then this the path will be ignored.
const MAX_LATENCY: Duration = Duration::from_secs(60 * 60);
Copy link
Contributor

Choose a reason for hiding this comment

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

this seems rather pointless.. latency of 1 hour?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I don't really know how this is useful either. Though this code is copy-pasted and I'd really like to avoid doing unrelated changes here. I do want to carry on fixing up things here though, but in small PRs that each target one thing because my attempt to do a bunch of this together became messy and un-reviewable.

@flub
Copy link
Contributor Author

flub commented Aug 5, 2024

fwiw test that rely on this functionality now run in 200ms again instead of being 1.2s

@flub flub requested a review from dignifiedquire August 5, 2024 09:24
@flub flub added fix Fixes a bug c-iroh labels Aug 5, 2024
@dignifiedquire dignifiedquire added this to the v0.22.0 milestone Aug 5, 2024
@flub flub enabled auto-merge August 5, 2024 14:53
@flub flub added this pull request to the merge queue Aug 5, 2024
Merged via the queue into main with commit f5b3918 Aug 5, 2024
28 checks passed
@flub flub deleted the flub/single-direct-addr branch August 5, 2024 15:32
github-merge-queue bot pushed a commit that referenced this pull request Aug 9, 2024
# Description

There are no functional changes, this only moves code and fixes up
imports.

## Breaking Changes

None

## Notes & open questions

This is on top of #2580, which needs to be merged first.

## Change checklist

- [x] Self-review.
- [x] Documentation updates following the [style
guide](https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text),
if relevant.
- [x] Tests if relevant.
- [x] All breaking changes documented.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c-iroh fix Fixes a bug
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

NodeAddr with a direct address incurs an extra RTT
2 participants