From 9b7b14c16c85516e91cb0c377d918d34db160c9e Mon Sep 17 00:00:00 2001 From: Idogwu Chinonso Date: Sun, 23 Aug 2026 12:23:30 +0100 Subject: [PATCH] chore!: update libcmt to machine-guest-tools v0.18.0 Bump the vendored machine-guest-tools submodule from v0.17.2 to v0.18.0 and adapt the bindings to its breaking changes. Upstream changes affecting the public headers bindgen consumes: - Removed the unimplemented `cmt_abi_start_frame` declaration. The corresponding `abi::start_frame` wrapper is dropped; it bound a symbol with no implementation behind it, so any caller already failed to link. - Renamed `HTIF_YIELD_REASON_ADVANCE`/`_INSPECT` to `_ADVANCE_STATE`/ `_INSPECT_STATE`. Regenerated; no internal callers. - Renamed the `cmt_rollup_t` cache field `finish_root_hash` to `finish_outputs_merkle_root`, and the libcmt mock's file suffix from `.outputs_root_hash` to `.outputs_merkle_root`. No internal callers, and no test harness in this repo reads the old file name. - Renamed `struct cmt_rollup_finish` to `cmt_rollup_finish_s`. The `cmt_rollup_finish_t` typedef absorbs this, so consumers are unaffected. No new public libcmt API was added, so there is nothing new to bind. The new bundled `libcmt/ioctl.h` is internal to `io.c` and is deliberately not added to wrapper.h. Dockerfile.echoApp: - Bump the guest-tools release pin to 0.18.0 with a recomputed sha256. - Drop the Cartesi linux-headers download. v0.18.0 vendors the cmio ioctl ABI in `libcmt/ioctl.h`, so libcmt no longer includes . This also removes a stale pin on kernel headers v0.20.0/ctsi-1 while v0.18.0 targets ctsi-2. - Pin the libcmt source clone to the same release the bindings are generated from. It previously cloned main unpinned, so the linked libcmt.a could drift from the generated bindings. Verified by building libcmt's host mock backend and running the echo app against it: advance and inspect both round-trip, a correct Voucher(address,uint256,bytes) is emitted, and the outputs Merkle root accumulates across inputs rather than resetting. Upstream's own libcmt test suite passes. The riscv64 cross-build stage was also built under Docker, confirming libcmt v0.18.0 compiles without the kernel headers package and the app links into a working riscv64 binary. BREAKING CHANGE: `abi::start_frame` is removed and the re-exported `HTIF_YIELD_REASON_ADVANCE`/`_INSPECT` constants are renamed to `_ADVANCE_STATE`/`_INSPECT_STATE`. --- DEPENDENCIES.lock | 2 +- build/Dockerfile.echoApp | 22 ++++++++-------------- src/abi.rs | 5 ----- third_party/machine-guest-tools | 2 +- 4 files changed, 10 insertions(+), 21 deletions(-) diff --git a/DEPENDENCIES.lock b/DEPENDENCIES.lock index d3845c0..2723e84 100644 --- a/DEPENDENCIES.lock +++ b/DEPENDENCIES.lock @@ -1 +1 @@ -cartesi/machine-guest-tools v0.17.2 3d838a2f80cd8fa614e38ea93efcfabe8ec65bea +cartesi/machine-guest-tools v0.18.0 5222250c69371f7cbe96e6082699a8ca22b5969c diff --git a/build/Dockerfile.echoApp b/build/Dockerfile.echoApp index e17a961..0f12c73 100644 --- a/build/Dockerfile.echoApp +++ b/build/Dockerfile.echoApp @@ -4,10 +4,8 @@ # for the defined date, no matter when the image is built. ARG UBUNTU_TAG=noble-20250910 ARG APT_UPDATE_SNAPSHOT=20250915T030400Z -ARG MACHINE_GUEST_TOOLS_VERSION=0.17.2 -ARG MACHINE_GUEST_TOOLS_SHA256SUM=c077573dbcf0cdc146adf14b480bfe454ca63aa4d3e8408c5487f550a5b77a41 -ARG LINUX_HEADERS_URLPATH=https://github.com/cartesi/machine-linux-image/releases/download/v0.20.0/linux-libc-dev-riscv64-cross-6.5.13-ctsi-1-v0.20.0.deb -ARG LINUX_HEADERS_SHA256=2723435e8b45d8fb7a79e9344f6dc517b3dbc08e03ac17baab311300ec475c08 +ARG MACHINE_GUEST_TOOLS_VERSION=0.18.0 +ARG MACHINE_GUEST_TOOLS_SHA256SUM=204d4260defd68e11b957ae1f1b511b6c2c74345c918748be06f592733b72dcd ARG RUST_VERSION=1.90.0 ################################################################################ @@ -100,18 +98,14 @@ COPY sample_apps/echo_app/.cargo ./.cargo # Copy source code COPY sample_apps/echo_app/src ./src -# Install Cartesi linux headers needed by libcmt (provides linux/cartesi/cmio.h) -ARG LINUX_HEADERS_URLPATH -ARG LINUX_HEADERS_SHA256 -RUN echo "[headers] Downloading Cartesi linux headers..." && \ - curl -fsSL -o /tmp/linux-headers.deb "$LINUX_HEADERS_URLPATH" && \ - echo "${LINUX_HEADERS_SHA256} /tmp/linux-headers.deb" | sha256sum -c - && \ - dpkg-deb -x /tmp/linux-headers.deb / && \ - rm /tmp/linux-headers.deb +# libcmt >= 0.18.0 bundles libcmt/ioctl.h (vendored linux/cartesi/cmio.h), so the +# Cartesi linux headers package is no longer needed to build it. # Build libcmt C library for RISC-V (required by libcmt-binding-rust at link time) -RUN echo "[libcmt] Cloning machine-guest-tools..." && \ - git clone --depth 1 https://github.com/cartesi/machine-guest-tools.git /tmp/machine-guest-tools +ARG MACHINE_GUEST_TOOLS_VERSION +RUN echo "[libcmt] Cloning machine-guest-tools v${MACHINE_GUEST_TOOLS_VERSION}..." && \ + git clone --depth 1 --branch v${MACHINE_GUEST_TOOLS_VERSION} \ + https://github.com/cartesi/machine-guest-tools.git /tmp/machine-guest-tools RUN echo "[libcmt] Building libcmt for riscv64..." && \ make -C /tmp/machine-guest-tools/sys-utils/libcmt libcmt TOOLCHAIN_PREFIX=riscv64-linux-gnu- RUN echo "[libcmt] Copying libcmt.a to known path..." && \ diff --git a/src/abi.rs b/src/abi.rs index 31bc609..32a2a0a 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -10,7 +10,6 @@ use crate::generated::{ cmt_abi_mark_frame, cmt_abi_peek_bytes_d, cmt_abi_peek_funsel, cmt_abi_put_address, cmt_abi_put_bool, cmt_abi_put_bytes_d, cmt_abi_put_bytes_s, cmt_abi_put_funsel, cmt_abi_put_uint, cmt_abi_put_uint_be, cmt_abi_put_uint256, cmt_abi_reserve_bytes_d, - cmt_abi_start_frame, }; use crate::{cmt_abi_address_t, cmt_abi_bytes_t, cmt_abi_u256_t, cmt_buf_t, to_io_result}; @@ -99,10 +98,6 @@ pub fn get_address(me: &mut cmt_buf_t, value: &mut cmt_abi_address_t) -> io::Res to_io_result(unsafe { cmt_abi_get_address(me, value) }) } -pub fn start_frame(me: &mut cmt_buf_t, frame: *mut c_void) -> io::Result<()> { - to_io_result(unsafe { cmt_abi_start_frame(me, frame) }) -} - pub fn get_bytes_s(me: &mut cmt_buf_t, of: &mut cmt_buf_t) -> io::Result<()> { to_io_result(unsafe { cmt_abi_get_bytes_s(me, of) }) } diff --git a/third_party/machine-guest-tools b/third_party/machine-guest-tools index 3d838a2..5222250 160000 --- a/third_party/machine-guest-tools +++ b/third_party/machine-guest-tools @@ -1 +1 @@ -Subproject commit 3d838a2f80cd8fa614e38ea93efcfabe8ec65bea +Subproject commit 5222250c69371f7cbe96e6082699a8ca22b5969c