Repository navigation
Conversation
In validation, AddCoins(check=false) is only used after BIP30 has already ensured the transaction does not overwrite any unspent outputs in the UTXO view. The coins view fuzz target can call AddCoins with arbitrary txids, so using the check=false fast path on non-coinbase transactions may violate the AddCoin caller contract and trigger logic errors. Only use check=false when we have first confirmed that none of the outputs are currently unspent. Otherwise fall back to check=true so AddCoins determines overwrites via the view.
The coins view fuzzer can call AddCoin with possible_overwrite=false for an outpoint that already exists unspent in the view, which violates the AddCoin caller contract. Derive possible_overwrite from PeekCoin so possible_overwrite=false is only used when the outpoint is absent.
Modify fuzzer logic to filter out invalid FRESH entries and ensure FRESH implies DIRTY, allowing BatchWrite failures to expose real bugs without resetting state.
Owner
Author
|
Pushed to bitcoin#34655 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is an alternative approach to bitcoin#34647.
First, add
CheckedSuband use it for decrements ofm_dirty_countandcachedCoinsUsage, so unsigned underflows turn into immediate failures instead of silently wrapping.Assertion `j <= i' failed.
The coins view fuzz targets can call
AddCoin/AddCoinsand constructBatchWritecursors in ways that violateCCoinsViewCachecaller contracts. These invalid states can triggerBatchWritestd::logic_errorand can desync dirty-entry accounting (caught byAssume(m_dirty_count == 0)currently).Make the fuzzer avoid generating invalid states instead of catching and resetting:
AddCoin’spossible_overwritefromPeekCoin, sopossible_overwrite=falseis only used when the outpoint is absent.AddCoins(check=false)when we have confirmed the txid has no unspent outputs; otherwise fall back tocheck=truesoAddCoinsdetermines overwrites via the view.CoinsViewCacheCursor, avoid settingFRESHwhen the parent already has an unspent coin, and ensureFRESHimpliesDIRTY.