-
Notifications
You must be signed in to change notification settings - Fork 876
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(kad): correctly handle NoKnownPeers
error when bootstrap
#5349
base: master
Are you sure you want to change the base?
fix(kad): correctly handle NoKnownPeers
error when bootstrap
#5349
Conversation
This looks a bit hacky, wouldn't it be better to modify the bootstrap |
I'm not sure to understand what you mean. Even if I would update the I agree that it would feel better to have a passive way to learn that a bootstrap did start or finish but I don't see how to implement that in a reasonably simple manner. The reason we need to know if a bootstrap as started or finished is because we don't want to cascade bootstrap requests. When a bootstrap is triggered (no matter if it was automatic, periodic or manual), we reset the automatic and periodic timer to their initial value. |
67e9aca
to
ec9898f
Compare
@@ -931,6 +931,7 @@ where | |||
/// This parameter is used to call [`Behaviour::bootstrap`] periodically and automatically | |||
/// to ensure a healthy routing table. | |||
pub fn bootstrap(&mut self) -> Result<QueryId, NoKnownPeers> { | |||
self.bootstrap_status.on_started(); |
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.
What I meant is that if peers.is_empty()
we may not want to call self.bootstrap_status.on_started()
at all, because we aren't performing a bootstrap.
If a periodic timer needs to be reset within the Status
then the timer reset should probably be implemented there rather than calling on_started()
, because no actual bootstrap is started. Or maybe I didn't understand what the original issue is?
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.
Sorry for the long time to reply.
I do agree a little bit with what you say. However, we encountered another issue with this on another matter.
Before periodic / automatic bootstrap, the user could always react to a NoKnownPeers
error because it was he that triggered the bootstrap. However, since now the bootstrap is triggered automatically, the user is never notified if a NoKnownPeers
error occurs.
That is why in our fork we have now removed the special case where we check if our routing table is empty before triggering a bootstrap : we always trigger it. Doing so allows us to receive an OutboundQueryProgressed
with empty stats, allowing us to learn that a bootstrap has failed. We can then react to it and do some stuffs.
If you agree with this change (removing the check for empty routing table), then I think we can close this conversation because we can call self.bootstrap_status.on_started()
because we actually always trigger one.
What do you think ? Do you agree that there is no need to check for empty routing table before triggering a bootstrap ? (no other kad
call does this by the way).
ec9898f
to
f2d3e48
Compare
f2d3e48
to
f0ee433
Compare
Description
After testing
master
, we encountered a bug due to #4838 when doing automatic or periodic bootstrap if the node has no known peers.Since it failed immediately, I though there was no need to call the
bootstrap_status.on_started
method. But no doing so never reset the periodic timer insidebootstrap_status
resulting in getting stuck to try to bootstrap every timepoll
is called onkad::Behaviour
.Notes & open questions
N/A
Change checklist