From 45537ab4dfa76fedede0830532ebc7da77a0f0ba Mon Sep 17 00:00:00 2001
From: Guillaume Ballet <3272758+gballet@users.noreply.github.com>
Date: Tue, 9 Sep 2025 14:54:39 -0400
Subject: [PATCH] move chainconfig to its own tag-protected file
---
cmd/keeper/README.md | 41 +++++++++++++++++++++++++------
cmd/keeper/chainconfig_hoodi.go | 26 ++++++++++++++++++++
cmd/keeper/chainconfig_mainnet.go | 26 ++++++++++++++++++++
cmd/keeper/chainconfig_sepolia.go | 26 ++++++++++++++++++++
cmd/keeper/getpayload_example.go | 4 ---
cmd/keeper/getpayload_ziren.go | 5 ----
cmd/keeper/stubs.go | 10 --------
7 files changed, 111 insertions(+), 27 deletions(-)
create mode 100644 cmd/keeper/chainconfig_hoodi.go
create mode 100644 cmd/keeper/chainconfig_mainnet.go
create mode 100644 cmd/keeper/chainconfig_sepolia.go
diff --git a/cmd/keeper/README.md b/cmd/keeper/README.md
index 209977aeb6..4b5c07e04d 100644
--- a/cmd/keeper/README.md
+++ b/cmd/keeper/README.md
@@ -12,13 +12,17 @@ It then executes the block statelessly and validates that the computed state roo
## Architecture
-The keeper uses build tags to compile platform-specific input methods:
+The keeper uses build tags to compile platform-specific input methods and chain configurations:
```
cmd/keeper/
-├── main.go # Main execution logic
-├── getpayload_example.go # Example implementation
-└── README.md # This file
+├── main.go # Main execution logic
+├── getpayload_example.go # Example implementation with embedded data
+├── getpayload_ziren.go # Ziren zkVM implementation
+├── chainconfig_mainnet.go # Mainnet chain configuration
+├── chainconfig_sepolia.go # Sepolia chain configuration
+├── chainconfig_hoodi.go # Hoodi chain configuration
+└── README.md # This file
```
## Creating a Custom Platform Implementation
@@ -66,7 +70,14 @@ func getInput() []byte {
### 2. Build for Your Platform
```bash
-go build -tags myplatform ./cmd/keeper
+# Build with specific platform and chain configuration
+go build -tags "myplatform mainnet" ./cmd/keeper
+
+# Available chain configurations:
+# - mainnet: Ethereum mainnet
+# - sepolia: Sepolia testnet
+# - hoodi: Hoodi testnet
+# If no chain tag is specified, defaults to mainnet
```
## Payload Structure
@@ -80,10 +91,24 @@ type Payload struct {
}
```
-## Example Implementation
+## Build Examples
-See `getinput_example.go` for a complete example that contains a payload. To build the example:
+### Example Implementation
+See `getpayload_example.go` for a complete example with embedded Hoodi block data:
```bash
-go build -tags example ./cmd/keeper
+# Build example with different chain configurations
+go build -tags "example hoodi" ./cmd/keeper # Example with Hoodi config (default for example)
+go build -tags "example mainnet" ./cmd/keeper # Example with mainnet config
+go build -tags "example sepolia" ./cmd/keeper # Example with Sepolia config
+```
+
+### Ziren zkVM Implementation
+Build for the Ziren zkVM platform:
+
+```bash
+# For MIPS architecture (typical for zkVM)
+GOOS=linux GOARCH=mipsle GOMIPS=softfloat go build -tags "ziren mainnet" ./cmd/keeper
+GOOS=linux GOARCH=mipsle GOMIPS=softfloat go build -tags "ziren sepolia" ./cmd/keeper
+GOOS=linux GOARCH=mipsle GOMIPS=softfloat go build -tags "ziren hoodi" ./cmd/keeper
```
diff --git a/cmd/keeper/chainconfig_hoodi.go b/cmd/keeper/chainconfig_hoodi.go
new file mode 100644
index 0000000000..8e98a1cb8a
--- /dev/null
+++ b/cmd/keeper/chainconfig_hoodi.go
@@ -0,0 +1,26 @@
+// 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 hoodi
+
+package main
+
+import "github.com/ethereum/go-ethereum/params"
+
+// getChainConfig returns the Hoodi testnet chain configuration.
+func getChainConfig() *params.ChainConfig {
+ return params.HoodiChainConfig
+}
\ No newline at end of file
diff --git a/cmd/keeper/chainconfig_mainnet.go b/cmd/keeper/chainconfig_mainnet.go
new file mode 100644
index 0000000000..e3e6dc4bdf
--- /dev/null
+++ b/cmd/keeper/chainconfig_mainnet.go
@@ -0,0 +1,26 @@
+// 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 !hoodi && !sepolia
+
+package main
+
+import "github.com/ethereum/go-ethereum/params"
+
+// getChainConfig returns the Ethereum mainnet chain configuration.
+func getChainConfig() *params.ChainConfig {
+ return params.MainnetChainConfig
+}
diff --git a/cmd/keeper/chainconfig_sepolia.go b/cmd/keeper/chainconfig_sepolia.go
new file mode 100644
index 0000000000..ee863e732f
--- /dev/null
+++ b/cmd/keeper/chainconfig_sepolia.go
@@ -0,0 +1,26 @@
+// 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 sepolia
+
+package main
+
+import "github.com/ethereum/go-ethereum/params"
+
+// getChainConfig returns the Sepolia testnet chain configuration.
+func getChainConfig() *params.ChainConfig {
+ return params.SepoliaChainConfig
+}
\ No newline at end of file
diff --git a/cmd/keeper/getpayload_example.go b/cmd/keeper/getpayload_example.go
index 51dbd55cdf..206652cecc 100644
--- a/cmd/keeper/getpayload_example.go
+++ b/cmd/keeper/getpayload_example.go
@@ -26,7 +26,6 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/core/stateless"
"github.com/ethereum/go-ethereum/core/types"
- "github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/rlp"
)
@@ -64,9 +63,6 @@ var witnessRlp []byte
//go:embed 1192c3_block.rlp
var blockRlp []byte
-func getChainConfig() *params.ChainConfig {
- return params.HoodiChainConfig
-}
// getInput is a platform-specific function that will recover the input payload
// and returns it as a slice. It is expected to be an RLP-encoded Payload structure
diff --git a/cmd/keeper/getpayload_ziren.go b/cmd/keeper/getpayload_ziren.go
index 56da511966..2cc8365388 100644
--- a/cmd/keeper/getpayload_ziren.go
+++ b/cmd/keeper/getpayload_ziren.go
@@ -20,13 +20,8 @@ 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.
diff --git a/cmd/keeper/stubs.go b/cmd/keeper/stubs.go
index f64290ed5e..4f92028240 100644
--- a/cmd/keeper/stubs.go
+++ b/cmd/keeper/stubs.go
@@ -18,8 +18,6 @@
package main
-import "github.com/ethereum/go-ethereum/params"
-
// getInput is a stub implementation for when no platform-specific build tags are set.
// This allows golangci-lint to typecheck the code without errors.
// The actual implementations are provided in platform-specific files.
@@ -27,11 +25,3 @@ func getInput() []byte {
// This is a no-op stub - real implementations are in platform-specific files
return nil
}
-
-// getChainConfig is a stub implementation for when no platform-specific build tags are set.
-// This allows golangci-lint to typecheck the code without errors.
-// The actual implementations are provided in platform-specific files.
-func getChainConfig() *params.ChainConfig {
- // This is a no-op stub - real implementations are in platform-specific files
- return nil
-}