diff --git a/core/rawdb/accessors_chain.go b/core/rawdb/accessors_chain.go index 573f1ce6bd1..9be7e938bee 100644 --- a/core/rawdb/accessors_chain.go +++ b/core/rawdb/accessors_chain.go @@ -88,19 +88,6 @@ func TruncateCanonicalHash(tx kv.RwTx, blockFrom uint64, markChainAsBad bool) er return nil } -// IsCanonicalHashDeprecated determines whether a header with the given hash is on the canonical chain. -func IsCanonicalHashDeprecated(db kv.Getter, hash common.Hash) (bool, *uint64, error) { - number := ReadHeaderNumber(db, hash) - if number == nil { - return false, nil, nil - } - canonicalHash, err := ReadCanonicalHash(db, *number) - if err != nil { - return false, nil, err - } - return canonicalHash != (common.Hash{}) && canonicalHash == hash, number, nil -} - func IsCanonicalHash(db kv.Getter, hash common.Hash, number uint64) (bool, error) { canonicalHash, err := ReadCanonicalHash(db, number) if err != nil { diff --git a/turbo/snapshotsync/freezeblocks/block_snapshots.go b/turbo/snapshotsync/freezeblocks/block_snapshots.go index d6552acc416..3ab51fdb637 100644 --- a/turbo/snapshotsync/freezeblocks/block_snapshots.go +++ b/turbo/snapshotsync/freezeblocks/block_snapshots.go @@ -436,13 +436,15 @@ func (s *RoSnapshots) idxAvailability() uint64 { // - user must be able: delete any snapshot file and Erigon will self-heal by re-downloading // - RPC return Nil for historical blocks if snapshots are not open func (s *RoSnapshots) OptimisticReopenWithDB(db kv.RoDB) { - _ = db.View(context.Background(), func(tx kv.Tx) error { - snList, _, err := rawdb.ReadSnapshots(tx) + var snList []string + _ = db.View(context.Background(), func(tx kv.Tx) (err error) { + snList, _, err = rawdb.ReadSnapshots(tx) if err != nil { return err } - return s.ReopenList(snList, true) + return nil }) + _ = s.ReopenList(snList, true) } func (s *RoSnapshots) LS() { @@ -484,6 +486,8 @@ func (s *RoSnapshots) Files() (list []string) { } func (s *RoSnapshots) OpenFiles() (list []string) { + log.Warn("[dbg] OpenFiles") + defer log.Warn("[dbg] OpenFiles end") s.segments.Scan(func(segtype snaptype.Enum, value *segments) bool { value.lock.RLock() defer value.lock.RUnlock() @@ -2068,7 +2072,7 @@ func (m *Merger) filesByRange(snapshots *RoSnapshots, from, to uint64) (map[snap func (m *Merger) filesByRangeOfType(view *View, from, to uint64, snapshotType snaptype.Type) []string { paths := make([]string, 0) - for _, sn := range view.Segments(snapshotType) { + for _, sn := range view.segments(snapshotType) { if sn.from < from { continue } @@ -2305,16 +2309,16 @@ func (s *RoSnapshots) ViewSingleFile(t snaptype.Type, blockNum uint64) (segment return nil, false, noop } -func (v *View) Segments(t snaptype.Type) []*Segment { +func (v *View) segments(t snaptype.Type) []*Segment { if s, ok := v.s.segments.Get(t.Enum()); ok { return s.segments } return nil } -func (v *View) Headers() []*Segment { return v.Segments(coresnaptype.Headers) } -func (v *View) Bodies() []*Segment { return v.Segments(coresnaptype.Bodies) } -func (v *View) Txs() []*Segment { return v.Segments(coresnaptype.Transactions) } +func (v *View) Headers() []*Segment { return v.segments(coresnaptype.Headers) } +func (v *View) Bodies() []*Segment { return v.segments(coresnaptype.Bodies) } +func (v *View) Txs() []*Segment { return v.segments(coresnaptype.Transactions) } func (v *View) Segment(t snaptype.Type, blockNum uint64) (*Segment, bool) { if s, ok := v.s.segments.Get(t.Enum()); ok { @@ -2329,7 +2333,7 @@ func (v *View) Segment(t snaptype.Type, blockNum uint64) (*Segment, bool) { } func (v *View) Ranges() (ranges []Range) { - for _, sn := range v.Segments(v.baseSegType) { + for _, sn := range v.segments(v.baseSegType) { ranges = append(ranges, sn.Range) } diff --git a/turbo/snapshotsync/freezeblocks/bor_snapshots.go b/turbo/snapshotsync/freezeblocks/bor_snapshots.go index f1790159e15..396241bc392 100644 --- a/turbo/snapshotsync/freezeblocks/bor_snapshots.go +++ b/turbo/snapshotsync/freezeblocks/bor_snapshots.go @@ -257,10 +257,10 @@ func (v *BorView) Close() { v.base.Close() } -func (v *BorView) Events() []*Segment { return v.base.Segments(borsnaptype.BorEvents) } -func (v *BorView) Spans() []*Segment { return v.base.Segments(borsnaptype.BorSpans) } -func (v *BorView) Checkpoints() []*Segment { return v.base.Segments(borsnaptype.BorCheckpoints) } -func (v *BorView) Milestones() []*Segment { return v.base.Segments(borsnaptype.BorMilestones) } +func (v *BorView) Events() []*Segment { return v.base.segments(borsnaptype.BorEvents) } +func (v *BorView) Spans() []*Segment { return v.base.segments(borsnaptype.BorSpans) } +func (v *BorView) Checkpoints() []*Segment { return v.base.segments(borsnaptype.BorCheckpoints) } +func (v *BorView) Milestones() []*Segment { return v.base.segments(borsnaptype.BorMilestones) } func (v *BorView) EventsSegment(blockNum uint64) (*Segment, bool) { return v.base.Segment(borsnaptype.BorEvents, blockNum) diff --git a/turbo/snapshotsync/snapshotsync.go b/turbo/snapshotsync/snapshotsync.go index f005d433ee0..f39ac44d75e 100644 --- a/turbo/snapshotsync/snapshotsync.go +++ b/turbo/snapshotsync/snapshotsync.go @@ -284,13 +284,6 @@ func WaitForDownloader(ctx context.Context, logPrefix string, headerchain, blobs return nil } - if headerchain { - snapshots.Close() - if cc.Bor != nil { - borSnapshots.Close() - } - } - //Corner cases: // - Erigon generated file X with hash H1. User upgraded Erigon. New version has preverified file X with hash H2. Must ignore H2 (don't send to Downloader) // - Erigon "download once": means restart/upgrade/downgrade must not download files (and will be fast) @@ -357,9 +350,6 @@ func WaitForDownloader(ctx context.Context, logPrefix string, headerchain, blobs } - // TODO: https://github.com/erigontech/erigon/issues/11271 - time.Sleep(10 * time.Second) - downloadStartTime := time.Now() const logInterval = 20 * time.Second logEvery := time.NewTicker(logInterval)