Skip to content

fuzz: remove unsupported coins cache cursor fuzz probe - #35562

Closed
l0rinc wants to merge 1 commit into
bitcoin:masterfrom
l0rinc:l0rinc/remove-constant-Cursor-fuzz
Closed

l0rinc wants to merge 1 commit into
bitcoin:masterfrom
l0rinc:l0rinc/remove-constant-Cursor-fuzz

Conversation

@l0rinc

@l0rinc l0rinc commented Jun 18, 2026 •

Copy link
Copy Markdown
Contributor

Problem: The coins_view fuzz target checked that CCoinsViewCache::Cursor() throws, but that method is intentionally unsupported and always throws: https://github.com/bitcoin/bitcoin/blob/93c6ea147422199777ddbc5f6d04134b82420b76/src/coins.h#L450-L452

Fix: Remove the input-independent throw check from the fuzz target. The target still exercises the useful cache/view behavior, and keeps DB-backed cursor coverage where cursor iteration is supported.
Some leftover scope-guards were also removed.

This was extracted from review discussion in #35295 (comment).

The coins view fuzz target called CCoinsViewCache::Cursor() only to assert that it throws.

That path is an unsupported API contract and is independent of fuzz input, so it does not add useful fuzz coverage. Keep the remaining cache/view checks and DB-backed cursor coverage, where cursor iteration is supported.
@DrahtBot

DrahtBot commented Jun 18, 2026 •

Copy link
Copy Markdown
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/35562.

Reviews

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

@sedited

sedited commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

This is cheap check, do we really need to remove this?

@l0rinc

l0rinc commented Jun 18, 2026

Copy link
Copy Markdown
Contributor Author

do we really need to remove this?

Isn't it just fake coverage? Why would we fuzz test a deterministic throw?

@sedited

sedited commented Jun 18, 2026 •

Copy link
Copy Markdown
Contributor

I think it is fine to pin behaviour here. We could do the same with a unit test I guess, but not sure if that is worth a pull request. Do you remember why this was an error and not just a hard assert?

EDIT: Was curious why this is even a virtual method, and seems like it doesn't need to be. The few users can get it from the CCoinsViewDB directly.

@l0rinc

l0rinc commented Jun 21, 2026

Copy link
Copy Markdown
Contributor Author

The few users can get it from the CCoinsViewDB directly.

Indeed, pushed it as a new PR, added you as coauthor: #35572

@l0rinc
l0rinc deleted the l0rinc/remove-constant-Cursor-fuzz branch June 21, 2026 06:42
achow101 added a commit that referenced this pull request Jul 14, 2026
72db4ac coins: drop stale cursor null checks (Lőrinc)
3d2f2d8 coins: pass UTXO stats view by reference (Lőrinc)
35aedb2 coins: drop cursor from base view (Lőrinc)
c6fbe2f coins: pass DB view to cursor users (Lőrinc)

Pull request description:

  **Problem:** `CCoinsView::Cursor()` makes cursor iteration look like a generic coins view operation, but cursor iteration is only supported by the DB-backed coins view.
  The cache override only threw, and the `coins_view` fuzz target only asserted that deterministic unsupported throw path.

  **Fix:** Make cursor iteration a `CCoinsViewDB` operation.
  Cursor users now take the DB-backed view directly, `CCoinsView` no longer exposes `Cursor()`, and the fuzz target keeps DB-backed cursor coverage while dropping the unsupported cache throw probe.
  The UTXO stats path is also tightened to pass the non-null DB view by reference, and stale null handling for DB cursors is removed.

  This was extracted from review discussion in #35295 (comment) and extended based on #35562 (comment).

ACKs for top commit:
  achow101:
    ACK 72db4ac
  sedited:
    Re-ACK 72db4ac
  w0xlt:
    ACK 72db4ac
  andrewtoth:
    ACK 72db4ac

