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

network: allow multi-role phonebook entries #6131

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

algorandskiy
Copy link
Contributor

@algorandskiy algorandskiy commented Sep 13, 2024

Summary

  1. Allowed a single phonebook entry to have multiple roles
    • P2P node can advertise both gossip and archival capabilities
    • The existing implementation did not support that but it was not an issue because (2) below
  2. Moved DHT operations to meshThread from GetPeers:
    • To have all DHT ops in one place
    • To have GeetPeers be non-network query dependent

Test Plan

Added unit tests for multi roles peers in phonebook and peerstore wrapper.

Copy link

codecov bot commented Sep 13, 2024

Codecov Report

Attention: Patch coverage is 93.44262% with 4 lines in your changes missing coverage. Please review.

Project coverage is 56.31%. Comparing base (eff5fb4) to head (ee6b2d0).

Files with missing lines Patch % Lines
network/p2pNetwork.go 85.71% 2 Missing and 1 partial ⚠️
network/phonebook/phonebook.go 95.65% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6131      +/-   ##
==========================================
+ Coverage   55.99%   56.31%   +0.31%     
==========================================
  Files         494      494              
  Lines       69958    69984      +26     
==========================================
+ Hits        39174    39408     +234     
+ Misses      28077    27901     -176     
+ Partials     2707     2675      -32     

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

@algorandskiy algorandskiy changed the title WIP: network: allow multi-role phonebook entries network: allow multi-role phonebook entries Sep 16, 2024
@algorandskiy algorandskiy requested review from cce and gmalouf September 16, 2024 14:44
@algorandskiy algorandskiy marked this pull request as ready for review September 16, 2024 14:44
// currently, we have two roles : relay role and archival role, which are mutually exclusive.
//
//msgp:ignore PhoneBookEntryRoles
type PhoneBookEntryRoles int
Copy link
Contributor Author

Choose a reason for hiding this comment

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

renamed because of linter complaint about "phonebook.PhoneBookXYZ" repeating

config/config_test.go Outdated Show resolved Hide resolved

// also discover archival nodes
var dhtArchivalPeers []peer.AddrInfo
const numPeersToDiscover = 5 // some arbitrary number TODO: figure out a better value based on peerSelector/fetcher algorithm
Copy link
Contributor

Choose a reason for hiding this comment

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

out of curiosity why 5 vs 4 (or vs GossipFanout)?

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe put this const at the top of the file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

if peerCore, ok := addrInfoToWsPeerCore(n, &info); ok {
peers = append(peers, &peerCore)
}
const maxNodes = 5 // some arbitrary number
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be the same global const as numPeersToDiscover like numArchivePeersToDiscover at the top

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -163,15 +194,20 @@ func (e *phonebookImpl) filterRetryTime(t time.Time, role PhoneBookEntryRoles) [
// new entries in addressesThey are being added
// existing items that aren't included in addressesThey are being removed
// matching entries don't change
func (e *phonebookImpl) ReplacePeerList(addressesThey []string, networkName string, role PhoneBookEntryRoles) {
func (e *phonebookImpl) ReplacePeerList(addressesThey []string, networkName string, role Roles) {
Copy link
Contributor

Choose a reason for hiding this comment

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

so phonebook.go's phonebookImpl.ReplacePeerList and peerstore.go's PeerStore.ReplacePeerList are the same?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

they surely have the same logic but a but different signatures

@algorandskiy algorandskiy requested a review from cce October 29, 2024 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants