Skip to content

fix(arbitrary): fix UTXO selection loop to iterate over entries instead of repeating first - #9826

Merged
mergify[bot] merged 2 commits into
ZcashFoundation:mainfrom
radik878:fix/utxo-loop-iteration
Aug 26, 2025
Merged

fix(arbitrary): fix UTXO selection loop to iterate over entries instead of repeating first#9826
mergify[bot] merged 2 commits into
ZcashFoundation:mainfrom
radik878:fix/utxo-loop-iteration

Conversation

@radik878

Copy link
Copy Markdown
Contributor

The find_valid_utxo_for_spend function was incorrectly using a while loop with
utxos.iter().next() which always returned the same first UTXO entry. This caused
the function to either select the first UTXO or fail after 100 attempts, instead
of properly scanning through available UTXOs.

Changed the loop to iterate over utxos.iter().take(100) to properly scan
different UTXO entries while maintaining the existing 100-entry limit for
performance reasons.

This fix improves the quality of generated test chains by enabling more
transparent spends from different UTXOs rather than repeatedly attempting
to spend the same first entry.

@radik878
radik878 requested a review from a team as a code owner August 24, 2025 18:12
@radik878
radik878 requested review from arya2 and removed request for a team August 24, 2025 18:12

@arya2 arya2 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch! This looks good pending a lint fix.

Comment thread zebra-chain/src/block/arbitrary.rs Outdated
Co-authored-by: Arya <aryasolhi@gmail.com>
@radik878

Copy link
Copy Markdown
Contributor Author

Nice catch! This looks good pending a lint fix.

comitted, thanks for review

mergify Bot added a commit that referenced this pull request Aug 26, 2025
@mergify
mergify Bot merged commit 3869448 into ZcashFoundation:main Aug 26, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants