Skip to content

chore: upgrade to Zig 0.16.0#5

Merged
wemeetagain merged 6 commits into
ChainSafe:mainfrom
lodekeeper-z:chore/zig-master
Apr 20, 2026
Merged

chore: upgrade to Zig 0.16.0#5
wemeetagain merged 6 commits into
ChainSafe:mainfrom
lodekeeper-z:chore/zig-master

Conversation

@lodekeeper-z
Copy link
Copy Markdown
Contributor

Upgrade to Zig 0.16.0-dev (master) — part of the lodestar-z Zig master upgrade effort.

Key changes:

  • std.iostd.Io migration
  • std.Io.Dir methods now require explicit io parameter
  • Build system changes for 0.16 compatibility

🤖 Generated with AI assistance

- addCSourceFiles/addIncludePath/addConfigHeader moved from Compile to Module
- ConfigHeader.getOutput() → getOutputFile()
- std.ArrayList: .init(alloc) → .empty + explicit allocator
- std.fs.cwd() → std.Io.Dir.cwd()
- dir.openDir/openFile/close now take io parameter
- Iterator.next() now takes io parameter
- file.readToEndAlloc() → dir.readFileAlloc(io, name, alloc, .unlimited)

🤖 Generated with AI assistance
lodekeeper-z and others added 5 commits March 19, 2026 20:19
The codebase uses Zig 0.16.0-dev (master) APIs:
- std.ArrayList.empty (no allocator init)
- std.testing.io / std.Io.Dir
- ConfigHeader.getOutputFile()

CI was pinned to 0.14.1 which lacks these APIs. Update to master.
Also drop minimum_zig_version since we target nightly.

🤖 Generated with AI assistance
These were accidentally committed when .gitignore lacked a trailing
newline, causing zig-out not to be ignored during the initial build.
@GrapeBaBa GrapeBaBa marked this pull request as ready for review April 16, 2026 15:39
Copilot AI review requested due to automatic review settings April 16, 2026 15:39
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Upgrades this package to be compatible with Zig 0.16-era standard library and build system APIs (Io/Dir API changes, ArrayList allocator passing, Build.Module API changes), as part of the broader Zig master upgrade effort mentioned in the PR metadata.

Changes:

  • Migrates filesystem usage in tests from std.fs/std.io style to std.Io with explicit io parameters.
  • Updates std.ArrayList usage to the newer allocator-passing APIs (empty, appendSlice(allocator, ...), toOwnedSlice(allocator)).
  • Adjusts build and CI configuration for Zig 0.16 compatibility (module-scoped build steps, Zig version bumps, ignore paths).

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/snappy.zig Updates test filesystem access to std.Io.Dir APIs requiring explicit io.
src/frame.zig Migrates std.ArrayList calls to allocator-explicit APIs used by newer Zig stdlib.
build.zig.zon Bumps the declared minimum Zig version to 0.16.0.
build.zig Updates build steps to use root_module methods and new config header output accessor.
.gitignore Normalizes Zig output/cache ignore patterns and adds zig-pkg/.
.github/workflows/ci.yml Updates CI formatting and Zig version env var to 0.16.0.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread build.zig.zon
Comment thread .github/workflows/ci.yml
@GrapeBaBa GrapeBaBa changed the title chore: upgrade to Zig 0.16.0-dev (master) chore: upgrade to Zig 0.16.0 Apr 17, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 6 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@wemeetagain wemeetagain merged commit 7139424 into ChainSafe:main Apr 20, 2026
11 checks passed
GrapeBaBa added a commit to GrapeBaBa/state-transition-z that referenced this pull request Apr 21, 2026
Four of the five Zig-0.16-upgrade PRs on our dependency forks have
merged into ChainSafe upstream main:

  * ChainSafe/blst.zig#4  → 6ad139a
  * ChainSafe/hashtree-z#10 → 56e406f
  * ChainSafe/snappy.zig#5 → 7139424
  * ChainSafe/zig-yaml#1  → b74f4e8

