validation: add reusable coins view for ConnectBlock #34164

pull andrewtoth wants to merge 1 commits into bitcoin:master from andrewtoth:reuse-connect-block changing 7 files +61 −2
  1. andrewtoth commented at 8:05 pm on December 28, 2025: contributor

    This is the first commit of #31132, which can be merged as an independent change. It has a small benefit on its own, but will help in moving the parent PR forward.

    Add a Reset() method to CCoinsViewCache that clears cacheCoins, cachedCoinsUsage, and hashBlock without flushing to the base view. This allows efficiently reusing a cache instance across multiple blocks.

    Introduce m_connect_block_view as a persistent cache layer for ConnectBlock, avoiding repeated memory allocations. On block validation failure, Reset() discards uncommitted changes without affecting the main cache.

  2. validation: add reusable coins view for ConnectBlock
    Add a `Reset()` method to `CCoinsViewCache` that clears `cacheCoins`,
    `cachedCoinsUsage`, and `hashBlock` without flushing to the `base` view.
    This allows efficiently reusing a cache instance across multiple blocks.
    
    Introduce `m_connect_block_view` as a persistent cache layer for `ConnectBlock`,
    avoiding repeated memory allocations. On block validation failure, `Reset()`
    discards uncommitted changes without affecting the main cache.
    
    Co-authored-by: l0rinc <pap.lorinc@gmail.com>
    3230be92e8
  3. DrahtBot added the label Validation on Dec 28, 2025
  4. DrahtBot commented at 8:05 pm on December 28, 2025: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/34164.

    Reviews

    See the guideline for information on the review process. A summary of reviews will appear here.

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #34132 (refactor: inline CCoinsViewErrorCatcher into CCoinsViewDB by l0rinc)
    • #34125 (refactor: reuse should_empty for chainstate flush condition by l0rinc)
    • #33866 (refactor: Let CCoinsViewCache::BatchWrite return void by sedited)
    • #32317 (kernel: Separate UTXO set access from validation functions by sedited)
    • #31132 (validation: fetch block inputs on parallel threads 3x faster IBD by andrewtoth)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

    LLM Linter (✨ experimental)

    Possible places where named args for integral literals may be used (e.g. func(x, /*named_arg=*/0) in C++, and func(x, named_arg=0) in Python):

    • Coin{CTxOut{m_rng.randrange(10), CScript{} « m_rng.randbytes(CScriptBase::STATIC_SIZE + 1)}, 1, false} in src/test/coins_tests.cpp

    2025-12-28


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-01-01 09:12 UTC

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