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 4 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.65079% with 4 lines in your changes missing coverage. Please review.

Project coverage is 56.24%. Comparing base (90353e5) to head (d604984).
Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
network/p2pNetwork.go 86.95% 2 Missing and 1 partial ⚠️
network/phonebook/phonebook.go 95.65% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6131      +/-   ##
==========================================
+ Coverage   56.19%   56.24%   +0.04%     
==========================================
  Files         494      494              
  Lines       69943    69971      +28     
==========================================
+ Hits        39307    39352      +45     
+ Misses      27960    27952       -8     
+ Partials     2676     2667       -9     

☔ 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 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

@@ -782,7 +782,7 @@ func TestLocal_ValidateP2PHybridConfig(t *testing.T) {
NetAddress: test.netAddress,
}
err := c.ValidateP2PHybridConfig()
require.Equal(t, test.err, err != nil, "test=%d", i)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

another linter complaint


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

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

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

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