-
Notifications
You must be signed in to change notification settings - Fork 178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Default 3rd argument of gettxout should be True #1295
Conversation
There are other places where Here I don't think unconfirmed should be included:
Also here definitely joinmarket-clientserver/jmclient/jmclient/maker.py Lines 82 to 85 in 16fa85b
Also here in taker code, as commitments must be confirmed (althrough joinmarket-clientserver/jmclient/jmclient/taker.py Lines 757 to 759 in e082c3c
Concept ACK on changing argument default, but all places it is called should be carefully re-checked. |
I checked all of them - but it for sure doesn't hurt to check more! In the PoDLE related ones (in maker and taker modules) the age is checked separately, as you noted. There's a confusion that's easy to miss here: setting the 3rd argument of The logic isn't that obvious (which is doubtless why I (assuming it was me) got it wrong in the first place .. at best a partial excuse, but there you go). |
On reflection we could reduce the confusion by renaming the argument |
Code change is straightforward, tests pass.
This indeed seems to be the case, it's easy to verify that given UTXO A and an unconfirmed transaction spending it, Does this mean a taker will now accept 0 conf from makers? In
Git grep shows 9 instances, 3 of which are in |
Right, good catch. This logic is twisty. I checked that the maker is ensuring 1 conf with the This should be done as mentioned above by using |
If |
Well so 'includeconf' should better be called 'includeconfs' because it means 'include the number of confirmations'. Whereas the old name for the other variable 'includeunconf' was wildly misleading, instead of very slightly unclear; it suggested that if you set it to True, the only change that would happen would be that the returned result would include utxos that were currently unconfirmed, and as discussed here, that is wrong.
You could say that for sure, but I think it's a bit pedantic and I don't think there is cause of concern here. My concern with the other things is that the names of those arguments were at least a part of why this bug occurred. So your complaint about includeconf, whether it was partially a joke or not, I kind of agree and think we should add 's'. |
Ohh, sorry, somehow didn't read properly what this argument does, that it affects returned result not which UTXOs are included. |
Auditing usages before making another change. These links are from current master in case that causes a confusion. Usage 1:
There's no point in disallowing unconfirmed utxos here. It's only used in Usage 2:
This is only used by snicker code currently, and here unconfirmed should probably be better allowed. Usage 3:
The original reason for this issue; here we don't want to accept unconfirmed utxos. Usage 4: This is a check at signature-insertion time of the utxo's validity. It should follow the same logic as above (since we already checked the utxo was confirmed, this really just checks that it hasn't been spent in the meantime; so the important part here is that joinmarket-clientserver/jmclient/jmclient/taker.py Lines 645 to 646 in b066097
Usage 5: The other usage in taker.py relate to PoDLE commitments, here the age is checked anyway so it doesn't really matter. joinmarket-clientserver/jmclient/jmclient/taker.py Lines 758 to 759 in b066097
Usage 6:
As you can see from the lines below, the age was already being checked here and we don't want unconfirmed, so much as Usage 5 we can allow them, or not, they will be rejected anyway. Usage 7: joinmarket-clientserver/jmclient/jmclient/maker.py Lines 84 to 85 in b066097
This one is also a PoDLE check, so that the same reasoning applies: it doesn't really matter, as the age is checked anyway. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 81d64d7
2a9972f addresses the needs of usage 3 and as per @PulpCattel 's point, so we now reject both conflicted spends and unconfirmed utxos from makers. As per the details above, I don't think any of the other usages require changes. It is debatable whether we should have this as another argument to |
I'll squash and merge at some point fairly soon but more review would be very welcome; it's a rather important fix, or at the least, it's a sensitive one, as it could change the internal mechanics of coinjoin negotiation. |
So to summarize, logic is: Maker only selects utxos that have minconfs 1 for offer size, and for actually converting an order into an input utxo set (see Taker uses Takers also, after this change, check for the confirmations field of the returned dict from |
Fixes #1294. Before this commit, calls to query_utxo_set with default arguments would ignore the mempool and thus return utxos which were spent in unconfirmed transactions. Thus, takers would continue negotiation of coinjoins with makers who sent them already-spent utxos, leading to failure at broadcast time. This was not intended behaviour; we want takers to reject utxos that are double spent in the mempool. This commit changes that default argument to True so that utxo set changes in the mempool are accounted for. It also switches the name of the includeunconf argument, which was misleading, to include_mempool, with appropriately updated docstring. Finally, in this commit we also ensure that callers of this function check, where necessary, the returned confirmations field to disallow unconfirmed utxos where that is necessary.
2a9972f
to
a3e1ba3
Compare
Squashed in a3e1ba3. Now merging, as it has had a fair bit of review and is an important change that can affect several other fixes. |
Fixes #1294.
Before this commit, calls to query_utxo_set with default arguments
would ignore the mempool and thus return utxos which were spent in
unconfirmed transactions. Thus, takers would continue negotiation of
coinjoins with makers who sent them already-spent utxos, leading to
failure at broadcast time. This was not intended behaviour; we want
takers to reject utxos that are double spent in the mempool.
This commit changes that default argument to True so that utxo set
changes in the mempool are accounted for. All current calls to this
function use the default value of the includeunconf argument.