move chainconfig to its own tag-protected file

This commit is contained in:
Guillaume Ballet 2025-09-09 14:54:39 -04:00 committed by Felix Lange
parent b871219572
commit 45537ab4df
7 changed files with 111 additions and 27 deletions

View file

@ -12,13 +12,17 @@ It then executes the block statelessly and validates that the computed state roo
## Architecture ## 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/ cmd/keeper/
├── main.go # Main execution logic ├── main.go # Main execution logic
├── getpayload_example.go # Example implementation ├── getpayload_example.go # Example implementation with embedded data
└── README.md # This file ├── 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 ## Creating a Custom Platform Implementation
@ -66,7 +70,14 @@ func getInput() []byte {
### 2. Build for Your Platform ### 2. Build for Your Platform
```bash ```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 ## 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 ```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
``` ```

View file

@ -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 <http://www.gnu.org/licenses/>.
//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
}

View file

@ -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 <http://www.gnu.org/licenses/>.
//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
}

View file

@ -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 <http://www.gnu.org/licenses/>.
//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
}

View file

@ -26,7 +26,6 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/core/stateless" "github.com/ethereum/go-ethereum/core/stateless"
"github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/rlp"
) )
@ -64,9 +63,6 @@ var witnessRlp []byte
//go:embed 1192c3_block.rlp //go:embed 1192c3_block.rlp
var blockRlp []byte var blockRlp []byte
func getChainConfig() *params.ChainConfig {
return params.HoodiChainConfig
}
// getInput is a platform-specific function that will recover the input payload // 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 // and returns it as a slice. It is expected to be an RLP-encoded Payload structure

View file

@ -20,13 +20,8 @@ package main
import ( import (
zkruntime "github.com/zkMIPS/zkMIPS/crates/go-runtime/zkm_runtime" 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. // getInput reads the input payload from the zkVM runtime environment.
// The zkVM host provides the RLP-encoded Payload structure containing // The zkVM host provides the RLP-encoded Payload structure containing
// the block and witness data through the runtime's input mechanism. // the block and witness data through the runtime's input mechanism.

View file

@ -18,8 +18,6 @@
package main package main
import "github.com/ethereum/go-ethereum/params"
// getInput is a stub implementation for when no platform-specific build tags are set. // getInput is a stub implementation for when no platform-specific build tags are set.
// This allows golangci-lint to typecheck the code without errors. // This allows golangci-lint to typecheck the code without errors.
// The actual implementations are provided in platform-specific files. // 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 // This is a no-op stub - real implementations are in platform-specific files
return nil 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
}