feat(kad): improve automatic bootstrap
Description
As discussed in the last maintainer call, some improvements are probably necessary for the automatic bootstrap feature (introduced by https://github.com/libp2p/rust-libp2p/pull/4838). Indeed, like @drHuangMHT mentioned in https://github.com/libp2p/rust-libp2p/issues/5341 and like @guillaumemichel has agreed, triggering a bootstrap every time an update happens inside the routing table consumes a lot more resources.
The idea behind the automatic bootstrap feature it that, when a peer is starting, if a routing table update happens we probably don't want to wait for the periodic bootstrap to trigger and we want to trigger it right now. However, like @guillaumemichel said, this is something we want to do at startup or when a network connectivity problem happens, we don't want to do that all the time.
This PR is a proposal to trigger automatically a bootstrap on routing table update but only when we have less that K_VALUE peers in it (meaning that we are starting up or something went wrong and the fact that a new peer is inserted is probably a sign that the network connectivity issue is resolved).
I have also added a new triggering condition like mentioned in the maintainer call. When discovering a new listen address and if we have no connected peers, we trigger a bootstrap. This condition is based on our own experience at Stormshield : some peers were starting before the network interfaces were up, doing so, the automatic and periodic bootstrap failed, but when the network interfaces were finally up, we were waiting X minutes for the periodic bootstrap to actually trigger a bootstrap and join the p2p network.
Notes & open questions
Change checklist
- [x] I have performed a self-review of my own code
- [x] I have made corresponding changes to the documentation
- [ ] I have added tests that prove my fix is effective or that my feature works
- [x] A changelog entry has been made in the appropriate crates
This pull request has merge conflicts. Could you please resolve them @stormshield-frb? 🙏
@stormshield-frb can you check what's happening with https://github.com/libp2p/rust-libp2p/actions/runs/9777683040/job/26994305156?pr=5474#step:6:46 ?
@stormshield-frb can you check what's happening with https://github.com/libp2p/rust-libp2p/actions/runs/9777683040/job/26994305156?pr=5474#step:6:46 ?
Should be corrected @jxs. The use crate::K_VALUE was removed in a recent commit from master that's why it failed.
It seems there is a problem with the runner no ? Almost every job fails, complaining about a unknown command tomlq
It seems there is a problem with the runner no ? Almost every job fails, complaining about a unknown command
tomlq
yeah submitted https://github.com/libp2p/rust-libp2p/pull/5481 to address it, thanks François