diff --git a/cmd/downloader/downloader/util.go b/cmd/downloader/downloader/util.go index 30f1dd67f..437dcef64 100644 --- a/cmd/downloader/downloader/util.go +++ b/cmd/downloader/downloader/util.go @@ -165,7 +165,7 @@ func seedableHistorySnapshots(dir string) ([]string, error) { if err != nil { return nil, fmt.Errorf("ParseFileName: %w", err) } - if to-from != 8 { + if to-from != snap.Erigon3SeedableSteps { continue } res = append(res, filepath.Join("history", f.Name())) diff --git a/turbo/app/snapshots.go b/turbo/app/snapshots.go index 0fd586a5b..6ddd1aeb4 100644 --- a/turbo/app/snapshots.go +++ b/turbo/app/snapshots.go @@ -122,7 +122,7 @@ var ( SnapshotSegmentSizeFlag = cli.Uint64Flag{ Name: "segment.size", Usage: "Amount of blocks in each segment", - Value: snap.Erigon21SegmentSize, + Value: snap.Erigon2SegmentSize, } SnapshotRebuildFlag = cli.BoolFlag{ Name: "rebuild", diff --git a/turbo/snapshotsync/block_snapshots.go b/turbo/snapshotsync/block_snapshots.go index f538ca1a5..177c34a22 100644 --- a/turbo/snapshotsync/block_snapshots.go +++ b/turbo/snapshotsync/block_snapshots.go @@ -936,7 +936,7 @@ func Segments(dir string) (res []snap.FileInfo, missingSnapshots []Range, err er func chooseSegmentEnd(from, to, blocksPerFile uint64) uint64 { next := (from/blocksPerFile + 1) * blocksPerFile to = cmp.Min(next, to) - return to - (to % snap.Erigon21MinSegmentSize) // round down to the nearest 1k + return to - (to % snap.Erigon2MinSegmentSize) // round down to the nearest 1k } type BlockRetire struct { @@ -1075,7 +1075,7 @@ type DBEventNotifier interface { func retireBlocks(ctx context.Context, blockFrom, blockTo uint64, chainID uint256.Int, tmpDir string, snapshots *RoSnapshots, db kv.RoDB, workers int, downloader proto_downloader.DownloaderClient, lvl log.Lvl, notifier DBEventNotifier) error { log.Log(lvl, "[snapshots] Retire Blocks", "range", fmt.Sprintf("%dk-%dk", blockFrom/1000, blockTo/1000)) // in future we will do it in background - if err := DumpBlocks(ctx, blockFrom, blockTo, snap.Erigon21SegmentSize, tmpDir, snapshots.Dir(), db, workers, lvl); err != nil { + if err := DumpBlocks(ctx, blockFrom, blockTo, snap.Erigon2SegmentSize, tmpDir, snapshots.Dir(), db, workers, lvl); err != nil { return fmt.Errorf("DumpBlocks: %w", err) } if err := snapshots.ReopenFolder(); err != nil { @@ -1867,7 +1867,7 @@ func (r Range) String() string { return fmt.Sprintf("%dk-%dk", r.from/1000, r.to func (*Merger) FindMergeRanges(currentRanges []Range) (toMerge []Range) { for i := len(currentRanges) - 1; i > 0; i-- { r := currentRanges[i] - if r.to-r.from >= snap.Erigon21SegmentSize { // is complete .seg + if r.to-r.from >= snap.Erigon2SegmentSize { // is complete .seg continue } @@ -2061,7 +2061,7 @@ func BuildProtoRequest(downloadRequest []DownloadRequest) *proto_downloader.Down }) } } else { - if r.ranges.to-r.ranges.from != snap.Erigon21SegmentSize { + if r.ranges.to-r.ranges.from != snap.Erigon2SegmentSize { continue } for _, t := range snap.AllSnapshotTypes { diff --git a/turbo/snapshotsync/snap/files.go b/turbo/snapshotsync/snap/files.go index 9e4ff6851..462edfb3c 100644 --- a/turbo/snapshotsync/snap/files.go +++ b/turbo/snapshotsync/snap/files.go @@ -133,8 +133,9 @@ func ParseFileName(dir, fileName string) (res FileInfo, err error) { return FileInfo{From: from * 1_000, To: to * 1_000, Path: filepath.Join(dir, fileName), T: snapshotType, Ext: ext}, nil } -const Erigon21SegmentSize = 500_000 -const Erigon21MinSegmentSize = 1_000 +const Erigon3SeedableSteps = 32 +const Erigon2SegmentSize = 500_000 +const Erigon2MinSegmentSize = 1_000 // FileInfo - parsed file metadata type FileInfo struct { @@ -146,7 +147,7 @@ type FileInfo struct { } func (f FileInfo) TorrentFileExists() bool { return common.FileExist(f.Path + ".torrent") } -func (f FileInfo) Seedable() bool { return f.To-f.From == Erigon21SegmentSize } +func (f FileInfo) Seedable() bool { return f.To-f.From == Erigon2SegmentSize } func (f FileInfo) NeedTorrentFile() bool { return f.Seedable() && !f.TorrentFileExists() } func IdxFiles(dir string) (res []FileInfo, err error) { return FilesWithExt(dir, ".idx") }