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: update various protocols to autoshard #1857

Merged
merged 3 commits into from
Aug 17, 2023
Merged

feat: update various protocols to autoshard #1857

merged 3 commits into from
Aug 17, 2023

Conversation

SionoiS
Copy link
Contributor

@SionoiS SionoiS commented Jul 21, 2023

Description

Updating LIGHTPUSH & FILTER protocols to handle autosharding.

Changes

  • LIGHTPUSH take optional pubsub topics and compute shards.
  • FITLER take optional pubsub topics and compute shards.

Tracking #1846

@SionoiS
Copy link
Contributor Author

SionoiS commented Jul 21, 2023

I'm not sure how to change FILTER to handle multiple shards. The code ATM assumes one pubsub and multiple content topics.

@SionoiS SionoiS changed the title feat: update various protocol to autoshard feat: update various protocols to autoshard Jul 21, 2023
@SionoiS SionoiS marked this pull request as ready for review August 1, 2023 13:25
@SionoiS
Copy link
Contributor Author

SionoiS commented Aug 1, 2023

I added some tests and fixed a bug.

waku/v2/node/waku_node.nim Outdated Show resolved Hide resolved
@SionoiS
Copy link
Contributor Author

SionoiS commented Aug 2, 2023

Added a proc for optional autosharding, changed the cluster index and count for gen0 and added back topics in config with a deprecation note.

@SionoiS SionoiS linked an issue Aug 2, 2023 that may be closed by this pull request
3 tasks
@SionoiS SionoiS self-assigned this Aug 2, 2023
@SionoiS
Copy link
Contributor Author

SionoiS commented Aug 2, 2023

@jakubgs When we merge this to master the config will be back to normal. --topic will be back as deprecated with --pubsub-topic and --content-topic present.

Copy link
Contributor

@jm-clius jm-clius left a comment

Choose a reason for hiding this comment

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

Made a comment below re filter, but it applies to all the protocols: I think we don't want the underlying protocols to change, just provide applications with some "middleware" logic when they interact with the node that populates shards in API calls to the underlying protocols. IMO protocols should remain completely unaware of autosharding, which occurs at a higher layer.

waku/v2/waku_filter/rpc.nim Outdated Show resolved Hide resolved
@SionoiS
Copy link
Contributor Author

SionoiS commented Aug 3, 2023

Made a comment below re filter, but it applies to all the protocols: I think we don't want the underlying protocols to change, just provide applications with some "middleware" logic when they interact with the node that populates shards in API calls to the underlying protocols. IMO protocols should remain completely unaware of autosharding, which occurs at a higher layer.

The protocols are not the code in nwaku. They are in the RFCs and for FILTER for example the pubsub topic is optional. They were not following the protocol, now they do.

I totally miss this part If the request contains filter criteria, it MUST contain a pubsub_topic and the content_topics set MUST NOT be empty.

As for where we decide to compute the shard, my idea was that light node should have the least amount of computing to do.

I'll make the changes.

waku/v2/waku_store/client.nim Outdated Show resolved Hide resolved
@SionoiS
Copy link
Contributor Author

SionoiS commented Aug 4, 2023

It's still a bit weird how you have to send multiple request in the case of the content topic not using the same shards.

Copy link
Contributor

@alrevuelta alrevuelta left a comment

Choose a reason for hiding this comment

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

left some comments, all of them related to pubsub vs content topic. let me know what you think or if im missing something :)

apps/wakunode2/external_config.nim Outdated Show resolved Hide resolved
examples/v2/filter_subscriber.nim Outdated Show resolved Hide resolved
examples/v2/filter_subscriber.nim Outdated Show resolved Hide resolved
waku/v2/waku_filter_v2/client.nim Outdated Show resolved Hide resolved
@alrevuelta
Copy link
Contributor

@SionoiS

It's still a bit weird how you have to send multiple request in the case of the content topic not using the same shards.

If we remove the pubsub topic from the request then you dont need to send multiple requests? The full node will "infer" it.

@jm-clius
Copy link
Contributor

jm-clius commented Aug 8, 2023

It's still a bit weird how you have to send multiple request in the case of the content topic not using the same shards.

True. If we don't change the underlying light protocols themselves, the "middleware" on the light client that populates the pubsub topic in requests might have to create multiple requests instead of one. To me this still seems safer as an initial step, rather than removing the pubsub topic from the protocol itself and having implicit assumption that the service node the client is contacting is on the same version/generation of autosharding as the client (in other words, on protocol level we remain explicit about shards/pubsub topics). Happy to have people disagree with me here, as I do think we eventually want to simplify how the protocols are used too. This just seems to me the simplest/safest increment to get there.

@SionoiS
Copy link
Contributor Author

SionoiS commented Aug 8, 2023

implicit assumption that the service node the client is contacting is on the same version/generation of autosharding as the client

The generation to use is in the content topic there's not assumptions. unsupported generation = bad request.

As for the version, any autosharding algo. change is breaking change. unsupported version = bad request.
This one is weak since the version is not in the protocol.

Copy link
Contributor

@jm-clius jm-clius left a comment

Choose a reason for hiding this comment

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

