From ac1731907d335775f45e013756dbdf4b00cb798c Mon Sep 17 00:00:00 2001 From: rjl493456442 Date: Fri, 22 Aug 2025 20:00:18 +0800 Subject: [PATCH] triedb/pathdb: improve err message in historical state reader (#32477) Fixes https://github.com/ethereum/go-ethereum/issues/32474 --- triedb/pathdb/reader.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/triedb/pathdb/reader.go b/triedb/pathdb/reader.go index b7b18f13f9..5c12a8e55f 100644 --- a/triedb/pathdb/reader.go +++ b/triedb/pathdb/reader.go @@ -207,11 +207,11 @@ type HistoricalStateReader struct { // HistoricReader constructs a reader for accessing the requested historic state. func (db *Database) HistoricReader(root common.Hash) (*HistoricalStateReader, error) { // Bail out if the state history hasn't been fully indexed - if db.indexer == nil || !db.indexer.inited() { - return nil, errors.New("state histories haven't been fully indexed yet") + if db.indexer == nil || db.freezer == nil { + return nil, fmt.Errorf("historical state %x is not available", root) } - if db.freezer == nil { - return nil, errors.New("state histories are not available") + if !db.indexer.inited() { + return nil, errors.New("state histories haven't been fully indexed yet") } // States at the current disk layer or above are directly accessible via // db.StateReader.