From b8712195721fad85f8105c9fedc29cf96bca04e6 Mon Sep 17 00:00:00 2001 From: Guillaume Ballet <3272758+gballet@users.noreply.github.com> Date: Tue, 9 Sep 2025 14:25:43 -0400 Subject: [PATCH] add ziren guest program Co-authored-by: weilzkm <140377101+weilzkm@users.noreply.github.com> --- cmd/keeper/getpayload_example.go | 4 +++- cmd/keeper/getpayload_ziren.go | 37 ++++++++++++++++++++++++++++++++ cmd/keeper/main.go | 2 ++ cmd/keeper/stubs.go | 2 +- go.mod | 7 ++++++ go.sum | 4 ++++ 6 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 cmd/keeper/getpayload_ziren.go diff --git a/cmd/keeper/getpayload_example.go b/cmd/keeper/getpayload_example.go index 2127a60bff..51dbd55cdf 100644 --- a/cmd/keeper/getpayload_example.go +++ b/cmd/keeper/getpayload_example.go @@ -30,8 +30,10 @@ import ( "github.com/ethereum/go-ethereum/rlp" ) -// This is taken from PR #32216 until it's merged // ExtWitness is a witness RLP encoding for transferring across clients. +// This is taken from PR #32216 until it's merged. +// It contains block headers, contract codes, state nodes, and storage keys +// required for stateless execution verification. type ExtWitness struct { Headers []*types.Header `json:"headers"` Codes []hexutil.Bytes `json:"codes"` diff --git a/cmd/keeper/getpayload_ziren.go b/cmd/keeper/getpayload_ziren.go new file mode 100644 index 0000000000..56da511966 --- /dev/null +++ b/cmd/keeper/getpayload_ziren.go @@ -0,0 +1,37 @@ +// Copyright 2025 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 ziren + +package main + +import ( + zkruntime "github.com/zkMIPS/zkMIPS/crates/go-runtime/zkm_runtime" + "github.com/ethereum/go-ethereum/params" +) + +func getChainConfig() *params.ChainConfig { + return params.MainnetChainConfig +} + +// getInput reads the input payload from the zkVM runtime environment. +// The zkVM host provides the RLP-encoded Payload structure containing +// the block and witness data through the runtime's input mechanism. +func getInput() []byte { + // Read the RLP-encoded payload directly from the zkVM runtime + input := zkruntime.Read[[]byte]() + return input +} diff --git a/cmd/keeper/main.go b/cmd/keeper/main.go index ba44360cde..0aba562e72 100644 --- a/cmd/keeper/main.go +++ b/cmd/keeper/main.go @@ -27,6 +27,8 @@ import ( "github.com/ethereum/go-ethereum/rlp" ) +// Payload represents the input data for stateless execution containing +// a block and its associated witness data for verification. type Payload struct { Block *types.Block Witness *stateless.Witness diff --git a/cmd/keeper/stubs.go b/cmd/keeper/stubs.go index 66a14d1192..f64290ed5e 100644 --- a/cmd/keeper/stubs.go +++ b/cmd/keeper/stubs.go @@ -14,7 +14,7 @@ // 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 +//go:build !example && !ziren package main diff --git a/go.mod b/go.mod index 28c9af9259..32f76536a7 100644 --- a/go.mod +++ b/go.mod @@ -77,10 +77,17 @@ require ( gopkg.in/yaml.v3 v3.0.1 ) +replace ( + github.com/zkMIPS/zkMIPS => github.com/weilzkm/zkMIPS v0.0.0-20250909003003-28d77c6da0a4 + github.com/zkMIPS/zkMIPS/crates/go-runtime/zkm_runtime => github.com/weilzkm/zkMIPS/crates/go-runtime/zkm_runtime v0.0.0-20250909003003-28d77c6da0a4 +) + require ( + github.com/zkMIPS/zkMIPS/crates/go-runtime/zkm_runtime v0.0.0-00010101000000-000000000000 github.com/Azure/azure-sdk-for-go/sdk/azcore v1.7.0 // indirect github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 // indirect github.com/DataDog/zstd v1.4.5 // indirect + github.com/ProjectZKM/Ziren v1.1.5-0.20250905082253-b08c6f04754a // indirect github.com/StackExchange/wmi v1.2.1 // indirect github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.13 // indirect github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.43 // indirect diff --git a/go.sum b/go.sum index 53913262ae..340b37ddaf 100644 --- a/go.sum +++ b/go.sum @@ -14,6 +14,8 @@ github.com/DataDog/zstd v1.4.5 h1:EndNeuB0l9syBZhut0wns3gV1hL8zX8LIu6ZiVHWLIQ= github.com/DataDog/zstd v1.4.5/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= +github.com/ProjectZKM/Ziren v1.1.5-0.20250905082253-b08c6f04754a h1:CcAopGCk/nDibTW/xjbF9x857n/5nVwIS3gTrNoqSLE= +github.com/ProjectZKM/Ziren v1.1.5-0.20250905082253-b08c6f04754a/go.mod h1:rtDqI3yXT1S+xow+/3VxJVht8DRSO8XFfRn6vEqRYYE= github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA= github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8= github.com/VictoriaMetrics/fastcache v1.12.2 h1:N0y9ASrJ0F6h0QaC3o6uJb3NIZ9VKLjCM7NQbSmF7WI= @@ -362,6 +364,8 @@ github.com/urfave/cli/v2 v2.27.5/go.mod h1:3Sevf16NykTbInEnD0yKkjDAeZDS0A6bzhBH5 github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8= github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= +github.com/weilzkm/zkMIPS/crates/go-runtime/zkm_runtime v0.0.0-20250909003003-28d77c6da0a4 h1:lcn3LrFmGY6eu4+BrzKkfnN2MoLShmgCEYf+nKE+bOU= +github.com/weilzkm/zkMIPS/crates/go-runtime/zkm_runtime v0.0.0-20250909003003-28d77c6da0a4/go.mod h1:zk/SUgiiVz2U1ufZ+yM2MHPbD93W25KH5zK3qAxXbT4= github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 h1:gEOO8jv9F4OT7lGCjxCBTO/36wtF6j2nSip77qHd4x4= github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=