From bd3c8431d9f7282e840670ef72c9a7c8f67e3271 Mon Sep 17 00:00:00 2001 From: Guillaume Ballet <3272758+gballet@users.noreply.github.com> Date: Sat, 28 Mar 2026 11:39:44 +0100 Subject: [PATCH] build, cmd/keeper: add "womir" target (#34079) This PR enables the block validation of keeper in the womir/openvm zkvm. It also fixes some issues related to building the executables in CI. Namely, it activates the build which was actually disabled, and also resolves some resulting build conflicts by fixing the tags. Co-authored-by: Leo --- build/ci.go | 20 +++++++------ cmd/keeper/getpayload_example.go | 1 + cmd/keeper/getpayload_wasm.go | 4 +-- cmd/keeper/getpayload_womir.go | 49 ++++++++++++++++++++++++++++++++ cmd/keeper/stubs.go | 4 +-- 5 files changed, 66 insertions(+), 12 deletions(-) create mode 100644 cmd/keeper/getpayload_womir.go diff --git a/build/ci.go b/build/ci.go index dce01f01a8..173288bcdc 100644 --- a/build/ci.go +++ b/build/ci.go @@ -107,17 +107,21 @@ var ( Tags: "ziren", Env: map[string]string{"GOMIPS": "softfloat", "CGO_ENABLED": "0"}, }, + { + Name: "womir", + GOOS: "wasip1", + GOARCH: "wasm", + Tags: "womir", + }, { Name: "wasm-js", GOOS: "js", GOARCH: "wasm", - Tags: "example", }, { Name: "wasm-wasi", GOOS: "wasip1", GOARCH: "wasm", - Tags: "example", }, { Name: "example", @@ -163,11 +167,11 @@ var ( // Distros for which packages are created debDistros = []string{ - "xenial", // 16.04, EOL: 04/2026 - "bionic", // 18.04, EOL: 04/2028 - "focal", // 20.04, EOL: 04/2030 - "jammy", // 22.04, EOL: 04/2032 - "noble", // 24.04, EOL: 04/2034 + "xenial", // 16.04, EOL: 04/2026 + "bionic", // 18.04, EOL: 04/2028 + "focal", // 20.04, EOL: 04/2030 + "jammy", // 22.04, EOL: 04/2032 + "noble", // 24.04, EOL: 04/2034 } // This is where the tests should be unpacked. @@ -305,7 +309,7 @@ func doInstallKeeper(cmdline []string) { args := slices.Clone(gobuild.Args) args = append(args, "-o", executablePath(outputName)) args = append(args, ".") - build.MustRun(&exec.Cmd{Path: gobuild.Path, Args: args, Env: gobuild.Env}) + build.MustRun(&exec.Cmd{Path: gobuild.Path, Args: args, Env: gobuild.Env, Dir: gobuild.Dir}) } } diff --git a/cmd/keeper/getpayload_example.go b/cmd/keeper/getpayload_example.go index 683cc79248..8f40a7bd11 100644 --- a/cmd/keeper/getpayload_example.go +++ b/cmd/keeper/getpayload_example.go @@ -15,6 +15,7 @@ // along with the go-ethereum library. If not, see . //go:build example +// +build example package main diff --git a/cmd/keeper/getpayload_wasm.go b/cmd/keeper/getpayload_wasm.go index b912678825..5024ac7d49 100644 --- a/cmd/keeper/getpayload_wasm.go +++ b/cmd/keeper/getpayload_wasm.go @@ -14,8 +14,8 @@ // You should have received a copy of the GNU Lesser General Public License // along with the go-ethereum library. If not, see . -//go:build wasm -// +build wasm +//go:build wasm && !womir +// +build wasm,!womir package main diff --git a/cmd/keeper/getpayload_womir.go b/cmd/keeper/getpayload_womir.go new file mode 100644 index 0000000000..8645dc7c26 --- /dev/null +++ b/cmd/keeper/getpayload_womir.go @@ -0,0 +1,49 @@ +// Copyright 2026 The go-ethereum Authors +// This file is part of the go-ethereum library. +// +// The go-ethereum library is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// The go-ethereum library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with the go-ethereum library. If not, see . + +//go:build womir + +package main + +import "unsafe" + +// These match the WOMIR guest-io imports (env module). +// Protocol: __hint_input prepares next item, __hint_buffer reads words. +// Each item has format: [byte_len_u32_le, ...data_words_padded_to_4bytes] +// +//go:wasmimport env __hint_input +func hintInput() + +//go:wasmimport env __hint_buffer +func hintBuffer(ptr unsafe.Pointer, numWords uint32) +func readWord() uint32 { + var buf [4]byte + hintBuffer(unsafe.Pointer(&buf[0]), 1) + return uint32(buf[0]) | uint32(buf[1])<<8 | uint32(buf[2])<<16 | uint32(buf[3])<<24 +} +func readBytes() []byte { + hintInput() + byteLen := readWord() + numWords := (byteLen + 3) / 4 + data := make([]byte, numWords*4) + hintBuffer(unsafe.Pointer(&data[0]), numWords) + return data[:byteLen] +} + +// getInput reads the RLP-encoded Payload from the WOMIR hint stream. +func getInput() []byte { + return readBytes() +} diff --git a/cmd/keeper/stubs.go b/cmd/keeper/stubs.go index 407a21a145..de7ee64353 100644 --- a/cmd/keeper/stubs.go +++ b/cmd/keeper/stubs.go @@ -14,8 +14,8 @@ // You should have received a copy of the GNU Lesser General Public License // along with the go-ethereum library. If not, see . -//go:build !example && !ziren && !wasm -// +build !example,!ziren,!wasm +//go:build !example && !ziren && !wasm && !womir +// +build !example,!ziren,!wasm,!womir package main