-
Notifications
You must be signed in to change notification settings - Fork 35.5k
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
refactor: Simplify CTxMempool/BlockAssembler fields, remove some external mapTx access #28391
refactor: Simplify CTxMempool/BlockAssembler fields, remove some external mapTx access #28391
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. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
9f854df
to
18503e0
Compare
Concept ACK fwiw |
18503e0
to
93be096
Compare
93be096
to
a5bdd7e
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.
Concept ACK on the changes on in this PR.
This refactor all seems relevant.
The commits are really atomic and easier to review. 💯
a5bdd7e
to
f0577ea
Compare
Rebased a5bdd7e -> f0577ea (simplifyMemPoolInteractions_0 -> simplifyMemPoolInteractions_1, compare) |
f0577ea
to
5fb9ddf
Compare
The behavior is the same as CalculateMemPoolAncestors. The only difference is the string returned, and the string is discarded anyway since checkChainLimits only cares about pass/fail.
Allows calling UpdateLockPoints() with a (const) txiter. Note that this was already possible for caller using mapTx.modify(txiter). The point here is to not be accessing mapTx when doing so.
vTxHashes exposes a complex mapTx iterator type that its external users don't need. Directly populate it with CTransactionRef instead.
-BEGIN VERIFY SCRIPT- git grep -l "vTxHashesIdx" src | xargs sed -i "s/vTxHashesIdx/idx_randomized/g" git grep -l "vTxHashes" src | xargs sed -i "s/vTxHashes/txns_randomized/g" -END VERIFY SCRIPT-
Use the helper function instead of reaching into the mapTx member object.
3b73acb
to
4dd94ca
Compare
Updated 3b73acb -> 4dd94ca (simplifyMemPoolInteractions_15 -> simplifyMemPoolInteractions_16, 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 4dd94ca
reACK 4dd94ca |
re-ACK 4dd94ca 👝 Show signatureSignature:
|
|
||
std::vector<CTxMemPoolEntryRef> ret; | ||
ret.reserve(mapTx.size()); | ||
for (const auto& it : GetSortedDepthAndScore()) { |
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.
Is there a reason that we are invoking GetSortedDepthAndScore()
here, ie do any of the callers rely on a particular sort order?
(I'm planning to eliminate this function in #28676, so just want to understand if this behavior needs to be preserved for some reason.)
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.
This function is supposed to mimic infoAll
, which was originally used in this patchset to retrieve mempool information instead of directly accessing mapTx
. Looking at its usage you are right, the way I read this too there were no order promises made prior to this patch. I opened #29019 to instead just iterate through mapTx
.
…mits` error message to wallet 8dec9c5 wallet, mempool: propagete `checkChainLimits` error message to wallet (ismaelsadeeq) Pull request description: * Requested in [#28391 comment](bitcoin/bitcoin#28391 (comment)) * The error message is static when a new transaction is created and package limit is reached. `Transaction has too long of a mempool chain` While the [`CTxMempool::CheckPackageLimits`](https://github.com/bitcoin/bitcoin/blob/5800c558eb5efb4839ed00d6967e43306d68e1c3/src/txmempool.cpp#L199) provide explicit information about the error message. * This PR updates [`CTxMempool::CheckPackageLimits`](https://github.com/bitcoin/bitcoin/blob/5800c558eb5efb4839ed00d6967e43306d68e1c3/src/txmempool.cpp#L199) return type to `util::Result<void>`, `CheckPackageLimits` now returns void when package limit is not hit, and returns the error string whenever package limit is hit instead of using out parameter `errString`. * The PR updates [`checkChainLimits`](https://github.com/bitcoin/bitcoin/blob/5800c558eb5efb4839ed00d6967e43306d68e1c3/src/node/interfaces.cpp#L703) return type to `util::Result<void>`. * Now the wallet `CreateTransactionInternal` will have access to the package limit error string whenever its hit. * Also Updated functional test to reflect the error message from `CTxMempool::CheckPackageLimits` output. ACKs for top commit: glozow: utACK 8dec9c5 Sjors: utACK 8dec9c5 TheCharlatan: Re-ACK 8dec9c5 Tree-SHA512: ddeac18aeba6f8e3be0e3fe76bf3db655352e3b415169f1f83ea1e8976a2f3e3de021c8da6880eb8382ab52d545e418e3f4d57adcc68ecb4f390339710ee6f30
Should we backport 453b481? |
Instead of reaching into the mapTx data structure, use a helper method that provides the required vector of CTxMemPoolEntry pointers. Github-Pull: bitcoin#28391 Rebased-From: 453b481
Instead of reaching into the mapTx data structure, use a helper method that provides the required vector of CTxMemPoolEntry pointers. Github-Pull: bitcoin#28391 Rebased-From: 453b481
Instead of reaching into the mapTx data structure, use a helper method that provides the required vector of CTxMemPoolEntry pointers. Github-Pull: bitcoin#28391 Rebased-From: 453b481
11f3a7e Use hardened runtime on macOS release builds. (Mark Friedenbach) ac1b9a5 [test] import descriptor wallet with reorged parent + IsFromMe child in mempool (glozow) ecb8ebc [test] rescan legacy wallet with reorged parent + IsFromMe child in mempool (Gloria Zhao) 438ac29 snapshots: don't core dump when running -checkblockindex after `loadtxoutset` (Mark Friedenbach) 7ec3455 [log] mempool loading (glozow) fe0f8fe net: create I2P sessions with both ECIES-X25519 and ElGamal encryption (Jon Atack) fc62271 [refactor] Add helper for iterating through mempool entries (stickies-v) Pull request description: Backports for 26.x. Includes: - 453b481 from #28391 - #29179 - #29200 - #29227 - #28791 - #29127 ACKs for top commit: stickies-v: ACK 11f3a7e Tree-SHA512: 20ef871ec768f2328056d83f958e595b36ae9b8baa8a6e8b0e1f02c3df4b16965a8e05dcb4323afbcc9ecc4bdde10931232512022c39ee7e12baf9795bf25bf1
Motivation
mapTx
or its iterators directly.Overview of things done in this PR:
vTxHashes
a vector of transaction references instead of a pair of transaction hash and iterator. The trade off here is that the data is retrieved on the fly withGetEntry
instead of being cached invTxHashes
.GetEntry
helper method to replace the more involvedGetIter
where applicablemapTx
access withCTxMemPool
helper methodscheckChainLimits
call innode/interfaces.cpp
CTxMemPoolEntry
slockPoints
mutable such that they can be changed with a const iterator directly instead of going throughmapTx
BlockAssembler
'sinBlock
andfailedTx
sets of transaction hashes.