Skip to content

Commit

Permalink
E3: make state snapshots download optional (#13107)
Browse files Browse the repository at this point in the history
  • Loading branch information
Giulio2002 authored Dec 20, 2024
1 parent 3b7ac41 commit 0c86f24
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
7 changes: 7 additions & 0 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,11 @@ var (
Name: ethconfig.FlagSnapStateStop,
Usage: "Workaround to stop producing new state files, if you meet some state-related critical bug. It will stop aggregate DB history in a state files. DB will grow and may slightly slow-down - and removing this flag in future will not fix this effect (db size will not greatly reduce).",
}
SnapSkipStateSnapshotDownloadFlag = cli.BoolFlag{
Name: "snap.skip-state-snapshot-download",
Usage: "Skip state download and start from genesis block",
Value: false,
}
TorrentVerbosityFlag = cli.IntFlag{
Name: "torrent.verbosity",
Value: 2,
Expand Down Expand Up @@ -749,6 +754,7 @@ var (
Usage: "Enable WRITE_MAP feature for fast database writes and fast commit times",
Value: true,
}

HealthCheckFlag = cli.BoolFlag{
Name: "healthcheck",
Usage: "Enabling grpc health check",
Expand Down Expand Up @@ -1860,6 +1866,7 @@ func SetEthConfig(ctx *cli.Context, nodeConfig *nodecfg.Config, cfg *ethconfig.C
cfg.Snapshot.KeepBlocks = ctx.Bool(SnapKeepBlocksFlag.Name)
cfg.Snapshot.ProduceE2 = !ctx.Bool(SnapStopFlag.Name)
cfg.Snapshot.ProduceE3 = !ctx.Bool(SnapStateStopFlag.Name)
cfg.Snapshot.DisableDownloadE3 = ctx.Bool(SnapSkipStateSnapshotDownloadFlag.Name)
cfg.Snapshot.NoDownloader = ctx.Bool(NoDownloaderFlag.Name)
cfg.Snapshot.Verify = ctx.Bool(DownloaderVerifyFlag.Name)
cfg.Snapshot.DownloaderAddr = strings.TrimSpace(ctx.String(DownloaderAddrFlag.Name))
Expand Down
15 changes: 8 additions & 7 deletions eth/ethconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,14 @@ func init() {
//go:generate gencodec -dir . -type Config -formats toml -out gen_config.go

type BlocksFreezing struct {
KeepBlocks bool // produce new snapshots of blocks but don't remove blocks from DB
ProduceE2 bool // produce new block files
ProduceE3 bool // produce new state files
NoDownloader bool // possible to use snapshots without calling Downloader
Verify bool // verify snapshots on startup
DownloaderAddr string
ChainName string
KeepBlocks bool // produce new snapshots of blocks but don't remove blocks from DB
ProduceE2 bool // produce new block files
ProduceE3 bool // produce new state files
NoDownloader bool // possible to use snapshots without calling Downloader
Verify bool // verify snapshots on startup
DisableDownloadE3 bool // disable download state snapshots
DownloaderAddr string
ChainName string
}

func (s BlocksFreezing) String() string {
Expand Down
8 changes: 6 additions & 2 deletions turbo/snapshotsync/snapshotsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func adjustBlockPrune(blocks, minBlocksToDownload uint64) uint64 {
return blocks - blocks%snaptype.Erigon2MergeLimit
}

func shouldUseStepsForPruning(name string) bool {
func isStateSnapshot(name string) bool {
return strings.HasPrefix(name, "idx") || strings.HasPrefix(name, "history") || strings.HasPrefix(name, "accessor")
}

Expand All @@ -182,7 +182,7 @@ func buildBlackListForPruning(pruneMode bool, stepPrune, minBlockToDownload, blo
}
var _, to uint64
var err error
if shouldUseStepsForPruning(name) {
if isStateSnapshot(name) {
// parse "from" (0) and "to" (64) from the name
// parse the snapshot "kind". e.g kind of 'idx/v1-accounts.0-64.ef' is "idx/v1-accounts"
rangeString := strings.Split(name, ".")[1]
Expand Down Expand Up @@ -337,6 +337,10 @@ func WaitForDownloader(ctx context.Context, logPrefix string, dirs datadir.Dirs,
if caplin == OnlyCaplin && !strings.Contains(p.Name, "beaconblocks") && !strings.Contains(p.Name, "blobsidecars") && !strings.Contains(p.Name, "caplin") {
continue
}

if isStateSnapshot(p.Name) && blockReader.FreezingCfg().DisableDownloadE3 {
continue
}
if !blobs && strings.Contains(p.Name, "blobsidecars") {
continue
}
Expand Down

0 comments on commit 0c86f24

Please sign in to comment.