It's a bit simpler to unconditionally shuffle once in SelectCoins instead of in SelectCoinsMinConf which is repeatedly called.
Remove redundant shuffle in KnapsackSolver #15752
pull madeken wants to merge 1 commits into bitcoin:master from madeken:master changing 3 files +4 −59-
madeken commented at 11:58 PM on April 4, 2019: none
- fanquake added the label Wallet on Apr 4, 2019
-
Empact commented at 9:17 AM on April 5, 2019: member
NACK this is not redundant, e.g.
-
madeken commented at 3:51 PM on April 5, 2019: none
@Empact the comment is wrong...
The reason it sometimes fails and sometimes succeeds is because of the randomization here: https://github.com/bitcoin/bitcoin/blob/e21129e78e38935eb3310207c5be7cf2b1f422e7/src/wallet/coinselection.cpp#L195
but note at that stage it's iterating over a sorted list:
-
MarcoFalke commented at 3:58 PM on April 5, 2019: member
The tests are failing, so they need to be updated in the same commit
-
gmaxwell commented at 4:07 PM on April 5, 2019: contributor
What happens if there are ties in the sort or multiple smallest elements >= N?
- madeken force-pushed on Apr 5, 2019
- madeken force-pushed on Apr 5, 2019
-
madeken commented at 5:55 PM on April 5, 2019: none
Rebased, updated original post (description) and removed the test of randomness in
SelectCoinsMinConfas it's no longer applicable andSelectCoinsdoesn't make it easy to do the same test. -
72c233650a
Lift the wallet shuffle from SelectCoinsMinConf to SelectCoins
That way it's only done once
- madeken force-pushed on Apr 5, 2019
-
Empact commented at 8:08 PM on April 5, 2019: member
That looks better to me, but if deterministic output is significant to privacy, I'd rather have less efficient operation covered by a test than more efficient operation without one, particularly wrt coin selection.
-
madeken commented at 9:07 PM on April 5, 2019: none
@Empact even without the shuffle (which it has), the privacy implications are tiny. It only makes a difference in an extreme edge case: if BnB fails (does its own sorting), and if the sum of < N is <N fails (has its own randomization) and if the smallest >= N input has ties.
And even then, the privacy difference between "This is the smallest >= N input (first tie-breaking)" and "This is a smallest >= N input (random tie-breaking)" is going pretty negligible.
-
gmaxwell commented at 9:36 PM on April 5, 2019: contributor
Why bother with the change however? I'm not really seeing the motivation for it, saving say 0.5ms in a 500ms operation isn't particularly interesting. Actually figuring out if the privacy difference is material isn't free....
- madeken closed this on Apr 11, 2019
- DrahtBot locked this on Dec 16, 2021