Skip to content

Comments

basichost: use autonatv2 to verify reachability#3231

Merged
sukunrt merged 19 commits intomasterfrom
push-wlpnwouzykwp
Jun 3, 2025
Merged

basichost: use autonatv2 to verify reachability#3231
sukunrt merged 19 commits intomasterfrom
push-wlpnwouzykwp

Conversation

@sukunrt
Copy link
Member

@sukunrt sukunrt commented Mar 9, 2025

This introduces addrsReachabilityTracker that tracks reachability on
a set of addresses. It probes reachability for addresses periodically
and has an exponential backoff in case there are too many errors
or we don't have any valid autonatv2 peer.

There's no smartness in the address selection logic currently. We just
test all provided addresses. It also doesn't use the addresses provided
by AddrsFactory, so currently there's no way to get a user provided
address tested for reachability, something that would be a problem for
dns addresses. I intend to introduce an alternative to
AddrsFactory, something like, AnnounceAddrs(addrs []ma.Multiaddr)
that's just appended to the set of addresses that we have, and check
reachability for those addresses.

There's only one method exposed in the BasicHost right now that's
ReachableAddrs() []ma.Multiaddr that returns the host's reachable
addrs. Users can also use the event EvtHostReachableAddrsChanged
to be notified when any addrs reachability changes.

@sukunrt sukunrt force-pushed the push-wlpnwouzykwp branch 8 times, most recently from 01ace3a to 44a53e9 Compare March 17, 2025 15:26
@sukunrt sukunrt force-pushed the push-wlpnwouzykwp branch from 44a53e9 to 4020bb4 Compare March 22, 2025 15:44
@sukunrt sukunrt force-pushed the push-wlpnwouzykwp branch 4 times, most recently from 6c3df6a to fb5c929 Compare March 22, 2025 16:49
@sukunrt sukunrt marked this pull request as ready for review March 22, 2025 16:59
@sukunrt sukunrt requested review from MarcoPolo and guillaumemichel and removed request for MarcoPolo and guillaumemichel March 22, 2025 16:59
@sukunrt sukunrt marked this pull request as draft March 22, 2025 16:59
This introduces `addrsReachabilityTracker` that tracks reachability on
a set of addresses. It probes reachability for addresses periodically
and has an exponential backoff in case there are too many errors
or we don't have any valid autonatv2 peer. 

There's no smartness in the address selection logic currently. We just
test all provided addresses. It also doesn't use the addresses provided
by `AddrsFactory`, so currently there's no way to get a user provided
address tested for reachability, something that would be a problem for 
dns addresses. I intend to introduce an alternative to 
`AddrsFactory`, something like, `AnnounceAddrs(addrs []ma.Multiaddr)`
that's just appended to the set of addresses that we have, and check
reachability for those addresses. 

There's only one method exposed in the BasicHost right now that's 
`ReachableAddrs() []ma.Multiaddr` that returns the host's reachable
addrs. Users can also use the event `EvtHostReachableAddrsChanged`
to be notified when any addrs reachability changes.
@sukunrt sukunrt force-pushed the push-wlpnwouzykwp branch from fb5c929 to 818a700 Compare March 23, 2025 18:31
@sukunrt sukunrt requested a review from MarcoPolo March 24, 2025 15:09
@sukunrt sukunrt marked this pull request as ready for review March 24, 2025 15:09
@sukunrt sukunrt requested a review from guillaumemichel March 24, 2025 15:27
Copy link
Collaborator

@MarcoPolo MarcoPolo left a comment

Choose a reason for hiding this comment

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

I took a glance, but this is a lot. I get that the core logic is pretty straightforward which is nice, but there's a lot of plumbing required. It might be nicer if this weren't in the basic host package so it could be evaluated along a stricter API boundary.

It would also be nice if we could add some fuzz/invariant tests to the reachability tracker.

@sukunrt sukunrt force-pushed the push-wlpnwouzykwp branch 2 times, most recently from 5c32430 to abf1bdf Compare April 28, 2025 20:30
@sukunrt sukunrt force-pushed the push-wlpnwouzykwp branch from abf1bdf to 0b46ec6 Compare April 28, 2025 20:30
Copy link
Collaborator

@MarcoPolo MarcoPolo left a comment

Choose a reason for hiding this comment

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

After these comments, I think this is good! This is a lot of plumbing. Thanks for being careful about it and adding a lot of tests :)

// - context is completed
// - there are too many consecutive failures from the client
// - the client has no valid peers to probe
func runProbes(ctx context.Context, concurrency int, addrsTracker *probeManager, client autonatv2Client) bool {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This feels like it should be a method on addrsReachabilityTracker after
probeManager is consolidated to it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

Okay, can we make this a method on probeManager at least?

MarcoPolo

This comment was marked as duplicate.

@sukunrt sukunrt force-pushed the push-wlpnwouzykwp branch 5 times, most recently from 104d6a0 to 44c871a Compare May 14, 2025 22:07
@sukunrt sukunrt force-pushed the push-wlpnwouzykwp branch from 44c871a to 9f7bf58 Compare May 15, 2025 18:30
@sukunrt sukunrt force-pushed the push-wlpnwouzykwp branch from 9f7bf58 to 1f0f310 Compare May 15, 2025 18:33
@sukunrt sukunrt force-pushed the push-wlpnwouzykwp branch from 1f0f310 to d048ba7 Compare May 16, 2025 08:40
Copy link
Contributor

@guillaumemichel guillaumemichel left a comment

Choose a reason for hiding this comment

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

Looks good!

// - context is completed
// - there are too many consecutive failures from the client
// - the client has no valid peers to probe
func runProbes(ctx context.Context, concurrency int, addrsTracker *probeManager, client autonatv2Client) bool {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Okay, can we make this a method on probeManager at least?

Copy link
Collaborator

@MarcoPolo MarcoPolo left a comment

Choose a reason for hiding this comment

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

Minor things, but looks good. Feel free to merge after addressing the nits.

@sukunrt sukunrt force-pushed the push-wlpnwouzykwp branch from cf01834 to 3beeed0 Compare June 3, 2025 11:21
@sukunrt sukunrt merged commit fb1d951 into master Jun 3, 2025
11 checks passed
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