go-ethereum/core/rawdb
Bosul Mun 5c253e557e
core/rawdb: prevent truncateHead from returning an error for empty tables (#35258)
This PR is related to the recent bug reported in #35210.

While trying to reproduce the error, I found that when the head state is
missing (e.g. unclean shutdown), we attempt to truncate the head to the
most recent block with state across all chain freezer tables.

However, for newly added tables such as the bal table, both the head and
tail are initialized to the minimum head of the existing chain freezer
tables. As a result, the `truncateHead` fails with the “truncate below
tail” error.

This PR fixes the issue by resetting newly added empty tables with
`items` as the tail when `truncateHead(items)` is called on them.
2026-07-01 09:43:11 +08:00
..
ancienttest core/rawdb, ethdb, cmd, triedb: manage finalized block-accessList in freezer (#34977) 2026-06-01 11:01:42 +08:00
eradb core/rawdb/eradb: support ere files in era store (#34978) 2026-06-22 17:00:43 +02:00
testdata core/rawdb: avoid unnecessary receipt processing for log filtering (#23147) 2021-09-28 12:54:49 +02:00
accessors_chain.go core/rawdb, ethdb, cmd, triedb: manage finalized block-accessList in freezer (#34977) 2026-06-01 11:01:42 +08:00
accessors_chain_test.go core/rawdb, ethdb, cmd, triedb: manage finalized block-accessList in freezer (#34977) 2026-06-01 11:01:42 +08:00
accessors_history.go core/rawdb, triedb/pathdb: introduce trienode history (#32596) 2025-10-10 14:51:27 +08:00
accessors_indexes.go all: fix all typos, as reported by crates-ci/typos (#35008) 2026-06-10 18:50:51 +02:00
accessors_indexes_test.go ethapi: reduce some of the wasted effort in GetTransactionReceipt (#32021) 2025-07-01 15:18:49 +08:00
accessors_metadata.go core/rawdb: remove outdated functions (#32542) 2025-09-04 17:25:33 +08:00
accessors_overlay.go core/state: introduce the TransitionState object (verkle transition part 1) (#31634) 2025-08-05 09:34:12 +08:00
accessors_snapshot.go eth/downloader, eth/protocols/snap: freeze pivot once state is downloaded (#35155) 2026-06-15 16:09:41 +08:00
accessors_state.go core/rawdb, triedb/pathdb: re-structure the trienode history header (#32907) 2025-10-25 16:16:16 +08:00
accessors_sync.go core, accounts, eth, trie: handle genesis state missing (#28171) 2023-09-28 10:00:53 +03:00
accessors_trie.go core/rawdb: fix misleading comment in HasTrieNode (#32599) 2025-09-15 10:45:50 +08:00
ancient_scheme.go core/rawdb, ethdb, cmd, triedb: manage finalized block-accessList in freezer (#34977) 2026-06-01 11:01:42 +08:00
ancient_utils.go core/rawdb, ethdb, cmd, triedb: manage finalized block-accessList in freezer (#34977) 2026-06-01 11:01:42 +08:00
chain_freezer.go core: add debug log and repair the missing hash and receipts (#35190) 2026-06-23 14:46:38 +08:00
chain_iterator.go core/rawdb: fix incorrect tail value in unindexTransactions log output (#33796) 2026-02-09 15:49:53 +08:00
chain_iterator_test.go core/rawdb: skip missing block bodies during tx unindexing (#33573) 2026-01-12 14:25:22 +08:00
database.go ethdb/pebble, cmd, node: add pebble v2 support (#34009) 2026-06-22 12:50:49 +02:00
freezer.go core: add debug log and repair the missing hash and receipts (#35190) 2026-06-23 14:46:38 +08:00
freezer_batch.go core/rawdb: capture open file error and fix resource leak (#33147) 2025-11-11 16:01:37 +08:00
freezer_memory.go core/rawdb, ethdb, cmd, triedb: manage finalized block-accessList in freezer (#34977) 2026-06-01 11:01:42 +08:00
freezer_memory_test.go core/rawdb, ethdb, cmd, triedb: manage finalized block-accessList in freezer (#34977) 2026-06-01 11:01:42 +08:00
freezer_meta.go core/rawdb: fix freezer metadata log field ordering (#35246) 2026-06-29 20:59:12 +08:00
freezer_meta_test.go core/rawdb: introduce flush offset in freezer (#30392) 2025-02-04 11:45:45 +01:00
freezer_resettable.go core/rawdb, ethdb, cmd, triedb: manage finalized block-accessList in freezer (#34977) 2026-06-01 11:01:42 +08:00
freezer_resettable_test.go core/rawdb: implement in-memory freezer (#29135) 2024-04-30 11:33:22 +02:00
freezer_table.go core/rawdb: prevent truncateHead from returning an error for empty tables (#35258) 2026-07-01 09:43:11 +08:00
freezer_table_test.go core/rawdb, triedb/pathdb: enable trienode history alongside existing data (#33934) 2026-03-12 09:21:54 +08:00
freezer_test.go core/rawdb, ethdb, cmd, triedb: manage finalized block-accessList in freezer (#34977) 2026-06-01 11:01:42 +08:00
freezer_utils.go core/rawdb: fix file descriptor leak in freezer error paths (#34735) 2026-04-20 11:06:17 +08:00
freezer_utils_test.go all: more linters (#24783) 2022-06-13 16:24:45 +02:00
freezer_utils_unix.go core/rawdb: fix freezer dir.Sync() failure on Windows (#34115) 2026-03-30 15:34:23 +08:00
freezer_utils_windows.go core/rawdb: fix freezer dir.Sync() failure on Windows (#34115) 2026-03-30 15:34:23 +08:00
key_length_iterator.go core/rawdb: add specified key length iterator (#24535) 2022-03-15 10:28:26 +02:00
key_length_iterator_test.go core/rawdb: add specified key length iterator (#24535) 2022-03-15 10:28:26 +02:00
schema.go eth/downloader, eth/protocols/snap: freeze pivot once state is downloaded (#35155) 2026-06-15 16:09:41 +08:00
table.go core/rawdb, ethdb, cmd, triedb: manage finalized block-accessList in freezer (#34977) 2026-06-01 11:01:42 +08:00
table_test.go ethdb: Implement DeleteRange in batch (#31947) 2025-06-20 19:40:41 +08:00