Skip to content
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(p2p): make bootstrapping non-blocking #167

Merged
merged 1 commit into from
Mar 25, 2024
Merged

Conversation

Wondertan
Copy link
Member

@Wondertan Wondertan commented Mar 25, 2024

We were waiting for all bootstrapper connections to either fail or succeed. The side effect of this approach is that a single connection may stall for various reasons, preventing the Exchange client from starting in an adequate amount of time.

This patch ensures that every connection attempt has a generous timeout of 1m and that connections are not blocked for startup. We don't, in fact, need to wait for any connection to succeed and continue application startup. This also optimizes the startup time in the best case, as the application would be able to operate with new connections as they come and established, instead of waiting for the whole group of bootstrapper connections to either fall or succeed.

@Wondertan Wondertan self-assigned this Mar 25, 2024
@codecov-commenter
Copy link

codecov-commenter commented Mar 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 63.02%. Comparing base (bdda26a) to head (e0c6a97).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #167      +/-   ##
==========================================
+ Coverage   62.87%   63.02%   +0.15%     
==========================================
  Files          39       39              
  Lines        3577     3573       -4     
==========================================
+ Hits         2249     2252       +3     
+ Misses       1155     1150       -5     
+ Partials      173      171       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Wondertan Wondertan force-pushed the p2p/connect-timeout branch from 181faa3 to e0c6a97 Compare March 25, 2024 13:55
@Wondertan Wondertan changed the title fix(p2p): set connect timeout fix(p2p): make bootstrapping non-blocking Mar 25, 2024
@Wondertan Wondertan marked this pull request as ready for review March 25, 2024 14:05
@Wondertan Wondertan enabled auto-merge (squash) March 25, 2024 14:10
@Wondertan Wondertan merged commit 3b63466 into main Mar 25, 2024
4 checks passed
@Wondertan Wondertan deleted the p2p/connect-timeout branch March 25, 2024 14:12
Comment on lines -82 to -85
// bootstrap connections to trusted
wg := sync.WaitGroup{}
wg.Add(len(trusted))
defer wg.Wait()
Copy link
Member

Choose a reason for hiding this comment

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

Does removing of waitgroup imply, that it doesn't need to wait for any connections to succeed anymore before returning from bootstrap()? Is it ok if all of the (or some) fail?

Copy link
Member Author

@Wondertan Wondertan Mar 25, 2024

Choose a reason for hiding this comment

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

Is it ok if all of the (or some) fail?

yes

Does removing of waitgroup imply, that it doesn't need to wait for any connections to succeed anymore before returning from bootstrap()?

Also yes, with a little caveat. The waiting for connections will still happen on the libp2p swarm level, if application decides to request anything and connections are still in progress

Copy link
Member

Choose a reason for hiding this comment

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

Just trying to understand what happens here. Looks like bootsrap() is acting as an optional call, since it does not wait for any connections and does not even has retries. So there might be 0 connections in the end. Does bootsrap() suppose to provide some connections to peer-tracker? If all of the connection fail would it result in some unwanted state? Would it make sense to add reconnects inside bootsrap in case 0 successful connections happened?

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.

5 participants