From bd9ead8071ff6edc74434825b1d3685f948c4723 Mon Sep 17 00:00:00 2001 From: Gary Rong Date: Mon, 2 Jun 2025 15:11:03 +0800 Subject: [PATCH] core/rawdb: fix range deletion --- core/rawdb/accessors_history.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/rawdb/accessors_history.go b/core/rawdb/accessors_history.go index 8fbec95faa..50512b7d1a 100644 --- a/core/rawdb/accessors_history.go +++ b/core/rawdb/accessors_history.go @@ -17,6 +17,8 @@ package rawdb import ( + "bytes" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/log" @@ -158,7 +160,9 @@ func increaseKey(key []byte) []byte { // Note, this method assumes the storage space with prefix `StateHistoryIndexPrefix` // is exclusively occupied by the history indexing data! func DeleteStateHistoryIndex(db ethdb.KeyValueRangeDeleter) { - if err := db.DeleteRange(StateHistoryIndexPrefix, increaseKey(StateHistoryIndexPrefix)); err != nil { + start := StateHistoryIndexPrefix + limit := increaseKey(bytes.Clone(StateHistoryIndexPrefix)) + if err := db.DeleteRange(start, limit); err != nil { log.Crit("Failed to delete history index range", "err", err) } }