From fe6c3f69dc52b02c5742007425c7d8a4412481a0 Mon Sep 17 00:00:00 2001 From: jsvisa Date: Fri, 15 Aug 2025 08:43:50 +0800 Subject: [PATCH] triedb: skip if frozen is empty Signed-off-by: jsvisa --- triedb/pathdb/history_indexer.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/triedb/pathdb/history_indexer.go b/triedb/pathdb/history_indexer.go index 054d43e946..3c0737f381 100644 --- a/triedb/pathdb/history_indexer.go +++ b/triedb/pathdb/history_indexer.go @@ -511,6 +511,19 @@ func (i *indexIniter) index(done chan struct{}, interrupt *atomic.Int32, lastID } return } + // If the freezer is empty, no state history has been written. + // This can happen when the freezer was corrupted/lost + frozen, err := i.freezer.Ancients() + if err != nil { + log.Error("Failed to retrieve head of state history", "err", err) + return + } + if frozen == 0 { + storeIndexMetadata(i.disk, lastID) + log.Info("No state history to index, skipping", "beginID", beginID, "lastID", lastID) + return + } + log.Info("Start history indexing", "beginID", beginID, "lastID", lastID) var (