triedb/pathdb: return an error if the trienode history is not empty

This commit is contained in:
Gary Rong 2026-03-04 10:31:33 +08:00
parent f99bf44e0e
commit b68e88af29

View file

@ -429,18 +429,14 @@ func repairHistory(db ethdb.Database, isVerkle bool, readOnly bool, stateID uint
if stateID <= thead {
truncTo = min(truncTo, thead)
} else {
ttail, err := trienodes.Tail()
if err != nil {
return nil, nil, err
}
_, err = trienodes.TruncateTail(stateID)
if err != nil {
return nil, nil, err
}
if thead == 0 {
_, err = trienodes.TruncateTail(stateID)
if err != nil {
return nil, nil, err
}
log.Warn("Initialized trienode history")
} else {
log.Warn("Purged stale trienode history", "from", ttail, "to", thead-1, "count", thead-ttail)
return nil, nil, fmt.Errorf("gap between state [#%d] and trienode history [#%d]", stateID, thead)
}
}
}