Switch the brittle hand-maintained `from codec import <symbol-list>` to a
plain `import`, so adding a codec helper no longer means editing the list.
Use `except ProtobufError` because codec re-exports its own ProtobufError,
which would otherwise clash with our app-layer ./types/protobuf_error one.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Addresses review feedback: skipping a field by reading its value
discards an allocated result. Use the codec's `skipValue`, which
advances the stream without materialising the value. (The previous
allocating length-delimited discard was already removed by the
parse-once change; this applies the same intent to the fixed32/64
skips that remain.)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Addresses review feedback on PR #77: `getField` rescanned the whole
buffer on every call, giving O(fields × len) decode. Parse the message
once at `ProtoBuffer.init(data)` in a single forward pass with the
library's reader, indexing values by field number; the accessors are
then plain lookups (last-wins / repeated semantics fall out of wire
order). Public API and wire behaviour are unchanged.
The full type-driven `Protobuf.encode/decode` API is intentionally not
used here: it cannot express the backward-compatible causal-history
decode (field 3 is repeated HistoryEntry now, repeated bare-string IDs
in legacy messages), and its default-value omission would drop the
always-written empty fields the strict decoder requires (e.g. empty
`content` on sync messages), breaking compatibility with peers on the
current wire format.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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>
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>