136 Commits

Author SHA1 Message Date
Ivan FB
f5153ac5a9
chore: stop cargo fmt from rewriting the generated bindings
The #[path] imports make rustfmt treat the vendor's generated bindings as
crate source, so `cargo fmt` rewrapped ~1400 lines of api.rs/ffi.rs inside
the submodule. The next regen reverts that, so it is pure churn -- and it
shows up as a spurious dirty vendor.

rustfmt.toml `ignore` would be the natural fix, but it is nightly-only and
is silently dropped on stable ("unstable features are only available in
nightly channel"), so the skip attribute goes on the imports instead.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-16 18:45:56 +02:00
Ivan FB
fec1784ad5
feat(channels): expose channelExists through the bindings
Bumps vendor to pick up channelExists, cherry-picked onto the nim-ffi
0.2.0 lineage: the chore/channel-exists branch forked before that
migration, so its pre-0.2.0 {.ffi.} shape would not compile here.

The typed model carries a real bool, so channel_exists_async returns
Result<bool, _> rather than the "true"/"false" string the original
would have produced.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-16 17:56:34 +02:00
Ivan FB
6d56b9b523
chore: drop the cmd.c cmdCount/cmdLine shim
The shim existed to satisfy Nim's cmdCount/cmdLine globals, which the static
library referenced when it pulled in the command-line machinery. Nothing in
liblogosdelivery.a (nor any archive on the link line) references either symbol
now, and a clean rebuild of the workspace and the basic example links without
it.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-16 17:03:33 +02:00
Ivan FB
1b25e5c327
refactor: collapse waku-sys into waku-bindings
waku-sys was a thin -sys crate that only re-exported the generated FFI
sources via #[path] and carried the build. It sat between waku-bindings
and the generated crate for no real benefit -- the generated crate is the
actual -sys equivalent, and its own build.rs cannot build logos-delivery
(bare `nim c`, one link directive). So the wrapper is folded in:

- The build (make liblogosdelivery + the 13 link directives, librln
  discovery, cmd.c) moves into waku-bindings/build.rs.
- waku-bindings pulls the generated ffi/types/api modules directly by
  #[path] into the vendor submodule, which moves from waku-sys/vendor to
  the repo root (vendor/).
- ciborium/flume and the cc build-dep move over; the waku-sys path
  dependency is dropped.

Consumers are unaffected -- they always depended only on waku-bindings.
This is one crate and one layer fewer.

build.rs now also removes a stale build/liblogosdelivery.dylib after the
static build: the generated ffi.rs declares `#[link(name =
"logosdelivery")]` with no kind, so a dylib left by a non-STATIC make
would be linked dynamically over the static archive.

Full suite passes (4 tests + doctest, 1 ignored) and all three examples
build.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-16 16:47:10 +02:00
Ivan FB
84f7daa0ce
docs: make the available operations discoverable; document local use
Consuming apps depend on this crate from a local checkout, and the
operations were hard to find: the crate root was `pub use waku_sys::*`,
so everything a caller can do was hidden as methods on a glob-exported
LogosDeliveryCtx.

The crate-root docs now carry an Operations map — node lifecycle,
messaging, reliable channels, and the typed event listeners — with the
method names and a runnable example, so `cargo doc` and reading lib.rs
both show what is callable. The low-level waku_* kernel surface is noted
as the tier beneath.

The README gains a "Using the crate" section: clone + checkout, the
local path dependency, and the Nim/make/Rust build prerequisites.

Also fixes stale rustdoc links in the restored store DTOs and a bare URL
in the config docs, so the doc build is warning-clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-16 15:41:03 +02:00
Ivan FB
4ac3452ffd
feat: typed CBOR requests for send and channel_send
Bumps vendor to the typed SendRequest / ChannelSendRequest procs and
updates the channels test to fill the typed struct instead of building a
JSON string. send_async now takes SendRequest, channel_send_async takes
(channel_id, ChannelSendRequest); both structs are re-exported from the
generated crate.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-16 14:48:55 +02:00
Ivan FB
9ba6c4d4f1
chore: bump vendor to the generated C header + honest cbor lock
Picks up the two logos-delivery commits: the generated C header
replacing the stale hand-written ones, and the cbor_serialization lock
corrected to 0.4.0. Neither touches the generated Rust bindings; the full
suite still passes.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-16 12:22:43 +02:00
Ivan FB
3ee17ecc4d
test: give each test binary its own persistency root
Cargo runs test binaries in parallel and serial_test only serialises
within one, so the channels and node suites were sharing ./data — two
processes over one on-disk persistency root. Nothing here proves that
caused harm, but shared mutable state across concurrent processes is not
worth leaving in place.

local_storage_path is added to WakuNodeConfig to make this expressible.
The field is worth having regardless: it was simply missing, and its
docs record that the persistency singleton refuses re-targeting, so a
second node in the same process must use the same path or fail to start.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-16 09:19:04 +02:00
Ivan FB
dfedf2ba15
fix: rebuild when the vendor's Nim sources change
build.rs only invalidated on the generated rust_bindings, so editing any
Nim source left the linked archive stale and the tests silently ran
against the previous build -- which cost an hour of debugging a channel
failure against instrumentation that was never in the binary.

Also corrects channel_message_reaches_peer's ignore reason. The message
is not lost in SDS: Persistency is a process-wide singleton that refuses
re-targeting, so two in-process nodes share one SDS job whose rows are
keyed by channel id alone. The receiver loads the sender's history and
SDS rightly calls the message a replay. The channels API is fine; the
test needs two processes.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-16 09:07:04 +02:00
Ivan FB
aade2ed4d8
test: validate the channels API against a real peer
The channel test only checked that create/send/close returned values, so
it passed while every send failed downstream: channel_send returns a
request id immediately and reports the outcome asynchronously, and with
no listener on onChannelMessageError there was nothing to notice. Asking
the question properly -- two nodes, one channel, does the payload arrive
-- surfaced three things, none of them caused by the nim-ffi migration.

Encryption was never installed, so no segment could ever be sent; that is
fixed in the vendor by naming the mechanism at channel creation.

Autosharding could not be switched on from here at all. A channel's shard
is derived from its content topic, so without it the send cannot even
auto-subscribe. num-shards-in-network exists on the kernel conf but
WakuNodeConfig never exposed it, so it is added here.

Ingress is still dropped below this layer, so channel_message_reaches_peer
is #[ignore]d with the evidence in its doc comment rather than deleted or
weakened into a test that cannot fail. The single-node test keeps its
narrow scope and now says why it asserts nothing about arrival.

The error listeners stay: a send that fails silently is exactly how this
went unnoticed, and they turn a timeout into a diagnosis.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-16 08:40:26 +02:00
Ivan FB
dd4d093945
fix(examples): port toy-chat and tic-tac-toe-gui to the generated API
examples/ is its own cargo workspace and only examples/basic is a member
of the root one, so nothing built from the repo root ever compiled these
two. They still used waku_new, set_event_callback, WakuEvent and the
WakuNodeHandle typestate, none of which exist any more.

Both collapse their App<State> typestate: the node no longer carries one,
so neither can the app wrapping it. Event handling shrinks to a single
add_on_received_message_listener -- the filter on content topic stays,
but the enum match, the JSON parse and the panics on unexpected variants
go, since a listener only receives what it registered for. Payloads are
base64-decoded by the caller now.

The store DTOs (StoreQueryRequest, StoreResponse, StoreWakuMessageResponse)
come back as general/store.rs: they are plain serde shapes, and deleting
node/store.rs took them out along with the FFI call they sat next to.
toy-chat needs them to build the store query JSON and read the response.

CI gains a check over examples/Cargo.toml. Without it these rot silently
on the next API change, which is exactly how they got here.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-16 01:28:54 +02:00
Ivan FB
6a107e66cc
fix(test): let the echo's Result decide default_echo
The select arm discarded test_echo_messages' Result, so the test passed
whenever that future finished -- including the path where the message
never arrived and it returned Err. Only the 1000s timeout could fail it,
which made the assertion close to vacuous for the case it exists to
cover.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-16 01:09:34 +02:00
Ivan FB
430ebc0bda
feat!: expose the generated bindings, drop the hand-written FFI tier
The generated crate already provides what this tier existed to build:
CBOR marshalling, the callback dance, and a typed method per proc. So
macros.rs (trampoline, handle_ffi_call) and libwaku_response.rs
(RET_OK/RET_ERR, LibwakuResponse) are deleted rather than ported, and
node/events.rs goes with them -- its WakuEvent enum is now one generated
payload struct per event, which is what the typed listeners hand back.

What survives is what the generated crate does not give us: the domain
layer (WakuMessage, WakuContentTopic, MessageHash, pubsubtopic) and
WakuNodeConfig, which still serialises to the JSON create_node takes --
that JSON is unchanged, only its transport moved to CBOR.

BREAKING CHANGE: WakuNodeHandle and its Initialized/Running typestate,
waku_new, and waku_destroy are gone; callers use LogosDeliveryCtx::create
and let Drop tear the node down. set_event_callback is gone too: events
are per-name now, so a whole-stream callback has no equivalent -- use the
typed add_on_*_listener methods, which deliver a payload struct instead
of a JSON string to match on.

Tests and the example move with the API. The event handling gets shorter
rather than longer: no from_str, no matching five variants, no panicking
on Unrecognized -- a listener only receives the event it registered for.
Callers now base64-decode payloads themselves, since that was WakuMessage's
serde doing it before.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-16 01:08:23 +02:00
Ivan FB
98d005c9e1
feat: consume the vendor's generated FFI bindings in waku-sys
nim-ffi 0.2.0 generates the Rust bindings from the Nim source, so
bindgen over the hand-written headers is no longer the source of truth
-- and could not be, since those headers describe the pre-CBOR ABI.

The generated sources are referenced in place under vendor rather than
copied, so regenerating them in logos-delivery flows straight through
with nothing to keep in sync. They stay sibling modules because api.rs
resolves its neighbours through `super::`.

build.rs keeps driving the build: it runs the vendor's make target,
scans for the version-and-hash-named nimble package dirs and librln, and
emits the miniupnpc / natpmp / c++ link flags. The generated build.rs
does none of that (it runs a bare `nim c --mm:orc` against a path that
does not resolve here), so only the bindgen half is dropped.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-16 00:56:16 +02:00
Ivan FB
96499cc735
feat: reliable channels bindings and vendor bump
Exposes the reliable-channel surface: channel_create / channel_send /
channel_close on WakuNodeHandle, backed by the logosdelivery_channel_*
FFI calls. Channel state is persisted, so re-creating a closed channel
resumes it rather than starting fresh, and send payloads travel
base64-encoded.

Adds the three channel lifecycle events (received / sent / error) to
WakuEvent, plus the messaging events (sent, error, propagated, received)
and connection status change, so callers can observe delivery rather
than only firing and hoping.

build.rs resolves the nimble package dirs and librln by scanning rather
than hardcoding, since their names carry versions and hashes that move
whenever nimble.lock does. It also checks make's exit status: a failed
build previously passed silently and the crate linked a stale library
from an earlier run.

Bumps the vendor submodule to master.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-16 00:44:30 +02:00
Igor Sirotin
95040402fe
chore: update license files to comply with Logos licensing requirements 2026-02-05 15:09:10 +00:00
Darshan
eb847fdb80
fix: ci workflow (#125) 2025-12-16 17:53:30 +05:30
Darshan
a02e631d53
chore: align with recent rename (#124) 2025-12-16 01:40:40 +05:30
Darshan K
4ec20e2ebe
chore: upgrade to V0.36.0 (#123) 2025-11-13 00:12:21 +05:30
gabrielmer
57505a1c06
chore: update store json to camelCase (#117) 2025-04-11 14:26:07 +03:00
Ivan FB
1d95d05dd7
avoid closure to be dropped in release mode (#116) 2025-03-05 09:39:15 +01:00
Ivan FB
9c9900897e
Adapt for nwaku v0.35 (#114)
* build.rs: initialize submodules the first time cargo build is invoked in waku-sys
* messagehash.rs only contains a String as the hex representation of msg hash
* events.rs adapt test to parse message event containing msg-hash in hex string format
* bump nwaku to v0.35.0
* waku-sys/build.rs use STATIC=1 instead of STATIC=true
2025-02-12 10:06:16 +01:00
richΛrd
90577d1d58
feat: add discv5_bootstrap_nodes attribute to the config (#112) 2025-02-03 13:33:14 -04:00
Ivan FB
247f740f1d
docs: add simple README.md for all examples (#111)
Co-authored-by: richΛrd <info@richardramos.me>
2025-01-20 16:15:45 +01:00
Ivan FB
75b5c4c4f8
add Makefile and scripts allow build libwaku in cargo publish (#108) 2025-01-14 17:03:40 +01:00
Ivan Folgueira Bande
64736c0284
README.md change go-waku with nwaku 2025-01-13 15:30:08 +01:00
Ivan FB
c2412134d3
upgrade major version to create 1.0.0 (#107) 2025-01-13 09:50:05 +01:00
Ivan FB
0c0b834aa0
Recover toy chat app powered by libwaku/nwaku (#105)
* bump nwaku to the current master branch ( commit: 625c8ee5 )
* make the waku crate to behave tokio-asynchronously
* use of store
* use of lightpush and filter
* add waku-bindings/src/general/messagehash.rs
* add waku-bindings/src/general/time.rs
* add waku-bindings/src/general/waku_decode.rs
* add WakuEvent management (WakuMessage, ConnectionChange, TopicHealthChange.)
* add waku-bindings/src/macros.rs
2025-01-10 15:19:31 +01:00
Ivan FB
fd7e73a7f0
Tic tac toe example (#104)
* 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>
2024-11-28 10:35:41 +01:00
richΛrd
7a2e4d1d01
feat: RLN Relay (#101) 2024-04-01 15:15:50 -04:00
richΛrd
1ed7dd48ed
chore: disable windows builds temporarily (#100) 2024-03-21 09:17:59 -04:00
richΛrd
201a38a64e
feat: example app (#99) 2024-03-11 12:00:30 -04:00
richΛrd
69a48725ca
refactor: node handle constructor and messageHash on publish (#98)
* refactor: node handle constructor and messageId on publish
* refactor: add back typestate
* chore: rename messageId to messageHash
2024-03-01 11:31:00 -04:00
richΛrd
a10a5c2d22
refactor: use a enum for handling the responses, and don't ignore the return code (#97)
* refactor: handle return code and use an enum to handle responses
* fix: nwaku does not return an envelope hash on publish
2024-03-01 11:25:02 -04:00
richΛrd
646f6f0080
refactor: hide *mut c_void behind WakunodeContext (#96) 2024-02-26 11:13:30 -04:00
Richard Ramos
c434e9ebf5
refactor: remove getters 2024-02-22 10:57:02 -04:00
Richard Ramos
9d3b575037
chore: remove example (for now) 2024-02-21 15:54:55 -04:00
Richard Ramos
ac96b834a0
chore: use rust node address instead of fleet node in tests 2024-02-21 14:07:42 -04:00
Richard Ramos
79b8428bb5
feat: add listen addresses 2024-02-21 11:59:40 -04:00
Richard Ramos
9c696e6097
feat: expose waku_version 2024-02-20 16:06:03 -04:00
Richard Ramos
685a6aef0a
fix: event handler 2024-02-16 10:45:20 -04:00
Richard Ramos
1f9283a849
fix: event callback signature 2024-02-13 18:03:34 -04:00
Richard Ramos
5687e2585c
chore: make sure waku_new, waku_start and waku_stop work 2024-02-13 16:18:16 -04:00
Richard Ramos
ca72e70bb6
chore: link required libraries and RLN 2024-02-13 14:50:00 -04:00
Richard Ramos
1d8626b110
chore: remove code no longer needed (for now) 2024-02-12 20:13:49 -04:00
Richard Ramos
8755d9a7c8
refactor: remove unneeded functions and change some data types 2024-02-08 17:16:34 -04:00
Richard Ramos
9d73230c8a
chore: remove unneeded files (for now) 2024-02-08 17:15:49 -04:00
Richard Ramos
9750a329ab
feat: use nwaku instead of go-waku 2024-02-08 11:54:49 -04:00
richΛrd
1ea96f80b2
feat: add dns discovery parameters (#85) 2024-02-06 13:38:51 -04:00
richΛrd
5aaafc7c20
fix: content topic should accept strings (#84) v0.5.0 2023-12-08 17:30:30 -04:00