Fix race condition (and other small fixes) in z_shieldcoinbase test#98
Open
nullcopy wants to merge 4 commits into
Open
Fix race condition (and other small fixes) in z_shieldcoinbase test#98nullcopy wants to merge 4 commits into
nullcopy wants to merge 4 commits into
Conversation
z_listunspent shows new coinbase before zallet's recover_history scan task (30s idle tick, not woken on tip change, sync.rs) makes it spendable to the proposal builder, so exact-count sweeps raced the scan (e.g. 101 of 111). The pre-sweep barrier now waits for the mature count to hold steady past that tick. No sync RPC exists yet (zcash/wallet#316).
The proposal treats coinbase as spendable at exactly COINBASE_MATURITY confirmations (its target height is tip+1), so z_listunspent(COINBASE_MATURITY+1) missed the boundary UTXO the sweep selects. Use minconf=COINBASE_MATURITY and mine to tip 101, so block 1 (A) and block 2 (B) are the only mature coinbase and the UUID sweep selects exactly those two.
Replace the post-sweep residual-count check (which depended on an incidental just-matured block) with a direct one: capture each receiver's pre-sweep coinbase UTXO and assert both are spent by the single UUID sweep. Wait for the balance to reach exactly shieldingValue - fee as the barrier.
Summing a z_listunspent snapshot to predict shieldingValue/remainingValue is unsound: z_listunspent and the proposal use different maturity tips, so across the regtest subsidy halving (6.25 -> 3.125) the boundary block's value differs between them. Anchor value checks to the operation's own reported shieldingValue and the balance delta (post == pre + value - fee); keep counts asserted exactly. F4 verifies the limit remainder with a second unlimited sweep before the first is mined, which must drain exactly what the first reported remaining.
95ce688 to
592cc92
Compare
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.
The race condition (#97) is the critical fix. Also includes:
Closes: #97