2017-04-14 10:29:00 +02:00
|
|
|
// Copyright 2017 The go-ethereum Authors
|
2017-04-12 16:27:23 +02:00
|
|
|
// This file is part of go-ethereum.
|
|
|
|
//
|
|
|
|
// go-ethereum is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// go-ethereum 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 General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bufio"
|
|
|
|
"errors"
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
"reflect"
|
2023-08-31 19:37:17 +02:00
|
|
|
"runtime"
|
|
|
|
"strings"
|
2017-04-12 16:27:23 +02:00
|
|
|
"unicode"
|
|
|
|
|
2024-03-22 22:37:47 +08:00
|
|
|
"github.com/ethereum/go-ethereum/eth/downloader"
|
|
|
|
|
2023-04-27 18:57:29 +08:00
|
|
|
"github.com/ethereum/go-ethereum/accounts"
|
2021-08-25 22:34:22 +02:00
|
|
|
"github.com/ethereum/go-ethereum/accounts/external"
|
|
|
|
"github.com/ethereum/go-ethereum/accounts/keystore"
|
|
|
|
"github.com/ethereum/go-ethereum/accounts/scwallet"
|
|
|
|
"github.com/ethereum/go-ethereum/accounts/usbwallet"
|
2017-04-12 16:27:23 +02:00
|
|
|
"github.com/ethereum/go-ethereum/cmd/utils"
|
2023-12-28 10:42:37 +08:00
|
|
|
"github.com/ethereum/go-ethereum/common"
|
2024-01-03 15:38:39 +08:00
|
|
|
"github.com/ethereum/go-ethereum/core/rawdb"
|
2021-02-05 20:51:15 +08:00
|
|
|
"github.com/ethereum/go-ethereum/eth/ethconfig"
|
2020-08-03 19:40:46 +02:00
|
|
|
"github.com/ethereum/go-ethereum/internal/ethapi"
|
2022-06-27 18:22:36 +02:00
|
|
|
"github.com/ethereum/go-ethereum/internal/flags"
|
2022-09-23 14:08:25 +02:00
|
|
|
"github.com/ethereum/go-ethereum/internal/version"
|
2021-06-30 12:57:32 +02:00
|
|
|
"github.com/ethereum/go-ethereum/log"
|
2021-01-18 14:36:05 +01:00
|
|
|
"github.com/ethereum/go-ethereum/metrics"
|
2017-04-12 16:27:23 +02:00
|
|
|
"github.com/ethereum/go-ethereum/node"
|
|
|
|
"github.com/ethereum/go-ethereum/params"
|
|
|
|
"github.com/naoina/toml"
|
2023-08-31 19:37:17 +02:00
|
|
|
"github.com/urfave/cli/v2"
|
2017-04-12 16:27:23 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2022-06-27 18:22:36 +02:00
|
|
|
dumpConfigCommand = &cli.Command{
|
|
|
|
Action: dumpConfig,
|
2017-04-12 16:27:23 +02:00
|
|
|
Name: "dumpconfig",
|
2023-02-21 02:35:04 -05:00
|
|
|
Usage: "Export configuration values in a TOML format",
|
|
|
|
ArgsUsage: "<dumpfile (optional)>",
|
2022-07-25 17:07:44 +08:00
|
|
|
Flags: flags.Merge(nodeFlags, rpcFlags),
|
2023-02-21 02:35:04 -05:00
|
|
|
Description: `Export configuration values in TOML format (to stdout by default).`,
|
2017-04-12 16:27:23 +02:00
|
|
|
}
|
|
|
|
|
2022-06-27 18:22:36 +02:00
|
|
|
configFileFlag = &cli.StringFlag{
|
2023-12-27 14:27:35 +08:00
|
|
|
Name: "config",
|
|
|
|
Usage: "TOML configuration file",
|
|
|
|
Category: flags.EthCategory,
|
2017-04-12 16:27:23 +02:00
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
// These settings ensure that TOML keys use the same names as Go struct fields.
|
|
|
|
var tomlSettings = toml.Config{
|
|
|
|
NormFieldName: func(rt reflect.Type, key string) string {
|
|
|
|
return key
|
|
|
|
},
|
|
|
|
FieldToKey: func(rt reflect.Type, field string) string {
|
|
|
|
return field
|
|
|
|
},
|
|
|
|
MissingField: func(rt reflect.Type, field string) error {
|
2021-06-30 12:57:32 +02:00
|
|
|
id := fmt.Sprintf("%s.%s", rt.String(), field)
|
|
|
|
if deprecated(id) {
|
|
|
|
log.Warn("Config field is deprecated and won't have an effect", "name", id)
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
var link string
|
2017-04-12 16:27:23 +02:00
|
|
|
if unicode.IsUpper(rune(rt.Name()[0])) && rt.PkgPath() != "main" {
|
|
|
|
link = fmt.Sprintf(", see https://godoc.org/%s#%s for available fields", rt.PkgPath(), rt.Name())
|
|
|
|
}
|
|
|
|
return fmt.Errorf("field '%s' is not defined in %s%s", field, rt.String(), link)
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
type ethstatsConfig struct {
|
|
|
|
URL string `toml:",omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type gethConfig struct {
|
2021-02-05 20:51:15 +08:00
|
|
|
Eth ethconfig.Config
|
2019-11-14 10:04:16 +01:00
|
|
|
Node node.Config
|
|
|
|
Ethstats ethstatsConfig
|
2021-01-18 14:36:05 +01:00
|
|
|
Metrics metrics.Config
|
2017-04-12 16:27:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func loadConfig(file string, cfg *gethConfig) error {
|
|
|
|
f, err := os.Open(file)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
defer f.Close()
|
|
|
|
|
|
|
|
err = tomlSettings.NewDecoder(bufio.NewReader(f)).Decode(cfg)
|
|
|
|
// Add file name to errors that have a line number.
|
|
|
|
if _, ok := err.(*toml.LineError); ok {
|
|
|
|
err = errors.New(file + ", " + err.Error())
|
|
|
|
}
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
func defaultNodeConfig() node.Config {
|
2022-09-23 14:08:25 +02:00
|
|
|
git, _ := version.VCS()
|
2017-04-12 16:27:23 +02:00
|
|
|
cfg := node.DefaultConfig
|
|
|
|
cfg.Name = clientIdentifier
|
2022-09-23 14:08:25 +02:00
|
|
|
cfg.Version = params.VersionWithCommit(git.Commit, git.Date)
|
2020-01-28 10:37:08 +01:00
|
|
|
cfg.HTTPModules = append(cfg.HTTPModules, "eth")
|
|
|
|
cfg.WSModules = append(cfg.WSModules, "eth")
|
2017-04-12 16:27:23 +02:00
|
|
|
cfg.IPCPath = "geth.ipc"
|
|
|
|
return cfg
|
|
|
|
}
|
|
|
|
|
2023-04-27 18:57:29 +08:00
|
|
|
// loadBaseConfig loads the gethConfig based on the given command line
|
|
|
|
// parameters and config file.
|
|
|
|
func loadBaseConfig(ctx *cli.Context) gethConfig {
|
2017-04-12 16:27:23 +02:00
|
|
|
// Load defaults.
|
|
|
|
cfg := gethConfig{
|
2021-02-05 20:51:15 +08:00
|
|
|
Eth: ethconfig.Defaults,
|
2021-01-18 14:36:05 +01:00
|
|
|
Node: defaultNodeConfig(),
|
|
|
|
Metrics: metrics.DefaultConfig,
|
2017-04-12 16:27:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Load config file.
|
2022-06-27 18:22:36 +02:00
|
|
|
if file := ctx.String(configFileFlag.Name); file != "" {
|
2017-04-12 16:27:23 +02:00
|
|
|
if err := loadConfig(file, &cfg); err != nil {
|
|
|
|
utils.Fatalf("%v", err)
|
|
|
|
}
|
|
|
|
}
|
2024-01-03 15:38:39 +08:00
|
|
|
|
|
|
|
scheme := cfg.Eth.StateScheme
|
|
|
|
if scheme != "" {
|
|
|
|
if !rawdb.ValidateStateScheme(scheme) {
|
|
|
|
utils.Fatalf("Invalid state scheme param in config: %s", scheme)
|
|
|
|
}
|
2023-12-18 15:34:58 +08:00
|
|
|
}
|
2023-12-18 17:07:50 +08:00
|
|
|
if cfg.Eth.Genesis != nil && cfg.Eth.Genesis.Config != nil {
|
|
|
|
log.Warn("Chain config in the configuration file is ignored!")
|
|
|
|
}
|
2021-03-03 22:08:14 +08:00
|
|
|
|
2017-04-12 16:27:23 +02:00
|
|
|
// Apply flags.
|
|
|
|
utils.SetNodeConfig(ctx, &cfg.Node)
|
2023-04-27 18:57:29 +08:00
|
|
|
return cfg
|
|
|
|
}
|
|
|
|
|
|
|
|
// makeConfigNode loads geth configuration and creates a blank node instance.
|
|
|
|
func makeConfigNode(ctx *cli.Context) (*node.Node, gethConfig) {
|
|
|
|
cfg := loadBaseConfig(ctx)
|
2017-04-12 16:27:23 +02:00
|
|
|
stack, err := node.New(&cfg.Node)
|
|
|
|
if err != nil {
|
|
|
|
utils.Fatalf("Failed to create the protocol stack: %v", err)
|
|
|
|
}
|
2021-08-25 22:34:22 +02:00
|
|
|
// Node doesn't by default populate account manager backends
|
2023-04-27 18:57:29 +08:00
|
|
|
if err := setAccountManagerBackends(stack.Config(), stack.AccountManager(), stack.KeyStoreDir()); err != nil {
|
2021-08-25 22:34:22 +02:00
|
|
|
utils.Fatalf("Failed to set account manager backends: %v", err)
|
|
|
|
}
|
|
|
|
|
2017-04-12 16:27:23 +02:00
|
|
|
utils.SetEthConfig(ctx, stack, &cfg.Eth)
|
2022-06-27 18:22:36 +02:00
|
|
|
if ctx.IsSet(utils.EthStatsURLFlag.Name) {
|
|
|
|
cfg.Ethstats.URL = ctx.String(utils.EthStatsURLFlag.Name)
|
2017-04-12 16:27:23 +02:00
|
|
|
}
|
2021-01-18 14:36:05 +01:00
|
|
|
applyMetricConfig(ctx, &cfg)
|
|
|
|
|
2017-04-12 16:27:23 +02:00
|
|
|
return stack, cfg
|
|
|
|
}
|
|
|
|
|
2020-08-06 09:24:36 +02:00
|
|
|
// makeFullNode loads geth configuration and creates the Ethereum backend.
|
2020-08-03 19:40:46 +02:00
|
|
|
func makeFullNode(ctx *cli.Context) (*node.Node, ethapi.Backend) {
|
2017-04-12 16:27:23 +02:00
|
|
|
stack, cfg := makeConfigNode(ctx)
|
2023-12-28 10:42:37 +08:00
|
|
|
if ctx.IsSet(utils.RialtoHash.Name) {
|
|
|
|
v := ctx.String(utils.RialtoHash.Name)
|
|
|
|
params.RialtoGenesisHash = common.HexToHash(v)
|
|
|
|
}
|
|
|
|
|
2023-04-26 18:17:37 +03:00
|
|
|
if ctx.IsSet(utils.OverrideCancun.Name) {
|
|
|
|
v := ctx.Uint64(utils.OverrideCancun.Name)
|
|
|
|
cfg.Eth.OverrideCancun = &v
|
2021-02-25 09:10:30 +02:00
|
|
|
}
|
2024-05-21 17:46:42 +08:00
|
|
|
if ctx.IsSet(utils.OverrideHaber.Name) {
|
|
|
|
v := ctx.Uint64(utils.OverrideHaber.Name)
|
|
|
|
cfg.Eth.OverrideHaber = &v
|
|
|
|
}
|
2024-05-30 11:51:34 +08:00
|
|
|
if ctx.IsSet(utils.OverrideBohr.Name) {
|
|
|
|
v := ctx.Uint64(utils.OverrideBohr.Name)
|
|
|
|
cfg.Eth.OverrideBohr = &v
|
|
|
|
}
|
2023-06-28 11:08:48 +02:00
|
|
|
if ctx.IsSet(utils.OverrideVerkle.Name) {
|
|
|
|
v := ctx.Uint64(utils.OverrideVerkle.Name)
|
|
|
|
cfg.Eth.OverrideVerkle = &v
|
2021-04-16 21:29:22 +02:00
|
|
|
}
|
2024-03-22 22:37:47 +08:00
|
|
|
if ctx.IsSet(utils.OverrideFullImmutabilityThreshold.Name) {
|
|
|
|
params.FullImmutabilityThreshold = ctx.Uint64(utils.OverrideFullImmutabilityThreshold.Name)
|
|
|
|
downloader.FullMaxForkAncestry = ctx.Uint64(utils.OverrideFullImmutabilityThreshold.Name)
|
|
|
|
}
|
|
|
|
if ctx.IsSet(utils.OverrideMinBlocksForBlobRequests.Name) {
|
|
|
|
params.MinBlocksForBlobRequests = ctx.Uint64(utils.OverrideMinBlocksForBlobRequests.Name)
|
|
|
|
}
|
|
|
|
if ctx.IsSet(utils.OverrideDefaultExtraReserveForBlobRequests.Name) {
|
|
|
|
params.DefaultExtraReserveForBlobRequests = ctx.Uint64(utils.OverrideDefaultExtraReserveForBlobRequests.Name)
|
|
|
|
}
|
2024-05-17 16:18:29 +08:00
|
|
|
if ctx.IsSet(utils.OverrideBreatheBlockInterval.Name) {
|
|
|
|
params.BreatheBlockInterval = ctx.Uint64(utils.OverrideBreatheBlockInterval.Name)
|
|
|
|
}
|
2024-04-18 15:12:05 +08:00
|
|
|
|
2022-12-08 21:40:43 +08:00
|
|
|
backend, eth := utils.RegisterEthService(stack, &cfg.Eth)
|
2022-08-19 11:14:59 +02:00
|
|
|
|
2023-08-31 19:37:17 +02:00
|
|
|
// Create gauge with geth system and build information
|
|
|
|
if eth != nil { // The 'eth' backend may be nil in light mode
|
|
|
|
var protos []string
|
|
|
|
for _, p := range eth.Protocols() {
|
|
|
|
protos = append(protos, fmt.Sprintf("%v/%d", p.Name, p.Version))
|
|
|
|
}
|
|
|
|
metrics.NewRegisteredGaugeInfo("geth/info", nil).Update(metrics.GaugeInfoValue{
|
2023-09-13 20:17:55 +03:00
|
|
|
"arch": runtime.GOARCH,
|
|
|
|
"os": runtime.GOOS,
|
|
|
|
"version": cfg.Node.Version,
|
|
|
|
"protocols": strings.Join(protos, ","),
|
2023-08-31 19:37:17 +02:00
|
|
|
})
|
|
|
|
}
|
2017-04-12 16:27:23 +02:00
|
|
|
|
2022-08-19 11:14:59 +02:00
|
|
|
// Configure log filter RPC API.
|
|
|
|
filterSystem := utils.RegisterFilterAPI(stack, backend, &cfg.Eth)
|
|
|
|
|
|
|
|
// Configure GraphQL if requested.
|
2022-06-27 18:22:36 +02:00
|
|
|
if ctx.IsSet(utils.GraphQLEnabledFlag.Name) {
|
2022-08-19 11:14:59 +02:00
|
|
|
utils.RegisterGraphQLService(stack, backend, filterSystem, &cfg.Node)
|
2019-01-21 06:38:13 -08:00
|
|
|
}
|
2017-04-12 16:27:23 +02:00
|
|
|
// Add the Ethereum Stats daemon if requested.
|
|
|
|
if cfg.Ethstats.URL != "" {
|
2020-08-03 19:40:46 +02:00
|
|
|
utils.RegisterEthStatsService(stack, backend, cfg.Ethstats.URL)
|
2017-04-12 16:27:23 +02:00
|
|
|
}
|
2022-12-16 07:59:16 +08:00
|
|
|
|
2023-08-23 17:46:08 +08:00
|
|
|
git, _ := version.VCS()
|
2022-12-16 07:59:16 +08:00
|
|
|
utils.SetupMetrics(ctx,
|
2023-08-23 17:46:08 +08:00
|
|
|
utils.EnableBuildInfo(git.Commit, git.Date),
|
2024-03-29 15:04:33 +08:00
|
|
|
utils.EnableMinerInfo(ctx, &cfg.Eth.Miner),
|
|
|
|
utils.EnableNodeInfo(&cfg.Eth.TxPool, stack.Server().NodeInfo()),
|
2022-12-16 07:59:16 +08:00
|
|
|
)
|
2020-08-03 19:40:46 +02:00
|
|
|
return stack, backend
|
2017-04-12 16:27:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// dumpConfig is the dumpconfig command.
|
|
|
|
func dumpConfig(ctx *cli.Context) error {
|
|
|
|
_, cfg := makeConfigNode(ctx)
|
|
|
|
comment := ""
|
|
|
|
|
|
|
|
if cfg.Eth.Genesis != nil {
|
|
|
|
cfg.Eth.Genesis = nil
|
|
|
|
comment += "# Note: this config doesn't contain the genesis block.\n\n"
|
|
|
|
}
|
|
|
|
|
|
|
|
out, err := tomlSettings.Marshal(&cfg)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-01-07 19:56:50 +11:00
|
|
|
|
|
|
|
dump := os.Stdout
|
|
|
|
if ctx.NArg() > 0 {
|
|
|
|
dump, err = os.OpenFile(ctx.Args().Get(0), os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0644)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
defer dump.Close()
|
|
|
|
}
|
|
|
|
dump.WriteString(comment)
|
|
|
|
dump.Write(out)
|
|
|
|
|
2017-04-12 16:27:23 +02:00
|
|
|
return nil
|
|
|
|
}
|
2021-01-18 14:36:05 +01:00
|
|
|
|
|
|
|
func applyMetricConfig(ctx *cli.Context, cfg *gethConfig) {
|
2022-06-27 18:22:36 +02:00
|
|
|
if ctx.IsSet(utils.MetricsEnabledFlag.Name) {
|
|
|
|
cfg.Metrics.Enabled = ctx.Bool(utils.MetricsEnabledFlag.Name)
|
2021-01-18 14:36:05 +01:00
|
|
|
}
|
2022-06-27 18:22:36 +02:00
|
|
|
if ctx.IsSet(utils.MetricsEnabledExpensiveFlag.Name) {
|
|
|
|
cfg.Metrics.EnabledExpensive = ctx.Bool(utils.MetricsEnabledExpensiveFlag.Name)
|
2021-01-18 14:36:05 +01:00
|
|
|
}
|
2022-06-27 18:22:36 +02:00
|
|
|
if ctx.IsSet(utils.MetricsHTTPFlag.Name) {
|
|
|
|
cfg.Metrics.HTTP = ctx.String(utils.MetricsHTTPFlag.Name)
|
2021-01-18 14:36:05 +01:00
|
|
|
}
|
2022-06-27 18:22:36 +02:00
|
|
|
if ctx.IsSet(utils.MetricsPortFlag.Name) {
|
|
|
|
cfg.Metrics.Port = ctx.Int(utils.MetricsPortFlag.Name)
|
2021-01-18 14:36:05 +01:00
|
|
|
}
|
2022-06-27 18:22:36 +02:00
|
|
|
if ctx.IsSet(utils.MetricsEnableInfluxDBFlag.Name) {
|
|
|
|
cfg.Metrics.EnableInfluxDB = ctx.Bool(utils.MetricsEnableInfluxDBFlag.Name)
|
2021-01-18 14:36:05 +01:00
|
|
|
}
|
2022-06-27 18:22:36 +02:00
|
|
|
if ctx.IsSet(utils.MetricsInfluxDBEndpointFlag.Name) {
|
|
|
|
cfg.Metrics.InfluxDBEndpoint = ctx.String(utils.MetricsInfluxDBEndpointFlag.Name)
|
2021-01-18 14:36:05 +01:00
|
|
|
}
|
2022-06-27 18:22:36 +02:00
|
|
|
if ctx.IsSet(utils.MetricsInfluxDBDatabaseFlag.Name) {
|
|
|
|
cfg.Metrics.InfluxDBDatabase = ctx.String(utils.MetricsInfluxDBDatabaseFlag.Name)
|
2021-01-18 14:36:05 +01:00
|
|
|
}
|
2022-06-27 18:22:36 +02:00
|
|
|
if ctx.IsSet(utils.MetricsInfluxDBUsernameFlag.Name) {
|
|
|
|
cfg.Metrics.InfluxDBUsername = ctx.String(utils.MetricsInfluxDBUsernameFlag.Name)
|
2021-01-18 14:36:05 +01:00
|
|
|
}
|
2022-06-27 18:22:36 +02:00
|
|
|
if ctx.IsSet(utils.MetricsInfluxDBPasswordFlag.Name) {
|
|
|
|
cfg.Metrics.InfluxDBPassword = ctx.String(utils.MetricsInfluxDBPasswordFlag.Name)
|
2021-01-18 14:36:05 +01:00
|
|
|
}
|
2022-06-27 18:22:36 +02:00
|
|
|
if ctx.IsSet(utils.MetricsInfluxDBTagsFlag.Name) {
|
|
|
|
cfg.Metrics.InfluxDBTags = ctx.String(utils.MetricsInfluxDBTagsFlag.Name)
|
2021-01-18 14:36:05 +01:00
|
|
|
}
|
2022-06-27 18:22:36 +02:00
|
|
|
if ctx.IsSet(utils.MetricsEnableInfluxDBV2Flag.Name) {
|
|
|
|
cfg.Metrics.EnableInfluxDBV2 = ctx.Bool(utils.MetricsEnableInfluxDBV2Flag.Name)
|
2021-08-17 18:40:14 +02:00
|
|
|
}
|
2022-06-27 18:22:36 +02:00
|
|
|
if ctx.IsSet(utils.MetricsInfluxDBTokenFlag.Name) {
|
|
|
|
cfg.Metrics.InfluxDBToken = ctx.String(utils.MetricsInfluxDBTokenFlag.Name)
|
2021-08-17 18:40:14 +02:00
|
|
|
}
|
2022-06-27 18:22:36 +02:00
|
|
|
if ctx.IsSet(utils.MetricsInfluxDBBucketFlag.Name) {
|
|
|
|
cfg.Metrics.InfluxDBBucket = ctx.String(utils.MetricsInfluxDBBucketFlag.Name)
|
2021-08-17 18:40:14 +02:00
|
|
|
}
|
2022-06-27 18:22:36 +02:00
|
|
|
if ctx.IsSet(utils.MetricsInfluxDBOrganizationFlag.Name) {
|
|
|
|
cfg.Metrics.InfluxDBOrganization = ctx.String(utils.MetricsInfluxDBOrganizationFlag.Name)
|
2021-08-17 18:40:14 +02:00
|
|
|
}
|
2021-01-18 14:36:05 +01:00
|
|
|
}
|
2021-06-30 12:57:32 +02:00
|
|
|
|
|
|
|
func deprecated(field string) bool {
|
2021-07-06 22:03:09 +02:00
|
|
|
switch field {
|
|
|
|
case "ethconfig.Config.EVMInterpreter":
|
|
|
|
return true
|
|
|
|
case "ethconfig.Config.EWASMInterpreter":
|
|
|
|
return true
|
cmd, core, eth, graphql, trie: no persisted clean trie cache file (#27525)
The clean trie cache is persisted periodically, therefore Geth can
quickly warmup the cache in next restart.
However it will reduce the robustness of system. The assumption is
held in Geth that if the parent trie node is present, then the entire
sub-trie associated with the parent are all prensent.
Imagine the scenario that Geth rewinds itself to a past block and
restart, but Geth finds the root node of "future state" in clean
cache then regard this state is present in disk, while is not in fact.
Another example is offline pruning tool. Whenever an offline pruning
is performed, the clean cache file has to be removed to aviod hitting
the root node of "deleted states" in clean cache.
All in all, compare with the minor performance gain, system robustness
is something we care more.
2023-07-04 15:21:06 +08:00
|
|
|
case "ethconfig.Config.TrieCleanCacheJournal":
|
|
|
|
return true
|
|
|
|
case "ethconfig.Config.TrieCleanCacheRejournal":
|
|
|
|
return true
|
2021-07-06 22:03:09 +02:00
|
|
|
default:
|
|
|
|
return false
|
|
|
|
}
|
2021-06-30 12:57:32 +02:00
|
|
|
}
|
2021-08-25 22:34:22 +02:00
|
|
|
|
2023-04-27 18:57:29 +08:00
|
|
|
func setAccountManagerBackends(conf *node.Config, am *accounts.Manager, keydir string) error {
|
2021-08-25 22:34:22 +02:00
|
|
|
scryptN := keystore.StandardScryptN
|
|
|
|
scryptP := keystore.StandardScryptP
|
|
|
|
if conf.UseLightweightKDF {
|
|
|
|
scryptN = keystore.LightScryptN
|
|
|
|
scryptP = keystore.LightScryptP
|
|
|
|
}
|
|
|
|
|
|
|
|
// Assemble the supported backends
|
|
|
|
if len(conf.ExternalSigner) > 0 {
|
|
|
|
log.Info("Using external signer", "url", conf.ExternalSigner)
|
2023-05-08 15:01:14 +08:00
|
|
|
if extBackend, err := external.NewExternalBackend(conf.ExternalSigner); err == nil {
|
|
|
|
am.AddBackend(extBackend)
|
2021-08-25 22:34:22 +02:00
|
|
|
return nil
|
|
|
|
} else {
|
|
|
|
return fmt.Errorf("error connecting to external signer: %v", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// For now, we're using EITHER external signer OR local signers.
|
|
|
|
// If/when we implement some form of lockfile for USB and keystore wallets,
|
|
|
|
// we can have both, but it's very confusing for the user to see the same
|
|
|
|
// accounts in both externally and locally, plus very racey.
|
|
|
|
am.AddBackend(keystore.NewKeyStore(keydir, scryptN, scryptP))
|
|
|
|
if conf.USB {
|
|
|
|
// Start a USB hub for Ledger hardware wallets
|
|
|
|
if ledgerhub, err := usbwallet.NewLedgerHub(); err != nil {
|
|
|
|
log.Warn(fmt.Sprintf("Failed to start Ledger hub, disabling: %v", err))
|
|
|
|
} else {
|
|
|
|
am.AddBackend(ledgerhub)
|
|
|
|
}
|
|
|
|
// Start a USB hub for Trezor hardware wallets (HID version)
|
|
|
|
if trezorhub, err := usbwallet.NewTrezorHubWithHID(); err != nil {
|
|
|
|
log.Warn(fmt.Sprintf("Failed to start HID Trezor hub, disabling: %v", err))
|
|
|
|
} else {
|
|
|
|
am.AddBackend(trezorhub)
|
|
|
|
}
|
|
|
|
// Start a USB hub for Trezor hardware wallets (WebUSB version)
|
|
|
|
if trezorhub, err := usbwallet.NewTrezorHubWithWebUSB(); err != nil {
|
|
|
|
log.Warn(fmt.Sprintf("Failed to start WebUSB Trezor hub, disabling: %v", err))
|
|
|
|
} else {
|
|
|
|
am.AddBackend(trezorhub)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if len(conf.SmartCardDaemonPath) > 0 {
|
|
|
|
// Start a smart card hub
|
|
|
|
if schub, err := scwallet.NewHub(conf.SmartCardDaemonPath, scwallet.Scheme, keydir); err != nil {
|
|
|
|
log.Warn(fmt.Sprintf("Failed to start smart card hub, disabling: %v", err))
|
|
|
|
} else {
|
|
|
|
am.AddBackend(schub)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|