Tree-SHA512: 12a81330a6ec1b91a7e4393f3761ea9ed4702ecb24312f1defa5a9a079a396ce921fc52f74fe296e5ac7ab20d5b5a8a84e858c96847f333c58b7fa9de9e8143e
Kino1994 pushed a commit to Kino1994/bitcoin-full-history that referenced this pull request Jul 19, 2026
9fdde8e coins: drop stale cursor null checks (Lőrinc)
c42bfb3 coins: pass UTXO stats view by reference (Lőrinc)
18dab78 coins: drop cursor from base view (Lőrinc)
fffcc01 coins: pass DB view to cursor users (Lőrinc)

Pull request description:

  **Problem:** `CCoinsView::Cursor()` makes cursor iteration look like a generic coins view operation, but cursor iteration is only supported by the DB-backed coins view.
  The cache override only threw, and the `coins_view` fuzz target only asserted that deterministic unsupported throw path.

  **Fix:** Make cursor iteration a `CCoinsViewDB` operation.
  Cursor users now take the DB-backed view directly, `CCoinsView` no longer exposes `Cursor()`, and the fuzz target keeps DB-backed cursor coverage while dropping the unsupported cache throw probe.
  The UTXO stats path is also tightened to pass the non-null DB view by reference, and stale null handling for DB cursors is removed.

  This was extracted from review discussion in bitcoin/bitcoin#35295 (comment) and extended based on bitcoin/bitcoin#35562 (comment).

ACKs for top commit:
  achow101:
    ACK 9fdde8e
  sedited:
    Re-ACK 9fdde8e
  w0xlt:
    ACK 9fdde8e
  andrewtoth:
    ACK 9fdde8e

Tree-SHA512: 12a81330a6ec1b91a7e4393f3761ea9ed4702ecb24312f1defa5a9a079a396ce921fc52f74fe296e5ac7ab20d5b5a8a84e858c96847f333c58b7fa9de9e8143e
Kino1994 pushed a commit to Kino1994/bitcoin-full-history that referenced this pull request Aug 19, 2026
72db4accbf5bae74d061db1aeee9e0688c0da2f5 coins: drop stale cursor null checks (Lőrinc)
3d2f2d8de09d162863f7b8e7e48e347d7d87c648 coins: pass UTXO stats view by reference (Lőrinc)
35aedb2823692756dbe958b08f415c2b3e0be4ea coins: drop cursor from base view (Lőrinc)
c6fbe2f66cff3846068795b3e2c459242b7be56b coins: pass DB view to cursor users (Lőrinc)

Pull request description:

  **Problem:** `CCoinsView::Cursor()` makes cursor iteration look like a generic coins view operation, but cursor iteration is only supported by the DB-backed coins view.
  The cache override only threw, and the `coins_view` fuzz target only asserted that deterministic unsupported throw path.

  **Fix:** Make cursor iteration a `CCoinsViewDB` operation.
  Cursor users now take the DB-backed view directly, `CCoinsView` no longer exposes `Cursor()`, and the fuzz target keeps DB-backed cursor coverage while dropping the unsupported cache throw probe.
  The UTXO stats path is also tightened to pass the non-null DB view by reference, and stale null handling for DB cursors is removed.

  This was extracted from review discussion in bitcoin/bitcoin#35295 (comment) and extended based on bitcoin/bitcoin#35562 (comment).

ACKs for top commit:
  achow101:
    ACK 72db4accbf5bae74d061db1aeee9e0688c0da2f5
  sedited:
    Re-ACK 72db4accbf5bae74d061db1aeee9e0688c0da2f5
  w0xlt:
    ACK 72db4accbf5bae74d061db1aeee9e0688c0da2f5
  andrewtoth:
    ACK 72db4accbf5bae74d061db1aeee9e0688c0da2f5

Tree-SHA512: 12a81330a6ec1b91a7e4393f3761ea9ed4702ecb24312f1defa5a9a079a396ce921fc52f74fe296e5ac7ab20d5b5a8a84e858c96847f333c58b7fa9de9e8143e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants