chore: upgrade to Zig 0.16.0-dev (master)#252
chore: upgrade to Zig 0.16.0-dev (master)#252lodekeeper-z wants to merge 33 commits intoChainSafe:mainfrom
Conversation
- Replace @type(.{.@"struct" = ...}) with @struct() builtin - Replace @type(.{.optional = ...}) with ?T syntax - Replace std.io.getStdOut().writer() with std.debug.print or init.io - Fix std.fs.cwd() → std.Io.Dir.cwd() in zbuild - Replace std.ArrayList with std.array_list.AlignedManaged (managed) - Fix depth.zig build_options optional handling - Add @ptrCast for BLS [*c] pointer coercions - Fix SyncCommitteeIndices to use managed ArrayList 🤖 Generated with AI assistance
- Replace std.fs.cwd() with std.Io.Dir.cwd() - Replace std.fs.File with std.Io.File - Replace std.fs.Dir with std.Io.Dir - Replace makePath with createDirPath - Replace std.io.AnyWriter with *std.Io.Writer - Thread io: std.Io through era Reader/Writer - Fix bench main signatures for std.process.Init - Fix zbench ArrayListUnmanaged empty init - Fix blst_hash_to_g2 @ptrCast 🤖 Generated with AI assistance
- Replace zbuild-dependent build.zig with standard std.Build code
- Remove zbuild, zbench, metrics, httpz deps (not yet 0.16-compatible)
- Fix std.json.writeStream -> std.json.Stringify
- Fix std.fmt.fmtSliceHexLower removal (use {x} format directly)
- Fix std.Io.Dir methods needing io parameter
- Fix std.Io.File.writer() API change (returns File.Writer)
- Fix std.http.Client requiring io field
- Fix build_options optional unwrap (zero_hash_max_depth)
- Fix Dir.Iterator.next() requiring io parameter
- Skip bindings/bench modules (deps not 0.16-ready)
Build passes. Core tests (hashing, hex, config, ssz) pass.
🤖 Generated with AI assistance
- Fix refAllDeclsRecursive -> refAllDecls (removed in 0.16) - Fix Thread.Mutex -> std.atomic.Mutex - Fix Thread.Pool usage in pubkey_cache (serial fallback for now) - Fix posix.getrandom (removed) -> timestamp-based seed - Add @ptrCast for [*c] pointer coercions in BLS bindings - All core modules pass: constants, preset, hex, hashing, config, consensus_types, persistent_merkle_tree, ssz Still needs work: - BLS module: Thread.ResetEvent, ThreadPool need 0.16 Io.Event migration - state_transition: blocked on BLS + metrics dep - bindings/bench: blocked on zapi/zbench/metrics deps 🤖 Generated with AI assistance
🤖 Generated with AI assistance
….free - Create timer.zig shim (std.time.Timer removed, use Io.Clock.awake) - Create metrics_stub.zig (external metrics dep not yet 0.16-compatible) - Fix allocator.free on pointer-to-array (0.16 requires slice type) - Fix @setEvalBranchQuota for ContainerTreeView comptime loop All core + state_transition tests now pass. 🤖 Generated with AI assistance
- Fix std.fmt.FormatOptions -> std.fmt.Options (0.16 rename) - Fix ArrayList zero-init (requires .items/.capacity fields in 0.16) - Fix setEth1DataVotes to take pointer (matches container set() signature) - Wire test:fork_types and test:era into build.zig All 12 test modules now pass: constants, preset, hex, hashing, config, consensus_types, persistent_merkle_tree, ssz, bls, state_transition, fork_types, era 🤖 Generated with AI assistance
🤖 Generated with AI assistance
Including test:era and test:fork_types which were wired and fixed in previous commit. 🤖 Generated with AI assistance
Remove the standalone timer.zig shim file and inline the Timer type into metrics.zig where all timing helpers already live. Zig 0.16 replaced std.time.Timer with std.Io.Clock.Timestamp. The blessed API is: - std.Io.Clock.Timestamp.now(io, .awake) for monotonic timestamps - .durationTo() for elapsed time as Clock.Duration - .raw.nanoseconds for the i96 nanosecond count Timer.start() no longer returns an error union since the Io.Clock API is infallible, so all `try Timer.start()` calls are simplified. readSeconds() is now a method on Timer instead of a free function, giving callers a cleaner `timer.readSeconds()` interface. 🤖 Generated with AI assistance
- Bump ZIG_VERSION to 0.16.0-dev.2915+065c6e794 in CI and publish-bindings workflows - Add test:fork_types, test:era, test:constants steps to build-test job 🤖 Generated with AI assistance
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request performs a comprehensive upgrade of the project to the latest Zig 0.16.0-dev version. The primary goal is to align the codebase with the new Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Ignored Files
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
- Run zig fmt on all source files - Replace local dep paths with git+https URLs in build.zig.zon - Remove zbuild CI job (replaced by direct build.zig) - Disable bindings-test and build-examples CI jobs (deps not yet 0.16-compatible) - Comment out benchmark build step (zbench/metrics/httpz not yet 0.16-compatible) 🤖 Generated with AI assistance
There was a problem hiding this comment.
Code Review
This pull request successfully upgrades the project to Zig 0.16.0-dev, addressing numerous API changes across the standard library, including std.Io, std.Thread, std.json, and comptime struct/tuple handling. The changes are well-executed adaptations to the new Zig ecosystem. Temporary workarounds for incompatible dependencies are noted with appropriate TODOs, indicating a clear path for future completion. The build system has also been refactored to align with the new std.Build model, moving away from zbuild.
|
CI update: macOS fails on hashtree-z ARM assembly — Ubuntu x64 and arm64 still pending in CI queue. |
Removes zig-pkg/ and deps/ directories that were accidentally committed. Dependencies are fetched from git URLs in build.zig.zon at build time. 🤖 Generated with AI assistance
🤖 Generated with AI assistance
blst.zig build.zig was not defining __APPLE__ explicitly when compiling blst's assembly.S. Zig's bundled clang doesn't auto-define __APPLE__ for .S files even on macOS targets, causing the ELF branch to be taken instead of mach-o. This left all ARM64 mach-o symbols unassembled, producing linker errors like 'undefined symbol: _mulx_mont_384'. Fix is in lodekeeper-z/blst.zig@9ea29f6: if (target.result.os.tag == .macos) lib.root_module.addCMacro("__APPLE__", "1"); 🤖 Generated with AI assistance
The mlugg/setup-zig@v2 action caches the zig build directory between runs. When dependencies change (build.zig.zon updated), the old compiled artifacts are restored from cache, causing stale libblst.a and other compiled deps to be used even though the source/flags have changed. Include build.zig.zon content hash in the cache-key so the cache is invalidated whenever dependencies are updated. 🤖 Generated with AI assistance
Previous attempt used addCMacro which only affects the Zig compiler, not clang. The define must be in c_flags to reach the assembly.S compilation. New commit 1143280 in lodekeeper-z/blst.zig fixes this correctly. 🤖 Generated with AI assistance
Fixes macOS ARM64 undefined symbol errors (_ctx_inverse_mod_383 etc). Root cause: std.Target.x86.featureSetHas on ARM64 cpu features checked bit 13 which is ARM64's balance_fp_ops, not x86 ADX. Apple Silicon has balance_fp_ops enabled, so __ADX__ was incorrectly defined, causing server.c to reference ctx_*-prefixed symbols that don't exist in the ARM64 mach-o assembly. Fix: blst.zig@254f286 now guards the __ADX__ check with arch == .x86_64. 🤖 Generated with AI assistance
The test/fuzz/ directory had its own build.zig.zon referencing the old ChainSafe/snappy.zig which uses zig 0.14.1 APIs. Update to the upgraded lodekeeper-z/snappy.zig fork that supports zig 0.16.0-dev. 🤖 Generated with AI assistance
The actual spec test archive extracts to e.g. minimal/minimal/... and general/general/... — no intermediate 'tests/' directory. The write scripts were using paths like: spec_test_out_dir/version/minimal/tests/minimal/... spec_test_out_dir/version/general/tests/general/... Fixed in: - test/spec/write_spec_tests.zig - test/spec/ssz/write_generic_tests.zig - test/spec/ssz/write_static_tests.zig - test/spec/bls/write_spec_tests.zig Both the discovery-time paths (used to iterate during code gen) and the runtime path strings (embedded in generated test files) are fixed. 🤖 Generated with AI assistance
- Fix era test: openFile called with wrong arg count (4 args vs 3 expected) std.Io.Dir.openFile(io, path, flags) -> openFile(io, path, flags) - Fix e2s.zig: PReadError/PWriteError -> ReadPositionalError/WritePositionalError - Fix era.zig, Reader.zig, Writer.zig: pass io arg to readEntry/readVersion - Fix download_spec_tests.zig: implement full tar extraction - Update test/spec/root.zig (regenerated) 🤖 Generated with AI assistance
🤖 Generated with AI assistance
🤖 Generated with AI assistance
🤖 Generated with AI assistance
🤖 Generated with AI assistance
- Replace readToEndAlloc with reader-based readFileToEnd helper - Add io parameter to openFile/close calls - Update parseYamlToJson for new yaml Value variants (string/int/float/boolean) - Use .written() instead of .items on Io.Writer.Allocating - Update renderToStdErr → renderToStderr with new signature 🤖 Generated with AI assistance
- Add io parameter to openFile, close, statFile calls - Replace readToEndAlloc with reader-based readFileToEnd helper - Fix in test_case.zig and all runner files (transition, sanity, merkle_proof, fork) 🤖 Generated with AI assistance
🤖 Generated with AI assistance
…rsing Updates yaml dependency to include: - fix: treat quoted strings as strings (not coerced to int/bool/float) - fix: handle typed yaml values when parsing as string pointers This fixes BLS spec tests and most SSZ spec test yaml parsing failures. 🤖 Generated with AI assistance
Zig 0.16 enforces tagged union safety — accessing a field of the previous variant after assigning a new variant panics at runtime. Save init_group/write_group/finished_group values into local variables before transitioning the state union. 🤖 Generated with AI assistance
Updates yaml dependency to include:
- Flow mapping support ({A: 123, B: 456})
- Doc end marker fix
- Scalar-only Value type (no typed int/float/boolean parsing in load)
- Quoted string preservation
Updates ssz/test_case.zig parseYamlToJson for scalar Value type.
🤖 Generated with AI assistance
The generated static_tests.zig was emitting test_dir.close() without the io parameter required by Zig 0.16's Dir.close(io) API. 🤖 Generated with AI assistance
Upgrade lodestar-z and all dependencies to Zig 0.16.0-dev.2915 (pre-release master).
What changed
Language/stdlib migration
std.io→std.Io(complete I/O rewrite)std.Io.Dirmethods now require explicitioparameterstd.time.Timerremoved → usingstd.Io.Clock.Timestampdirectly@Typestruct construction changesstd.ArrayList→ unmanaged defaultallocator.freeon array pointers needs slice castBuild system
Dependencies (draft PRs opened)
Test status (local, linux x64)
All 12 test modules pass.
Known gaps
🤖 Generated with AI assistance