From d5585fe5791e1ca61554b0be700da1d24dcc4039 Mon Sep 17 00:00:00 2001 From: jsvisa Date: Tue, 5 Aug 2025 10:46:20 +0800 Subject: [PATCH] fix Signed-off-by: jsvisa --- triedb/pathdb/database.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/triedb/pathdb/database.go b/triedb/pathdb/database.go index d78dfdc137..82cb7e52ff 100644 --- a/triedb/pathdb/database.go +++ b/triedb/pathdb/database.go @@ -337,11 +337,13 @@ func (db *Database) repairHistory() error { } if pruned != 0 { log.Warn("Truncated extra state histories", "number", pruned) - // Reset the state history index metadata to current state id. if meta := loadIndexMetadata(db.diskdb); meta != nil { - oldID := meta.Last - log.Warn("Reset state history index metadata after truncation", "oldID", oldID, "newID", id) - storeIndexMetadata(db.diskdb, id) + // Reset the state history index metadata to current state id + // if it's out of boundry. + if old := meta.Last; old > id { + log.Warn("Reset state history index metadata after truncation", "oldID", old, "newID", id) + storeIndexMetadata(db.diskdb, id) + } } } return nil