From 1fe1ef3d33b7d98a58417f3c622b074239d20ce2 Mon Sep 17 00:00:00 2001 From: Jason-Wanxt Date: Wed, 6 May 2026 19:04:26 +0800 Subject: [PATCH 1/3] add ux improvement changes --- core/rawdb/chain_iterator.go | 14 ++++++++++---- core/rawdb/database.go | 12 +++++++++++- core/state/pruner/pruner.go | 4 ++-- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/core/rawdb/chain_iterator.go b/core/rawdb/chain_iterator.go index afa1aa7a4c..f5ca6566d8 100644 --- a/core/rawdb/chain_iterator.go +++ b/core/rawdb/chain_iterator.go @@ -298,9 +298,10 @@ func unindexTransactions(db ethdb.Database, from uint64, to uint64, interrupt ch // we expect the first number to come in to be [from]. Therefore, setting // nextNum to from means that the queue gap-evaluation will work correctly - nextNum = from - queue = prque.New[int64, *blockTxHashes](nil) - blocks, txs = 0, 0 // for stats reporting + nextNum = from + queue = prque.New[int64, *blockTxHashes](nil) + blocks, txs = 0, 0 // for stats reporting + loggedFirstBanner = false ) // Otherwise spin up the concurrent iterator and unindexer for delivery := range hashesCh { @@ -338,7 +339,12 @@ func unindexTransactions(db ethdb.Database, from uint64, to uint64, interrupt ch } // If we've spent too much time already, notify the user of what we're doing if time.Since(logged) > 8*time.Second { - log.Info("Unindexing transactions", "blocks", blocks, "txs", txs, "total", to-from, "elapsed", common.PrettyDuration(time.Since(start))) + if !loggedFirstBanner { + log.Info("Unindexing transactions — this is normal maintenance and does not indicate data loss", "blocks", blocks, "txs", txs, "total", to-from, "elapsed", common.PrettyDuration(time.Since(start))) + loggedFirstBanner = true + } else { + log.Debug("Unindexing transactions", "blocks", blocks, "txs", txs, "total", to-from, "elapsed", common.PrettyDuration(time.Since(start))) + } logged = time.Now() } } diff --git a/core/rawdb/database.go b/core/rawdb/database.go index 39e1a64e5a..9af5eaa490 100644 --- a/core/rawdb/database.go +++ b/core/rawdb/database.go @@ -714,8 +714,18 @@ func ReadChainMetadata(db ethdb.KeyValueStore) [][]string { return fmt.Sprintf("%d (%#x)", *val, *val) } + // databaseVersion is special-cased: when nil, it means the database is + // uninitialized (rather than an optional/empty field), so we surface a + // more actionable message instead of the generic "". + ppDatabaseVersion := func(val *uint64) string { + if val == nil { + return "not set (new or uninitialized database)" + } + return fmt.Sprintf("%d (%#x)", *val, *val) + } + data := [][]string{ - {"databaseVersion", pp(ReadDatabaseVersion(db))}, + {"databaseVersion", ppDatabaseVersion(ReadDatabaseVersion(db))}, {"headBlockHash", fmt.Sprintf("%v", ReadHeadBlockHash(db))}, {"headFastBlockHash", fmt.Sprintf("%v", ReadHeadFastBlockHash(db))}, {"headHeaderHash", fmt.Sprintf("%v", ReadHeadHeaderHash(db))}, diff --git a/core/state/pruner/pruner.go b/core/state/pruner/pruner.go index 11f3963a3e..473c053d58 100644 --- a/core/state/pruner/pruner.go +++ b/core/state/pruner/pruner.go @@ -68,8 +68,8 @@ type Config struct { // - iterate the database, delete all other state entries which // don't belong to the target state and the genesis state // -// It can take several hours(around 2 hours for mainnet) to finish -// the whole pruning work. It's recommended to run this offline tool +// It can take several hours to several days, depending on chain size and +// disk speed, to finish the whole pruning work. It's recommended to run this offline tool // periodically in order to release the disk usage and improve the // disk read performance to some extent. type Pruner struct { From 104d732441ed750905cf395aebe403ed20286025 Mon Sep 17 00:00:00 2001 From: Jason-W123 <147362502+Jason-W123@users.noreply.github.com> Date: Fri, 8 May 2026 01:07:13 +0800 Subject: [PATCH 2/3] Update core/rawdb/database.go Co-authored-by: lightclient <14004106+lightclient@users.noreply.github.com> --- core/rawdb/database.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/rawdb/database.go b/core/rawdb/database.go index 9af5eaa490..d63b250536 100644 --- a/core/rawdb/database.go +++ b/core/rawdb/database.go @@ -719,7 +719,7 @@ func ReadChainMetadata(db ethdb.KeyValueStore) [][]string { // more actionable message instead of the generic "". ppDatabaseVersion := func(val *uint64) string { if val == nil { - return "not set (new or uninitialized database)" + return ", database not initialized" } return fmt.Sprintf("%d (%#x)", *val, *val) } From d1e27caf7f1805e836d071c6656c741f452eaf14 Mon Sep 17 00:00:00 2001 From: Jason-W123 <147362502+Jason-W123@users.noreply.github.com> Date: Fri, 8 May 2026 01:08:27 +0800 Subject: [PATCH 3/3] Update core/rawdb/chain_iterator.go Co-authored-by: lightclient <14004106+lightclient@users.noreply.github.com> --- core/rawdb/chain_iterator.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/rawdb/chain_iterator.go b/core/rawdb/chain_iterator.go index f5ca6566d8..d725033930 100644 --- a/core/rawdb/chain_iterator.go +++ b/core/rawdb/chain_iterator.go @@ -340,7 +340,7 @@ func unindexTransactions(db ethdb.Database, from uint64, to uint64, interrupt ch // If we've spent too much time already, notify the user of what we're doing if time.Since(logged) > 8*time.Second { if !loggedFirstBanner { - log.Info("Unindexing transactions — this is normal maintenance and does not indicate data loss", "blocks", blocks, "txs", txs, "total", to-from, "elapsed", common.PrettyDuration(time.Since(start))) + log.Info("Removing old transaction ids from transaction lookup index", "blocks", blocks, "txs", txs, "total", to-from, "elapsed", common.PrettyDuration(time.Since(start))) loggedFirstBanner = true } else { log.Debug("Unindexing transactions", "blocks", blocks, "txs", txs, "total", to-from, "elapsed", common.PrettyDuration(time.Since(start)))