go-ethereum/eth
Felföldi Zsolt 14d576c002
core/filtermaps: hashdb safe delete range (#31525)
This PR adds `rawdb.SafeDeleteRange` and uses it for range deletion in
`core/filtermaps`. This includes deleting the old bloombits database,
resetting the log index database and removing index data for unindexed
tail epochs (which previously weren't properly implemented for the
fallback case).
`SafeDeleteRange` either calls `ethdb.DeleteRange` if the node uses the
new path based state scheme or uses an iterator based fallback method
that safely skips trie nodes in the range if the old hash based state
scheme is used. Note that `ethdb.DeleteRange` also has its own iterator
based fallback implementation in `ethdb/leveldb`. If a path based state
scheme is used and the backing db is pebble (as it is on the majority of
new nodes) then `rawdb.SafeDeleteRange` uses the fast native range
delete.
Also note that `rawdb.SafeDeleteRange` has different semantics from
`ethdb.DeleteRange`, it does not automatically return if the operation
takes a long time. Instead it receives a `stopCallback` that can
interrupt the process if necessary. This is because in the safe mode
potentially a lot of entries are iterated without being deleted (this is
definitely the case when deleting the old bloombits database which has a
single byte prefix) and therefore restarting the process every time a
fixed number of entries have been iterated would result in a quadratic
run time in the number of skipped entries.

When running in safe mode, unindexing an epoch takes about a second,
removing bloombits takes around 10s while resetting a full log index
might take a few minutes. If a range delete operation takes a
significant amount of time then log messages are printed. Also, any
range delete operation can be interrupted by shutdown (tail uinindexing
can also be interrupted by head indexing, similarly to how tail indexing
works). If the last unindexed epoch might have "dirty" index data left
then the indexed map range points to the first valid epoch and
`cleanedEpochsBefore` points to the previous, potentially dirty one. At
startup it is always assumed that the epoch before the first fully
indexed one might be dirty. New tail maps are never rendered and also no
further maps are unindexed before the previous unindexing is properly
cleaned up.

---------

Co-authored-by: Gary Rong <garyrong0905@gmail.com>
Co-authored-by: Felix Lange <fjl@twurst.com>
2025-03-31 14:47:56 +02:00
..
catalyst eth/catalyst: set FeeRecipient in dev mode (#31316) 2025-03-17 09:32:44 +01:00
downloader all: nuke total difficulty (#30744) 2025-01-28 18:55:41 +01:00
ethconfig eth/filters: implement log filter using new log index (#31080) 2025-03-17 18:59:04 +01:00
fetcher params,core: add max and target value to chain config (#31002) 2025-02-04 15:43:18 +01:00
filters eth/filter: downgrade log level (#31450) 2025-03-21 14:08:51 +01:00
gasestimator internal/ethapi: support for beacon root and withdrawals in simulate api (#31304) 2025-03-24 19:08:53 +01:00
gasprice eth/gasprice: sanity check ratio values (#31270) 2025-02-27 15:40:35 +08:00
protocols core/txpool, eth: add GetRLP to transaction pool (#31307) 2025-03-19 14:20:50 +08:00
tracers internal/ethapi: exclude 7702 authorities from result in eth_createAccessList (#31336) 2025-03-25 15:01:21 +01:00
api_admin.go eth: ignore genesis block on importChain (#27956) 2023-08-21 13:32:34 -04:00
api_backend.go core/txpool: fix nonce assignment in local tracker (#31496) 2025-03-28 12:32:24 +01:00
api_debug.go miner: refactor the miner, make the pending block on demand (#28623) 2024-03-06 14:45:03 +02:00
api_debug_test.go all: implement state history v2 (#30107) 2025-01-17 02:59:02 +01:00
api_miner.go miner: refactor the miner, make the pending block on demand (#28623) 2024-03-06 14:45:03 +02:00
backend.go core/filtermaps: hashdb safe delete range (#31525) 2025-03-31 14:47:56 +02:00
handler.go eth: downgrade peer removal error to warning level (#31492) 2025-03-26 19:57:08 +08:00
handler_eth.go eth: check blob transaction validity on the peer goroutine when received (#31219) 2025-03-01 14:10:38 +01:00
handler_eth_test.go core/txpool: remove locals-tracking from txpools (#30559) 2025-02-04 17:23:01 +01:00
handler_snap.go eth: check snap satelliteness, delegate drop to eth (#22235) 2021-02-02 10:44:36 +02:00
handler_test.go core/txpool, eth: add GetRLP to transaction pool (#31307) 2025-03-19 14:20:50 +08:00
peer.go eth: remove admin.peers[i].eth.head and difficulty (#26804) 2023-03-06 09:27:46 +02:00
peerset.go consensus, cmd, core, eth: remove support for non-merge mode of operation (#29169) 2024-03-05 16:13:28 +02:00
state_accessor.go all: implement state history v2 (#30107) 2025-01-17 02:59:02 +01:00
sync.go consensus, cmd, core, eth: remove support for non-merge mode of operation (#29169) 2024-03-05 16:13:28 +02:00
sync_test.go eth/protocols/eth: prevent hanging dispatch (#30918) 2025-01-06 16:31:53 +01:00