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(store): allow using a specific node #2192

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

danisharora099
Copy link
Collaborator

Problem

Users need the ability to specify the peers used for their apps, for different protocols. Specifically for Store: https://discord.com/channels/1110799176264056863/1290694275683582085/1291644836742565929

Solution

Provides the ability to pass a specific node multiaddr while node creation to be used for Store. Falls back to random nodes if not passed.

Notes

Contribution checklist:

  • covered by unit tests;
  • covered by e2e test;
  • add ! in title if breaks public API;

@danisharora099 danisharora099 requested a review from a team as a code owner October 24, 2024 14:27
Copy link

github-actions bot commented Oct 24, 2024

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
Waku node 86.74 KB (+0.13% 🔺) 1.8 s (+0.13% 🔺) 912 ms (-25.66% 🔽) 2.7 s
Waku Simple Light Node 137.15 KB (+0.25% 🔺) 2.8 s (+0.25% 🔺) 2 s (+48.18% 🔺) 4.7 s
ECIES encryption 22.88 KB (0%) 458 ms (0%) 435 ms (-7.41% 🔽) 893 ms
Symmetric encryption 22.37 KB (0%) 448 ms (0%) 410 ms (-17.76% 🔽) 858 ms
DNS discovery 70.54 KB (0%) 1.5 s (0%) 650 ms (-49.5% 🔽) 2.1 s
Peer Exchange discovery 71.93 KB (+0.17% 🔺) 1.5 s (+0.17% 🔺) 1.3 s (+8.41% 🔺) 2.7 s
Local Peer Cache Discovery 65.17 KB (0%) 1.4 s (0%) 492 ms (-38.94% 🔽) 1.8 s
Privacy preserving protocols 76.16 KB (0%) 1.6 s (0%) 1.5 s (+12.41% 🔺) 3 s
Waku Filter 81.07 KB (+0.12% 🔺) 1.7 s (+0.12% 🔺) 1.1 s (-2.01% 🔽) 2.7 s
Waku LightPush 75.76 KB (+0.07% 🔺) 1.6 s (+0.07% 🔺) 1.1 s (-28.43% 🔽) 2.6 s
History retrieval protocols 77.67 KB (+0.06% 🔺) 1.6 s (+0.06% 🔺) 1.3 s (+42.34% 🔺) 2.8 s
Deterministic Message Hashing 7.39 KB (0%) 148 ms (0%) 102 ms (-66.78% 🔽) 250 ms

* List of nodes' multiaddrs as strings to use for each protocol. If not specified, random nodes will be used.
* This should be used only if you know what you are doing.
*/
nodeToUse?: {
Copy link
Collaborator

Choose a reason for hiding this comment

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

can you create store field with following type:
store: Partial<StoreProtocolOptions>

and StoreProtocolOptions can have:

type StoreProtocolOptions = {
  peers: [],
};

example for Filter in one of open PRs - 09127df

@@ -3,6 +3,7 @@ import type { Peer, Stream } from "@libp2p/interface";
import type {
Copy link
Collaborator

Choose a reason for hiding this comment

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

please, let's not introduce changes into this file and instead prefer peer in store.ts with something like

const preferedPeer = this.libp2p.getConnections().find(c => c.remotePeer.toString() === preferedPeerIdStr);
const peer = preferedPeer || this.getPeer();

@@ -224,6 +232,18 @@ export class WakuNode implements IWaku {
return this.connectionManager.isConnected();
}

private async dialMultiaddr(
Copy link
Collaborator

Choose a reason for hiding this comment

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

let's not introduce this operation and use ConnectionManager

@danisharora099 danisharora099 marked this pull request as draft December 2, 2024 08:07
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.

feat: API allows usage of specific nodes for protocols
2 participants