Skip to content

chore(varint): adopt shared zig-varint (drop in-tree copy)#75

Merged
ch4r10t33r merged 1 commit into
mainfrom
chore/adopt-zig-varint-57
Jul 4, 2026
Merged

chore(varint): adopt shared zig-varint (drop in-tree copy)#75
ch4r10t33r merged 1 commit into
mainfrom
chore/adopt-zig-varint-57

Conversation

@ch4r10t33r

Copy link
Copy Markdown
Collaborator

Closes #57.

Now that zig-ethp2p is on Zig 0.16 (which zig-varint requires), this drops the ~38-line in-tree multiformats unsigned-varint in src/wire/varint.zig in favour of a thin re-export of zig_varint.unsigned — the same shared codec zquic (#126) and zig-libp2p (#98) already adopted.

Changes

  • build.zig.zon: zig fetch --save of zig-varint v0.1.0.
  • build.zig: zig_varint module wired next to quic / compat (available to all test modules).
  • src/wire/varint.zig: now re-exports append, decode, decodeNonNegativeI32, DecodeError from zig_varint.unsigned, keeping the exact call-site API in wire/rs.zig, wire/broadcast.zig, sim/gossipsub_rpc_pb.zig. The cursor decoders map to the relaxed variant to preserve the previous decoder's tolerance of non-minimal encodings.

Verification

Stock Zig 0.16.0: zig fmt --check, zig build test, and the split roots test-broadcast / test-sim-gossipsub / test-sim-rs all pass — the wire/gossipsub golden-byte tests exercise the shared codec unchanged.

Now that zig-ethp2p is on Zig 0.16 (which zig-varint requires), replace the
~38-line in-tree multiformats unsigned-varint in `src/wire/varint.zig` with a
thin re-export of `zig_varint.unsigned` — the same shared codec zquic and
zig-libp2p already use.

`append` / `decode` / `decodeNonNegativeI32` / `DecodeError` keep their names
and signatures so the call sites in `wire/rs.zig`, `wire/broadcast.zig`, and
`sim/gossipsub_rpc_pb.zig` are unchanged. The cursor decoders map to the
relaxed variant to preserve the previous decoder's tolerance of non-minimal
encodings. `zig_varint` is wired next to the zquic/compat modules in build.zig.

Closes #57.
@ch4r10t33r ch4r10t33r merged commit 277c875 into main Jul 4, 2026
7 checks passed
@ch4r10t33r ch4r10t33r deleted the chore/adopt-zig-varint-57 branch July 4, 2026 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chore(varint): adopt shared zig-varint after 0.16 migration

1 participant