-
Notifications
You must be signed in to change notification settings - Fork 38.7k
wallet: Do not set fInMempool in transactionAddedToMempool when tx is not in the mempool #22359
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
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsNo conflicts as of last run. |
promag
left a comment
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.
Not sure about this, can't the transaction be removed from the mempool after isInMempool?
Wouldn't be more correct to SyncWithValidationInterfaceQueue at the end of the RPC call - in the same way it's called at the beginning? This ensures transactionRemovedFromMempool is processed to the caller?
|
I could be missing something but it seems to me neither solution is clearly correct in all cases. The advantages of this solution over #18440 are that:
But I do agree with the general point that a fully correct solution is probably a blocking solution. I just think the blocking should be targeted. Not more narrow or more wide than it needs to be. For example could add |
Thinking about this, in a really pathological case where a replaced transaction got added back to the mempool, this could hang. Dropping Any case, will ACK this PR. IMO, this is the best fix for we have for now, and it is straightforward and simple, even if it is not 100% right in every case and doesn't have a fancy test. |
ryanofsky
left a comment
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.
Code review ACK fa9ef0e8c6f379499ba7415040b76a76afdb02dc. This is a pretty simple fix that should make tests more reliable and the RPC more reliable in applications and should be better than status quo even if it is not 100% in every case (see previous discussion).
|
Should we do this in |
… not in the mempool Github-Pull: bitcoin#22359 Rebased-From: fa9ef0e8c6f379499ba7415040b76a76afdb02dc
|
Maybe it should avoid @@ -1078,10 +1078,11 @@ bool CWallet::AbandonTransaction(const uint256& hashTx)
std::set<uint256> done;
// Can't mark abandoned if confirmed or in mempool
+ if (chain().isInMempool(hashTx)) return false;
auto it = mapWallet.find(hashTx);
assert(it != mapWallet.end());
const CWalletTx& origtx = it->second;
- if (origtx.GetDepthInMainChain() != 0 || origtx.InMempool()) {
+ if (origtx.GetDepthInMainChain() != 0) {
return false;
} |
promag
left a comment
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.
Code review ACK fa9ef0e8c6f379499ba7415040b76a76afdb02dc.
Thx, done. |
Maybe the mempool status should be removed and simply be queried when needed? Otherwise it just seems like applying random patches that happen to improve the situation, but don't actually fix the underlying issue. |
I think there are two drawbacks to querying the mempool when needed:
I think if we combine transaction states (730df28 from #21206) with the notify suggestion mentioned earlier (in #22359 (comment) and #22359 (comment)), that is a clean and robust solution that gets rid of all race conditions. But since that requires reviewing and writing more code, using |
ryanofsky
left a comment
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.
Code review ACK fa6fd3d. Only change since last review is extending workaround to transactionRemovedFromMempool. Since we know this workaround is imperfect and the goal of this PR is mainly to fix CI errors, I would probably be inclined to limit the workaround to as few places as possible where we have seen actual failures, instead of adding the workaround to as many places as possible, where there is some chance it might trigger new failures. But since this workaround is so straightforward and almost looks like a real fix, probably it doesn't matter.
Block waiting for transactions to enter the mempool to avoid race conditions as discussed bitcoin#22359 (comment)
FWIW, I started implementing this in f54631d (branch). It could be cleaned up more, and doesn't have a dedicated test, and might not be totally complete (might need one or two more |
Block waiting for transactions to enter the mempool to avoid race conditions as discussed bitcoin#22359 (comment)
meshcollider
left a comment
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.
utACK fa6fd3d
…dToMempool when tx is not in the mempool fa6fd3d wallet: Properly set fInMempool in mempool notifications (MarcoFalke) Pull request description: A wallet method (like bumping the fee) might have set `fInMempool` to false because the transaction was removed from the mempool (See commit fa4e088). Avoid setting it back to true (incorrectly) in the validation interface background thread. Fixes bitcoin#22357 ACKs for top commit: ryanofsky: Code review ACK fa6fd3d. Only change since last review is extending workaround to `transactionRemovedFromMempool`. Since we know this workaround is imperfect and the goal of this PR is mainly to fix CI errors, I would probably be inclined to limit the workaround to as few places as possible where we have seen actual failures, instead of adding the workaround to as many places as possible, where there is some chance it might trigger new failures. But since this workaround is so straightforward and almost looks like a real fix, probably it doesn't matter. meshcollider: utACK fa6fd3d Tree-SHA512: d690136a577f1f532aa1fee80d3f6600ff7fc61286fbf564a53d7938d5ae52d33f0dbb0fef8b8c041a4970fb424f0b9f1ee7ce791e0ff8354e0000ecc9e22b84
Github-Pull: bitcoin#22359 Rebased-From: fa6fd3d
Github-Pull: bitcoin#22359 Rebased-From: fa6fd3d
A wallet method (like bumping the fee) might have set
fInMempoolto false because the transaction was removed from the mempool (See commit fa4e088).Avoid setting it back to true (incorrectly) in the validation interface background thread.
Fixes #22357