chore(varint): adopt shared zig-varint (drop in-tree copy)#75
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #57.
Now that zig-ethp2p is on Zig 0.16 (which
zig-varintrequires), this drops the ~38-line in-tree multiformats unsigned-varint insrc/wire/varint.zigin favour of a thin re-export ofzig_varint.unsigned— the same shared codec zquic (#126) and zig-libp2p (#98) already adopted.Changes
build.zig.zon:zig fetch --saveofzig-varintv0.1.0.build.zig:zig_varintmodule wired next toquic/compat(available to all test modules).src/wire/varint.zig: now re-exportsappend,decode,decodeNonNegativeI32,DecodeErrorfromzig_varint.unsigned, keeping the exact call-site API inwire/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 rootstest-broadcast/test-sim-gossipsub/test-sim-rsall pass — the wire/gossipsub golden-byte tests exercise the shared codec unchanged.