6 Commits

Author SHA1 Message Date
Ivan FB
e2ec4d55b3
feat: replace nim-libp2p protobuf with nim-protobuf-serialization
libp2p was pulled in solely for its `minprotobuf` field codec, dragging
in its full transitive tree (secp256k1, nimcrypto, websock, etc.). Swap
it for nim-protobuf-serialization, whose low-level `codec` module gives
the same protobuf wire primitives without the networking stack.

The wire/snapshot codecs build messages by hand at the field level and
rely on a backward-compatible decode path the type-driven
`Protobuf.encode/decode` API cannot express. To keep that code intact,
`protobufutil.nim` is a thin `ProtoBuffer` shim over the new `codec`
module, preserving the exact field-level behaviour the codecs depend on
(plain varints, length-delimited bytes/strings with no UTF-8 validation,
unknown-wire-type fields skipped as protoc does).

Dependency closure (nimble.lock, nix/deps.nix) regenerated accordingly:
libp2p and its 8 exclusive transitive deps dropped, protobuf_serialization
and its npeg dependency added.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-10 15:46:14 +02:00
Ivan FB
c4d41aa5a5
chore: bump nim-ffi to 0.1.6 (enforces -d:noSignalHandler)
nim-ffi 0.1.6 fails the build if -d:noSignalHandler is missing, so the
libsds build can no longer silently drop the flag that lets the Go host
keep ownership of OS signal handlers (the regression that crashed
status-go functional tests). sds.nimble already passes the flag; this
wires the compile-time guard in.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-09 23:51:55 +02:00
Ivan FB
5c8d0f1915
fix(lock): keep proper-version lock format (nimble-version agnostic)
Regenerating the lock with newer nimble (0.22.3) rewrote entries to the
"#<rev>" special-version form, added a `nim` compiler entry, and listed `nim`
as a dependency everywhere. The nimble bundled with the nim 2.2.4 toolchain
(used by status-go CI) can't consume that: it fails on the nim checksum, then
"key not found: nim", then `git init` on a "#"-versioned bearssl dir.

Take the pre-existing lock format (proper tagged versions, no `nim` entry,
bearssl_pkey_decoder pinned as 0.1.0) and only bump the `ffi` entry to 0.1.5.
Verified building libsds in a fresh clean-room under both nimble 0.18.2 and
0.22.3.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-09 00:53:21 +02:00
Ivan FB
431f2afe7b
fix(libsds): adapt to nim-ffi 0.1.5 recycle API
nim-ffi 0.1.5 reworked the context pool to recycle contexts (reuse the
worker thread + its fds) instead of tearing them down per cycle, which is
what fixes the per-create/destroy fd leak. Two consumer-side changes are
required for libsds to work with it:

- SdsCreateRmReq: nim-ffi no longer points `myLib` at a thread-stack var;
  it owns it as a createShared'd object and frees it on recycle. So the
  handler must (re)allocate `ctx.myLib` before assigning, otherwise the
  first create dereferences a nil `myLib` and segfaults.

- SdsCleanupReliabilityManager: use `releaseFFIContext` (recycle) instead
  of `destroyFFIContext` (full teardown). Recycle keeps the worker and its
  fds alive for the next manager; destroy would reintroduce the leak. It is
  non-blocking and fires `callback` from the FFI thread once drained, so the
  synchronous RET_OK fire is dropped.

Lock nim-ffi to 0.1.5 (f6a3a33). Verified: libsds builds (--mm:refc) and the
status-go reliability suite (incl. the multi-manager fd test) is green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-08 18:46:15 +02:00
Ivan FB
7725beb5e5
start using nim-ffi 0.1.4 (#74) 2026-06-03 09:46:52 +02:00
Ivan FB
0dea35d364
feat: refactor to support building with Nimble (#52)
Changes include:

- Removing all submodules from vendor folder.
- Updating sds.nimble with required depndencies.
- Generating a nimble.lock file using Nimble.
- Updated Nim code to reference depndencies correctly.
- Added nix/deps.nix fixed output derivation that calls Nimble.
- Updated nixpkgs to use 25.11 commit which provides Nimbe 0.20.1.
- Disabled Nix Android builds on MacOS due to Nimble segfault.

Signed-off-by: Jakub Sokołowski <jakub@status.im>
2026-02-11 16:32:02 +01:00