This PR is split out from #33018 to keep that PR focused on removing the FRESH-but-not-DIRTY cache state.
Problem
::GetCoin() is an interface for querying the UTXO set, so production implementations should only ever return unspent coins. Tests should mimic this to provide useful feedback.
Fix:
- Add a fail-fast assertion that
CCoinsViewDB::GetCoin()never returns a spent coin. - Align unit tests and fuzz simulations with the production
GetCoin()contract by never returning spent coins. - Replace the unreachable “spent coin returned by parent” handling in
CCoinsViewCache::FetchCoin()withAssert(!coin.IsSpent()), drop outdatedspent+FRESHdocs, and tightenSanityCheck()invariants.
Behavior is unchanged, it just aligns our tests to exercise valid states.