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

nwaku c-bindings (NodeJS + Python) #1332

Closed
6 of 9 tasks
Tracked by #2420
fryorcraken opened this issue Nov 3, 2022 · 11 comments
Closed
6 of 9 tasks
Tracked by #2420

nwaku c-bindings (NodeJS + Python) #1332

fryorcraken opened this issue Nov 3, 2022 · 11 comments
Assignees

Comments

@fryorcraken
Copy link
Collaborator

fryorcraken commented Nov 3, 2022

Planned start date: started ~May'23
Due date:

Summary

nwaku is the reference implementation of the Waku protocol. To enable developers to use the reference implementation in their native application, nwaku needs to expose c-bindings.
As Nim is a garbage collected language, integration in other garbage collected languages such as NodeJS or Python may not be straightforward, as one needs to ensure that the garbage collector of either languages to not conflict with each other

Acceptance Criteria

  • 1. Expose c-binding API as defined in https://rfc.vac.dev/spec/36/
  • 2. Provide a NodeJS package and example using said c-binding API
  • 3. Provide a Python package and example using said c-binding API

Tasks

  • Important to implement chore: apply thread-safe enhancements in C-bindings #1878 in order to accomplish point 1. from the acceptance criteria.
  • [ ] Adapt https://rfc.vac.dev/spec/36/ as per changes in proc signatures.
  • [ ] Extend the waku implementation protocols. So far only the relay protocol is supported. Before that, we need to have a solid relay implementation
  • Create a separate NodeJs repo within the waku org. This repo should have nwaku as a submodule.
  • Create a separate Python repo within the waku org. This repo should have nwaku as a submodule.

Future Tasks

  • Extend the library to other platforms ( see Language Bindings #904 )
  • Adapt https://rfc.vac.dev/spec/36/ as per changes in proc signatures.
  • Extend the waku implementation protocols. So far only the relay protocol is supported. Before that, we need to have a solid relay implementation

RAID (Risks, Assumptions, Issues and Dependencies)

  • It is unclear whether this possible with Nim as preliminary research did not find any existing example with NodeJS.
    • A workable approach has been found.
  • This would be the second implementation of WAKU2-BINDING RFC, hence it may lead to changes in the RFC.
Original issue

Problem

NodeJS is used by projects such as RAILGUN to build a backend/node.
Currently, developers of such projects have the following choices:

  • integrate js-waku: not ideal as js-waku targets the browser environment and hence is lacking service node feature such as:
    • server side implementation/performance optimization of protocols (e.g. store, filter, light push)
    • RLN (currently only exporting zerokit to wasm for the browser, which does not work in NodeJS due to difference in APIs)
  • Use nwaku or go-waku as a service node
    • via JSON RPC API (which is limited)
    • via HTTP REST API (not yet delivered)
  • Use go-waku c-bindings (which requires work to do as we do not provide a JS wrapper at this stage

None of the choices above are ideal/straightforward.

Acceptance Criteria

A clear strategy to integrate nwaku in NodeJS. Two steps will be required:

  1. Select the most efficient way for NodeJS and Waku to communicate (REST API? Unix socket? C-binding? etc)
  2. Deliver an off-the-shelf solution/wrapper so that a user can install a npm package and communicate with their nwaku node
  3. Deliver an off-the-shelf solution/wrapper so that a user can install a npm package and deploy/run a nwaku node

(3) can be done at a later stage/tracked with a new issue once (1) and (2) are done.

@fryorcraken
Copy link
Collaborator Author

Regarding this. Is c-binding the best solution? Should we just start with providing a go-waku npm packages for NodeJS, similar to the React Native one?

Cc @richard-ramos

@fryorcraken fryorcraken changed the title feat: use nwaku with NodeJS [Milestone] nwaku c-bindings Aug 7, 2023
@fryorcraken fryorcraken added milestone Tracks a subteam milestone E:2023-many-platforms labels Aug 7, 2023
@fryorcraken

This comment was marked as resolved.

@Ivansete-status
Copy link
Collaborator

Weekly Update

  • achieved:
    • Moved the Waku execution into a secondary working thread. Essential for NodeJs.
    • Adapted the NodeJs example to use the libwaku with the working-thread approach. The example had been receiving relay messages during a weekend. The memory was stable without crashing.
  • next: start applying the thread-safety recommendations chore: apply thread-safe enhancements in C-bindings #1878

@fryorcraken fryorcraken changed the title [Milestone] nwaku c-bindings [Epic] nwaku c-bindings Aug 24, 2023
@fryorcraken fryorcraken added Epic and removed milestone Tracks a subteam milestone labels Aug 24, 2023
@Ivansete-status
Copy link
Collaborator

Weekly Update

  • achieved: Started applying thread-safe recommendations, making the Waku Node instance to be created within the Waku Thread itself.
  • next: Carry on with the thread-safety recommendations: avoid using Channel to communicate main thread and the Waku Thread.

@Ivansete-status
Copy link
Collaborator

Weekly Update

@fryorcraken fryorcraken removed the Epic label Sep 5, 2023
@fryorcraken fryorcraken changed the title [Epic] nwaku c-bindings nwaku c-bindings (NodeJS + Python) Sep 5, 2023
@fryorcraken fryorcraken added E:NodeJS Bindings E:NodeJS Library See https://github.com/waku-org/pm/issues/81 for details and removed E:NodeJS Bindings labels Sep 5, 2023
@Ivansete-status
Copy link
Collaborator

Weekly Update

@Ivansete-status
Copy link
Collaborator

Ivansete-status commented Sep 22, 2023

Weekly Update

@Ivansete-status
Copy link
Collaborator

Ivansete-status commented Sep 29, 2023

Weekly Update

  • achieved:

  • next: Separate the PR mentioned above and submit another one which only avoids using global variables but doesn't add the wip-Rust integration.

@Ivansete-status
Copy link
Collaborator

Weekly Update

@chair28980 chair28980 added E:nwaku Bindings and removed E:NodeJS Library See https://github.com/waku-org/pm/issues/81 for details labels Feb 15, 2024
@chair28980 chair28980 mentioned this issue Feb 15, 2024
19 tasks
@Ivansete-status
Copy link
Collaborator

@fryorcraken, @chair28980 - This can be considered as completed because:

The NodeJs repo has been created, and from there nodejs-waku packages can be built: https://github.com/waku-org/waku-nodejs-bindings
The Python repo has been created, and from there py-waku packages can be built: https://github.com/waku-org/waku-python-bindings

Besides, I've moved the following tasks to the upcoming epics:

@Ivansete-status
Copy link
Collaborator

@fryorcraken - I'm closing this because we have NodeJs and Python repos available as stated in my previous comment.

@chair28980:

I've added the following points to the waku-org/pm#141 issue, and I removed the point that referred to this issue that I'm closing (nwaku/issues/1332)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

No branches or pull requests

3 participants