-
Notifications
You must be signed in to change notification settings - Fork 42
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: reintroduce and deprecate named sharding, make autosharding default for all other cases #1751
Conversation
7fc587f
to
2ab556e
Compare
2ab556e
to
656de73
Compare
size-limit report 📦
|
54dfdc3
to
3c40f20
Compare
3c40f20
to
2d12040
Compare
packages/interfaces/src/filter.ts
Outdated
@@ -25,7 +25,7 @@ export interface IFilterSubscription { | |||
export type IFilter = IReceiver & | |||
IBaseProtocol & { | |||
createSubscription( | |||
pubsubTopicShardInfo?: SingleShardInfo, | |||
pubsubTopicShardInfo?: SingleShardInfo | string, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's maintain using PubsubTopic
as the type instead of string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in latest commit
*/ | ||
pubsubTopic?: PubsubTopic; | ||
pubsubTopicShardInfo?: SingleShardInfo; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not a fan of this redundancy :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@danisharora099 This is temporary and a deprecated option. I kept it to allow autosharding support without introducing breaking changes for any existing users.
Another option would be to just keep pubsubTopic
and make its type pubsubTopic?: PubsubTopic | SingleShardInfo
, but I'm not sure how to communicate that we're deprecating part of a type. I'm open to other suggestions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think deprecation period is a good way to go so that we will fully remove the flag in the upcoming update.
In which case I think we should bump minor version and release 0.1.*
.
@@ -79,6 +80,8 @@ class Encoder implements IEncoder { | |||
} | |||
|
|||
export interface EncoderOptions extends BaseEncoderOptions { | |||
/** Indicates if autosharding is enabled */ | |||
autosharding?: boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure i understand the relevance of having this flag on EncoderOptions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these shouldn't be here; removed from here and ecies.ts
in latest commit
e7fe3ff
to
eb98b3d
Compare
/** | ||
* Create a Waku node configured to use autosharding or static sharding. | ||
*/ | ||
export async function createNode( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To me it seems that we should avoid introduction of a new create function and change the createLightNode
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eventually we will change createLightNode
, but for now we don't want to introduce breaking changes as it was an existing function. If createLightNode
is used with options.shardInfo
set, then it behaves almost identical to this new function, with the only difference being that shardInfo
is optional. If that's satisfactory, then I'm happy to just remove this new function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that is enough - but we should make sure to depict it in an example and document it.
@@ -49,7 +49,8 @@ class LightPush extends BaseProtocol implements ILightPush { | |||
|
|||
constructor(libp2p: Libp2p, options?: ProtocolCreateOptions) { | |||
super(LightPushCodec, libp2p.components); | |||
this.pubsubTopics = this.initializePubsubTopic(options?.shardInfo); | |||
this.pubsubTopics = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: seems repetitive, let's include into this.initializePubsubTopic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did it this way because we will be removing options.pubsubTopics
in the future. This way, we just need to remove the ??
expression in this spot while keeping the function signature and behavior of initializePubsubTopics
the same
const pubsubTopic = pubsubTopicShardInfo | ||
? singleShardInfoToPubsubTopic(pubsubTopicShardInfo) | ||
: DefaultPubsubTopic; | ||
const pubsubTopic = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wondering is this.initializePubsubTopic
can be used here or adjusted to be used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.initializePubsubTopic
is used to set the pubsub topics for the Filter
object, while this const pubsubTopic
is used to get/set the pubsub topic for the Subscription
object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated ternary expression to be less verbose in latest commit
eb98b3d
to
9811938
Compare
* @deprecated | ||
* Waku will stop supporting named sharding. Only static sharding and autosharding will be supported moving forward. | ||
*/ | ||
pubsubTopics?: PubsubTopic[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adklempner can you, please, create a task with description of what should be removed to completely deprecate parameters/functionality? So that we address it in a skip release or something
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I opened #1775
packages/core/src/lib/store/index.ts
Outdated
@@ -79,7 +79,8 @@ class Store extends BaseProtocol implements IStore { | |||
|
|||
constructor(libp2p: Libp2p, options?: ProtocolCreateOptions) { | |||
super(StoreCodec, libp2p.components); | |||
this.pubsubTopics = this.initializePubsubTopic(options?.shardInfo); | |||
this.pubsubTopics = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is duplicated - let's make this.initializePubsubTopic(options.pubsubTopics, options.shardInfo)
or something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, I think I figured out a good approach: have initializePubsubTopic
accept ProtocolCreateOptions
and have the deprecated logic in there. When it comes time to remove named sharding, we'll just need to update the function instead of each instance where it's called. Updated in latest commit
9811938
to
960f38f
Compare
960f38f
to
df09fc6
Compare
Problem
Named sharding was removed completely and the APIs were changed. If we release a new package, this would break any existing projects that use js-waku. Named sharding should be deprecated, but the constructors/API should be maintained such that any existing projects have time to migrate to static or autosharding.
Solution
createNode
, which only supports static/autosharding.shardInfo
is set inProtocolCreateOptions
.pubsubTopics
field inProtocolCreateOptions
.Notes