Skip to content

upgrade to zig 0.15.2#543

Merged
gballet merged 17 commits intomainfrom
anshalshukla/zig-0.15.2-upgrade
Feb 14, 2026
Merged

upgrade to zig 0.15.2#543
gballet merged 17 commits intomainfrom
anshalshukla/zig-0.15.2-upgrade

Conversation

@anshalshukla
Copy link
Copy Markdown
Collaborator

No description provided.

@anshalshukla anshalshukla force-pushed the anshalshukla/zig-0.15.2-upgrade branch from 21a5a56 to 4c47532 Compare February 3, 2026 18:05
@anshalshukla anshalshukla force-pushed the anshalshukla/zig-0.15.2-upgrade branch from 4c47532 to 0b88820 Compare February 3, 2026 18:24
@anshalshukla anshalshukla requested a review from gballet February 5, 2026 16:58
@gballet gballet changed the title feat: upgrade to zig 0.15.2 upgrade to zig 0.15.2 Feb 5, 2026
build/risc0.zig Outdated
// user data length + data
try writer.writeInt(u32, @truncate(bindata.len), .little);
_ = try writer.write(bindata);
try writer.interface.writeAll(&std.mem.toBytes(@as(u32, @truncate(bindata.len))));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

what if this runs on a big endian platform?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

fixed it, it will now convert it into little endian

defer self.mutex.unlock();

try self.stream.writeAll(event_json);
var write_buf: [4096]u8 = undefined;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

allocate (and free) memory, there's an allocator available in self.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I've changed it to allocate, 512 bytes instead of 4096 since it is for sse events, I think it is better to do a stack allocation here instead of heap allocation. I've also added testcases to make sure that the write_buf is sufficiently large to handle the event json even if new events are added.

Comment on lines +85 to +86
var read_buffer: [4096]u8 = undefined;
var write_buffer: [4096]u8 = undefined;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

same here, use an allocator

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Just to be clear, this is required so the stack mem is not over utilized to serve API requests? Made the change

defer metrics_output.deinit();
fn handleMetrics(_: *const Self, request: *std.http.Server.Request) void {
// 64KiB buffer for metrics output: ipv4 max limit
var buffer: [65536]u8 = undefined;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

definitely use an allocator here, this is guaranteed to overflow under stress

/// Helper function to format state keys consistently
pub fn formatStateKey(allocator: Allocator, state_root: types.Root) ![]const u8 {
return std.fmt.allocPrint(allocator, "state:{any}", .{std.fmt.fmtSliceHexLower(&state_root)});
return std.fmt.allocPrint(allocator, "state:{x}", .{&state_root});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

sometimes you pass by value and sometimes by pointer. Try to pass by pointer if you can.

@anshalshukla anshalshukla requested a review from gballet February 6, 2026 12:05
- Both [risc0](https://github.com/risc0/risc0) (v3.0.3) and OpenVM provers are supported:
- risc0 requires the toolchain to be [installed](https://dev.risczero.com/api/zkvm/install): `rzup install r0vm 3.0.3`
- OpenVM is self-contained (no external toolchain needed)
- Zeam requires zig version 0.15.2 to build.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this is the only thing that needs to change in this PR, the rest isn't related to this change and should be reverted

build/risc0.zig Outdated
// magic + binary format
_ = try writer.write(magic);
try writer.writeInt(u32, BinaryFormatVersion, .little);
var write_buf: [4096]u8 = undefined;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

that doesn't look correct, I don't think that the whole binary file can fit in 4K

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@copilot suggest the proper number of bytes to allocate here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this change is frankly weird, was it needed or done by AI?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

It's needed because of the change in writer interface. I'll use an allocating writer here instead.

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 11, 2026

@gballet I've opened a new pull request, #566, to work on those changes. Once the pull request is ready, I'll request review from you.

@anshalshukla anshalshukla force-pushed the anshalshukla/zig-0.15.2-upgrade branch 2 times, most recently from f6a95a9 to 04c180c Compare February 12, 2026 07:34
Copy link
Copy Markdown
Contributor

@gballet gballet left a comment

Choose a reason for hiding this comment

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

LGTM. We agreed with Anshal that this was breaking the risc0 prover, but I will investigate the topic as I am doing heavy editing for provers anyway.

@gballet gballet merged commit 8e77865 into main Feb 14, 2026
11 of 12 checks passed
@gballet gballet deleted the anshalshukla/zig-0.15.2-upgrade branch February 14, 2026 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants