diff --git a/cmd/abigen/main.go b/cmd/abigen/main.go index 6d361b483..2c65209b0 100644 --- a/cmd/abigen/main.go +++ b/cmd/abigen/main.go @@ -19,6 +19,7 @@ package main import ( "encoding/json" "fmt" + "github.com/ledgerwatch/erigon-lib/common" "io" "os" "path/filepath" @@ -180,7 +181,7 @@ func abigen(c *cli.Context) error { } else { // Generate the list of types to exclude from binding exclude := make(map[string]bool) - for _, kind := range utils.SplitAndTrim(c.String(excFlag.Name)) { + for _, kind := range common.CliString2Array(c.String(excFlag.Name)) { exclude[strings.ToLower(kind)] = true } var err error diff --git a/cmd/downloader/downloadernat/nat.go b/cmd/downloader/downloadernat/nat.go index 5aa0f29db..f3b7075f5 100644 --- a/cmd/downloader/downloadernat/nat.go +++ b/cmd/downloader/downloadernat/nat.go @@ -1,12 +1,13 @@ package downloadernat import ( - "github.com/ledgerwatch/erigon-lib/downloader/downloadercfg" + "github.com/anacrolix/torrent" "github.com/ledgerwatch/erigon/p2p/nat" "github.com/ledgerwatch/log/v3" ) -func DoNat(natif nat.Interface, cfg *downloadercfg.Cfg, logger log.Logger) { +// DoNat can mutate `cfg` parameter +func DoNat(natif nat.Interface, cfg *torrent.ClientConfig, logger log.Logger) { switch natif.(type) { case nil: // No NAT interface, do nothing. diff --git a/cmd/downloader/main.go b/cmd/downloader/main.go index 53de0e035..98e466954 100644 --- a/cmd/downloader/main.go +++ b/cmd/downloader/main.go @@ -4,6 +4,8 @@ import ( "context" "errors" "fmt" + "github.com/ledgerwatch/log/v3" + "github.com/pelletier/go-toml" "net" "os" "path/filepath" @@ -25,8 +27,6 @@ import ( "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/erigon/turbo/debug" "github.com/ledgerwatch/erigon/turbo/logging" - "github.com/ledgerwatch/log/v3" - "github.com/pelletier/go-toml/v2" "github.com/spf13/cobra" "google.golang.org/grpc" "google.golang.org/grpc/credentials" @@ -37,7 +37,9 @@ import ( ) var ( + webseeds string datadirCli string + filePath string forceRebuild bool forceVerify bool downloaderApiAddr string @@ -58,7 +60,7 @@ func init() { utils.CobraFlags(rootCmd, debug.Flags, utils.MetricFlags, logging.Flags) withDataDir(rootCmd) - + rootCmd.Flags().StringVar(&webseeds, utils.WebSeedsFlag.Name, utils.WebSeedsFlag.Value, utils.WebSeedsFlag.Usage) rootCmd.Flags().StringVar(&natSetting, "nat", utils.NATFlag.Value, utils.NATFlag.Usage) rootCmd.Flags().StringVar(&downloaderApiAddr, "downloader.api.addr", "127.0.0.1:9093", "external downloader api network address, for example: 127.0.0.1:9093 serves remote downloader interface") rootCmd.Flags().StringVar(&downloadRateStr, "torrent.download.rate", utils.TorrentDownloadRateFlag.Value, utils.TorrentDownloadRateFlag.Usage) @@ -73,6 +75,9 @@ func init() { rootCmd.Flags().BoolVar(&disableIPV4, "downloader.disable.ipv4", utils.DisableIPV4.Value, utils.DisableIPV6.Usage) rootCmd.PersistentFlags().BoolVar(&forceVerify, "verify", false, "Force verify data files if have .torrent files") + withDataDir(createTorrent) + withFile(createTorrent) + withDataDir(printTorrentHashes) printTorrentHashes.PersistentFlags().BoolVar(&forceRebuild, "rebuild", false, "Force re-create .torrent files") printTorrentHashes.Flags().StringVar(&targetFile, "targetfile", "", "write output to file") @@ -80,6 +85,7 @@ func init() { panic(err) } + rootCmd.AddCommand(createTorrent) rootCmd.AddCommand(printTorrentHashes) } @@ -89,6 +95,12 @@ func withDataDir(cmd *cobra.Command) { panic(err) } } +func withFile(cmd *cobra.Command) { + cmd.Flags().StringVar(&filePath, "file", "", "") + if err := cmd.MarkFlagFilename(utils.DataDirFlag.Name); err != nil { + panic(err) + } +} func main() { ctx, cancel := common.RootContext() @@ -138,10 +150,10 @@ func Downloader(ctx context.Context, logger log.Logger) error { if err != nil { return fmt.Errorf("invalid nat option %s: %w", natSetting, err) } - staticPeers := utils.SplitAndTrim(staticPeersStr) + staticPeers := common.CliString2Array(staticPeersStr) version := "erigon: " + params.VersionWithCommit(params.GitCommit) - cfg, err := downloadercfg2.New(dirs.Snap, version, torrentLogLevel, downloadRate, uploadRate, torrentPort, torrentConnsPerFile, torrentDownloadSlots, staticPeers) + cfg, err := downloadercfg2.New(dirs, version, torrentLogLevel, downloadRate, uploadRate, torrentPort, torrentConnsPerFile, torrentDownloadSlots, staticPeers, webseeds) if err != nil { return err } @@ -149,7 +161,7 @@ func Downloader(ctx context.Context, logger log.Logger) error { cfg.ClientConfig.DisableIPv6 = disableIPV6 cfg.ClientConfig.DisableIPv4 = disableIPV4 - downloadernat.DoNat(natif, cfg, logger) + downloadernat.DoNat(natif, cfg.ClientConfig, logger) d, err := downloader.New(ctx, cfg) if err != nil { @@ -181,6 +193,30 @@ func Downloader(ctx context.Context, logger log.Logger) error { return nil } +var createTorrent = &cobra.Command{ + Use: "torrent_create", + Example: "go run ./cmd/downloader torrent_create --datadir= --file=", + RunE: func(cmd *cobra.Command, args []string) error { + //logger := debug.SetupCobra(cmd, "integration") + //dirs := datadir.New(datadirCli) + //ctx := cmd.Context() + + fileDir, fileName := filepath.Split(filePath) + info := &metainfo.Info{PieceLength: downloadercfg2.DefaultPieceSize, Name: fileName} + if err := info.BuildFromFilePath(filePath); err != nil { + return err + } + mi, err := downloader.CreateMetaInfo(info, nil) + if err != nil { + return err + } + if err := downloader.CreateTorrentFromMetaInfo(fileDir, info, mi); err != nil { + return err + } + return nil + }, +} + var printTorrentHashes = &cobra.Command{ Use: "torrent_hashes", Example: "go run ./cmd/downloader torrent_hashes --datadir ", @@ -250,15 +286,6 @@ var printTorrentHashes = &cobra.Command{ }, } -// nolint -func removePieceCompletionStorage(snapDir string) { - _ = os.RemoveAll(filepath.Join(snapDir, "db")) - _ = os.RemoveAll(filepath.Join(snapDir, ".torrent.db")) - _ = os.RemoveAll(filepath.Join(snapDir, ".torrent.bolt.db")) - _ = os.RemoveAll(filepath.Join(snapDir, ".torrent.db-shm")) - _ = os.RemoveAll(filepath.Join(snapDir, ".torrent.db-wal")) -} - func StartGrpc(snServer *downloader.GrpcServer, addr string, creds *credentials.TransportCredentials, logger log.Logger) (*grpc.Server, error) { lis, err := net.Listen("tcp", addr) if err != nil { diff --git a/cmd/observer/database/db_sqlite.go b/cmd/observer/database/db_sqlite.go index ba056fbe8..d8065f992 100644 --- a/cmd/observer/database/db_sqlite.go +++ b/cmd/observer/database/db_sqlite.go @@ -5,11 +5,11 @@ import ( "database/sql" "errors" "fmt" + "github.com/ledgerwatch/erigon-lib/common" "net" "strings" "time" - "github.com/ledgerwatch/erigon/cmd/utils" _ "modernc.org/sqlite" ) @@ -709,7 +709,7 @@ func (db *DBSQLite) FindNeighborBucketKeys(ctx context.Context, id NodeID) ([]st if !keysStr.Valid { return nil, nil } - return utils.SplitAndTrim(keysStr.String), nil + return common.CliString2Array(keysStr.String), nil } func (db *DBSQLite) UpdateSentryCandidatesLastEventTime(ctx context.Context, value time.Time) error { diff --git a/cmd/p2psim/main.go b/cmd/p2psim/main.go index 6eb48e923..3f567847b 100644 --- a/cmd/p2psim/main.go +++ b/cmd/p2psim/main.go @@ -39,12 +39,12 @@ import ( "context" "encoding/json" "fmt" + "github.com/ledgerwatch/erigon-lib/common" "io" "os" "strings" "text/tabwriter" - "github.com/ledgerwatch/erigon/cmd/utils" "github.com/ledgerwatch/erigon/turbo/logging" "github.com/urfave/cli/v2" @@ -292,7 +292,7 @@ func createNode(ctx *cli.Context) error { config.PrivateKey = privKey } if services := ctx.String("services"); services != "" { - config.Lifecycles = utils.SplitAndTrim(services) + config.Lifecycles = common.CliString2Array(services) } node, err := client.CreateNode(config) if err != nil { diff --git a/cmd/sentinel/cli/cliSettings.go b/cmd/sentinel/cli/cliSettings.go index 12ab7ad1b..a587cb5aa 100644 --- a/cmd/sentinel/cli/cliSettings.go +++ b/cmd/sentinel/cli/cliSettings.go @@ -3,6 +3,7 @@ package cli import ( "errors" "fmt" + common2 "github.com/ledgerwatch/erigon-lib/common" "os" "strings" "time" @@ -132,10 +133,10 @@ func SetupConsensusClientCfg(ctx *cli.Context) (*ConsensusClientCliCfg, error) { cfg.BeaconDataCfg = rawdb.BeaconDataConfigurations[ctx.String(flags.BeaconDBModeFlag.Name)] // Process bootnodes if ctx.String(flags.BootnodesFlag.Name) != "" { - cfg.NetworkCfg.BootNodes = utils.SplitAndTrim(ctx.String(flags.BootnodesFlag.Name)) + cfg.NetworkCfg.BootNodes = common2.CliString2Array(ctx.String(flags.BootnodesFlag.Name)) } if ctx.String(flags.SentinelStaticPeersFlag.Name) != "" { - cfg.NetworkCfg.StaticPeers = utils.SplitAndTrim(ctx.String(flags.SentinelStaticPeersFlag.Name)) + cfg.NetworkCfg.StaticPeers = common2.CliString2Array(ctx.String(flags.SentinelStaticPeersFlag.Name)) fmt.Println(cfg.NetworkCfg.StaticPeers) } cfg.TransitionChain = ctx.Bool(flags.TransitionChainFlag.Name) diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 92b7872f8..77b23ad5c 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -736,6 +736,11 @@ var ( Usage: "URL of Heimdall service", Value: "http://localhost:1317", } + WebSeedsFlag = cli.StringFlag{ + Name: "webseeds", + Usage: "comma-separated URL's, holding metadata about network-support infrastructure (like S3 buckets with snapshots, bootnodes, etc...)", + Value: "", + } // WithoutHeimdallFlag no heimdall (for testing purpose) WithoutHeimdallFlag = cli.BoolFlag{ @@ -861,7 +866,7 @@ func setBootstrapNodesV5(ctx *cli.Context, cfg *p2p.Config) { func GetBootnodesFromFlags(urlsStr, chain string) ([]*enode.Node, error) { var urls []string if urlsStr != "" { - urls = SplitAndTrim(urlsStr) + urls = libcommon.CliString2Array(urlsStr) } else { urls = params.BootnodeURLsOfChain(chain) } @@ -871,7 +876,7 @@ func GetBootnodesFromFlags(urlsStr, chain string) ([]*enode.Node, error) { func setStaticPeers(ctx *cli.Context, cfg *p2p.Config) { var urls []string if ctx.IsSet(StaticPeersFlag.Name) { - urls = SplitAndTrim(ctx.String(StaticPeersFlag.Name)) + urls = libcommon.CliString2Array(ctx.String(StaticPeersFlag.Name)) } else { chain := ctx.String(ChainFlag.Name) urls = params.StaticPeerURLsOfChain(chain) @@ -890,7 +895,7 @@ func setTrustedPeers(ctx *cli.Context, cfg *p2p.Config) { return } - urls := SplitAndTrim(ctx.String(TrustedPeersFlag.Name)) + urls := libcommon.CliString2Array(ctx.String(TrustedPeersFlag.Name)) trustedNodes, err := ParseNodesFromURLs(urls) if err != nil { Fatalf("Option %s: %v", TrustedPeersFlag.Name, err) @@ -1005,7 +1010,7 @@ func setListenAddress(ctx *cli.Context, cfg *p2p.Config) { cfg.ProtocolVersion = ctx.UintSlice(P2pProtocolVersionFlag.Name) } if ctx.IsSet(SentryAddrFlag.Name) { - cfg.SentryAddr = SplitAndTrim(ctx.String(SentryAddrFlag.Name)) + cfg.SentryAddr = libcommon.CliString2Array(ctx.String(SentryAddrFlag.Name)) } // TODO cli lib doesn't store defaults for UintSlice properly so we have to get value directly cfg.AllowedPorts = P2pProtocolAllowedPorts.Value.Value() @@ -1040,18 +1045,6 @@ func setNAT(ctx *cli.Context, cfg *p2p.Config) { } } -// SplitAndTrim splits input separated by a comma -// and trims excessive white space from the substrings. -func SplitAndTrim(input string) (ret []string) { - l := strings.Split(input, ",") - for _, r := range l { - if r = strings.TrimSpace(r); r != "" { - ret = append(ret, r) - } - } - return ret -} - // setEtherbase retrieves the etherbase from the directly specified // command line flags. func setEtherbase(ctx *cli.Context, cfg *ethconfig.Config) { @@ -1232,7 +1225,7 @@ func setTxPool(ctx *cli.Context, fullCfg *ethconfig.Config) { cfg.Disable = true } if ctx.IsSet(TxPoolLocalsFlag.Name) { - locals := SplitAndTrim(ctx.String(TxPoolLocalsFlag.Name)) + locals := libcommon.CliString2Array(ctx.String(TxPoolLocalsFlag.Name)) for _, account := range locals { if !libcommon.IsHexAddress(account) { Fatalf("Invalid account in --txpool.locals: %s", account) @@ -1270,7 +1263,7 @@ func setTxPool(ctx *cli.Context, fullCfg *ethconfig.Config) { } if ctx.IsSet(TxPoolTraceSendersFlag.Name) { // Parse the command separated flag - senderHexes := SplitAndTrim(ctx.String(TxPoolTraceSendersFlag.Name)) + senderHexes := libcommon.CliString2Array(ctx.String(TxPoolTraceSendersFlag.Name)) cfg.TracedSenders = make([]string, len(senderHexes)) for i, senderHex := range senderHexes { sender := libcommon.HexToAddress(senderHex) @@ -1379,7 +1372,7 @@ func setMiner(ctx *cli.Context, cfg *params.MiningConfig) { panic(fmt.Sprintf("Erigon supports only remote miners. Flag --%s or --%s is required", MinerNotifyFlag.Name, MinerSigningKeyFileFlag.Name)) } if ctx.IsSet(MinerNotifyFlag.Name) { - cfg.Notify = SplitAndTrim(ctx.String(MinerNotifyFlag.Name)) + cfg.Notify = libcommon.CliString2Array(ctx.String(MinerNotifyFlag.Name)) } if ctx.IsSet(MinerExtraDataFlag.Name) { cfg.ExtraData = []byte(ctx.String(MinerExtraDataFlag.Name)) @@ -1404,7 +1397,7 @@ func setWhitelist(ctx *cli.Context, cfg *ethconfig.Config) { return } cfg.Whitelist = make(map[uint64]libcommon.Hash) - for _, entry := range SplitAndTrim(whitelist) { + for _, entry := range libcommon.CliString2Array(whitelist) { parts := strings.Split(entry, "=") if len(parts) != 2 { Fatalf("Invalid whitelist entry: %s", entry) @@ -1498,11 +1491,11 @@ func SetEthConfig(ctx *cli.Context, nodeConfig *nodecfg.Config, cfg *ethconfig.C } logger.Info("torrent verbosity", "level", lvl.LogString()) version := "erigon: " + params.VersionWithCommit(params.GitCommit) - cfg.Downloader, err = downloadercfg2.New(cfg.Dirs.Snap, version, lvl, downloadRate, uploadRate, ctx.Int(TorrentPortFlag.Name), ctx.Int(TorrentConnsPerFileFlag.Name), ctx.Int(TorrentDownloadSlotsFlag.Name), ctx.StringSlice(TorrentDownloadSlotsFlag.Name)) + cfg.Downloader, err = downloadercfg2.New(cfg.Dirs, version, lvl, downloadRate, uploadRate, ctx.Int(TorrentPortFlag.Name), ctx.Int(TorrentConnsPerFileFlag.Name), ctx.Int(TorrentDownloadSlotsFlag.Name), ctx.StringSlice(TorrentDownloadSlotsFlag.Name), ctx.String(WebSeedsFlag.Name)) if err != nil { panic(err) } - downloadernat.DoNat(nodeConfig.P2P.NAT, cfg.Downloader, logger) + downloadernat.DoNat(nodeConfig.P2P.NAT, cfg.Downloader.ClientConfig, logger) } nodeConfig.Http.Snap = cfg.Snapshot @@ -1549,7 +1542,7 @@ func SetEthConfig(ctx *cli.Context, nodeConfig *nodecfg.Config, cfg *ethconfig.C if urls == "" { cfg.EthDiscoveryURLs = []string{} } else { - cfg.EthDiscoveryURLs = SplitAndTrim(urls) + cfg.EthDiscoveryURLs = libcommon.CliString2Array(urls) } } // Override any default configs for hard coded networks. @@ -1619,7 +1612,7 @@ func SetDNSDiscoveryDefaults(cfg *ethconfig.Config, genesis libcommon.Hash) { } func SplitTagsFlag(tagsFlag string) map[string]string { - tags := SplitAndTrim(tagsFlag) + tags := libcommon.CliString2Array(tagsFlag) tagsMap := map[string]string{} for _, t := range tags { @@ -1635,17 +1628,6 @@ func SplitTagsFlag(tagsFlag string) map[string]string { return tagsMap } -// MakeConsolePreloads retrieves the absolute paths for the console JavaScript -// scripts to preload before starting. -func MakeConsolePreloads(ctx *cli.Context) []string { - // Skip preloading if there's nothing to preload - if ctx.String(PreloadJSFlag.Name) == "" { - return nil - } - // Otherwise resolve absolute paths and return them - return SplitAndTrim(ctx.String(PreloadJSFlag.Name)) -} - func CobraFlags(cmd *cobra.Command, urfaveCliFlagsLists ...[]cli.Flag) { flags := cmd.PersistentFlags() for _, urfaveCliFlags := range urfaveCliFlagsLists { diff --git a/go.mod b/go.mod index 41acab78a..94d1c3a91 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.19 require ( github.com/erigontech/mdbx-go v0.27.14 - github.com/ledgerwatch/erigon-lib v0.0.0-20230911023914-a17786143476 + github.com/ledgerwatch/erigon-lib v0.0.0-20230912051720-c36f222fd6d0 github.com/ledgerwatch/erigon-snapshot v1.2.1-0.20230911054727-4e865b051314 github.com/ledgerwatch/log/v3 v3.9.0 github.com/ledgerwatch/secp256k1 v1.0.0 diff --git a/go.sum b/go.sum index ff7a7254b..2e362d508 100644 --- a/go.sum +++ b/go.sum @@ -499,8 +499,8 @@ github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v0.0.0-20170224010052-a616ab194758 h1:0D5M2HQSGD3PYPwICLl+/9oulQauOuETfgFvhBDffs0= github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c= github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8= -github.com/ledgerwatch/erigon-lib v0.0.0-20230911023914-a17786143476 h1:fKbEGitRmRmI0H02MaEmnlqQLj3n7TlE6Beasma77yE= -github.com/ledgerwatch/erigon-lib v0.0.0-20230911023914-a17786143476/go.mod h1:Iy7Gah8RFSvAutIr3Unph+ttp/7TMXmXOByXk9sXE6A= +github.com/ledgerwatch/erigon-lib v0.0.0-20230912051720-c36f222fd6d0 h1:i7d9yBkUr0FxmvFqupc/wYNrs11mEwqowivqIFxUkxM= +github.com/ledgerwatch/erigon-lib v0.0.0-20230912051720-c36f222fd6d0/go.mod h1:DRy/PNMCuzakVJFE42OR9F3SARTLxlfK7R4JwP5u/5k= github.com/ledgerwatch/erigon-snapshot v1.2.1-0.20230911054727-4e865b051314 h1:TeQoOW2o0rL5jF4ava+SlB8l0mhzM8ISnq81okJ790c= github.com/ledgerwatch/erigon-snapshot v1.2.1-0.20230911054727-4e865b051314/go.mod h1:3AuPxZc85jkehh/HA9h8gabv5MSi3kb/ddtzBsTVJFo= github.com/ledgerwatch/log/v3 v3.9.0 h1:iDwrXe0PVwBC68Dd94YSsHbMgQ3ufsgjzXtFNFVZFRk= diff --git a/node/rpcstack_test.go b/node/rpcstack_test.go index 0280ab84e..d9b4a643d 100644 --- a/node/rpcstack_test.go +++ b/node/rpcstack_test.go @@ -19,6 +19,7 @@ package node import ( "bytes" "fmt" + "github.com/ledgerwatch/erigon-lib/common" "io" "net/http" "net/url" @@ -86,20 +87,6 @@ type originTest struct { expFail []string } -// splitAndTrim splits input separated by a comma -// and trims excessive white space from the substrings. -// Copied over from flags.go -func splitAndTrim(input string) (ret []string) { - l := strings.Split(input, ",") - for _, r := range l { - r = strings.TrimSpace(r) - if len(r) > 0 { - ret = append(ret, r) - } - } - return ret -} - // TestWebsocketOrigins makes sure the websocket origins are properly handled on the websocket server. func TestWebsocketOrigins(t *testing.T) { tests := []originTest{ @@ -165,7 +152,7 @@ func TestWebsocketOrigins(t *testing.T) { }, } for _, tc := range tests { - srv := createAndStartServer(t, &httpConfig{}, true, &wsConfig{Origins: splitAndTrim(tc.spec)}) + srv := createAndStartServer(t, &httpConfig{}, true, &wsConfig{Origins: common.CliString2Array(tc.spec)}) url := fmt.Sprintf("ws://%v", srv.listenAddr()) for _, origin := range tc.expOk { if err := wsRequest(t, url, origin); err != nil { diff --git a/tests/bor/helper/miner.go b/tests/bor/helper/miner.go index ed743971c..14abe7adc 100644 --- a/tests/bor/helper/miner.go +++ b/tests/bor/helper/miner.go @@ -112,7 +112,7 @@ func InitMiner(genesis *types.Genesis, privKey *ecdsa.PrivateKey, withoutHeimdal return nil, nil, err } - downloaderConfig, err := downloadercfg.New(datadir.New(ddir).Snap, nodeCfg.Version, torrentLogLevel, downloadRate, uploadRate, utils.TorrentPortFlag.Value, utils.TorrentConnsPerFileFlag.Value, utils.TorrentDownloadSlotsFlag.Value, []string{}) + downloaderConfig, err := downloadercfg.New(datadir.New(ddir), nodeCfg.Version, torrentLogLevel, downloadRate, uploadRate, utils.TorrentPortFlag.Value, utils.TorrentConnsPerFileFlag.Value, utils.TorrentDownloadSlotsFlag.Value, []string{}, "") if err != nil { return nil, nil, err } @@ -147,7 +147,7 @@ func InitMiner(genesis *types.Genesis, privKey *ecdsa.PrivateKey, withoutHeimdal ethCfg.TxPool.DBDir = nodeCfg.Dirs.TxPool ethCfg.DeprecatedTxPool.CommitEvery = 15 * time.Second ethCfg.DeprecatedTxPool.StartOnInit = true - ethCfg.Downloader.ListenPort = utils.TorrentPortFlag.Value + minerID + ethCfg.Downloader.ClientConfig.ListenPort = utils.TorrentPortFlag.Value + minerID ethCfg.TxPool.AccountSlots = 1000000 ethCfg.DeprecatedTxPool.AccountSlots = 1000000 ethCfg.DeprecatedTxPool.GlobalSlots = 1000000 diff --git a/turbo/app/backup_cmd.go b/turbo/app/backup_cmd.go index 6dfdc621d..dc7aecda0 100644 --- a/turbo/app/backup_cmd.go +++ b/turbo/app/backup_cmd.go @@ -2,6 +2,7 @@ package app import ( "fmt" + "github.com/ledgerwatch/erigon-lib/common" "os" "path/filepath" @@ -94,14 +95,14 @@ func doBackup(cliCtx *cli.Context) error { var lables = []kv.Label{kv.ChainDB, kv.TxPoolDB, kv.DownloaderDB} if cliCtx.IsSet(BackupToPageSizeFlag.Name) { lables = lables[:0] - for _, l := range utils.SplitAndTrim(cliCtx.String(BackupLabelsFlag.Name)) { + for _, l := range common.CliString2Array(cliCtx.String(BackupLabelsFlag.Name)) { lables = append(lables, kv.UnmarshalLabel(l)) } } var tables []string if cliCtx.IsSet(BackupTablesFlag.Name) { - tables = utils.SplitAndTrim(cliCtx.String(BackupTablesFlag.Name)) + tables = common.CliString2Array(cliCtx.String(BackupTablesFlag.Name)) } readAheadThreads := backup.ReadAheadThreads diff --git a/turbo/cli/default_flags.go b/turbo/cli/default_flags.go index 1595f0319..7344934f2 100644 --- a/turbo/cli/default_flags.go +++ b/turbo/cli/default_flags.go @@ -142,6 +142,7 @@ var DefaultFlags = []cli.Flag{ &utils.DownloaderVerifyFlag, &HealthCheckFlag, &utils.HeimdallURLFlag, + &utils.WebSeedsFlag, &utils.WithoutHeimdallFlag, &utils.HeimdallgRPCAddressFlag, &utils.BorBlockPeriodFlag, diff --git a/turbo/cli/flags.go b/turbo/cli/flags.go index ec5a9d306..471e891e9 100644 --- a/turbo/cli/flags.go +++ b/turbo/cli/flags.go @@ -215,7 +215,7 @@ func ApplyFlagsForEthConfig(ctx *cli.Context, cfg *ethconfig.Config, logger log. ctx.Uint64(PruneReceiptBeforeFlag.Name), ctx.Uint64(PruneTxIndexBeforeFlag.Name), ctx.Uint64(PruneCallTracesBeforeFlag.Name), - utils.SplitAndTrim(ctx.String(ExperimentsFlag.Name)), + libcommon.CliString2Array(ctx.String(ExperimentsFlag.Name)), ) if err != nil { utils.Fatalf(fmt.Sprintf("error while parsing mode: %v", err)) @@ -370,10 +370,10 @@ func setEmbeddedRpcDaemon(ctx *cli.Context, cfg *nodecfg.Config, logger log.Logg AuthRpcPort: ctx.Int(utils.AuthRpcPort.Name), JWTSecretPath: jwtSecretPath, TraceRequests: ctx.Bool(utils.HTTPTraceFlag.Name), - HttpCORSDomain: utils.SplitAndTrim(ctx.String(utils.HTTPCORSDomainFlag.Name)), - HttpVirtualHost: utils.SplitAndTrim(ctx.String(utils.HTTPVirtualHostsFlag.Name)), - AuthRpcVirtualHost: utils.SplitAndTrim(ctx.String(utils.AuthRpcVirtualHostsFlag.Name)), - API: utils.SplitAndTrim(apis), + HttpCORSDomain: libcommon.CliString2Array(ctx.String(utils.HTTPCORSDomainFlag.Name)), + HttpVirtualHost: libcommon.CliString2Array(ctx.String(utils.HTTPVirtualHostsFlag.Name)), + AuthRpcVirtualHost: libcommon.CliString2Array(ctx.String(utils.AuthRpcVirtualHostsFlag.Name)), + API: libcommon.CliString2Array(apis), HTTPTimeouts: rpccfg.HTTPTimeouts{ ReadTimeout: ctx.Duration(HTTPReadTimeoutFlag.Name), WriteTimeout: ctx.Duration(HTTPWriteTimeoutFlag.Name),