Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 38d5672

Browse files
mh0ltAskAlexSharov
authored andcommittedMay 27, 2024·
Add flag for bor waypoint types (#10281)
This adds additional flag processing to disable waypoint snaps is `bor.waypoints` is not set Co-authored-by: alex.sharov <AskAlexSharov@gmail.com>
1 parent c0be07d commit 38d5672

File tree

4 files changed

+26
-7
lines changed

4 files changed

+26
-7
lines changed
 

‎cmd/utils/flags.go

+2
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ import (
6060
"github.com/ledgerwatch/erigon/p2p/nat"
6161
"github.com/ledgerwatch/erigon/p2p/netutil"
6262
"github.com/ledgerwatch/erigon/params"
63+
borsnaptype "github.com/ledgerwatch/erigon/polygon/bor/snaptype"
6364
"github.com/ledgerwatch/erigon/rpc/rpccfg"
6465
"github.com/ledgerwatch/erigon/turbo/logging"
6566
)
@@ -1583,6 +1584,7 @@ func setBorConfig(ctx *cli.Context, cfg *ethconfig.Config) {
15831584
cfg.WithoutHeimdall = ctx.Bool(WithoutHeimdallFlag.Name)
15841585
cfg.WithHeimdallMilestones = ctx.Bool(WithHeimdallMilestones.Name)
15851586
cfg.WithHeimdallWaypointRecording = ctx.Bool(WithHeimdallWaypoints.Name)
1587+
borsnaptype.RecordWayPoints(cfg.WithHeimdallWaypointRecording)
15861588
cfg.PolygonSync = ctx.Bool(PolygonSyncFlag.Name)
15871589
}
15881590

‎migrations/prohibit_new_downloads2.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ var ProhibitNewDownloadsLock2 = Migration{
4545
locked = append(locked, t.Name())
4646
}
4747

48-
for _, t := range borsnaptype.BorSnapshotTypes {
48+
for _, t := range borsnaptype.BorSnapshotTypes() {
4949
locked = append(locked, t.Name())
5050
}
5151

‎polygon/bor/snaptype/types.go

+20-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ import (
3131
)
3232

3333
func init() {
34-
borTypes := append(coresnaptype.BlockSnapshotTypes, BorSnapshotTypes...)
34+
initTypes()
35+
}
36+
37+
func initTypes() {
38+
borTypes := append(coresnaptype.BlockSnapshotTypes, BorSnapshotTypes()...)
3539

3640
snapcfg.RegisterKnownTypes(networkname.MumbaiChainName, borTypes)
3741
snapcfg.RegisterKnownTypes(networkname.AmoyChainName, borTypes)
@@ -402,10 +406,23 @@ var (
402406
return buildValueIndex(ctx, sn, salt, d, firstMilestoneId, tmpDir, p, lvl, logger)
403407
}),
404408
)
405-
406-
BorSnapshotTypes = []snaptype.Type{BorEvents, BorSpans, BorCheckpoints, BorMilestones}
407409
)
408410

411+
var recordWaypoints bool
412+
413+
func RecordWayPoints(value bool) {
414+
recordWaypoints = value
415+
initTypes()
416+
}
417+
418+
func BorSnapshotTypes() []snaptype.Type {
419+
if recordWaypoints {
420+
return []snaptype.Type{BorEvents, BorSpans, BorCheckpoints, BorMilestones}
421+
}
422+
423+
return []snaptype.Type{BorEvents, BorSpans}
424+
}
425+
409426
func extractValueRange(ctx context.Context, table string, valueFrom, valueTo uint64, db kv.RoDB, collect func([]byte) error, workers int, lvl log.Lvl, logger log.Logger) (uint64, error) {
410427
logEvery := time.NewTicker(20 * time.Second)
411428
defer logEvery.Stop()

‎turbo/snapshotsync/freezeblocks/bor_snapshots.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ func (br *BlockRetire) retireBorBlocks(ctx context.Context, minBlockNum uint64,
101101
return nil
102102
}
103103

104-
err := merger.Merge(ctx, &snapshots.RoSnapshots, borsnaptype.BorSnapshotTypes, rangesToMerge, snapshots.Dir(), true /* doIndex */, onMerge, onDelete)
104+
err := merger.Merge(ctx, &snapshots.RoSnapshots, borsnaptype.BorSnapshotTypes(), rangesToMerge, snapshots.Dir(), true /* doIndex */, onMerge, onDelete)
105105

106106
if err != nil {
107107
return blocksRetired, err
@@ -127,7 +127,7 @@ type BorRoSnapshots struct {
127127
// - gaps are not allowed
128128
// - segment have [from:to] semantic
129129
func NewBorRoSnapshots(cfg ethconfig.BlocksFreezing, snapDir string, segmentsMin uint64, logger log.Logger) *BorRoSnapshots {
130-
return &BorRoSnapshots{*newRoSnapshots(cfg, snapDir, borsnaptype.BorSnapshotTypes, segmentsMin, logger)}
130+
return &BorRoSnapshots{*newRoSnapshots(cfg, snapDir, borsnaptype.BorSnapshotTypes(), segmentsMin, logger)}
131131
}
132132

133133
func (s *BorRoSnapshots) Ranges() []Range {
@@ -199,7 +199,7 @@ func removeBorOverlaps(dir string, active []snaptype.FileInfo, max uint64) {
199199
}
200200

201201
func (s *BorRoSnapshots) ReopenFolder() error {
202-
files, _, err := typedSegments(s.dir, s.segmentsMin.Load(), borsnaptype.BorSnapshotTypes, false)
202+
files, _, err := typedSegments(s.dir, s.segmentsMin.Load(), borsnaptype.BorSnapshotTypes(), false)
203203
if err != nil {
204204
return err
205205
}

0 commit comments

Comments
 (0)
Please sign in to comment.