Repository navigation
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## unstable #10818 +/- ##
============================================
+ Coverage 59.09% 59.10% +0.01%
============================================
Files 983 983
Lines 40451 40448 -3
Branches 8615 8615
============================================
+ Hits 23903 23907 +4
+ Misses 14099 14091 -8
- Partials 2449 2450 +1 🚀 New features to boost your workflow:
|
Dockerfile and Dockerfile.dev bumped ZIG_VERSION to 0.17.1 but kept the 0.16.0 tarball checksums, so sha256sum -c failed and the images could not build. Values match https://ziglang.org/download/index.json and Dockerfile.fuzz.
Zig 0.17.1 std.posix defines Darwin IP.PKTINFO, IP.DONTFRAG, IPV6.RECVPKTINFO, IPV6.PKTINFO and IPV6.DONTFRAG with the values native.zig hardcoded (26, 28, 61, 46, 62), and the same symbols on Linux, so take them from std. IP.DONTFRAG is only referenced in comptime-pruned Darwin branches; udp tests pass on macOS and x86_64-linux-gnu / aarch64-linux-musl builds compile. The epoch cache test comment referred to -Doptimize=ReleaseFast, which Zig 0.17 spells fast.
Linking the native archive on Linux bypasses afl-cc's instrumentation pass, and root_module.fuzz alone makes Zig emit only its own inline 8-bit counters, so AFL++ saw no edges in Zig code. Enable trace-pc-guard, which AFL++'s runtime counts, and force the LLVM backend: x86_64 Debug otherwise uses the self-hosted backend, which emits no sancov at all. Measured in ubuntu:24.04 arm64 with Ubuntu's AFL++, fuzz-ssz_basic built with -Doptimize=safe, afl-fuzz -V 15 on corpus/ssz_basic-cmin: - before: 0 trace_pc_guard call sites, total_edges 18, edges_found 4 - after: 15356 call sites, total_edges 15374, edges_found 18 Zig 0.17.1 src/codegen/llvm.zig enables TracePCGuard only from san_cov_trace_pc_guard. On x86_64-linux Debug, an archive gets __sancov_guards and __sanitizer_cov_trace_pc_guard references only with both use_llvm and the flag set. Archives for x86_64 safe and aarch64 Debug are byte-identical with or without use_llvm.
Replace APIs that Zig 0.17.1 std marks deprecated: std.fmt.bufPrint/bufPrintSentinel -> std.mem.print/printSentinel, std.mem.indexOfScalar -> findScalar, std.mem.copyForwards -> @memmove (every site copies equal lengths; two shift in place), std.fs.path/max_path_bytes -> std.Io.Dir.path/max_path_bytes (including code emitted by the spec test writers), std.tar.pipeToFileSystem -> std.tar.extract, and Run add*Arg -> add*Arg2. The 0.17 release notes change @bitcast on arrays to follow logical bit order independent of endianness. The two UDP casts between in_pktinfo's network-order u32 fields and [4]u8 meant memory reinterpretation, so use std.mem.toBytes / bytesToValue. Identical on the little-endian binding targets. Audited @hasDecl, which now only sees pub declarations: every probed type lives in another file, so results are unchanged. Comments now spell optimize modes the 0.17 way. Verified with Zig 0.17.1 on macOS arm64: test:state_transition, udp, era, hex, cpu_count, beacon_node, tidy, fault_io (396/411 passed, 15 skipped); build-lib:bindings, benches, scripts and spec writers (92/92); build-test:udp for x86_64-linux-gnu and aarch64-linux-musl; test/fuzz configures.
Brings in #10793, which matches the cherry-picked 93e0f4a, so its diff drops out of this branch. Resolve the epoch_cache_test.zig conflict by removing the comment saying the regression only reproduces in fast builds. Under Zig 0.17.1, reverting the #10793 fix crashes 68 test:state_transition tests in debug with "attempt to use null value", including both #10793 tests: 0.17.1 reads an optional's null flag from its low bit, so the 0xAA undefined fill reads as null in safe modes too.
@fromBackingInt coerces its operand to the enum's backing integer, and Zig only coerces implicitly when no value can be lost, so the @intcast that zig fmt's @enumFromInt upgrade inserts is a no-op wherever the operand already has that type or widens to it. Arithmetic, shift and bitwise operands are evaluated without a result type either way, so overflow and truncation behaviour is unchanged. Removed it on 203 of 207 lines; the remaining four narrow usize to Node.Id's u32 backing. Every build-test module, build-lib:bindings and the bench, script and spec writer executables compile with Zig 0.17.1 (177/177 steps), and persistent_merkle_tree, ssz, state_transition, fork_types, ere_verifier, consensus_types and tidy tests pass (866/868, 2 skipped).
Re-pin hashtree-z (69158be), snappy.zig (23869bb), zig-yaml (2b6c488) and zapi (8315594) to the PR heads that drop redundant casts and the remaining deprecated Zig 0.17 APIs. Hashes from zig fetch of each URL. With these pins: all Zig test modules except fixture-backed spec tests pass (1019/1020, 1 skipped), test/fuzz configures, the mainnet addon builds, and binding tests pass except suites needing unbuilt TS packages or ERA fixtures.
Re-pin zbuild to 7424bc8 (ChainSafe/zbuild#10, drops deprecated mem.indexOf*/Build.dupe and tests 0.17.0 and 0.17.1) and zapi to bc33a3d (ChainSafe/zapi#96, pinned to the same zbuild). Hashes from zig fetch with an empty global cache. Zig test modules, bindings and executables build and pass, test/fuzz configures, and the mainnet addon builds.
This branch has not been deployed
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.
Motivation
Upgrade Lodestar's Zig code and native Node.js addon to Zig 0.17.1. Migrate APIs that the Zig 0.17.0 release notes (also the notes for 0.17.1) or the 0.17.1 standard library mark deprecated or removed, rather than relying on compatibility aliases.
Description
Allocator.print,std.mem.print),SafeAllocator, bit sets, type reflection, enum backing integers (@backingInt/@fromBackingInt, without redundant@intCast), target metadata, ceiling division,@memmove,std.Io.Dir.path,std.tar.extract, and theRun.add*Arg2build APIs. Port the execution block hash module that landed onunstableduring review.@bitCaston arrays now follows logical bit order, so the two UDP casts between network-orderu32fields and[4]u8usestd.mem.toBytes/bytesToValue;@hasDeclnow sees onlypubdeclarations, and every probed type lives in another file, so results are unchanged.std.posix.@chainsafe/zapi@4.5.0passes--global-cache-dir(removed in Zig 0.17) and only accepts the old optimize names.patches/@chainsafe__zapi@4.5.0.patchpasses the cache throughZIG_GLOBAL_CACHE_DIR, and the optimize mode moved intozapi.variants(-Doptimize=safe). Drop both once a zapi release includes chore: support Zig 0.17.1 zapi#96.zig fetch. Re-pin to the mergedmaincommits before this PR merges, since squash merges replace these SHAs.undefinedoptional panics in debug and safe builds (68test:state_transitiontests crash without it). It is merged into this branch fromunstable.AI Assistance Disclosure