Conversation
- Update inline asm clobber syntax from legacy string format to
new struct format (.{ .memory = true })
- Fix alignedAlloc alignment parameter type (comptime_int -> Alignment enum)
There was a problem hiding this comment.
Pull request overview
This PR updates the OpenVM zkVM runtime wiring to better match the project’s RISC-V runtime layout and introduces a new OpenVM-specific input path using OpenVM “hint” instructions, while also enabling OpenVM as a built zkVM runtime target in the build.
Changes:
- Refactors the OpenVM linker script to a more complete RISC-V layout (sections, gp, bss symbols, discards).
- Reworks OpenVM runtime input handling to read a length prefix and then pull word-aligned input via new hint syscalls.
- Adds
openvmto thezkvm_targetslist so its runtime ELF is built alongside the other zkVM targets.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| pkgs/state-transition-runtime/src/openvm/openvm.ld | Replaces the simplistic memory/sections layout with a full RISC-V style linker script. |
| pkgs/state-transition-runtime/src/openvm/lib.zig | Adjusts heap range and replaces the input reader with hint-based, word-aligned input loading. |
| pkgs/state-transition-runtime/src/openvm/io.zig | Replaces byte-at-a-time printing/input reading with hint-based I/O syscalls. |
| build.zig | Adds OpenVM to the set of zkVM runtime targets built by default. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const std = @import("std"); | ||
|
|
There was a problem hiding this comment.
const std = @import("std"); is now unused in this file, which will fail compilation under Zig's unused-declaration checks. Remove the import or use it.
| const std = @import("std"); |
| : | ||
| : [char] "r" (@as(usize, c)), | ||
| : [ptr] "r" (str.ptr), | ||
| [len] "{x11}" (str.len), |
There was a problem hiding this comment.
print_str passes a pointer to memory into inline asm but does not include a .memory clobber. If callers build/modify the buffer right before printing (e.g. formatted logs), the compiler may reorder memory operations around the asm. Add a memory clobber to ensure the printed bytes reflect prior writes.
| [len] "{x11}" (str.len), | |
| [len] "{x11}" (str.len), | |
| : .{ .memory = true } |
| const input_len: usize = @intCast(len_buf); | ||
|
|
||
| const word_count: u32 = @intCast((input_len + 3) / 4); | ||
| const buf = allocator.alignedAlloc(u8, .@"4", word_count * 4) catch @panic("could not allocate space for input"); | ||
|
|
||
| pub fn free_input(allocator: std.mem.Allocator, input: []const u8) void { | ||
| allocator.free(input); | ||
| io.hint_buffer_u32(buf.ptr, word_count); | ||
|
|
||
| return buf[0..input_len]; |
There was a problem hiding this comment.
input_len is derived from an external hint (io.hint_store_u32) and then used in (input_len + 3) / 4 to compute word_count without any upper bound check, which can overflow usize on RV32 for very large lengths and cause word_count * 4 to be smaller than input_len. In that case allocator.alignedAlloc reserves fewer bytes than are exposed via the returned slice buf[0..input_len], so callers of get_input can perform out-of-bounds reads/writes on the heap, potentially corrupting adjacent data or leaking sensitive state. Add explicit limits and overflow checks on input_len (e.g. ensuring input_len <= max_allowed && input_len + 3 does not overflow and that buf.len >= input_len) before allocating and constructing the returned slice.
- Remove dotnet, Android SDK, CodeQL, and Docker images on Ubuntu runners to reclaim ~30GB of disk space before building - Force rocksdb dependency to .ReleaseFast regardless of project optimize level, reducing debug info size significantly - Fixes CI out-of-disk-space errors during rocksdb compilation
* add some fixes
* openvm: fix zig 0.15.2 compatibility
- Update inline asm clobber syntax from legacy string format to
new struct format (.{ .memory = true })
- Fix alignedAlloc alignment parameter type (comptime_int -> Alignment enum)
* openvm/io: remove unused std import (Zig 0.15 compat)
* ci: free disk space on runners + force rocksdb ReleaseFast
- Remove dotnet, Android SDK, CodeQL, and Docker images on Ubuntu runners
to reclaim ~30GB of disk space before building
- Force rocksdb dependency to .ReleaseFast regardless of project optimize
level, reducing debug info size significantly
- Fixes CI out-of-disk-space errors during rocksdb compilation
---------
Co-authored-by: tellabg <249254436+tellabg@users.noreply.github.com>
No description provided.