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

chore: move protocols CreateOptions into interfaces and #1145

Merged
merged 3 commits into from
Feb 2, 2023

Conversation

danisharora099
Copy link
Collaborator

ref: #1000

@danisharora099 danisharora099 linked an issue Feb 1, 2023 that may be closed by this pull request
@github-actions
Copy link

github-actions bot commented Feb 1, 2023

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
Waku core 132.98 KB (+0.02% 🔺) 2.7 s (+0.02% 🔺) 3.4 s (+16.16% 🔺) 6 s
Waku default setup 424.49 KB (+0.01% 🔺) 8.5 s (+0.01% 🔺) 5.3 s (-14.59% 🔽) 13.7 s
ECIES encryption 44.48 KB (0%) 890 ms (0%) 1.8 s (+11.95% 🔺) 2.7 s
Symmetric encryption 44.48 KB (0%) 890 ms (0%) 1.5 s (-23.96% 🔽) 2.3 s
DNS discovery 108.08 KB (0%) 2.2 s (0%) 3.3 s (-1.93% 🔽) 5.5 s
Privacy preserving protocols 131.97 KB (+0.02% 🔺) 2.7 s (+0.02% 🔺) 2 s (-33.33% 🔽) 4.6 s
Light protocols 133.99 KB (+0.02% 🔺) 2.7 s (+0.02% 🔺) 2.9 s (+8.84% 🔺) 5.6 s
History retrieval protocols 133.78 KB (+0.01% 🔺) 2.7 s (+0.01% 🔺) 3 s (+8.46% 🔺) 5.7 s

@danisharora099 danisharora099 marked this pull request as ready for review February 1, 2023 07:08
Copy link
Collaborator

@weboko weboko left a comment

Choose a reason for hiding this comment

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

cool 😎

@danisharora099 danisharora099 merged commit 10b3898 into master Feb 2, 2023
@danisharora099 danisharora099 deleted the chore/protocol-options-improvement branch February 2, 2023 02:32
@danisharora099 danisharora099 mentioned this pull request Feb 2, 2023
13 tasks
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.

Some remaining work to tackle.

@@ -66,18 +55,21 @@ export type UnsubscribeFunction = () => Promise<void>;
*/
class Filter implements IFilter {
multicodec: string;
pubSubTopic: string;
options: ProtocolCreateOptions;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Changelog update needed to highlight breaking change in API.

/**
* Implements the [Waku v2 Light Push protocol](https://rfc.vac.dev/spec/19/).
*/
class LightPush implements ILightPush {
multicodec: string;
pubSubTopic: string;
options: ProtocolCreateOptions;
Copy link
Collaborator

Choose a reason for hiding this comment

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

update changelog to highlight api breaking change

super(components, options);
this.multicodecs = constants.RelayCodecs;

this.observers = new Map();

this.pubSubTopic = options?.pubSubTopic ?? DefaultPubSubTopic;
this.options = options ?? {};
Copy link
Collaborator

Choose a reason for hiding this comment

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

you end up applyuing the default pubsub topic and every usage of this.option. This is cumbersome and prone to developer error.

Apply the default values in the constructor:

this.options = Object.assign({pubSubTopic: DefaultPubSubTopic}, options, {})

Or same logic in a getter get options(): ProtocolOptions

Or create a class that handles the ProtocolOptions and automatically apply default values

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

TypeScript doesn't know if a particular value as been assigned to an object (``Object.assign) so would need to explicitly typecast it. Instead, I've replaced this.options` with a private `pubSubTopic` variable.

@@ -88,7 +88,8 @@ export async function createLightNode(
const store = wakuStore(options);
const lightPush = wakuLightPush(options);
const filter = wakuFilter(options);
const peerExchange = wakuPeerExchange(options);

Copy link
Collaborator

Choose a reason for hiding this comment

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

odd

Comment on lines +37 to +38
// we can probably move `peerId` into `ProtocolCreateOptions` and remove `ProtocolOptions` and pass it in the constructor
// however, filter protocol can use multiple peers, so we need to think about this
Copy link
Collaborator

Choose a reason for hiding this comment

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

All protocol can use multiple peers. I don't think PeerId belongs to CreateOptions.

Do note that it makes sense to have PubSubTopic in ProtocolOptions (too). Let's see how Waku scaling goes:

For now I'd remove this todo and leave it as it is and we can decide later once we ahve more information on sharding and Waku usage.

@@ -88,7 +88,8 @@ export async function createLightNode(
const store = wakuStore(options);
Copy link
Collaborator

Choose a reason for hiding this comment

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

You have not removed the CreateOptions definition in this file. I expect it to be replaced with CreateProtocolOPtions from @waku/interfaces

@danisharora099
Copy link
Collaborator Author

@fryorcraken the above have been addressed here #1153

danisharora099 added a commit that referenced this pull request Feb 9, 2023
* address comments from #1145

* fix: typedoc

* address comments in #1146 (review)

- update changelog
- change naming for `EciesEncoderOptions` and
`SymmetricEncoderOptions`
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.

Remove dupe CreateOptions interfaces
3 participants