From eaa9418ac184fba1be81e1473ba42db1668714f0 Mon Sep 17 00:00:00 2001 From: Lee Gyumin <82251551+legm0310@users.noreply.github.com> Date: Fri, 13 Mar 2026 17:45:14 +0900 Subject: [PATCH] core/rawdb: enforce exact key length for num->hash and td in db inspect (#34000) This PR improves `db inspect` classification accuracy in `core/rawdb/database.go` by tightening key-shape checks for: - `Block number->hash` - `Difficulties (deprecated)` Previously, both categories used prefix/suffix heuristics and could mis-bucket unrelated entries. --- core/rawdb/database.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/rawdb/database.go b/core/rawdb/database.go index 576e32b961..a13afb9c0e 100644 --- a/core/rawdb/database.go +++ b/core/rawdb/database.go @@ -478,9 +478,9 @@ func InspectDatabase(db ethdb.Database, keyPrefix, keyStart []byte) error { bodies.add(size) case bytes.HasPrefix(key, blockReceiptsPrefix) && len(key) == (len(blockReceiptsPrefix)+8+common.HashLength): receipts.add(size) - case bytes.HasPrefix(key, headerPrefix) && bytes.HasSuffix(key, headerTDSuffix): + case bytes.HasPrefix(key, headerPrefix) && bytes.HasSuffix(key, headerTDSuffix) && len(key) == (len(headerPrefix)+8+common.HashLength+len(headerTDSuffix)): tds.add(size) - case bytes.HasPrefix(key, headerPrefix) && bytes.HasSuffix(key, headerHashSuffix): + case bytes.HasPrefix(key, headerPrefix) && bytes.HasSuffix(key, headerHashSuffix) && len(key) == (len(headerPrefix)+8+common.HashLength+len(headerHashSuffix)): numHashPairings.add(size) case bytes.HasPrefix(key, headerNumberPrefix) && len(key) == (len(headerNumberPrefix)+common.HashLength): hashNumPairings.add(size)