rust-libp2p icon indicating copy to clipboard operation
rust-libp2p copied to clipboard

feat(kad): improve automatic bootstrap

Open stormshield-frb opened this issue 1 year ago • 1 comments

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

stormshield-frb avatar Jun 18 '24 16:06 stormshield-frb

This pull request has merge conflicts. Could you please resolve them @stormshield-frb? 🙏

mergify[bot] avatar Jun 18 '24 18:06 mergify[bot]

@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 ?

jxs avatar Jul 03 '24 12:07 jxs

@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.

stormshield-frb avatar Jul 03 '24 15:07 stormshield-frb

It seems there is a problem with the runner no ? Almost every job fails, complaining about a unknown command tomlq

stormshield-frb avatar Jul 03 '24 20:07 stormshield-frb

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

jxs avatar Jul 04 '24 10:07 jxs