From 92fb52c5aca8eefa9c16ebbe3fe1102042964577 Mon Sep 17 00:00:00 2001 From: Mark Holt <135143369+mh0lt@users.noreply.github.com> Date: Fri, 10 Jan 2025 15:10:23 +0000 Subject: [PATCH] Move downloader config after bor (#13374) This fixes `no metadata` in the downloader becuase checkpoints and milestones are only optionally included at the moment. If the downloader config is initiated before the bor flags have run the optional files will be exluded from the downloading whitelist and therefore ignore. --- cmd/utils/flags.go | 64 ++++++++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 31 deletions(-) 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