Skip to content

Commit

Permalink
Move downloader config after bor (#13374)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mh0lt authored Jan 10, 2025
1 parent 5aa2055 commit 92fb52c
Showing 1 changed file with 33 additions and 31 deletions.
64 changes: 33 additions & 31 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 92fb52c

Please sign in to comment.