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

feat: support serviceslots in peermanager #631

Merged
merged 14 commits into from
Aug 10, 2023
Merged

Conversation

chaitanyaprem
Copy link
Collaborator

@chaitanyaprem chaitanyaprem commented Aug 8, 2023

Description

Added concept of service slots in peer manager similar to waku-org/nwaku#1473.
Also updated Store protocol to use the new selectPeer function from peerManager.

Changes

  • Added new methods to support service slots in peer manager
  • Updated Store protocol to use service-Slots.
  • Update all other protocols to use new selectPeer API from peermanager

Keeping the existing selectPeer functionality in utils package. The reason behind this is so that a user can use any of the Waku protocols without initializing a wakunode, but by just initializing a libp2p host. Documentation shall be created to document the usage of g-waku in both ways.

Tests

  • Added new tests for peer-manager serviceSlots

@status-im-auto
Copy link

status-im-auto commented Aug 8, 2023

Jenkins Builds

Click to see older builds (55)
Commit #️⃣ Finished (UTC) Duration Platform Result
✖️ 5e9f086 #1 2023-08-08 09:18:03 ~14 sec nix-flake 📄log
✔️ 5e9f086 #1 2023-08-08 09:19:04 ~1 min linux 📦deb
✖️ 5e9f086 #1 2023-08-08 09:19:14 ~1 min tests 📄log
✔️ 5e9f086 #1 2023-08-08 09:21:37 ~3 min android 📦tgz
✔️ 5e9f086 #1 2023-08-08 09:22:24 ~4 min ios 📦tgz
✔️ 1f08554 #2 2023-08-08 09:33:49 ~32 sec linux 📦deb
✖️ 1f08554 #2 2023-08-08 09:35:13 ~1 min tests 📄log
✔️ 1f08554 #2 2023-08-08 09:35:17 ~1 min nix-flake 📄log
✔️ 1f08554 #2 2023-08-08 09:36:57 ~3 min android 📦tgz
✔️ 1f08554 #2 2023-08-08 09:37:07 ~3 min ios 📦tgz
✔️ 9e4c86c #3 2023-08-08 09:46:18 ~53 sec linux 📦deb
✖️ 9e4c86c #3 2023-08-08 09:46:28 ~59 sec tests 📄log
✔️ 9e4c86c #3 2023-08-08 09:47:30 ~2 min nix-flake 📄log
✔️ 9e4c86c #3 2023-08-08 09:49:03 ~3 min android 📦tgz
✔️ 9e4c86c #3 2023-08-08 09:49:18 ~3 min ios 📦tgz
✔️ cd59c2e #4 2023-08-08 10:21:52 ~1 min linux 📦deb
✔️ cd59c2e #4 2023-08-08 10:22:27 ~2 min nix-flake 📄log
✔️ cd59c2e #4 2023-08-08 10:23:21 ~2 min tests 📄log
✔️ cd59c2e #4 2023-08-08 10:24:26 ~4 min ios 📦tgz
✔️ cd59c2e #4 2023-08-08 10:26:12 ~5 min android 📦tgz
✔️ 9e367c3 #5 2023-08-09 06:48:26 ~1 min linux 📦deb
✔️ 9e367c3 #5 2023-08-09 06:48:59 ~1 min nix-flake 📄log
✖️ 9e367c3 #5 2023-08-09 06:49:08 ~1 min tests 📄log
✔️ 9e367c3 #5 2023-08-09 06:50:26 ~3 min ios 📦tgz
✔️ 9e367c3 #5 2023-08-09 06:50:27 ~3 min android 📦tgz
✔️ 5e63d1c #6 2023-08-09 07:25:40 ~31 sec linux 📦deb
✔️ 5e63d1c #6 2023-08-09 07:27:07 ~1 min tests 📄log
✔️ 5e63d1c #6 2023-08-09 07:27:18 ~2 min nix-flake 📄log
✔️ 5e63d1c #6 2023-08-09 07:28:12 ~3 min android 📦tgz
✔️ 5e63d1c #6 2023-08-09 07:28:56 ~3 min ios 📦tgz
✔️ 5e63d1c #1 2023-08-09 08:00:31 ~3 min tests 📄log
✔️ aaab112 #7 2023-08-09 08:01:05 ~3 min linux 📦deb
✔️ aaab112 #7 2023-08-09 08:02:21 ~4 min ios 📦tgz
✔️ aaab112 #7 2023-08-09 08:02:28 ~4 min nix-flake 📄log
✔️ aaab112 #7 2023-08-09 08:02:28 ~4 min tests 📄log
✔️ aaab112 #2 2023-08-09 08:03:18 ~2 min tests 📄log
✔️ aaab112 #7 2023-08-09 08:04:03 ~6 min android 📦tgz
75dedd1 #8 2023-08-10 00:10:47 ~17 sec linux 📄log
✖️ 75dedd1 #8 2023-08-10 00:10:56 ~23 sec tests 📄log
✖️ 75dedd1 #8 2023-08-10 00:11:24 ~54 sec nix-flake 📄log
✖️ 75dedd1 #3 2023-08-10 00:11:51 ~1 min tests 📄log
75dedd1 #8 2023-08-10 00:12:34 ~2 min android 📄log
75dedd1 #8 2023-08-10 00:13:42 ~3 min ios 📄log
✔️ 11a9e4c #9 2023-08-10 00:19:37 ~34 sec linux 📦deb
✔️ 11a9e4c #9 2023-08-10 00:20:47 ~1 min tests 📄log
✔️ 11a9e4c #9 2023-08-10 00:21:08 ~2 min nix-flake 📄log
✔️ 11a9e4c #4 2023-08-10 00:21:40 ~2 min tests 📄log
✔️ 11a9e4c #9 2023-08-10 00:22:11 ~3 min ios 📦tgz
✔️ 11a9e4c #9 2023-08-10 00:22:12 ~3 min android 📦tgz
✖️ 71f2af7 #10 2023-08-10 10:29:26 ~26 sec tests 📄log
✖️ 71f2af7 #5 2023-08-10 10:29:29 ~29 sec tests 📄log
✔️ 71f2af7 #10 2023-08-10 10:29:34 ~37 sec linux 📦deb
✔️ 71f2af7 #10 2023-08-10 10:30:46 ~1 min nix-flake 📄log
✔️ 71f2af7 #10 2023-08-10 10:32:34 ~3 min android 📦tgz
✔️ 71f2af7 #10 2023-08-10 10:32:39 ~3 min ios 📦tgz
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ 2aa4bf7 #11 2023-08-10 11:09:15 ~32 sec linux 📦deb
✔️ 2aa4bf7 #11 2023-08-10 11:11:00 ~2 min tests 📄log
✔️ 2aa4bf7 #11 2023-08-10 11:11:21 ~2 min nix-flake 📄log
✔️ 2aa4bf7 #11 2023-08-10 11:11:56 ~3 min android 📦tgz
✔️ 2aa4bf7 #11 2023-08-10 11:12:00 ~3 min ios 📦tgz
✔️ 2aa4bf7 #6 2023-08-10 11:12:14 ~3 min tests 📄log
✔️ 9a9464f #12 2023-08-10 11:55:08 ~32 sec linux 📦deb
✔️ 9a9464f #12 2023-08-10 11:56:19 ~1 min tests 📄log
✔️ 9a9464f #7 2023-08-10 11:56:24 ~1 min tests 📄log
✔️ 9a9464f #12 2023-08-10 11:56:32 ~1 min nix-flake 📄log
✔️ 9a9464f #12 2023-08-10 11:57:46 ~3 min android 📦tgz
✔️ 9a9464f #12 2023-08-10 11:58:09 ~3 min ios 📦tgz

@chaitanyaprem chaitanyaprem mentioned this pull request Aug 8, 2023
7 tasks
@chaitanyaprem chaitanyaprem marked this pull request as ready for review August 9, 2023 07:57
Copy link
Member

@richard-ramos richard-ramos left a comment

Choose a reason for hiding this comment

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

nice PR.
left some minor comments

@@ -225,6 +225,7 @@ func (c *PeerConnectionStrategy) workPublisher(ctx context.Context) {
case <-ctx.Done():
return
case p := <-c.peerCh:
//TODO: Modify to use peermanager AddPeer
Copy link
Member

Choose a reason for hiding this comment

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

Should we create an issue for this TODO?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This will be taken up during another peer-manager task itself, hence not required.
Just did not want to club it with service slots.

waku/v2/utils/peer.go Outdated Show resolved Hide resolved

// RemovePeer deletes peer from the peerStore after disconnecting it.
func (pm *PeerManager) RemovePeer(peerID peer.ID) {
// TODO: Need to handle removePeer also via peermanager
Copy link
Member

Choose a reason for hiding this comment

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

Should an issue be created to not forget about this?

waku/v2/peermanager/peer_manager.go Outdated Show resolved Hide resolved
waku/v2/peermanager/peer_manager.go Outdated Show resolved Hide resolved
waku/v2/peermanager/peer_manager.go Outdated Show resolved Hide resolved
waku/v2/peermanager/peer_manager.go Outdated Show resolved Hide resolved
if proto == WakuRelayIDv200 {
if filteredPeers.Len() > 0 {
pm.logger.Info("Got peer from peerstore", zap.String("peerId", filteredPeers[0].Pretty()))
return filteredPeers[0], nil
Copy link
Member

Choose a reason for hiding this comment

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

Should a random peer be returned instead to match the function description?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good catch!

@chaitanyaprem chaitanyaprem linked an issue Aug 10, 2023 that may be closed by this pull request
@github-advanced-security
Copy link

This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation.

peerIDs, ok := pm.serviceSlots[proto]
if ok || len(peerIDs) > 0 {
pm.logger.Info("Got peer from service slots", logging.HostID("peer", peerIDs[0]))
return peerIDs[0], nil
Copy link
Member

Choose a reason for hiding this comment

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

Maybe this should be random here as well? 🤔

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't see multiple static peers per service being added as of now, hence left it as is.
Anyways instead of random, at a later point we will have scoring and other params based selection.

@chaitanyaprem chaitanyaprem merged commit 9f45d27 into master Aug 10, 2023
2 checks passed
@chaitanyaprem chaitanyaprem deleted the feat/service-slots branch August 10, 2023 12:58
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.

chore: Implement RemovePeer in PeerManager
3 participants