Skip to content

Conversation

@guillaumemichel
Copy link
Collaborator

Fixes ipfs/kubo#11085

Previously, when using the SweepingProvider with the Accelerated DHT Client, the initial prefix length estimation and provide process would start before the initial fullrt crawl is complete. Before the crawl is complete, fullrt's GetClosestPeers doesn't return any peers, which makes the initial prefix length estimation and first provide operations incorrect.

This patch updates the connectivity checker's probe function, so that the node is considered online by the connectivity checker only after the accelerated DHT client is Ready (which means the initial crawl is complete).

@lidel lidel self-assigned this Jan 8, 2026
type readyKadClosestPeersRouter interface {
KadClosestPeersRouter
Ready() bool
}
Copy link
Contributor

@gammazero gammazero Jan 8, 2026

Choose a reason for hiding this comment

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

Seems like all closest peers routers should have a Ready method, since there must be some time to crawl the network. If that is true, then maybe better to make the Ready method part of the KadClosestPeersRouter interface.

Copy link
Member

Choose a reason for hiding this comment

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

Hm.. regular router does not crawl network upfront, only accelerated DHT client does this.
But it could be simpler code if we dont have separate interface, and make regular router have Ready() that just returns true?

iiuc:

  • KadClosestPeersRouter is exported but relatively new(?), so if we change it, better to do it early
  • External implementations that dont have any startup delay would need to add Ready() bool { return true }, probably ok

@guillaumemichel thoughts?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I would rather keep the FullRT complexity out of the provider module, and not depend on accelerated DHT interfaces at all.

IMO ipfs/kubo#11137 is a better fix.

log when provider is waiting for fullrt crawl to complete and when it
becomes ready, helping operators understand startup delays when using
Accelerated DHT Client with sweep provider
}
}

var loggedWaiting, loggedReady bool
Copy link
Member

@lidel lidel Jan 8, 2026

Choose a reason for hiding this comment

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

This is UX improvement: I strongly believe we should log this to INFO level, so user is not surprised provide system does nothing.

Pushed small improvement in 1a2a13c that will print this (only state transition, we dont spam logs):

2026-01-08T15:57:20.808+0100	DEBUG	dht/provider	provider/provider.go:492	Starting SweepingProvider
2026-01-08T15:57:20.808+0100	INFO	dht/provider	provider/provider.go:285	waiting for router to be Ready() before providing
...

2026-01-08T16:02:03.124+0100	INFO	dht/provider	provider/provider.go:291	router is Ready(), starting to provide
2026-01-08T16:02:03.125+0100	DEBUG	dht/provider	provider/provider.go:744	prefix len approximation is 7

(if the PR is refactored, just make sure we keep this level of verbosity about Ready state)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Users can also check the connectivity status in ipfs provide stat. Provide operations only happen when the status is online, not when disconnected or offline. The provider starts in disconnected state until it is ready to provide.

@lidel lidel mentioned this pull request Jan 8, 2026
49 tasks
// crawl to complete before providing. Otherwise, GetClosestPeers
// returns no peers and prefix length estimation is incorrect.
if readyRouter, ok := cfg.router.(readyKadClosestPeersRouter); ok {
if !readyRouter.Ready() {
Copy link
Contributor

Choose a reason for hiding this comment

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

If it is possible for the router to go from ready to not-ready state, then reset flags, and consider a single state variable.

Suggested change
if !readyRouter.Ready() {
if !readyRouter.Ready() {
if loggedReady {
// If router has gone from ready to not-ready state, reset flags.
loggedReady = false
loggedWaiting = false
}

If it is not possible for a router to go from ready to not-ready, then have a flag the avoids checks after reaching ready state.

@guillaumemichel
Copy link
Collaborator Author

IMO ipfs/kubo#11137 is a better fix and we can close this PR.

It moves fullrt dependency to kubo instead of having dependency on fullrt interfaces (such as Ready()) in the provider module.

@lidel
Copy link
Member

lidel commented Jan 10, 2026

I'm fine either way. ipfs/kubo#11137 is simple and already merged, if you feel this is overly verbose, we can close.

When it comes to UX, i think its unlikely people will debug logs.
If users get confused why nothing happens for first 5-10 minutes, we can improve ipfs provide stat instead

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.

DHT Sweep only sees 1 Region when Accelerated Client is enabled

4 participants