-
Notifications
You must be signed in to change notification settings - Fork 37.7k
mempool: Don't sort in entryAll #29019
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. Code CoverageFor detailed information about the code coverage, see the test coverage report. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. ConflictsNo conflicts as of last run. |
Will this PR not cause issues here? In |
Well, if it is needed, then 453b481 should not have been tagged "refactor", but "bugfix" and should be backported, along with a regression test? |
That is a good point, I'd missed that this just reverts back to the behaviour pre- |
I'm not necessarily planning to remove I think if the sorted order is not needed, probably best to remove it now so that we don't take the performance hit needlessly in the next release...? I mostly just wanted to know if I needed to replace it with the new topological sort I'm implementing or if it's fine to just revert back to the mapTx order. |
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 87fa444
src/txmempool.cpp
Outdated
@@ -832,8 +832,8 @@ std::vector<CTxMemPoolEntryRef> CTxMemPool::entryAll() const | |||
|
|||
std::vector<CTxMemPoolEntryRef> ret; | |||
ret.reserve(mapTx.size()); |
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.
nit: you could just write
AssertLockHeld(cs);
return {mapTx.begin(), mapTx.end()};
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.
Thanks, seems easy enough to re-ACK, so will push this.
Current call sites of entryAll do not require the entries to be sorted, so iterate through mapTx directly to retrieve the entries instead of using SortedDepthAndScore.
87fa444
to
f761f03
Compare
Updated 87fa444 -> f761f03 (entryAllNoOrder_0 -> entryAllNoOrder_1, compare) |
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.
re-ACK f761f03, very nice
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 f761f03
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 f761f03 given this brings us back to what we had before
It seems correct that none of the callsites need GetSortedDepthAndScore
, though maybe topological is needed in wallet? I had the same question. I guess insertion order doesn't imply topological if a parent was inserted later than a child, i.e. if it's from a reorg?
I wrote a test and I think we actually do need a topological sort here. See #29179. Cherry-picking this on top, it fails with
which indicates that the child wasn't identified as |
Seems like the new behavior incidentally fixed a bug, so closing this again in favor of #29179. Could do a follow-up eventually to make the |
…d in mempool df30247 [test] import descriptor wallet with reorged parent + IsFromMe child in mempool (glozow) c3d02be [test] rescan legacy wallet with reorged parent + IsFromMe child in mempool (Gloria Zhao) Pull request description: Originally motivated by #29019, which reverts back to having `requestMempoolTransactions` emit `transactionAddedToMempool` in `mapTx` default order instead of `GetSortedDepthAndScore` order. It's important that these notifications happen in topological order, otherwise the wallet rescan may miss transactions that belong to it. Notably, checking whether a transaction `IsFromMe` requires knowing its inputs, which may be from a mempool parent. When using `mapTx` order, a parent may come later than its child if it was added from a block disconnected in a reorg. This PR adds a test for this case. ACKs for top commit: achow101: ACK df30247 furszy: Code review ACK df30247, nits can be disregarded. Tree-SHA512: 2f1d9ef92313228adbbef94e634e5f7a9ec6e6a2c88e16aa343bdc95ffc9b9f9c82a569b412c9a3841db9d789e52f9283e8b9385731668d59355903e26e58a5d
Current call sites of entryAll do not require the entries to be sorted, so iterate through mapTx directly to retrieve the entries instead of using SortedDepthAndScore.
This is a follow up to #28391 and was noted here #28391 (comment).