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: Autosharding API for relay subscriptions #1983

Merged
merged 3 commits into from
Sep 26, 2023
Merged

feat: Autosharding API for relay subscriptions #1983

merged 3 commits into from
Sep 26, 2023

Conversation

SionoiS
Copy link
Contributor

@SionoiS SionoiS commented Sep 1, 2023

Description

Added new API that take only content topics and use autosharding to subscribe to the correct shard.

You have to manage the relay handlers otherwise it would happen that unsubscribing from a shard would remove all content topic handlers.

You also have to not duplicate or remove the default handlers otherwise Filter and/or Archive would receive no or duplicate messages.

I don't like adding more code to waku_node maybe adding a new component/sub-system would be better?

Changes

  • Autoshard relay JSONRPC API
  • Autoshard relay REST API
  • waku_node track subscriptions to avoid unsubbing from shard used by other content topics.
  • waku_relay now has the same proc than GossipSub unsubscribeAll which take no handler and unsubscribe that remove only the handler provided.
  • Tests for the new API

Tracking #1936

@github-actions
Copy link

github-actions bot commented Sep 1, 2023

You can find the image built from this PR at

quay.io/wakuorg/nwaku-pr:1983

Built from 86fc087

@SionoiS SionoiS self-assigned this Sep 1, 2023
@github-actions
Copy link

github-actions bot commented Sep 5, 2023

You can find the experimental image built from this PR at

quay.io/wakuorg/nwaku-pr:1983-experimental

@SionoiS SionoiS marked this pull request as ready for review September 5, 2023 18:55
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.

In general I think:

  • subscribing, unsubscribing and publishing on the underlying gossipsub object should only happen in one place. We currently have multiple paths towards each of these functions, which will be very error-prone and requires multiple logic duplications. If we add another API call for e.g. subscribe, it should simply do the necessary translations/conversions (e.g. determining the pubsub topic via autosharding) to call the "base" subscribe.
  • I think we should avoid mixed configuration here: people should either subscribe via content topics or directly on pubsub topic. In other words, once you've unsubscribed from all content topics matching a specific shard, that shard subscription can be safely removed without considering if we have configured a "direct" subscription too.
  • this would make the auto-subscription methods a very light layer on top of the existing subscribe/unsubscribe functions and hopefully minimise the state we have to keep

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

SionoiS commented Sep 7, 2023

It now only use publish subscribe and unsubscribe and does no longer keep track of pusub subscriptions.

Copy link
Collaborator

@Ivansete-status Ivansete-status left a comment

Choose a reason for hiding this comment

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

In general, I think it looks great! I added comments that I hope you find useful

waku/node/waku_node.nim Outdated Show resolved Hide resolved
waku/node/waku_node.nim Outdated Show resolved Hide resolved
waku/node/waku_node.nim Outdated Show resolved Hide resolved
waku/node/waku_node.nim Outdated Show resolved Hide resolved
waku/node/waku_node.nim Show resolved Hide resolved
waku/waku_relay/protocol.nim Outdated Show resolved Hide resolved
waku/node/rest/relay/types.nim Outdated Show resolved Hide resolved
waku/node/rest/relay/topic_cache.nim Outdated Show resolved Hide resolved
waku/node/jsonrpc/relay/handlers.nim Outdated Show resolved Hide resolved
waku/node/jsonrpc/relay/handlers.nim Outdated Show resolved Hide resolved
Copy link
Collaborator

@Ivansete-status Ivansete-status left a comment

Choose a reason for hiding this comment

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

Super nice and enriching PR! Thanks for it!

tests/wakunode_rest/test_rest_relay.nim Outdated Show resolved Hide resolved
tests/wakunode_rest/test_rest_relay.nim Show resolved Hide resolved
waku/waku_relay/protocol.nim Show resolved Hide resolved
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. I think this is now much cleaner than before. Approving as I don't want to be blocker, but have made some minor suggestions below.

waku/node/waku_node.nim Outdated Show resolved Hide resolved
waku/node/waku_node.nim Outdated Show resolved Hide resolved
# This is the 1st commit message:

feat: Autosharding API for relay subscriptions

# This is the commit message #2:

Fix
@SionoiS SionoiS merged commit 1763b1e into master Sep 26, 2023
9 of 10 checks passed
@SionoiS SionoiS deleted the relayAPI branch September 26, 2023 11:33
Ivansete-status added a commit that referenced this pull request Sep 26, 2023
…erly (#2082)

* libwaku.nim: unsubscribe -> unsubscribeAll to make it build properly

We introduced a change in the next PR
#1983
that made the `libwaku` to stop building properly
(make libwaku) because a signature change in the
`unsubscribe` proc of waku/waku_relay/protocol.nim.

This commit is a temporary workaround to make it work,
and not block any ongoing PR tests,
although not exactly as it is expected because we are
unsubscribing from all topics.

* ci.yml: adds library/** to force tests when changes under that folder
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.

None yet

4 participants