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: set cluster ID as optional when specifying shard info #1780

Merged
merged 1 commit into from
Jan 24, 2024

Conversation

adklempner
Copy link
Member

@adklempner adklempner commented Jan 11, 2024

Problem

To setup a node for autosharding, a user needs to explicitly specify both content topics and a cluster id to determine the pubsub topics. According to the RFC, the Waku Network always uses a cluster id of 1.

Solution

Makes clusterId (and all other fields in ShardingParams) optional when user creates a node using the sdk functions, by accepting Partial<ShardingParams>.
Each sdk function calls a sharding util function to validated the parameters and replace any missing ones with defaults where possible.
Internally, we mostly use ShardingParams where all fields are required.

Notes

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

github-actions bot commented Jan 11, 2024

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
Waku core 32.83 KB (+0.73% 🔺) 657 ms (+0.73% 🔺) 2.3 s (+122.12% 🔺) 3 s
Waku Simple Light Node 299.07 KB (+0.09% 🔺) 6 s (+0.09% 🔺) 3.1 s (-15.82% 🔽) 9.1 s
ECIES encryption 31.99 KB (+0.07% 🔺) 640 ms (+0.07% 🔺) 2 s (+44.35% 🔺) 2.6 s
Symmetric encryption 31.98 KB (+0.06% 🔺) 640 ms (+0.06% 🔺) 791 ms (-56.11% 🔽) 1.5 s
DNS discovery 106.72 KB (0%) 2.2 s (0%) 2.7 s (+10.34% 🔺) 4.9 s
Privacy preserving protocols 129.48 KB (+0.03% 🔺) 2.6 s (+0.03% 🔺) 1.8 s (+11.03% 🔺) 4.4 s
Light protocols 30.87 KB (+0.82% 🔺) 618 ms (+0.82% 🔺) 1.4 s (+37.17% 🔺) 2 s
History retrieval protocols 29.33 KB (+0.87% 🔺) 587 ms (+0.87% 🔺) 1.7 s (+48.4% 🔺) 2.2 s
Deterministic Message Hashing 5.92 KB (0%) 119 ms (0%) 343 ms (-2.86% 🔽) 461 ms

@adklempner adklempner force-pushed the adklempner/default-cluster-id branch from 0957c59 to e5f0cf4 Compare January 16, 2024 08:08
@@ -1,7 +1,7 @@
import type { PubsubTopic } from "./misc.js";

export interface SingleShardInfo {
clusterId: number;
clusterId?: number;
Copy link
Collaborator

Choose a reason for hiding this comment

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

instead of making this optional, i'd rather use DEFAULT_CLUSTER_ID that refers to 1 for TWN.

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 do this a followup PR @adklempner

Copy link
Member Author

Choose a reason for hiding this comment

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

@danisharora099 I made an update in my latest commit that makes all the fields required and instead uses Partial<ShardingParams> in all SDK create node functions, which are converted to regular ShardingParams before being used internally

@adklempner adklempner force-pushed the adklempner/default-cluster-id branch 6 times, most recently from 8286264 to c548c42 Compare January 24, 2024 04:12
@adklempner adklempner force-pushed the adklempner/default-cluster-id branch from c548c42 to 68d3229 Compare January 24, 2024 15:45
@adklempner adklempner merged commit 66824d6 into master Jan 24, 2024
9 of 11 checks passed
@adklempner adklempner deleted the adklempner/default-cluster-id branch January 24, 2024 16:33
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.

use Waku Network cluster id as default for autosharding
3 participants