Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E3: make state snapshots download optional #13107

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,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 @@ -766,6 +771,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 @@ -1872,6 +1878,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
Loading