diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index de1539344f0..42da9f80cd5 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -1888,37 +1888,6 @@ func SetEthConfig(ctx *cli.Context, nodeConfig *nodecfg.Config, cfg *ethconfig.C cfg.Snapshot.Verify = ctx.Bool(DownloaderVerifyFlag.Name) cfg.Snapshot.DownloaderAddr = strings.TrimSpace(ctx.String(DownloaderAddrFlag.Name)) cfg.Snapshot.ChainName = chain - if cfg.Snapshot.DownloaderAddr == "" { - downloadRateStr := ctx.String(TorrentDownloadRateFlag.Name) - uploadRateStr := ctx.String(TorrentUploadRateFlag.Name) - var downloadRate, uploadRate datasize.ByteSize - if err := downloadRate.UnmarshalText([]byte(downloadRateStr)); err != nil { - panic(err) - } - if err := uploadRate.UnmarshalText([]byte(uploadRateStr)); err != nil { - panic(err) - } - lvl, _, err := downloadercfg2.Int2LogLevel(ctx.Int(TorrentVerbosityFlag.Name)) - if err != nil { - panic(err) - } - logger.Info("torrent verbosity", "level", lvl.LogString()) - version := "erigon: " + params.VersionWithCommit(params.GitCommit) - webseedsList := libcommon.CliString2Array(ctx.String(WebSeedsFlag.Name)) - if known, ok := snapcfg.KnownWebseeds[chain]; ok { - webseedsList = append(webseedsList, known...) - } - cfg.Downloader, err = downloadercfg2.New(ctx.Context, cfg.Dirs, version, lvl, downloadRate, uploadRate, - ctx.Int(TorrentPortFlag.Name), ctx.Int(TorrentConnsPerFileFlag.Name), ctx.Int(TorrentDownloadSlotsFlag.Name), - libcommon.CliString2Array(ctx.String(TorrentStaticPeersFlag.Name)), - webseedsList, chain, true, ctx.Bool(DbWriteMapFlag.Name), - ) - if err != nil { - panic(err) - } - downloadernat.DoNat(nodeConfig.P2P.NAT, cfg.Downloader.ClientConfig, logger) - } - nodeConfig.Http.Snap = cfg.Snapshot if ctx.Command.Name == "import" { @@ -2009,6 +1978,39 @@ func SetEthConfig(ctx *cli.Context, nodeConfig *nodecfg.Config, cfg *ethconfig.C if ctx.IsSet(TrustedSetupFile.Name) { libkzg.SetTrustedSetupFilePath(ctx.String(TrustedSetupFile.Name)) } + + // Do this after chain config as there are chain type registration + // dependencies for know config which need to be set-up + if cfg.Snapshot.DownloaderAddr == "" { + downloadRateStr := ctx.String(TorrentDownloadRateFlag.Name) + uploadRateStr := ctx.String(TorrentUploadRateFlag.Name) + var downloadRate, uploadRate datasize.ByteSize + if err := downloadRate.UnmarshalText([]byte(downloadRateStr)); err != nil { + panic(err) + } + if err := uploadRate.UnmarshalText([]byte(uploadRateStr)); err != nil { + panic(err) + } + lvl, _, err := downloadercfg2.Int2LogLevel(ctx.Int(TorrentVerbosityFlag.Name)) + if err != nil { + panic(err) + } + logger.Info("torrent verbosity", "level", lvl.LogString()) + version := "erigon: " + params.VersionWithCommit(params.GitCommit) + webseedsList := libcommon.CliString2Array(ctx.String(WebSeedsFlag.Name)) + if known, ok := snapcfg.KnownWebseeds[chain]; ok { + webseedsList = append(webseedsList, known...) + } + cfg.Downloader, err = downloadercfg2.New(ctx.Context, cfg.Dirs, version, lvl, downloadRate, uploadRate, + ctx.Int(TorrentPortFlag.Name), ctx.Int(TorrentConnsPerFileFlag.Name), ctx.Int(TorrentDownloadSlotsFlag.Name), + libcommon.CliString2Array(ctx.String(TorrentStaticPeersFlag.Name)), + webseedsList, chain, true, ctx.Bool(DbWriteMapFlag.Name), + ) + if err != nil { + panic(err) + } + downloadernat.DoNat(nodeConfig.P2P.NAT, cfg.Downloader.ClientConfig, logger) + } } // SetDNSDiscoveryDefaults configures DNS discovery with the given URL if