Skip to content

Fix race condition (and other small fixes) in z_shieldcoinbase test#98

Open
nullcopy wants to merge 4 commits into
zcash:mainfrom
nullcopy:test/z_shieldcoinbase
Open

Fix race condition (and other small fixes) in z_shieldcoinbase test#98
nullcopy wants to merge 4 commits into
zcash:mainfrom
nullcopy:test/z_shieldcoinbase

Conversation

@nullcopy
Copy link
Copy Markdown
Contributor

The race condition (#97) is the critical fix. Also includes:

  • fixes an issue summing block rewards across halvings, causing false negatives (elucidated by timing changes above)
  • strengthens the multi-addr test to strictly check every coinbase was spent.
  • makes the mutli-addr maturity helper exactly match the expected maturity from the proposal, for more precise sweep checking.

Closes: #97

nullcopy added 4 commits May 29, 2026 13:29
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.
@nullcopy nullcopy force-pushed the test/z_shieldcoinbase branch from 95ce688 to 592cc92 Compare May 29, 2026 18:29
@nullcopy nullcopy marked this pull request as ready for review May 29, 2026 18:43
@nullcopy nullcopy requested review from daira and nuttycom May 29, 2026 18:59
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.

wallet_z_shieldcoinbase test race condition causes intermittent failures

1 participant