erigon3: set seedable files to 32 steps #5534

This commit is contained in:
Alex Sharov 2022-09-27 10:51:14 +07:00 committed by GitHub
parent fb44051a82
commit 9cac57bcc9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 9 deletions

View File

@ -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()))

View File

@ -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",

View File

@ -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 {

View File

@ -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") }