Coins Cache Cleanup checklist #34280

issue l0rinc opened this issue on January 14, 2026
  1. l0rinc commented at 10:23 AM on January 14, 2026: contributor

    The coins cache (the CCoinsView* stack, CCoinsViewCache, and friends) is a correctness- and performance-critical part of validation, IBD, and assumeutxo. Over time it has accumulated subtle invariants and legacy states (around cache entry flags, spent coin handling, and error catching), and we have been chipping away at it through focused refactors, bugfixes, tests, and performance work.

    This issue tracks the related PRs to help reviewers see how they fit together. The overall aim is fewer error cases, cleaner cache layering, and parallel validation.

    PRs needing review

    Testing

    • #34866 - fuzz: target concurrent leveldb reads

    Remove invalid cache states

    • #34864 - remove unreachable FRESH-but-not-DIRTY state from code and tests.

    Simplify view hierarchy

    • #35180
    • #35078
    • #34320 - replace HaveCoin() with GetCoin().
    • #34132 - coins: drop error catcher, centralize fatal read handling.

    Parallel coin fetching

    • #31132 - async input prefetch during ConnectBlock.

    Other

    • #34641 - node: scale default -dbcache with system RAM
    • #33854 - fix assumevalid ignored during reindex (see #31494).
    • #32317 - move UTXO access to SpendBlock (kernel API, Utreexo, SwiftSync).

    Recently merged

    • #31449 - getblockstats RPC UTXO overhead fix
    • #34124 - make CCoinsView purely virtual, add explicit CCoinsViewEmpty.
    • #34692 - increase the default dbcache value from 450MiB to 1024MiB
    • #34576 - threadpool: add ranged Submit overload
    • #34655 - fuzz: keep coins_view fuzzers within caller contracts
    • #34165 - add non-mutating PeekCoin() to avoid polluting the main cache.
    • #33512 - track dirty entries so flush progress reflects actual writes.
    • #33680 - split FORCE_SYNC/FORCE_FLUSH, keep cache warm for scantxoutset/gettxoutsetinfo/snapshots.
    • #34164 - add Reset() and reusable view to discard failed connects cheaply.
    • #34207 - ensure GetCoin() only returns unspent coins, align tests with production.
    • #34253 - validation: cache tip recency for lock-free IsInitialBlockDownload()
    • #33866 - remove always-true return from BatchWrite.
    • #33657 - allow reading partial block data (useful for bindex).
    • #33602 - reduce map lookups in BatchWrite.
    • #33333 - warn when -dbcache exceeds RAM cap.

    IRC context: https://bitcoin-irc.chaincode.com/bitcoin-core-dev/2026-01-08

  2. l0rinc renamed this:
    Coins Cache Cleanup tracking issue
    Coins Cache Cleanup checklist
    on Jan 14, 2026
  3. willcl-ark added the label Tracking Issue on Jan 14, 2026
  4. sedited commented at 5:48 PM on January 18, 2026: contributor

    The issue seems a bit overladen - I don't think listing all these PRs is useful. Maybe distill this down to just the coins-related PRs? The benefit I would expect from this issue is that I can connect the various PRs touching the coins and see how they relate to each other. Maybe to add to the benefits in the opening paragraph a bit: Fewer error cases, more ergonomic cache layering, and preparation for asynchronous operations.

  5. l0rinc commented at 6:27 PM on January 18, 2026: contributor

    Thanks for the suggestions @sedited and @andrewtoth. Updated the tracker and grouped the PRs - hopefully this helps reviewers see the structure (though many conflict or overlap depending on merge order). I put cleanups first since they'd let us avoid ugly hacks in the larger PRs, culminating in the parallel input fetcher. Let me know what else to adjust.

  6. l0rinc closed this on Mar 15, 2026

  7. l0rinc commented at 11:13 PM on March 15, 2026: contributor

    GitHub doesn't allow me to edit the issue anymore, wanted to try the close/reopen dance here, but apparently I can't reopen. Can someone please reopen and check if they can edit the issue?

  8. sipa reopened this on Mar 15, 2026

  9. ryanofsky referenced this in commit 976985eccd on Apr 13, 2026
Contributors
Linked (view graph)
#31132 validation: fetch block inputs on parallel threads#31449 coins,refactor: Reduce `getblockstats` RPC UTXO overhead estimation#31494 assumevalid is not always applied when reindexing#32317 kernel: Separate UTXO set access from validation functions#33333 coins: warn on oversized `-dbcache`#33512 coins: use dirty entry count for flush warnings and disk space checks#33602 [IBD] coins: reduce lookups in dbcache layer propagation#33657 rest: allow reading partial block data from storage#33680 validation: do not wipe utxo cache for stats/scans/snapshots#33854 fix assumevalid is ignored during reindex#33866 refactor: Let CCoinsViewCache::BatchWrite return void#34124 validation: make `CCoinsView` a pure virtual interface#34132 coins: drop error catcher, centralize fatal read handling#34164 validation: add reusable coins view for ConnectBlock#34165 coins: don't mutate main cache when connecting block#34207 coins/refactor: enforce `GetCoin()` returns only unspent coins#34253 validation: cache tip recency for lock-free `IsInitialBlockDownload()`#34320 coins: remove redundant and confusing `CCoinsViewDB::HaveCoin`#34576 threadpool: add ranged Submit overload#34641 node: scale default `-dbcache` with system RAM#34655 fuzz: keep `coins_view` fuzzers within caller contracts#34692 Bump dbcache to 1 GiB#34864 coins: make cache freshness imply dirtiness and remove invalid test states#34866 fuzz: target concurrent leveldb reads#35078 validation: merge `PeekCoin` into `GetCoin`#35180 move-only: hide coins cache internals

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-05-02 12:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me