From ea02c9ebc2e211027105a6847ed4508df716096c Mon Sep 17 00:00:00 2001 From: Sina Mahmoodi Date: Wed, 6 Mar 2024 18:42:18 +0100 Subject: [PATCH] fix eth config --- cmd/geth/config.go | 17 ----------------- cmd/utils/flags.go | 12 ++++++++++++ eth/backend.go | 10 +++++++++- eth/ethconfig/config.go | 4 ++-- 4 files changed, 23 insertions(+), 20 deletions(-) diff --git a/cmd/geth/config.go b/cmd/geth/config.go index 95d59a04fa..2f49c486f9 100644 --- a/cmd/geth/config.go +++ b/cmd/geth/config.go @@ -18,7 +18,6 @@ package main import ( "bufio" - "encoding/json" "errors" "fmt" "os" @@ -38,7 +37,6 @@ import ( "github.com/ethereum/go-ethereum/eth/catalyst" "github.com/ethereum/go-ethereum/eth/downloader" "github.com/ethereum/go-ethereum/eth/ethconfig" - "github.com/ethereum/go-ethereum/eth/tracers/directory/live" "github.com/ethereum/go-ethereum/internal/ethapi" "github.com/ethereum/go-ethereum/internal/flags" "github.com/ethereum/go-ethereum/internal/version" @@ -181,21 +179,6 @@ func makeFullNode(ctx *cli.Context) (*node.Node, ethapi.Backend) { cfg.Eth.OverrideVerkle = &v } - if ctx.IsSet(utils.VMTraceFlag.Name) { - if name := ctx.String(utils.VMTraceFlag.Name); name != "" { - var config string - if ctx.IsSet(utils.VMTraceConfigFlag.Name) { - config = ctx.String(utils.VMTraceConfigFlag.Name) - } - t, err := live.Directory.New(name, json.RawMessage(config)) - if err != nil { - utils.Fatalf("Failed to create tracer %q: %v", name, err) - } - - cfg.Eth.VMTracer = t - } - } - backend, eth := utils.RegisterEthService(stack, &cfg.Eth) // Create gauge with geth system and build information diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 2490e79fe5..41f782ed4f 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -1900,6 +1900,18 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) { if err := kzg4844.UseCKZG(ctx.String(CryptoKZGFlag.Name) == "ckzg"); err != nil { Fatalf("Failed to set KZG library implementation to %s: %v", ctx.String(CryptoKZGFlag.Name), err) } + // VM tracing config. + if ctx.IsSet(VMTraceFlag.Name) { + if name := ctx.String(VMTraceFlag.Name); name != "" { + var config string + if ctx.IsSet(VMTraceConfigFlag.Name) { + config = ctx.String(VMTraceConfigFlag.Name) + } + + cfg.VMTrace = name + cfg.VMTraceConfig = config + } + } } // SetDNSDiscoveryDefaults configures DNS discovery with the given URL if diff --git a/eth/backend.go b/eth/backend.go index 1ba7552d76..29af07cc56 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -18,6 +18,7 @@ package eth import ( + "encoding/json" "errors" "fmt" "math/big" @@ -44,6 +45,7 @@ import ( "github.com/ethereum/go-ethereum/eth/gasprice" "github.com/ethereum/go-ethereum/eth/protocols/eth" "github.com/ethereum/go-ethereum/eth/protocols/snap" + "github.com/ethereum/go-ethereum/eth/tracers/directory/live" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/internal/ethapi" @@ -192,7 +194,6 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) { var ( vmConfig = vm.Config{ EnablePreimageRecording: config.EnablePreimageRecording, - Tracer: config.VMTracer, } cacheConfig = &core.CacheConfig{ TrieCleanLimit: config.TrieCleanCache, @@ -206,6 +207,13 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) { StateScheme: scheme, } ) + if config.VMTrace != "" { + t, err := live.Directory.New(config.VMTrace, json.RawMessage(config.VMTraceConfig)) + if err != nil { + return nil, fmt.Errorf("Failed to create tracer %s: %v", config.VMTrace, err) + } + vmConfig.Tracer = t + } // Override the chain config with provided settings. var overrides core.ChainOverrides if config.OverrideCancun != nil { diff --git a/eth/ethconfig/config.go b/eth/ethconfig/config.go index 33ee536f88..27754f7c15 100644 --- a/eth/ethconfig/config.go +++ b/eth/ethconfig/config.go @@ -27,7 +27,6 @@ import ( "github.com/ethereum/go-ethereum/consensus/clique" "github.com/ethereum/go-ethereum/consensus/ethash" "github.com/ethereum/go-ethereum/core" - "github.com/ethereum/go-ethereum/core/tracing" "github.com/ethereum/go-ethereum/core/txpool/blobpool" "github.com/ethereum/go-ethereum/core/txpool/legacypool" "github.com/ethereum/go-ethereum/eth/downloader" @@ -153,7 +152,8 @@ type Config struct { EnablePreimageRecording bool // Enables VM tracing - VMTracer *tracing.Hooks + VMTrace string + VMTraceConfig string // Miscellaneous options DocRoot string `toml:"-"`