From 452facf4fd795c6b3a53fe7da9655097c69045c1 Mon Sep 17 00:00:00 2001 From: rizkyikiw42 Date: Thu, 13 Nov 2025 21:37:16 +0800 Subject: [PATCH] triedb/pathdb: remove unused trienode history code --- triedb/pathdb/history.go | 11 ----------- triedb/pathdb/history_trienode.go | 29 ----------------------------- triedb/pathdb/metrics.go | 7 ------- 3 files changed, 47 deletions(-) diff --git a/triedb/pathdb/history.go b/triedb/pathdb/history.go index d78999f218..fb3e1b8944 100644 --- a/triedb/pathdb/history.go +++ b/triedb/pathdb/history.go @@ -180,17 +180,6 @@ func newStorageIdentQuery(address common.Address, addressHash common.Hash, stora } } -// newTrienodeIdentQuery constructs a state identifier for a trie node. -// the addressHash denotes the address hash of the associated account; -// the path denotes the path of the node within the trie; -// -// nolint:unused -func newTrienodeIdentQuery(addrHash common.Hash, path []byte) stateIdentQuery { - return stateIdentQuery{ - stateIdent: newTrienodeIdent(addrHash, string(path)), - } -} - // history defines the interface of historical data, shared by stateHistory // and trienodeHistory. type history interface { diff --git a/triedb/pathdb/history_trienode.go b/triedb/pathdb/history_trienode.go index 1004106af9..fb5f34216a 100644 --- a/triedb/pathdb/history_trienode.go +++ b/triedb/pathdb/history_trienode.go @@ -26,12 +26,10 @@ import ( "math" "slices" "sort" - "time" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/ethdb" - "github.com/ethereum/go-ethereum/log" ) // Each trie node history entry consists of three parts (stored in three freezer @@ -658,33 +656,6 @@ func (r *trienodeHistoryReader) read(owner common.Hash, path string) ([]byte, er return ir.read(path) } -// writeTrienodeHistory persists the trienode history associated with the given diff layer. -// nolint:unused -func writeTrienodeHistory(writer ethdb.AncientWriter, dl *diffLayer) error { - start := time.Now() - h := newTrienodeHistory(dl.rootHash(), dl.parent.rootHash(), dl.block, dl.nodes.nodeOrigin) - header, keySection, valueSection, err := h.encode() - if err != nil { - return err - } - // Write history data into five freezer table respectively. - if err := rawdb.WriteTrienodeHistory(writer, dl.stateID(), header, keySection, valueSection); err != nil { - return err - } - trienodeHistoryDataBytesMeter.Mark(int64(len(valueSection))) - trienodeHistoryIndexBytesMeter.Mark(int64(len(header) + len(keySection))) - trienodeHistoryBuildTimeMeter.UpdateSince(start) - - log.Debug( - "Stored trienode history", "id", dl.stateID(), "block", dl.block, - "header", common.StorageSize(len(header)), - "keySection", common.StorageSize(len(keySection)), - "valueSection", common.StorageSize(len(valueSection)), - "elapsed", common.PrettyDuration(time.Since(start)), - ) - return nil -} - // readTrienodeMetadata resolves the metadata of the specified trienode history. // nolint:unused func readTrienodeMetadata(reader ethdb.AncientReader, id uint64) (*trienodeMetadata, error) { diff --git a/triedb/pathdb/metrics.go b/triedb/pathdb/metrics.go index 31c40053fc..da0aa99d37 100644 --- a/triedb/pathdb/metrics.go +++ b/triedb/pathdb/metrics.go @@ -73,13 +73,6 @@ var ( stateHistoryDataBytesMeter = metrics.NewRegisteredMeter("pathdb/history/state/bytes/data", nil) stateHistoryIndexBytesMeter = metrics.NewRegisteredMeter("pathdb/history/state/bytes/index", nil) - //nolint:unused - trienodeHistoryBuildTimeMeter = metrics.NewRegisteredResettingTimer("pathdb/history/trienode/time", nil) - //nolint:unused - trienodeHistoryDataBytesMeter = metrics.NewRegisteredMeter("pathdb/history/trienode/bytes/data", nil) - //nolint:unused - trienodeHistoryIndexBytesMeter = metrics.NewRegisteredMeter("pathdb/history/trienode/bytes/index", nil) - stateIndexHistoryTimer = metrics.NewRegisteredResettingTimer("pathdb/history/state/index/time", nil) stateUnindexHistoryTimer = metrics.NewRegisteredResettingTimer("pathdb/history/state/unindex/time", nil) trienodeIndexHistoryTimer = metrics.NewRegisteredResettingTimer("pathdb/history/trienode/index/time", nil)