document and clean up MaybeUpdateMempoolForReorg#23976
document and clean up MaybeUpdateMempoolForReorg#23976maflcko merged 2 commits intobitcoin:masterfrom
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. |
|
ACK c633c41e3089c44a90f1f8c32a2b411889cefcdf |
|
Related #23897. |
hebasto
left a comment
There was a problem hiding this comment.
Concept ACK.
What about
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -348,11 +348,11 @@ void CChainState::MaybeUpdateMempoolForReorg(
AssertLockHeld(m_mempool->cs);
AssertLockHeld(::cs_main);
const CTransaction& tx = it->GetTx();
+ if (!CheckFinalTx(m_chain.Tip(), tx, flags)) return true;
LockPoints lp = it->GetLockPoints();
const bool validLP{TestLockPointValidity(m_chain, lp)};
CCoinsViewMemPool view_mempool(&CoinsTip(), *m_mempool);
// The transaction must be final.
- if (!CheckFinalTx(m_chain.Tip(), tx, flags)) return true;
// Note if CheckSequenceLocks fails the LockPoints may still be invalid
// So it's critical that we remove the tx and not depend on the LockPoints.
if (!CheckSequenceLocks(m_chain.Tip(), view_mempool, tx, flags, &lp, validLP)) {?
|
Sorry for the delay! I've addressed @hebasto and @instagibbs comments and grouped in @hebasto's commit from #23958. |
hebasto
left a comment
There was a problem hiding this comment.
It looks like some changes that belong to the second commit--a replacing update_lock_points with a lambda--go to the first commit accidentally, no?
Co-authored-by: John Newbery <[email protected]>
No behavior change. This code was introduced in 5add7a7 before we required C++11, which is why the struct was needed. As we are now using more modern C++ and this is the only place where lockpoints are updated for mempool entries, it is more idiomatic to call `modify` with a lambda. Co-authored-by: Hennadii Stepanov <[email protected]>
Oops! Good catch, fixed. |
| @@ -372,18 +388,16 @@ void CChainState::MaybeUpdateMempoolForReorg( | |||
| assert(!coin.IsSpent()); | |||
| const auto mempool_spend_height{m_chain.Tip()->nHeight + 1}; | |||
| if (coin.IsSpent() || (coin.IsCoinBase() && mempool_spend_height - coin.nHeight < COINBASE_MATURITY)) { | |||
There was a problem hiding this comment.
nit: any reason to check for coin.IsSpent(), given the assertion?
maflcko
left a comment
There was a problem hiding this comment.
Approach ACK e177fca 😶
Did not review the last commit, but given the assert added in b4adc5a it should be correct.
Show signature
Signature:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
Approach ACK e177fcab3831b6d259da5164cabedcc9e78f6957 😶
Did not review the last commit, but given the assert added in b4adc5ad6769e4a5a6179dfff271cd4c9dc47a5b it should be correct.
-----BEGIN PGP SIGNATURE-----
iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
pUj/Ugv+N4lEh7A93jSO5imukN2scMEs6r7j7KNiTudrany2XPrSbTvJQgl+q46K
j5UPWvQCzJ0M+NpenYE0Eiefl51eZGRo+4rT06GlQJ/jNyZkutbVmbbNvspM19gg
lsnpx7pfaLR9MFAmIZQ3xz2y5zu2adewPtFrTAfKbxfkZbkR17+EayICGvXRked9
u/UGf/F/XmA/Yopnfn4jAHpPUlvvgKFxOaRFI76302IDY6D9XgzTAg2cjLBlUuy9
3KCf5UGPJ2fVYFcpf4OZdsGi+vzo17+UGOK0dcYb/wLqfr2VH/mZPL5o/jo2l3d4
EcGvDAzYRrM3tvRp9pFDO0O27avyvMw106RI/u1/TyqKX4apcblX954bAugIBXuN
ZgAed34pqaHeRqm9R1WdY1O270pehbUtv+NKWu6awEZ+j79vwF8UVwOModkepwbd
Fp0c+f4aEAzHLEEdpMR2l+XUrF97ZviaVNGXX06bfuIpSsw7MpR3K98SMmLxVyn9
CVsQAgjV
=YL6U
-----END PGP SIGNATURE-----
… row fa2bcc4 Run coin.IsSpent only once in a row (MarcoFalke) Pull request description: Follow-up to commit 64e4963 and bitcoin/bitcoin#23976 (comment) ACKs for top commit: glozow: utACK fa2bcc4, agree the assertion is sufficient theStack: Code-review ACK fa2bcc4 w0xlt: crACK bitcoin/bitcoin@fa2bcc4 shaavan: Code Review ACK fa2bcc4 brunoerg: crACK fa2bcc4 Tree-SHA512: 3be9d6b313bf6bb835f031826c81777b4659118d839001d084e72462391cb64ba81d06a5e07fd21fcfb709a71b08892b23212a98604ce8481da489476b72f072
fa2bcc4 Run coin.IsSpent only once in a row (MarcoFalke) Pull request description: Follow-up to commit 64e4963 and bitcoin#23976 (comment) ACKs for top commit: glozow: utACK fa2bcc4, agree the assertion is sufficient theStack: Code-review ACK fa2bcc4 w0xlt: crACK bitcoin@fa2bcc4 shaavan: Code Review ACK fa2bcc4 brunoerg: crACK fa2bcc4 Tree-SHA512: 3be9d6b313bf6bb835f031826c81777b4659118d839001d084e72462391cb64ba81d06a5e07fd21fcfb709a71b08892b23212a98604ce8481da489476b72f072
Summary: Co-authored-by: John Newbery <[email protected]> This is a partial backport of [[bitcoin/bitcoin#23976 | core#23976]] bitcoin/bitcoin@c7cd98c Test Plan: `ninja all check-all` Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Subscribers: Fabien Differential Revision: https://reviews.bitcoinabc.org/D12587
Summary: No behavior change. This code was introduced in 5add7a7 before we required C++11, which is why the struct was needed. As we are now using more modern C++ and this is the only place where lockpoints are updated for mempool entries, it is more idiomatic to call `modify` with a lambda. Co-authored-by: Hennadii Stepanov <[email protected]> This concludes backport of [[bitcoin/bitcoin#23976 | core#23976]] bitcoin/bitcoin@e177fca Depends on D12587 Test Plan: `ninja all check-all` Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Differential Revision: https://reviews.bitcoinabc.org/D12588
followup to #23683, addressing #23683 (comment)