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 creating node using application info #1809

Closed
wants to merge 1 commit into from

Conversation

adklempner
Copy link
Member

@adklempner adklempner commented Jan 24, 2024

Problem

All functions to create a node allow it to be setup for either autosharding or static sharding depending on which options are passed. However, we want to encourage users to run nodes with autosharding. Requiring specific configuration options in order to set up a node to run autosharding makes it more difficult to do so.

Solution

This commit adds SDK functions for creating a node configured to use autosharding by providing an application/version or a list of content topics.

Notes

@adklempner adklempner requested a review from a team as a code owner January 24, 2024 06:24
Copy link

github-actions bot commented Jan 24, 2024

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
Waku node 185.25 KB (0%) 3.8 s (0%) 981 ms (-19.03% 🔽) 4.7 s
Waku Simple Light Node 185.27 KB (0%) 3.8 s (0%) 632 ms (-24.74% 🔽) 4.4 s
ECIES encryption 22.89 KB (0%) 458 ms (0%) 141 ms (-63.75% 🔽) 599 ms
Symmetric encryption 22.34 KB (0%) 447 ms (0%) 368 ms (+12.49% 🔺) 814 ms
DNS discovery 70.06 KB (0%) 1.5 s (0%) 430 ms (-37.22% 🔽) 1.9 s
Privacy preserving protocols 39.84 KB (0%) 797 ms (0%) 515 ms (+19.91% 🔺) 1.4 s
Light protocols 20.58 KB (0%) 412 ms (0%) 222 ms (-16.25% 🔽) 634 ms
History retrieval protocols 19.34 KB (0%) 387 ms (0%) 236 ms (+18.56% 🔺) 623 ms
Deterministic Message Hashing 4.96 KB (0%) 100 ms (0%) 32 ms (-31.97% 🔽) 131 ms

packages/sdk/src/create.ts Outdated Show resolved Hide resolved
return _createNode(shardInfo.shardInfo, options);
}

export async function createNodeFromContentTopics(
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think combining it with createNode is better.
To me it seems reasonable to keep amount of create* function as low as possible. Ideally 2: light node, relay node (for later).

Copy link
Member Author

Choose a reason for hiding this comment

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

@adklempner adklempner marked this pull request as draft January 24, 2024 23:03
@adklempner adklempner force-pushed the feat/application-version-create-node branch from 3cff754 to e22cdd0 Compare January 24, 2024 23:32
@adklempner adklempner force-pushed the feat/application-version-create-node branch 2 times, most recently from 93e93ef to 5181b38 Compare March 1, 2024 20:54
@adklempner adklempner changed the title feat: support creating node using application info or content topic feat: support creating node using application info Mar 1, 2024
@adklempner adklempner force-pushed the feat/application-version-create-node branch 4 times, most recently from a4f3ac0 to a64c7d2 Compare March 4, 2024 15:31
@adklempner adklempner force-pushed the feat/application-version-create-node branch from a64c7d2 to f8b8df8 Compare March 4, 2024 19:44
@adklempner adklempner marked this pull request as ready for review March 4, 2024 21:54
it("given an application and version, creates a waku node with the correct pubsub topic", async function () {
const contentTopic = ensureValidContentTopic(ContentTopic);
const waku = await createApplicationNode(
contentTopic.application,
Copy link
Collaborator

@weboko weboko Mar 4, 2024

Choose a reason for hiding this comment

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

At this point I am thinking if we need a class for it:

class ContentTopic {
  static public fromString(value: string): ContentTopic {
    return new ContentTopic({ value });
  }

  constructor({ value, application, version }) {}

  get application() {}
  get version() {}
  get encoding() {}
}

before it seemed as overhead but more we go to autosharding realm I think it would a useful entity to:

  • encapsulate contentTopic related utils & types;
  • mechanism to re-usability and common interface;

@adklempner @danisharora099 would like to hear your thoughts on it

Copy link
Collaborator

Choose a reason for hiding this comment

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

yeah, i like your idea!
i think we can refactor sdk/utils/content_topic into class-based 👌

Copy link
Collaborator

Choose a reason for hiding this comment

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

@adklempner if you agree with approach we can follow up with this in a separate issue. Can be linked to https://github.com/waku-org/pm/issues/143

@@ -6,6 +6,15 @@ import { CreateWakuNodeOptions, WakuNode, WakuOptions } from "./waku.js";

export { Libp2pComponents };

export async function createApplicationNode(
Copy link
Collaborator

Choose a reason for hiding this comment

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

at this point we have way to many create* functions

for now let's have only createNode and extend with additional parameter in options

Copy link
Collaborator

Choose a reason for hiding this comment

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

@adklempner do you need support with this one? we can go ahead with this PR and follow up later as we discussed at prev PM

Comment on lines +10 to +11
application: string,
version: string,
Copy link
Collaborator

Choose a reason for hiding this comment

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

you can simplify the API with two args into just one by taking contentTopic: ContentTopic as the argument instead

it("given an application and version, creates a waku node with the correct pubsub topic", async function () {
const contentTopic = ensureValidContentTopic(ContentTopic);
const waku = await createApplicationNode(
contentTopic.application,
Copy link
Collaborator

Choose a reason for hiding this comment

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

yeah, i like your idea!
i think we can refactor sdk/utils/content_topic into class-based 👌

@weboko
Copy link
Collaborator

weboko commented May 7, 2024

@adklempner do you think we should proceed with this PR or take a step back and reconsider?

@adklempner adklempner marked this pull request as draft June 5, 2024 15:12
@weboko
Copy link
Collaborator

weboko commented Jun 17, 2024

Let's close this PR as a lot of things has changed and we'd need to re-evaluate this approach.

@weboko weboko closed this Jun 17, 2024
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: sdk function to setup autosharding node with application and version
3 participants