-
Notifications
You must be signed in to change notification settings - Fork 37.7k
refactor: AcceptToMemoryPool #23437
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: AcceptToMemoryPool #23437
Conversation
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. 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. |
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
I also have a branch that does this (amongst other things) here: https://github.com/jnewbery/bitcoin/tree/2021-09-process-transaction-2. Feel free to take anything you find useful from that branch.
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, good cleanup.
20867dc
to
034e827
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.
A few more comments inline
As these changes are already implemented in another branch, with more other commits, I can close this PR if it's better.
No, please continue with this PR! Just feel free to take anything from the other branch that you find useful.
Concept ACK |
1333ddf
to
aac6548
Compare
Possible follow-up idea that came to my mind while reviewing this PR: couldn't we simplify the interface of -MempoolAcceptResult AcceptToMemoryPool(const CChainParams& chainparams, CTxMemPool& pool,
- CChainState& active_chainstate, const CTransactionRef& tx,
+MempoolAcceptResult AcceptToMemoryPool(CChainState& active_chainstate, const CTransactionRef& tx,
int64_t accept_time, bool bypass_limits, bool test_accept)
EXCLUSIVE_LOCKS_REQUIRED(cs_main)
{
+ const CChainParams& chainparams{active_chainstate.m_params};
+ assert(active_chainstate.m_mempool != nullptr);
+ CTxMemPool& pool{*active_chainstate.m_mempool};
std::vector<COutPoint> coins_to_uncache;
MemPoolAccept::ATMPArgs args { chainparams, accept_time, bypass_limits, coins_to_uncache,
test_accept, /* m_allow_bip125_replacement */ true }; I couldn't think of a case where passing chainparams or a mempool instance that doesn't belong to the active chainstate makes much sense. Drawback though: currently the member |
#23173 is merged. Please rebase and I'll review. |
aac6548
to
5b2f49d
Compare
5b2f49d
to
9f96751
Compare
Please update the PR description now that #23173 is merged. |
9f96751
to
c3d1519
Compare
863703c
to
8f46eb5
Compare
@theStack and @stratospher thanks for the review. |
8f46eb5
to
4ec8b96
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 4ec8b96
utACK 4ec8b96 Happy to rereview this once it's rebased. |
4ec8b96
to
123f5de
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 123f5de
reACK 123f5de |
light code review ACK 123f5de |
* @param[in] tx The transaction to submit for mempool acceptance. | ||
* @param[in] accept_time The timestamp for adding the transaction to the mempool. Usually | ||
* the current system time, but may be different. |
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: I don't think we need to explain what the argument means at the call site.
f1f10c0 Remove CTxMemPool params from ATMP (lsilva01) Pull request description: Remove `CTxMemPool` parameter from `AcceptToMemoryPool` function, as suggested in bitcoin/bitcoin#23437 (comment) . This requires that `CChainState` has access to `MockedTxPool` in `tx_pool.cpp` as mentioned bitcoin/bitcoin#23173 (comment). So the `MockedTxPool` is attributed to `CChainState::m_mempool` before calling `AcceptToMemoryPool`. Requires #23437. ACKs for top commit: jnewbery: utACK f1f10c0 MarcoFalke: review ACK f1f10c0 🔙 Tree-SHA512: 2a4885f4645014fc1fa98bb1090f13721c1a0796bc0021b9cb43bc8cc13920b6eaf057d1f5ed796e0a110e7813e41fe0196334ce7c80d1231fc057a9a3bdf349
f1f10c0 Remove CTxMemPool params from ATMP (lsilva01) Pull request description: Remove `CTxMemPool` parameter from `AcceptToMemoryPool` function, as suggested in bitcoin#23437 (comment) . This requires that `CChainState` has access to `MockedTxPool` in `tx_pool.cpp` as mentioned bitcoin#23173 (comment). So the `MockedTxPool` is attributed to `CChainState::m_mempool` before calling `AcceptToMemoryPool`. Requires bitcoin#23437. ACKs for top commit: jnewbery: utACK f1f10c0 MarcoFalke: review ACK f1f10c0 🔙 Tree-SHA512: 2a4885f4645014fc1fa98bb1090f13721c1a0796bc0021b9cb43bc8cc13920b6eaf057d1f5ed796e0a110e7813e41fe0196334ce7c80d1231fc057a9a3bdf349
93134c7 Remove calls to global Params() in tx_pool test (lsilva01) bfdb258 Remove AcceptToMemoryPoolWithTime (lsilva01) Pull request description: This PR refactors AcceptToMemoryPool. . Remove `AcceptToMemoryPoolWithTime` (after #23173, this function is no longer needed). . Remove the `CChainParams chainparams` parameter from ATMP as they can be inferred from the current chain state. . Update the `tx_pool` test with new function signature. ACKs for top commit: jnewbery: reACK 93134c7 glozow: light code review ACK 93134c7 theStack: re-ACK 93134c7 Tree-SHA512: b672d9f091f5fcb4d163c0a443aa469b2ce6f37201136803201c620c3fa329ffb41abd50c5b528787fd1c47e8e09af5ec20ddaa0a4235352c9c619e5691dddb6
efbb49e Remove CTxMemPool params from ATMP (lsilva01) Pull request description: Remove `CTxMemPool` parameter from `AcceptToMemoryPool` function, as suggested in bitcoin/bitcoin#23437 (comment) . This requires that `CChainState` has access to `MockedTxPool` in `tx_pool.cpp` as mentioned bitcoin/bitcoin#23173 (comment). So the `MockedTxPool` is attributed to `CChainState::m_mempool` before calling `AcceptToMemoryPool`. Requires #23437. ACKs for top commit: jnewbery: utACK efbb49e MarcoFalke: review ACK efbb49e 🔙 Tree-SHA512: 2a4885f4645014fc1fa98bb1090f13721c1a0796bc0021b9cb43bc8cc13920b6eaf057d1f5ed796e0a110e7813e41fe0196334ce7c80d1231fc057a9a3bdf349
Summary: This is a backport of [[bitcoin/bitcoin#23437 | core#23437]] bitcoin/bitcoin@9360778 The fuzzer part of the first commit and the second commit are not applicable, due to missing fuzzer backports. Depends on D12236 Test Plan: `ninja all check-all` Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Subscribers: Fabien Differential Revision: https://reviews.bitcoinabc.org/D12238
This PR refactors AcceptToMemoryPool.
. Remove
AcceptToMemoryPoolWithTime
(after #23173, this function is no longer needed).. Remove the
CChainParams chainparams
parameter from ATMP as they can be inferred from the current chain state.. Update the
tx_pool
test with new function signature.