-
Notifications
You must be signed in to change notification settings - Fork 57
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
chore: [WIP-for opinions] move push logic to lightpush #2712
Conversation
You can find the image built from this PR at
Built from 9807c71 |
You can find the image built from this PR at
Built from 9807c71 |
Well, what do we gain with tightening coupling between lightpush and relay services? I think the biggest advance with light puhs and relay would be to propagate more information to the users about the success of the action. Like how many relay peers got the message or if we could require a minimum number of peers for success, etc. |
@@ -23,7 +24,7 @@ logScope: | |||
type WakuLightPush* = ref object of LPProtocol | |||
rng*: ref rand.HmacDrbgContext | |||
peerManager*: PeerManager | |||
pushHandler*: PushMessageHandler | |||
wakuRelay*: WakuRelay |
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 means that to test WakuLightPush
you need WakuRelay
. Please, no.
IMO, only acceptable options are;
- some kind of interface (more boilerplate)
- a channel (not yet functional in Chronos)
- a callback (current solution)
Right, good points @SionoiS and @NagyZoltanPeter. I would say that if lightpush is specified as something of a libp2p API specifically for Waku Relay, the inclusion of Waku Relay becomes an implicit dependency (in the same way as it is necessarily included for the Relay REST API, which is the most similar module to what lightpush provides). The problem with having layers of indirection, i.e. the lightpush server action being a callback defined and managed by the Waku node, is that it relegates a core part of the protocol implementation to node setup code. Now that we are planning to expand significantly the responsibilities of the lightpush server when pushing a message (starting with adding RLN proofs on behalf of light clients), most of the protocol will live outside the protocol module. I do accept though that it may be premature to flatten the structure and introduce more composition for the lightpush node. @shash256 I think a good alternative might then just be to at least define the pushHandler for adding RLN proofs in a separate helper module rather than keeping building protocol logic into the ever-growing waku_ node module. |
Mmm I agree that Lightpush has Relay as a dependency so there is already an intrinsic coupling between both. |
I disagree, Lightpush can and should work without Relay the least assumption about node configuration the better. In the most basic sense, the user is pushing a message to a node, if Relay is enabled the message is published, if Archive is enabled it is stored. If none are enabled then we disallow Lightpush at config time (same with REST).
As I stated in my comment, this is the only solution that we can use while maintaining composability AND separation.
In this case I would expect Lightpush to "ask" RLN for proofs and then "ask" Relay to publish the message (composability, separation & single responsibility). |
A fair way of abstracting lightpush as a protocol. My point is more general in that composability might be necessary if a protocol is indeed defined as dependent on another protocol. My feeling is that we've started moving in this direction for Lightpush. I think your point that it may be premature/unnecessary to introduce this coupling is valid and that lightpush is only a resource restricted way to ask a node to process a message in a variety of configurable ways, not necessarily to publish to a relay network (although I'd revise the spec in future to make this point clearer). With the above model RLN-proofs-as-a-service becomes a specific push handler for Lightpush.
If Lightpush is doing the asking, it's composing protocols :). But indeed a separate push handler can do this already with minimal changes to existing code. |
I think some level of abstraction is needed even if there is a tight connection on logic level between services. |
What if we move the callbacks from egg. RLN component would have a callback that return proofs, Autoshard component callback return shard of content topic, etc... This way we don't clutter |
One reminder (I believe you are all on the same page), is that we will push for libwaku in Status app, and we will want to support store and light push as a service in this context. So indeed, best to be wary of pushing too much glue code in waku node instead of libwaku |
Yes, I think that's a reasonable mid-way. I would separate these callbacks into a separate module for each component - e.g. |
@shash256 if we're not going to continue down this avenue, perhaps we can close this draft? |
Seems like we have some form of consensus to move callbacks from wakunode into each component. This has been done for light push in #2768 . So closing this PR for now. |
Description
For gathering thoughts on whether to do this to resolve the unnecessary indirection created by the pushHandler, as per @jm-clius suggestion.
cc: @SionoiS @NagyZoltanPeter
If we agree to go ahead with this, will modify the tests and whatever else is impacted by this change
Changes
removed the pushHandler pattern in waku_node.nim by adding a reference to wakuRelay into the Lightpush module and moving all push logic to this module itself.