Skip to content
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion apps/evm/cmd/rollback.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"github.com/ethereum/go-ethereum/common"
ds "github.com/ipfs/go-datastore"
"github.com/rs/zerolog"
"github.com/spf13/cobra"

goheaderstore "github.com/celestiaorg/go-header/store"
Expand Down Expand Up @@ -166,5 +167,5 @@ func createRollbackEngineClient(cmd *cobra.Command, db ds.Batching) (*evm.Engine
return nil, fmt.Errorf("JWT secret file '%s' is empty", jwtSecretFile)
}

return evm.NewEngineExecutionClient(ethURL, engineURL, jwtSecret, common.Hash{}, common.Address{}, db, false)
return evm.NewEngineExecutionClient(ethURL, engineURL, jwtSecret, common.Hash{}, common.Address{}, db, false, zerolog.Nop())
}
55 changes: 41 additions & 14 deletions apps/evm/cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ package cmd
import (
"bytes"
"context"
"encoding/json"
"fmt"
"os"
"path/filepath"
"time"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
"github.com/ipfs/go-datastore"
"github.com/rs/zerolog"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -56,7 +58,14 @@ var RunCmd = &cobra.Command{
}

tracingEnabled := nodeConfig.Instrumentation.IsTracingEnabled()
executor, err := createExecutionClient(cmd, datastore, tracingEnabled)

executor, err := createExecutionClient(
cmd,
datastore,
tracingEnabled,
nodeConfig.RootDir,
logger.With().Str("module", "engine_client").Logger(),
)
if err != nil {
return err
}
Expand All @@ -67,12 +76,6 @@ var RunCmd = &cobra.Command{
}

daClient := block.NewDAClient(blobClient, nodeConfig, logger)

// Attach logger to the EVM engine client if available
if ec, ok := executor.(*evm.EngineClient); ok {
ec.SetLogger(logger.With().Str("module", "engine_client").Logger())
}

headerNamespace := da.NamespaceFromString(nodeConfig.DA.GetNamespace())
dataNamespace := da.NamespaceFromString(nodeConfig.DA.GetDataNamespace())

Expand Down Expand Up @@ -200,7 +203,33 @@ func createSequencer(
return sequencer, nil
}

func createExecutionClient(cmd *cobra.Command, db datastore.Batching, tracingEnabled bool) (execution.Executor, error) {
func createExecutionClient(cmd *cobra.Command, db datastore.Batching, tracingEnabled bool, rootDir string, logger zerolog.Logger) (execution.Executor, error) {
feeRecipientStr, err := cmd.Flags().GetString(evm.FlagEvmFeeRecipient)
if err != nil {
return nil, fmt.Errorf("failed to get '%s' flag: %w", evm.FlagEvmFeeRecipient, err)
}
feeRecipient := common.HexToAddress(feeRecipientStr)

useGeth, _ := cmd.Flags().GetBool(evm.FlagEVMInProcessGeth)
if useGeth {
genesisPath, _ := cmd.Flags().GetString(evm.FlagEVMGenesisPath)
if len(genesisPath) == 0 {
return nil, fmt.Errorf("genesis path must be provided when using in-process Geth")
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The errors returned by cmd.Flags().GetBool() and cmd.Flags().GetString() are being ignored. This can lead to silent failures and unexpected behavior if the flags are not parsed correctly (e.g., due to a typo or incorrect type). The program might proceed with default values (e.g., an empty genesisPath), causing issues later on. It's crucial to handle these errors to make the command-line interface more robust.

Suggested change
useGeth, _ := cmd.Flags().GetBool(evm.FlagEVMInProcessGeth)
if useGeth {
genesisPath, _ := cmd.Flags().GetString(evm.FlagEVMGenesisPath)
if len(genesisPath) == 0 {
return nil, fmt.Errorf("genesis path must be provided when using in-process Geth")
}
useGeth, err := cmd.Flags().GetBool(evm.FlagEVMInProcessGeth)
if err != nil {
return nil, fmt.Errorf("failed to get '%s' flag: %w", evm.FlagEVMInProcessGeth, err)
}
if useGeth {
genesisPath, err := cmd.Flags().GetString(evm.FlagEVMGenesisPath)
if err != nil {
return nil, fmt.Errorf("failed to get '%s' flag: %w", evm.FlagEVMGenesisPath, err)
}
if len(genesisPath) == 0 {
return nil, fmt.Errorf("genesis path must be provided when using in-process Geth")
}


genesisBz, err := os.ReadFile(genesisPath)
if err != nil {
return nil, fmt.Errorf("failed to read genesis: %w", err)
}

var genesis core.Genesis
if err := json.Unmarshal(genesisBz, &genesis); err != nil {
return nil, fmt.Errorf("failed to unmarshal genesis: %w", err)
}

return evm.NewEngineExecutionClientWithGeth(&genesis, feeRecipient, db, logger)
}

// Read execution client parameters from flags
ethURL, err := cmd.Flags().GetString(evm.FlagEvmEthURL)
if err != nil {
Expand Down Expand Up @@ -236,16 +265,11 @@ func createExecutionClient(cmd *cobra.Command, db datastore.Batching, tracingEna
if err != nil {
return nil, fmt.Errorf("failed to get '%s' flag: %w", evm.FlagEvmGenesisHash, err)
}
feeRecipientStr, err := cmd.Flags().GetString(evm.FlagEvmFeeRecipient)
if err != nil {
return nil, fmt.Errorf("failed to get '%s' flag: %w", evm.FlagEvmFeeRecipient, err)
}

// Convert string parameters to Ethereum types
genesisHash := common.HexToHash(genesisHashStr)
feeRecipient := common.HexToAddress(feeRecipientStr)

return evm.NewEngineExecutionClient(ethURL, engineURL, jwtSecret, genesisHash, feeRecipient, db, tracingEnabled)
return evm.NewEngineExecutionClient(ethURL, engineURL, jwtSecret, genesisHash, feeRecipient, db, tracingEnabled, logger)
}

// addFlags adds flags related to the EVM execution client
Expand All @@ -256,4 +280,7 @@ func addFlags(cmd *cobra.Command) {
cmd.Flags().String(evm.FlagEvmGenesisHash, "", "Hash of the genesis block")
cmd.Flags().String(evm.FlagEvmFeeRecipient, "", "Address that will receive transaction fees")
cmd.Flags().String(flagForceInclusionServer, "", "Address for force inclusion API server (e.g. 127.0.0.1:8547). If set, enables the server for direct DA submission")

cmd.Flags().Bool(evm.FlagEVMInProcessGeth, false, "Use in-process Geth for EVM execution instead of external execution client")
cmd.Flags().String(evm.FlagEVMGenesisPath, "", "EVM genesis path for Geth")
}
3 changes: 3 additions & 0 deletions apps/evm/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ require (
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/ProjectZKM/Ziren/crates/go-runtime/zkvm_runtime v0.0.0-20251001021608-1fe7b43fc4d6 // indirect
github.com/StackExchange/wmi v1.2.1 // indirect
github.com/VictoriaMetrics/fastcache v1.13.0 // indirect
github.com/benbjohnson/clock v1.3.5 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bits-and-blooms/bitset v1.20.0 // indirect
Expand All @@ -49,6 +50,7 @@ require (
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/emicklei/dot v1.6.2 // indirect
github.com/ethereum/c-kzg-4844/v2 v2.1.5 // indirect
github.com/ethereum/go-bigmodexpfix v0.0.0-20250911101455-f9e208c548ab // indirect
github.com/ethereum/go-verkle v0.2.2 // indirect
github.com/ferranbt/fastssz v0.1.4 // indirect
github.com/filecoin-project/go-clock v0.1.0 // indirect
Expand All @@ -74,6 +76,7 @@ require (
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.3 // indirect
github.com/hashicorp/golang-lru v1.0.2 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/holiman/bloomfilter/v2 v2.0.3 // indirect
github.com/holiman/uint256 v1.3.2 // indirect
github.com/huin/goupnp v1.3.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions apps/evm/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,8 @@ github.com/alecthomas/assert/v2 v2.3.0/go.mod h1:pXcQ2Asjp247dahGEmsZ6ru0UVwnkhk
github.com/alecthomas/participle/v2 v2.0.0/go.mod h1:rAKZdJldHu8084ojcWevWAL8KmEU+AT+Olodb+WoN2Y=
github.com/alecthomas/participle/v2 v2.1.0/go.mod h1:Y1+hAs8DHPmc3YUFzqllV+eSQ9ljPTk0ZkPMtEdAx2c=
github.com/alecthomas/repr v0.2.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156 h1:eMwmnE/GDgah4HI848JfFxHt+iPb26b4zyfspmqY0/8=
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM=
github.com/andybalholm/brotli v1.0.5/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
github.com/apache/arrow/go/v14 v14.0.2/go.mod h1:u3fgh3EdgN/YQ8cVQRguVW3R+seMybFg8QBQ5LU+eBY=
Expand Down
Loading
Loading