-
Notifications
You must be signed in to change notification settings - Fork 8
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: use nwaku instead of go-waku #87
base: master
Are you sure you want to change the base?
Conversation
This PR so far compiles
The first time does take a while because it's building nim and downloading the submodules, so maybe we can consider generating .so/.a for different architectures and uploading them to the releases, if build times become a problem. |
I added |
We can now invoke the relay functions to publish and subscribe. I've run into some trouble setting up the event handler, which seems to work, but in the tests it fails when we attempt to push a value to a tokio channel (fails on line 48). waku-rust-bindings/waku-bindings/tests/node.rs Lines 45 to 53 in 24d7dd8
I'm investigating what's up with this. |
Thanks to @danielSanchezQ 's help, the event callback now works!
I'll now proceed to improve error handling as well as including suggestions from #88 |
This PR is mostly complete. |
@danielSanchezQ @Ivansete-status @SionoiS @danielSanchezQ , don't worry too much about all the deleted code. I'm going to add it back in future PRs towards this branch once the functionality is available in nwaku c-bindings :) |
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.
Nice base to build upon!
waku-bindings/src/node/relay.rs
Outdated
message: &WakuMessage, | ||
pubsub_topic: Option<WakuPubSubTopic>, | ||
pubsub_topic: &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.
In the future we may want to do something like pubsub_topic: impl Into<WakuPubsubTopic>
and impl From<String>
for WakuPubsubTopic
Or even better remove pubsub topic and use shards with the appropriate type constraints.
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.
Wonderful! Thanks for it!
I just added some minor comments
waku-bindings/src/node/management.rs
Outdated
pub fn waku_peer_id() -> Result<PeerId> { | ||
/// nwaku version | ||
#[allow(clippy::not_unsafe_ptr_arg_deref)] | ||
pub fn waku_version(ctx: *mut c_void) -> Result<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.
I think we can use const
in this particular case. Maybe we could check other fn
s and use the most restrictive option in each case.
pub fn waku_version(ctx: *mut c_void) -> Result<String> { | |
pub fn waku_version(ctx: *const c_void) -> Result<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.
Ah! in this case we're using bindgen to generate the bindings for libwaku.h automagically in https://github.com/waku-org/waku-rust-bindings/blob/nwaku/waku-sys/build.rs#L68-L79 and it translates *void
to *mut c_void
.
I could make the change and then cast the variable from *const
to *mut
right before interacting with nwaku, but since these functions are not exposed to the end user. We expose a friendlier API:
waku-rust-bindings/waku-bindings/src/node/mod.rs
Lines 48 to 50 in 646f6f0
pub fn version(&self) -> Result<String> { | |
management::waku_version(&self.ctx) | |
} |
I'm thinking we could accept to use a *mut
in this case, just to not have to do the cast.
waku-bindings/src/node/mod.rs
Outdated
/// Start a Waku node mounting all the protocols that were enabled during the Waku node instantiation. | ||
/// as per the [specification](https://rfc.vac.dev/spec/36/#extern-char-waku_start) | ||
pub fn start(self) -> Result<WakuNodeHandle<Running>> { | ||
management::waku_start().map(|_| WakuNodeHandle(Default::default())) | ||
pub fn start(&self) -> Result<()> { |
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.
In a future PR we might need to add error handling ( it is actually pending to be implemented in libwaku.nim
too .)
… return code (#97) * refactor: handle return code and use an enum to handle responses * fix: nwaku does not return an envelope hash on publish
* refactor: node handle constructor and messageId on publish * refactor: add back typestate * chore: rename messageId to messageHash
* update nwaku vendor to v0.33.1 * build.rs: add negentropy dependency and cmdCount cmdLine dependencies * fix: call waku_setup when instantiating waku_new * Properly decode a Vec<Multiaddr> * First commit tic-tac-toe * adding some simple game logic to coordinate the turns a little * some logic to panic if a proper event callback hasn't been set * restoring back the type state pattern introduced by Richard * new PubsubTopic type * fix clippy issues --------- Co-authored-by: Richard Ramos <info@richardramos.me>
This PR / branch will contain all the changes related to using nwaku instead of go-waku.
Once we achieve feature parity with current
master
, we need to reset that branch to point to the latest commit of this PR.libwaku.h
In separate PRs, the following functionality needs to be implemented
waku-rust-bindings/waku-bindings/src/node/mod.rs
Lines 26 to 34 in 5abd9cc