Skip to content

Commit

Permalink
naming: seg reopen -> open (#12410)
Browse files Browse the repository at this point in the history
  • Loading branch information
AskAlexSharov authored Oct 22, 2024
1 parent 6c95e9c commit 8f3b14d
Show file tree
Hide file tree
Showing 20 changed files with 105 additions and 105 deletions.
8 changes: 4 additions & 4 deletions cl/antiquary/antiquary.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func (a *Antiquary) Loop() error {
}

logInterval := time.NewTicker(30 * time.Second)
if err := a.sn.ReopenFolder(); err != nil {
if err := a.sn.OpenFolder(); err != nil {
return err
}
defer logInterval.Stop()
Expand Down Expand Up @@ -294,7 +294,7 @@ func (a *Antiquary) antiquate() error {
if err := freezeblocks.DumpBeaconBlocks(a.ctx, a.mainDB, from, to, a.sn.Salt, a.dirs, 1, log.LvlDebug, a.logger); err != nil {
return err
}
if err := a.sn.ReopenFolder(); err != nil {
if err := a.sn.OpenFolder(); err != nil {
return err
}
tx, err := a.mainDB.BeginRw(a.ctx)
Expand All @@ -312,7 +312,7 @@ func (a *Antiquary) antiquate() error {
if err := tx.Commit(); err != nil {
return err
}
if err := a.sn.ReopenFolder(); err != nil {
if err := a.sn.OpenFolder(); err != nil {
return err
}

Expand Down Expand Up @@ -393,7 +393,7 @@ func (a *Antiquary) antiquateBlobs() error {
}
to = (to / snaptype.CaplinMergeLimit) * snaptype.CaplinMergeLimit
a.logger.Info("[Antiquary] Finished Antiquating blobs", "from", currentBlobsProgress, "to", to)
if err := a.sn.ReopenFolder(); err != nil {
if err := a.sn.OpenFolder(); err != nil {
return err
}

Expand Down
2 changes: 1 addition & 1 deletion cl/phase1/stages/stage_history_download.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func SpawnStageHistoryDownload(cfg StageHistoryReconstructionCfg, ctx context.Co
continue
}
if cfg.sn != nil && cfg.sn.SegmentsMax() == 0 {
cfg.sn.ReopenFolder()
cfg.sn.OpenFolder()
}
logArgs = append(logArgs,
"slot", currProgress,
Expand Down
16 changes: 8 additions & 8 deletions cmd/capcli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ func (c *CheckSnapshots) Run(ctx *Context) error {
to = (to / snaptype.CaplinMergeLimit) * snaptype.CaplinMergeLimit

csn := freezeblocks.NewCaplinSnapshots(ethconfig.BlocksFreezing{}, beaconConfig, dirs, log.Root())
if err := csn.ReopenFolder(); err != nil {
if err := csn.OpenFolder(); err != nil {
return err
}

Expand Down Expand Up @@ -517,7 +517,7 @@ func (c *LoopSnapshots) Run(ctx *Context) error {
to = (to / snaptype.CaplinMergeLimit) * snaptype.CaplinMergeLimit

csn := freezeblocks.NewCaplinSnapshots(ethconfig.BlocksFreezing{}, beaconConfig, dirs, log.Root())
if err := csn.ReopenFolder(); err != nil {
if err := csn.OpenFolder(); err != nil {
return err
}

Expand Down Expand Up @@ -559,7 +559,7 @@ func (r *RetrieveHistoricalState) Run(ctx *Context) error {
defer tx.Rollback()

allSnapshots := freezeblocks.NewRoSnapshots(ethconfig.BlocksFreezing{}, dirs.Snap, 0, log.Root())
if err := allSnapshots.ReopenFolder(); err != nil {
if err := allSnapshots.OpenFolder(); err != nil {
return err
}
if err := state_accessors.ReadValidatorsTable(tx, vt); err != nil {
Expand All @@ -571,7 +571,7 @@ func (r *RetrieveHistoricalState) Run(ctx *Context) error {
eth1Getter := getters.NewExecutionSnapshotReader(ctx, blockReader, db)
eth1Getter.SetBeaconChainConfig(beaconConfig)
csn := freezeblocks.NewCaplinSnapshots(ethconfig.BlocksFreezing{}, beaconConfig, dirs, log.Root())
if err := csn.ReopenFolder(); err != nil {
if err := csn.OpenFolder(); err != nil {
return err
}
snr := freezeblocks.NewBeaconSnapshotReader(csn, eth1Getter, beaconConfig)
Expand Down Expand Up @@ -902,7 +902,7 @@ func (b *BlobArchiveStoreCheck) Run(ctx *Context) error {
defer db.Close()

csn := freezeblocks.NewCaplinSnapshots(ethconfig.BlocksFreezing{}, beaconConfig, dirs, log.Root())
if err := csn.ReopenFolder(); err != nil {
if err := csn.OpenFolder(); err != nil {
return err
}
snr := freezeblocks.NewBeaconSnapshotReader(csn, nil, beaconConfig)
Expand Down Expand Up @@ -1017,7 +1017,7 @@ func (c *CheckBlobsSnapshots) Run(ctx *Context) error {
defer tx.Rollback()

csn := freezeblocks.NewCaplinSnapshots(ethconfig.BlocksFreezing{}, beaconConfig, dirs, log.Root())
if err := csn.ReopenFolder(); err != nil {
if err := csn.OpenFolder(); err != nil {
return err
}
to := csn.FrozenBlobs()
Expand Down Expand Up @@ -1078,7 +1078,7 @@ func (c *CheckBlobsSnapshotsCount) Run(ctx *Context) error {
defer tx.Rollback()

csn := freezeblocks.NewCaplinSnapshots(ethconfig.BlocksFreezing{}, beaconConfig, dirs, log.Root())
if err := csn.ReopenFolder(); err != nil {
if err := csn.OpenFolder(); err != nil {
return err
}
to := csn.FrozenBlobs()
Expand Down Expand Up @@ -1145,7 +1145,7 @@ func (c *DumpBlobsSnapshotsToStore) Run(ctx *Context) error {
defer tx.Rollback()

csn := freezeblocks.NewCaplinSnapshots(ethconfig.BlocksFreezing{}, beaconConfig, dirs, log.Root())
if err := csn.ReopenFolder(); err != nil {
if err := csn.OpenFolder(); err != nil {
return err
}
to := csn.FrozenBlobs()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func NewHeimdallSimulator(ctx context.Context, snapDir string, logger log.Logger
}
}

if err = snapshots.ReopenFolder(); err != nil {
if err = snapshots.OpenFolder(); err != nil {
return nil, err
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/hack/hack.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ func extractBodies(datadir string) error {
KeepBlocks: true,
ProduceE2: false,
}, filepath.Join(datadir, "snapshots"), 0, log.New())
snaps.ReopenFolder()
snaps.OpenFolder()

/* method Iterate was removed, need re-implement
snaps.Bodies.View(func(sns []*snapshotsync.BodySegment) error {
Expand Down
6 changes: 3 additions & 3 deletions cmd/integration/commands/stages.go
Original file line number Diff line number Diff line change
Expand Up @@ -1300,11 +1300,11 @@ func allSnapshots(ctx context.Context, db kv.RoDB, logger log.Logger) (*freezebl

g := &errgroup.Group{}
g.Go(func() error {
_allSnapshotsSingleton.OptimisticalyReopenFolder()
_allSnapshotsSingleton.OptimisticalyOpenFolder()
return nil
})
g.Go(func() error {
_allBorSnapshotsSingleton.OptimisticalyReopenFolder()
_allBorSnapshotsSingleton.OptimisticalyOpenFolder()
return nil
})
g.Go(func() error { return _aggSingleton.OpenFolder() })
Expand All @@ -1314,7 +1314,7 @@ func allSnapshots(ctx context.Context, db kv.RoDB, logger log.Logger) (*freezebl
_, beaconConfig, _, err = clparams.GetConfigsByNetworkName(chainConfig.ChainName)
if err == nil {
_allCaplinSnapshotsSingleton = freezeblocks.NewCaplinSnapshots(snapCfg, beaconConfig, dirs, logger)
if err = _allCaplinSnapshotsSingleton.ReopenFolder(); err != nil {
if err = _allCaplinSnapshotsSingleton.OpenFolder(); err != nil {
return err
}
_allCaplinSnapshotsSingleton.LogStat("caplin")
Expand Down
8 changes: 4 additions & 4 deletions cmd/rpcdaemon/cli/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -423,8 +423,8 @@ func RemoteServices(ctx context.Context, cfg *httpcfg.HttpCfg, logger log.Logger
return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, err
}
if allSegmentsDownloadComplete {
allSnapshots.OptimisticalyReopenFolder()
allBorSnapshots.OptimisticalyReopenFolder()
allSnapshots.OptimisticalyOpenFolder()
allBorSnapshots.OptimisticalyOpenFolder()

allSnapshots.LogStat("remote")
allBorSnapshots.LogStat("bor:remote")
Expand Down Expand Up @@ -452,12 +452,12 @@ func RemoteServices(ctx context.Context, cfg *httpcfg.HttpCfg, logger log.Logger
logger.Warn("[snapshots] reopen", "err", err)
return nil
}
if err := allSnapshots.ReopenList(reply.BlocksFiles, true); err != nil {
if err := allSnapshots.OpenList(reply.BlocksFiles, true); err != nil {
logger.Error("[snapshots] reopen", "err", err)
} else {
allSnapshots.LogStat("reopen")
}
if err := allBorSnapshots.ReopenList(reply.BlocksFiles, true); err != nil {
if err := allBorSnapshots.OpenList(reply.BlocksFiles, true); err != nil {
logger.Error("[bor snapshots] reopen", "err", err)
} else {
allBorSnapshots.LogStat("bor:reopen")
Expand Down
8 changes: 4 additions & 4 deletions cmd/snapshots/cmp/cmp.go
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ func (c comparitor) compareHeaders(ctx context.Context, f1ents []fs.DirEntry, f2
NoDownloader: true,
}, info1.Dir(), info1.From, logger)

f1snaps.ReopenList([]string{ent1.Name()}, false)
f1snaps.OpenList([]string{ent1.Name()}, false)

info2, _, _ := snaptype.ParseFileName(c.session2.LocalFsRoot(), ent1.Name())

Expand All @@ -491,7 +491,7 @@ func (c comparitor) compareHeaders(ctx context.Context, f1ents []fs.DirEntry, f2
NoDownloader: true,
}, info2.Dir(), info2.From, logger)

f2snaps.ReopenList([]string{ent2.Name()}, false)
f2snaps.OpenList([]string{ent2.Name()}, false)

err = func() error {
logger.Info(fmt.Sprintf("Comparing %s %s", ent1.Name(), ent2.Name()))
Expand Down Expand Up @@ -761,7 +761,7 @@ func (c comparitor) compareBodies(ctx context.Context, f1ents []*BodyEntry, f2en
NoDownloader: true,
}, info1.Dir(), info1.From, logger)

f1snaps.ReopenList([]string{ent1.Body.Name(), ent1.Transactions.Name()}, false)
f1snaps.OpenList([]string{ent1.Body.Name(), ent1.Transactions.Name()}, false)

info2, _, _ := snaptype.ParseFileName(c.session2.LocalFsRoot(), ent2.Body.Name())

Expand All @@ -770,7 +770,7 @@ func (c comparitor) compareBodies(ctx context.Context, f1ents []*BodyEntry, f2en
NoDownloader: true,
}, info2.Dir(), info2.From, logger)

f2snaps.ReopenList([]string{ent2.Body.Name(), ent2.Transactions.Name()}, false)
f2snaps.OpenList([]string{ent2.Body.Name(), ent2.Transactions.Name()}, false)

err := func() error {
logger.Info(fmt.Sprintf("Comparing %s %s", ent1.Body.Name(), ent2.Body.Name()))
Expand Down
4 changes: 2 additions & 2 deletions eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -1447,9 +1447,9 @@ func setUpBlockReader(ctx context.Context, db kv.RwDB, dirs datadir.Dirs, snConf
return nil, nil, nil, nil, nil, err
}
if allSegmentsDownloadComplete {
allSnapshots.OptimisticalyReopenFolder()
allSnapshots.OptimisticalyOpenFolder()
if isBor {
allBorSnapshots.OptimisticalyReopenFolder()
allBorSnapshots.OptimisticalyOpenFolder()
}
_ = agg.OpenFolder()
} else {
Expand Down
10 changes: 5 additions & 5 deletions eth/stagedsync/stage_snapshots.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,12 +241,12 @@ func DownloadAndIndexSnapshotsIfNeed(s *StageState, ctx context.Context, tx kv.R
}
}

if err := cfg.blockReader.Snapshots().ReopenFolder(); err != nil {
if err := cfg.blockReader.Snapshots().OpenFolder(); err != nil {
return err
}

if cfg.chainConfig.Bor != nil {
if err := cfg.blockReader.BorSnapshots().ReopenFolder(); err != nil {
if err := cfg.blockReader.BorSnapshots().OpenFolder(); err != nil {
return err
}
}
Expand Down Expand Up @@ -275,7 +275,7 @@ func DownloadAndIndexSnapshotsIfNeed(s *StageState, ctx context.Context, tx kv.R
return err
}

if err := cfg.blockReader.Snapshots().ReopenSegments([]snaptype.Type{coresnaptype.Headers, coresnaptype.Bodies}, true); err != nil {
if err := cfg.blockReader.Snapshots().OpenSegments([]snaptype.Type{coresnaptype.Headers, coresnaptype.Bodies}, true); err != nil {
return err
}

Expand Down Expand Up @@ -1268,11 +1268,11 @@ func (u *snapshotUploader) removeBefore(before uint64) {
if len(toRemove) > 0 {
if snapshots, ok := u.cfg.blockReader.Snapshots().(*freezeblocks.RoSnapshots); ok {
snapshots.SetSegmentsMin(before)
snapshots.ReopenList(toReopen, true)
snapshots.OpenList(toReopen, true)
}

if snapshots, ok := u.cfg.blockReader.BorSnapshots().(*freezeblocks.BorRoSnapshots); ok {
snapshots.ReopenList(borToReopen, true)
snapshots.OpenList(borToReopen, true)
snapshots.SetSegmentsMin(before)
}

Expand Down
2 changes: 1 addition & 1 deletion p2p/enode/nodedb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ func TestDBPersistency(t *testing.T) {
}
db.Close()

// ReopenSegments the database and check the value
// OpenSegments the database and check the value
db, err = OpenDB(context.Background(), filepath.Join(root, "database"), root, log.Root())
if err != nil {
t.Fatalf("failed to open persistent database: %v", err)
Expand Down
6 changes: 3 additions & 3 deletions p2p/sentry/simulator/sentry_simulator.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,13 @@ func NewSentry(ctx context.Context, chain string, snapshotLocation string, peerC

knownSnapshots.InitSegments(files)

//s.knownSnapshots.ReopenList([]string{ent2.Name()}, false)
//s.knownSnapshots.OpenList([]string{ent2.Name()}, false)
activeSnapshots := freezeblocks.NewRoSnapshots(ethconfig.BlocksFreezing{
ProduceE2: false,
NoDownloader: true,
}, torrentDir, 0, logger)

if err := activeSnapshots.ReopenFolder(); err != nil {
if err := activeSnapshots.OpenFolder(); err != nil {
return nil, err
}

Expand Down Expand Up @@ -439,7 +439,7 @@ func (s *server) getHeader(ctx context.Context, blockNum uint64) (*coretypes.Hea
}
}

s.activeSnapshots.ReopenSegments([]snaptype.Type{coresnaptype.Headers}, true)
s.activeSnapshots.OpenSegments([]snaptype.Type{coresnaptype.Headers}, true)

header, err = s.blockReader.Header(ctx, nil, common.Hash{}, blockNum)

Expand Down
6 changes: 3 additions & 3 deletions turbo/app/snapshots_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -1058,21 +1058,21 @@ func openSnaps(ctx context.Context, dirs datadir.Dirs, chainDB kv.RwDB, logger l
cfg := ethconfig.NewSnapCfg(false, true, true, chainConfig.ChainName)

blockSnaps = freezeblocks.NewRoSnapshots(cfg, dirs.Snap, 0, logger)
if err = blockSnaps.ReopenFolder(); err != nil {
if err = blockSnaps.OpenFolder(); err != nil {
return
}
blockSnaps.LogStat("block")

borSnaps = freezeblocks.NewBorRoSnapshots(cfg, dirs.Snap, 0, logger)
if err = borSnaps.ReopenFolder(); err != nil {
if err = borSnaps.OpenFolder(); err != nil {
return
}

var beaconConfig *clparams.BeaconChainConfig
_, beaconConfig, _, err = clparams.GetConfigsByNetworkName(chainConfig.ChainName)
if err == nil {
csn = freezeblocks.NewCaplinSnapshots(cfg, beaconConfig, dirs, logger)
if err = csn.ReopenFolder(); err != nil {
if err = csn.OpenFolder(); err != nil {
return
}
csn.LogStat("caplin")
Expand Down
4 changes: 2 additions & 2 deletions turbo/services/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ type FullBlockReader interface {

type BlockSnapshots interface {
LogStat(label string)
ReopenFolder() error
ReopenSegments(types []snaptype.Type, allowGaps bool) error
OpenFolder() error
OpenSegments(types []snaptype.Type, allowGaps bool) error
SegmentsMax() uint64
SegmentsMin() uint64
Delete(fileName string) error
Expand Down
Loading

0 comments on commit 8f3b14d

Please sign in to comment.