Switch from `lodekeeper-z/<repo>?ref=chore/zig-master` to the merged
commit on `ChainSafe/<repo>` main for each. Content is identical so
the existing `hash` fields stay valid.

`zapi` (ChainSafe/zapi#9) is still open upstream — bump the
`lodekeeper-z/zapi` commit pointer to the current PR head
(fefb88ebf5c9) which includes the latest port/refactor work; TODO
note to switch to ChainSafe/zapi once ChainSafe#9 merges.
wemeetagain pushed a commit to ChainSafe/lodestar-z that referenced this pull request Apr 24, 2026
## Motivation

Get the codebase cleanly compatible with **Zig 0.16.0** release,
following the new "explicit `io` everywhere, no hidden global state"
design — without changing runtime behavior.

## Description

- **`std.Io`** — File/Dir operations, `Mutex`/`Condition`/`Event`
(cancelable vs uncancelable split), entropy via
`io.random`/`io.randomSecure`, timestamps via `std.Io.Timestamp`
- **ArrayList unmanaged** — allocator threaded through
`deinit`/`append`/`resize`/`ensureCapacity`/`clone`; replace `items.len
= N` hacks with `resize` / `expandToCapacity` /
`appendNTimesAssumeCapacity` (preserves semantics, matches
`initCapacity`'s Precise allocation)
- **Struct builder** — `@Type(.@"struct" = ...)` → `@Struct(names,
types, attrs)` builtin in `ssz/type/container.zig`
- **Copy-elision workaround** — `std.Io` 0.16 result-location semantics
pre-write the union tag of the assignment target, so reads from
`self.state.init_group.*` during RHS evaluation would observe the new
variant. Snapshot pre-upgrade fields to locals in `state_transition.zig`
fork-upgrade chain and `era/Writer.zig`
- **ThreadPool** — `io` is a parameter on
`init`/`deinit`/`verifyMultipleAggregateSignatures`/`aggregateVerify`
(not a stored field); normal paths use cancelable `lock`; shutdown +
`submitAndWait.done.wait` stay uncancelable with comments explaining the
invariant
- **Shared `src/time.zig`** — `timestampNow` / `since (Duration)` /
`durationSeconds`, replacing four duplicated helper pairs across
`state_transition` and `bench`
- **IO signature convention** — `(allocator?, io, file, ...)` applied
consistently to `e2s.*` and `era.*`
- **Reader API polish** — `takeArray` (zero-copy) + `readSliceAll` where
appropriate; drop single-buffer `readVecAll` and `catch |err| return
err`
- **Other**: `RefCount` comptime-reflect on wrapped T's deinit arity
(1-arg vs 2-arg) so 0.16 unmanaged `ArrayList` and project types with
stored allocators both work; `sanitize_c = .trap` on blst artifact so
Debug fuzz builds link without `libubsan`; untrack 426 stale
`test/fuzz/zig-pkg/` entries from the git index
- **CI**: `ZIG_VERSION` bumped `0.14.1 → 0.16.0`; `zbuild` sync-check +
`build-examples` jobs temporarily commented out pending upstream Zig
0.16 support

## Dependency PRs

Each Zig 0.16 upgrade landed as a dedicated PR on the upstream repo.
`build.zig.zon` points at `lodekeeper-z` forks on the `chore/zig-master`
branch until these merge and cut releases:

| Dependency | Upstream PR |
|---|---|
| `blst` |
[ChainSafe/blst.zig#4](ChainSafe/blst.zig#4) |
| `hashtree` |
[ChainSafe/hashtree-z#10](ChainSafe/hashtree-z#10)
|
| `snappy` |
[ChainSafe/snappy.zig#5](ChainSafe/snappy.zig#5)
|
| `yaml` |
[ChainSafe/zig-yaml#1](ChainSafe/zig-yaml#1) |
| `zapi` | [ChainSafe/zapi#9](ChainSafe/zapi#9)
|
| `httpz` (disabled) |
[karlseguin/http.zig#191](karlseguin/http.zig#191)
|
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.

4 participants