Thanks for moving sharding logic to the clients to keep the wire protocol the same. However, I'm still confused why the autosharding logic needs to be in the protocol clients. This effectively changes the protocol behaviour too (e.g. a filter subscribe now spinning off multiple subscribes). I would say the only thing that needs to be changed is where the application interacts with the public API, in other words: either in the JSON-RPC/REST APIs (e.g. here) or, if we want to be a bit more universal, in the Nim API for the node, e.g. here. If we follow the latter route, we'll still have a problem with store query, but the way to fix it IMO, would be to provide an API query* call where HistoryQuery creation is moved into the API call, while query criteria (content topics, optional pubsub, etc.) are provided separately as arguments.

@SionoiS
Copy link
Contributor Author

SionoiS commented Aug 10, 2023

Thanks for moving sharding logic to the clients to keep the wire protocol the same. However, I'm still confused why the autosharding logic needs to be in the protocol clients. This effectively changes the protocol behaviour too (e.g. a filter subscribe now spinning off multiple subscribes). I would say the only thing that needs to be changed is where the application interacts with the public API, in other words: either in the JSON-RPC/REST APIs (e.g. here) or, if we want to be a bit more universal, in the Nim API for the node, e.g. here. If we follow the latter route, we'll still have a problem with store query, but the way to fix it IMO, would be to provide an API query* call where HistoryQuery creation is moved into the API call, while query criteria (content topics, optional pubsub, etc.) are provided separately as arguments.

I got confused by node again. JSONRPC handlers call node.lightpushPublish() then it calls client.publish(), I though it called it directly.

I am not a fan of adding the "sharding middleware" to the APIs handlers and I also don't like node.

I guess I'll put it in node for now...

@SionoiS
Copy link
Contributor Author

SionoiS commented Aug 10, 2023

Is there a difference between omitting pubsub topic for a STORE request or one request per shards?

I see three different intent when making a request.

  1. I don't care about pubsub topics.
  2. I want autosharding
  3. I want messages for one pubsub topic.

1 and 2 are functionally the same but maybe we want to differentiate?

Also, like a said there's no easy way to merge results when sending multiple requests. How would you page?

Maybe we could error when requesting multiple shards at the same time?

WDYT? @jm-clius @alrevuelta

@jm-clius
Copy link
Contributor

I am not a fan of adding the "sharding middleware" to the APIs handlers and I also don't like node.

I understand, though I think both options are better than adding it into the protocols themselves. Another option may be just to create a new API for applications using autosharding? Up to you, especially since we can increment here.

Maybe we could error when requesting multiple shards at the same time?

Mmm. Yes, I think Store behaviour here is different than Filter, in that it's possible to query with an open (i.e. unpopulated) pubsub topic which would mean "don't care". But in the case of autosharding you assume your content topics are unique (i.e. doesn't span shards), so there's no reason to change anything for autosharding (the pubsub topic can just remain empty in the HistoryQuery). Where things will get interesting for store and other protocols is in how we select the store peer that is able to service our request - we'd need to know that it's a store node for the shard we're querying on.

@github-actions
Copy link

You can find the image built from this PR at

quay.io/wakuorg/nwaku-pr:1857

5 similar comments
@github-actions
Copy link

You can find the image built from this PR at

quay.io/wakuorg/nwaku-pr:1857

@github-actions
Copy link

You can find the image built from this PR at

quay.io/wakuorg/nwaku-pr:1857

@github-actions
Copy link

You can find the image built from this PR at

quay.io/wakuorg/nwaku-pr:1857

@github-actions
Copy link

You can find the image built from this PR at

quay.io/wakuorg/nwaku-pr:1857

@github-actions
Copy link

You can find the image built from this PR at

quay.io/wakuorg/nwaku-pr:1857

@github-actions
Copy link

You can find the image built from this PR at

quay.io/wakuorg/nwaku-pr:1857

2 similar comments
@github-actions
Copy link

You can find the image built from this PR at

quay.io/wakuorg/nwaku-pr:1857

@github-actions
Copy link

You can find the image built from this PR at

quay.io/wakuorg/nwaku-pr:1857

@github-actions
Copy link

You can find the image built from this PR at

quay.io/wakuorg/nwaku-pr:1857

Copy link
Contributor

@jm-clius jm-clius left a comment

Choose a reason for hiding this comment

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

Thanks for your patience. I have added some comments below but have also approved, since I think that when addressed this can be merged.

waku/waku_core/topics/sharding.nim Outdated Show resolved Hide resolved
waku/waku_core/topics/sharding.nim Outdated Show resolved Hide resolved
waku/node/waku_node.nim Show resolved Hide resolved
waku/node/waku_node.nim Outdated Show resolved Hide resolved
@SionoiS SionoiS merged commit cf30139 into master Aug 17, 2023
12 checks passed
@SionoiS SionoiS deleted the protocols branch August 17, 2023 12:11
@fryorcraken fryorcraken added E:1.2: Autosharding for autoscaling See https://github.com/waku-org/pm/issues/65 for details and removed E:2023-10k-users labels Sep 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E:1.2: Autosharding for autoscaling See https://github.com/waku-org/pm/issues/65 for details
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Autosharding v1
5 participants