diff --git a/cmd/keeper/README.md b/cmd/keeper/README.md index 4b5c07e04d..3939cc3ad4 100644 --- a/cmd/keeper/README.md +++ b/cmd/keeper/README.md @@ -7,6 +7,7 @@ Keeper command is a specialized tool for validating stateless execution of Ether The keeper reads an RLP-encoded payload containing: - A block to execute - A witness with the necessary state data +- A chainID It then executes the block statelessly and validates that the computed state root and receipt root match the values in the block header. @@ -19,10 +20,7 @@ cmd/keeper/ ├── 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 @@ -41,14 +39,6 @@ import ( // ... other imports as needed ) -// getChainConfig returns the chain configuration for this platform -func getChainConfig() *params.ChainConfig { - // Return the appropriate chain config for your platform - // Examples: params.MainnetChainConfig, params.SepoliaChainConfig, - // or a custom configuration - return params.MainnetChainConfig -} - // getInput returns the RLP-encoded payload func getInput() []byte { // Your platform-specific code to retrieve the RLP-encoded payload @@ -70,14 +60,7 @@ func getInput() []byte { ### 2. Build for Your Platform ```bash -# 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 +go build -tags "myplatform" ./cmd/keeper ``` ## Payload Structure @@ -98,17 +81,12 @@ See `getpayload_example.go` for a complete example with embedded Hoodi block dat ```bash # 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 +go build -tags "example" ./cmd/keeper ``` ### Ziren zkVM Implementation -Build for the Ziren zkVM platform: +Build for the Ziren zkVM platform, which is a MIPS ISA-based zkvm: ```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 +GOOS=linux GOARCH=mipsle GOMIPS=softfloat go build -tags "ziren" ./cmd/keeper ``` diff --git a/cmd/keeper/chainconfig_mainnet.go b/cmd/keeper/chainconfig.go similarity index 56% rename from cmd/keeper/chainconfig_mainnet.go rename to cmd/keeper/chainconfig.go index e3e6dc4bdf..c9859d450f 100644 --- a/cmd/keeper/chainconfig_mainnet.go +++ b/cmd/keeper/chainconfig.go @@ -14,13 +14,25 @@ // 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" +import ( + "fmt" -// getChainConfig returns the Ethereum mainnet chain configuration. -func getChainConfig() *params.ChainConfig { - return params.MainnetChainConfig + "github.com/ethereum/go-ethereum/params" +) + +// getChainConfig returns the appropriate chain configuration based on the chainID. +// Returns an error for unsupported chain IDs. +func getChainConfig(chainID uint64) (*params.ChainConfig, error) { + switch chainID { + case 0, params.MainnetChainConfig.ChainID.Uint64(): + return params.MainnetChainConfig, nil + case params.SepoliaChainConfig.ChainID.Uint64(): + return params.SepoliaChainConfig, nil + case params.HoodiChainConfig.ChainID.Uint64(): + return params.HoodiChainConfig, nil + default: + return nil, fmt.Errorf("unsupported chain ID: %d", chainID) + } } diff --git a/cmd/keeper/chainconfig_hoodi.go b/cmd/keeper/chainconfig_hoodi.go deleted file mode 100644 index 8e98a1cb8a..0000000000 --- a/cmd/keeper/chainconfig_hoodi.go +++ /dev/null @@ -1,26 +0,0 @@ -// 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_sepolia.go b/cmd/keeper/chainconfig_sepolia.go deleted file mode 100644 index ee863e732f..0000000000 --- a/cmd/keeper/chainconfig_sepolia.go +++ /dev/null @@ -1,26 +0,0 @@ -// 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 206652cecc..683cc79248 100644 --- a/cmd/keeper/getpayload_example.go +++ b/cmd/keeper/getpayload_example.go @@ -26,6 +26,7 @@ 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" ) @@ -63,7 +64,6 @@ var witnessRlp []byte //go:embed 1192c3_block.rlp var blockRlp []byte - // 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 // that contains the witness and the block. @@ -88,6 +88,7 @@ func getInput() []byte { } payload := Payload{ + ChainID: params.HoodiChainConfig.ChainID.Uint64(), Block: &block, Witness: witness, } diff --git a/cmd/keeper/main.go b/cmd/keeper/main.go index 0aba562e72..cfb06f0da0 100644 --- a/cmd/keeper/main.go +++ b/cmd/keeper/main.go @@ -30,6 +30,7 @@ import ( // Payload represents the input data for stateless execution containing // a block and its associated witness data for verification. type Payload struct { + ChainID uint64 Block *types.Block Witness *stateless.Witness } @@ -39,7 +40,11 @@ func main() { var payload Payload rlp.DecodeBytes(input, &payload) - chainConfig := getChainConfig() + chainConfig, err := getChainConfig(payload.ChainID) + if err != nil { + fmt.Fprintf(os.Stderr, "failed to get chain config: %v\n", err) + os.Exit(13) + } vmConfig := vm.Config{} crossStateRoot, crossReceiptRoot, err := core.ExecuteStateless(chainConfig, vmConfig, payload.Block, payload.Witness)