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

p2p: start p2p networking and DHT ops when starting services, not when instantiating them #5867

Merged
merged 7 commits into from
Dec 21, 2023

Conversation

algorandskiy
Copy link
Contributor

@algorandskiy algorandskiy commented Dec 11, 2023

Summary

  1. Made code changes required to follow the algod's Services architecture: make + start as separate stages.
    This is done by using NoListenAddr for p2p.Host and by providing an empty bootstrap callback to DHT.
    When net.Start() is being called, manually calling Listen on p2p host, and unblock the bootstrap callback to return phonebook or DNS addresses for peering.
  2. Also moved DHT init to netowork/p2p from node.
  3. Changed GossipNode.Start() signature to return an error (and possibly explicitly abort node startup).

Test Plan

  1. Existing tests passed
  2. Added DHT tests as part of p2p network

* Do not start listening/connecting until net.Start
  This is done by using NoListenAddr for p2p.Host
  and by providing an empty bootstrap callback to DHT
* Move DHT init to p2p from node

* TODO: p2p dht tests
Copy link

codecov bot commented Dec 12, 2023

Codecov Report

Attention: 49 lines in your changes are missing coverage. Please review.

Comparison is base (c37c155) 55.92% compared to head (5bd2c00) 55.89%.

Files Patch % Lines
network/p2p/p2p.go 30.43% 16 Missing ⚠️
network/p2pNetwork.go 87.50% 4 Missing and 3 partials ⚠️
daemon/algod/server.go 0.00% 6 Missing ⚠️
network/hybridNetwork.go 0.00% 6 Missing ⚠️
node/node.go 50.00% 4 Missing and 2 partials ⚠️
node/follower_node.go 58.33% 4 Missing and 1 partial ⚠️
network/p2p/capabilities.go 60.00% 2 Missing ⚠️
network/wsNetwork.go 80.00% 1 Missing ⚠️
Additional details and impacted files
@@               Coverage Diff               @@
##           feature/p2p    #5867      +/-   ##
===============================================
- Coverage        55.92%   55.89%   -0.03%     
===============================================
  Files              480      480              
  Lines            67692    67735      +43     
===============================================
+ Hits             37855    37861       +6     
- Misses           27272    27309      +37     
  Partials          2565     2565              

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

@algorandskiy algorandskiy changed the title WIP: start p2p networking when starting services, not when instantiating then p2p: start p2p networking and DHT ops when starting services, not when instantiating then Dec 13, 2023
@algorandskiy algorandskiy marked this pull request as ready for review December 13, 2023 23:05
@algorandskiy algorandskiy changed the title p2p: start p2p networking and DHT ops when starting services, not when instantiating then p2p: start p2p networking and DHT ops when starting services, not when instantiating them Dec 14, 2023
daemon/algod/server.go Outdated Show resolved Hide resolved
Comment on lines +104 to +108
// the libp2p.NoListenAddrs builtin disables relays but this one does not
var noListenAddrs = func(cfg *libp2p.Config) error {
cfg.ListenAddrs = []multiaddr.Multiaddr{}
return nil
}
Copy link
Contributor

Choose a reason for hiding this comment

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

libp2p docs say that their NoListenAddrs disables relays because:

It also disables relay, unless the user explicitly specifies with an option, as the transport creates an implicit listen address that would make the node dialable through any relay it was connected to.

This is worth looking into, perhaps with another test. I'll see if I can find out more

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I found there is already a test for B -> A -> C transmission - see TestP2PSubmitTX. So we are all covered.

network/hybridNetwork.go Outdated Show resolved Hide resolved
@algorandskiy algorandskiy merged commit 1de1595 into algorand:feature/p2p Dec 21, 2023
16 checks passed
@algorandskiy algorandskiy added the p2p Work related to the p2p project label Jan 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p2p Work related to the p2p project Skip-Release-Notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants