forked from libp2p/rust-libp2p
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Follow-up commits for AutoNATv2 #2
Merged
umgefahren
merged 32 commits into
umgefahren:implement-autonat-v2
from
libp2p:autonatv2-thomas-followup
Dec 30, 2023
Merged
Follow-up commits for AutoNATv2 #2
umgefahren
merged 32 commits into
umgefahren:implement-autonat-v2
from
libp2p:autonatv2-thomas-followup
Dec 30, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Through the use of let-else, we can early-exit on the unhappy-path. We also update the log message to remove the "cause" as there can be a multitude of reasons, why we received a nonce that we didn't expect, e.g. it could also be a bug in the client or the server implementation so we don't want to jump to conclusions here.
Fix the event handling to only update the flag for the connection that the event originated from.
Connections are always scoped to a particular peer and the PeerId is reported with every event sent from the handler to the behaviour. We don't need to include it in the event.
This is now handled in the `AddressInfo` struct.
We filter straight after this for the same conditions.
An AutoNAT server will always only dial a single address. Thus, we are more likely to get a quicker results for all our candidates if we send each candidate to a different server.
We only ever insert into the `peer_info` map for established connections. We either establish a connection or receive a `DialFailure`. Thus, there will never be any state in `peer_info` for a failed connection so there is nothing to be cleaned up.
4 tasks
The nonce of a probe is essentially like a primary key that is decided by the client. Thus, any event emitted by the handler should be indexed by the provided nonce. We can achieve this by using a `FuturesMap` instead of a `FuturesSet`. This gives us access to the nonce even in the case that the actual protocol times out. With the nonce in place, we had to re-model the event returned to the behaviour. Most importantly. we need to separate the different kinds of errors: - Complete execution of the protocol but address is not reachable - Protocol was aborted mid-way - Server does not support the protocol We can't really do anything if the protocols is aborted so we just represent this case with an `io::Error` that gets logged further up. As a result, this means we can remove the `Option` from the event emitted to the user and _always_ give them a `Multiaddr`.
thomaseizinger
force-pushed
the
autonatv2-thomas-followup
branch
from
December 30, 2023 06:02
f16b3a3
to
42ac03c
Compare
umgefahren
reviewed
Dec 30, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That looks very good to me. Thanks for the changes. It sped up the process.
} | ||
|
||
// FIXME: We don't want test-only APIs in our public API. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried using #[cfg(test)]. But that didn't work in integration tests.
umgefahren
merged commit Dec 30, 2023
88b1092
into
umgefahren:implement-autonat-v2
22 of 69 checks passed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Opening this as a separate PR because I don't have permissions to push to your branch directly.
I had some time on the plane and the WiFi connection was shit so I figured it is a better use of time to just write some code instead of more comments :)
Have a read through and let me know what you think. For most commits, I explained the reasoning of the change but if anything is unclear, please let me know.