Skip to content

Conversation

glozow
Copy link
Member

@glozow glozow commented Jan 4, 2022

followup to #23683, addressing #23683 (comment)

@glozow
Copy link
Member Author

glozow commented Jan 4, 2022

cc @jnewbery, as requested here

@DrahtBot
Copy link
Contributor

DrahtBot commented Jan 5, 2022

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #24080 (policy: Remove unused locktime flags by MarcoFalke)
  • #23897 (refactor: Separate lockpoint calculate logic from CheckSequenceLocks function by hebasto)

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.

@jnewbery
Copy link
Contributor

jnewbery commented Jan 5, 2022

ACK c633c41

@hebasto
Copy link
Member

hebasto commented Jan 5, 2022

Related #23897.

Copy link
Member

@hebasto hebasto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)) {

?

@glozow
Copy link
Member Author

glozow commented Jan 17, 2022

Sorry for the delay! I've addressed @hebasto and @instagibbs comments and grouped in @hebasto's commit from #23958.

Copy link
Member

@instagibbs instagibbs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 283936b

Copy link
Member

@hebasto hebasto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

glozow and others added 2 commits January 18, 2022 11:55
Co-authored-by: John Newbery <john@johnnewbery.com>
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 <32963518+hebasto@users.noreply.github.com>
@glozow
Copy link
Member Author

glozow commented Jan 18, 2022

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?

Oops! Good catch, fixed.

Copy link
Member

@hebasto hebasto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK e177fca, I have reviewed the code and it looks OK, I agree it can be merged.

Copy link
Member

@instagibbs instagibbs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK e177fca

@fanquake fanquake requested a review from jnewbery January 19, 2022 12:47
@@ -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)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: any reason to check for coin.IsSpent(), given the assertion?

Copy link
Member

@maflcko maflcko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-----

@maflcko maflcko merged commit 06b6369 into bitcoin:master Jan 19, 2022
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Jan 20, 2022
maflcko pushed a commit to bitcoin-core/gui that referenced this pull request Jan 24, 2022
… 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
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Jan 28, 2022
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
Fabcien pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Nov 24, 2022
Summary:
Co-authored-by: John Newbery <john@johnnewbery.com>

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
Fabcien pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Nov 24, 2022
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 <32963518+hebasto@users.noreply.github.com>

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
@bitcoin bitcoin locked and limited conversation to collaborators Jan 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants