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: use metadata protocol for awaiting connection to remote peer #1759

Merged

Conversation

danisharora099
Copy link
Collaborator

@danisharora099 danisharora099 commented Dec 14, 2023

Problem

Parent/origin: ##1756

There is a requirement to wait for ~50/100ms after a peer:connect event is fired as the Metadata Protocol is an async operation for which we need to wait to populate shard info, or we are disconnected if there is a cluster ID mismatch.

We need to wait for the Metadata protocol to complete before we can assume the peer is ready to be used to open connections reliably.

Solution

Notes

Can still foresee a case where a peer that is connected is used for a protocol instantly, thus creating a race condition.
Perhaps a more protocol-knit check should be added. Will also be helped with #1463

Copy link

github-actions bot commented Dec 14, 2023

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
Waku core 29.8 KB (+0.12% 🔺) 597 ms (+0.12% 🔺) 212 ms (+61.58% 🔺) 808 ms
Waku Simple Light Node 242.94 KB (+0.16% 🔺) 4.9 s (+0.16% 🔺) 333 ms (+81.62% 🔺) 5.2 s
ECIES encryption 30.24 KB (0%) 605 ms (0%) 162 ms (+86.54% 🔺) 767 ms
Symmetric encryption 30.22 KB (0%) 605 ms (0%) 124 ms (+14.86% 🔺) 728 ms
DNS discovery 121.81 KB (0%) 2.5 s (0%) 215 ms (+63.03% 🔺) 2.7 s
Privacy preserving protocols 118.6 KB (0%) 2.4 s (0%) 216 ms (+34.11% 🔺) 2.6 s
Light protocols 27.45 KB (+0.14% 🔺) 549 ms (+0.14% 🔺) 109 ms (+72.36% 🔺) 658 ms
History retrieval protocols 26.38 KB (+0.11% 🔺) 528 ms (+0.11% 🔺) 80 ms (+48.66% 🔺) 607 ms
Deterministic Message Hashing 5.92 KB (0%) 119 ms (0%) 25 ms (+3.78% 🔺) 143 ms

@danisharora099 danisharora099 force-pushed the chore/improve-sharded-peer-selection branch from 73223f6 to 2e400ec Compare December 15, 2023 10:32
@danisharora099 danisharora099 marked this pull request as ready for review December 15, 2023 12:46
@danisharora099 danisharora099 requested a review from a team as a code owner December 15, 2023 12:46
Copy link
Collaborator

@fryorcraken fryorcraken left a comment

Choose a reason for hiding this comment

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

I would suggest to have an event for the metadata protocol such as "shard info received" and use this as a way to track whether the protocol has been run.

.vscode/settings.json Outdated Show resolved Hide resolved
@weboko
Copy link
Collaborator

weboko commented Dec 19, 2023

I think this PR should be prefixed with feat!:

@danisharora099 danisharora099 changed the title chore: use metadata protocol for awaiting connection to remote peer feat: use metadata protocol for awaiting connection to remote peer Dec 20, 2023
@danisharora099
Copy link
Collaborator Author

I think this PR should be prefixed with feat!:

changed to feat -- how do you think this is a breaking change that would require the !?

@danisharora099
Copy link
Collaborator Author

danisharora099 commented Dec 20, 2023

I would suggest to have an event for the metadata protocol such as "shard info received" and use this as a way to track whether the protocol has been run.

This way of checking was used because on the off chance the service node does not send a request to us, or takes more time (which it is gauged by manual tests), we will initiate a request and ensure/enforce that we are on the same shard.
Listening on an event listener can take more time since we are expecting the node to reach out to us.

Let me know if you think otherwise @fryorcraken

@danisharora099
Copy link
Collaborator Author

danisharora099 commented Jan 2, 2024

I would suggest to have an event for the metadata protocol such as "shard info received" and use this as a way to track whether the protocol has been run.

This way of checking was used because on the off chance the service node does not send a request to us, or takes more time (which it is gauged by manual tests), we will initiate a request and ensure/enforce that we are on the same shard. Listening on an event listener can take more time since we are expecting the node to reach out to us.

Let me know if you think otherwise @fryorcraken

Merging this PR for now. Happy to address the proposed change of moving to an event-based functionality as a followup if decided.

@danisharora099 danisharora099 merged commit 1e793dd into feat/shard-peer-selection Jan 2, 2024
9 of 10 checks passed
@danisharora099 danisharora099 deleted the chore/improve-sharded-peer-selection branch January 2, 2024 10:11
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.

4 participants