Remove mempool global from interfaces #19848

pull MarcoFalke wants to merge 3 commits into bitcoin:master from MarcoFalke:2008-nomemint changing 3 files +41 −15
  1. MarcoFalke commented at 2:50 pm on August 31, 2020: member
    The chain interface has an m_node member, which has a pointer to the mempool global. Use the pointer instead of the global to prepare the removal of the mempool global. See #19556
  2. MarcoFalke added the label Refactoring on Aug 31, 2020
  3. promag commented at 3:03 pm on August 31, 2020: member
    Correct me if I’m wrong but m_node.mempool is always set right?
  4. MarcoFalke commented at 3:08 pm on August 31, 2020: member

    https://github.com/bitcoin/bitcoin/blob/068bc211881c790225e9979eb16ce4f44fb64e01/src/init.cpp#L1374

    Currently it will be set during init until shortly before shutdown is done. Though, in the future it may be nullptr for the whole runtime of the program (see also #19629 (comment))

  5. DrahtBot commented at 4:55 pm on August 31, 2020: member

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

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #19872 (Avoid locking CTxMemPool::cs recursively in some cases by hebasto)
    • #19572 (ZMQ: Create “sequence” notifier, enabling client-side mempool tracking by instagibbs)
    • #19556 (Remove mempool global by MarcoFalke)
    • #15719 (Wallet passive startup by ryanofsky)
    • #12677 (RPC: Add ancestor{count,size,fees} to listunspent output by luke-jr)

    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.

  6. hebasto commented at 5:42 pm on August 31, 2020: member
    Concept ACK.
  7. practicalswift commented at 7:09 pm on August 31, 2020: contributor
    Concept ACK
  8. darosior commented at 7:19 pm on August 31, 2020: member
    Concept ACK
  9. jnewbery commented at 8:31 am on September 2, 2020: member
    utACK fa5fa7e025164f9ac73741ece697e3ea4e7ed64c
  10. in src/policy/rbf.cpp:11 in fa5fa7e025 outdated
     4@@ -5,9 +5,10 @@
     5 #include <policy/rbf.h>
     6 #include <util/rbf.h>
     7 
     8-RBFTransactionState IsRBFOptIn(const CTransaction& tx, const CTxMemPool& pool)
     9+namespace {
    10+RBFTransactionState IsRBFOptIn(const CTransaction& tx, const CTxMemPool* const pool) NO_THREAD_SAFETY_ANALYSIS
    11 {
    12-    AssertLockHeld(pool.cs);
    13+    if (pool) AssertLockHeld(pool->cs);
    


    hebasto commented at 5:02 pm on September 2, 2020:

    Could we avoid:

    ?


    MarcoFalke commented at 8:08 am on September 3, 2020:
    Fixed
  11. ryanofsky approved
  12. ryanofsky commented at 5:23 pm on September 2, 2020: member
    Code review ACK fa5fa7e025164f9ac73741ece697e3ea4e7ed64c. Seems good for these calls to function without a mempool. Agree with hebasto it would be nice to clean up locking assertions within IsRBFOptIn. But if that requires more invasive changes to IsRBFOptIn, it would probably be better to do it in a targeted PR before or after this one.
  13. MarcoFalke force-pushed on Sep 3, 2020
  14. MarcoFalke commented at 8:08 am on September 3, 2020: member
    Changed the first commit to remove NO_THREAD_SAFETY_ANALYSIS. Let me know if this is better or if I should revert to the initial version.
  15. in src/policy/rbf.h:27 in fa9124d935 outdated
    27+ * @param tx   The unconfirmed transaction
    28+ * @param pool The mempool, which may contain the tx
    29+ *
    30+ * @return     The rbf state. May be UNKNOWN for unconfirmed transactions not
    31+ *             in the mempool. May be REPLACEABLE_BIP125 for transactions that
    32+ *             conflict with an in-chain transaction.
    


    hebasto commented at 6:38 pm on September 3, 2020:

    MarcoFalke commented at 6:47 am on September 4, 2020:
    It wasn’t the goal to document RBFTransactionState, but since you asked for it, I’ve done that
  16. hebasto changes_requested
  17. hebasto commented at 6:39 pm on September 3, 2020: member
    Approach ACK fa9124d93527fd5ff741000b790a3772f2961a52
  18. MarcoFalke force-pushed on Sep 4, 2020
  19. MarcoFalke commented at 6:48 am on September 4, 2020: member
    fixed up and force pushed last doc commit
  20. hebasto approved
  21. hebasto commented at 6:57 am on September 4, 2020: member
    ACK fadb436745515f16efb1330b36e6f3831c0ac5fb
  22. in src/policy/rbf.cpp:44 in fadb436745 outdated
    35@@ -36,3 +36,10 @@ RBFTransactionState IsRBFOptIn(const CTransaction& tx, const CTxMemPool& pool)
    36     }
    37     return RBFTransactionState::FINAL;
    38 }
    39+
    40+RBFTransactionState IsRBFOptInEmptyMempool(const CTransaction& tx)
    41+{
    42+    static const CTxMemPool pool_empty;
    43+    LOCK(pool_empty.cs);
    44+    return IsRBFOptIn(tx, pool_empty);
    


    jnewbery commented at 7:59 am on September 4, 2020:

    Seems like quite a roundabout way to avoid one line of code:

    0    // If we don't have a local mempool we can only check the transaction itself.
    1    return SignalsOptInRBF(tx) ? RBFTransactionState::REPLACEABLE_BIP125 : RBFTransactionState::UNKNOWN;
    
  23. jnewbery commented at 8:01 am on September 4, 2020: member

    I’m not very keen on the static const mempool and have an alternative.

    ACK fadb436745515f16efb1330b36e6f3831c0ac5fb

  24. ryanofsky approved
  25. ryanofsky commented at 7:09 pm on September 4, 2020: member
    Code review ack fadb436745515f16efb1330b36e6f3831c0ac5fb. Since last review reverted changes to IsRBFOptIn with different IsRBFOptInEmptyMempool workaround. John’s third workaround seems good too.
  26. darosior approved
  27. darosior commented at 7:14 pm on September 4, 2020: member

    tested ACK fadb436745515f16efb1330b36e6f3831c0ac5fb

    I also prefer jnewberry’s patch, but not against merging this without it.

  28. refactor: Add IsRBFOptInEmptyMempool
    Co-authored-by: John Newbery <jonnynewbs@gmail.com>
    fa831684e5
  29. Remove mempool global from interfaces faef4fc9b4
  30. doc: Add doxygen comment to IsRBFOptIn fa9ee52556
  31. MarcoFalke force-pushed on Sep 5, 2020
  32. MarcoFalke commented at 9:49 am on September 5, 2020: member

    Changed first commit according to feedback.

    Untitled png

  33. darosior approved
  34. darosior commented at 9:58 am on September 5, 2020: member
    ACK fa9ee52
  35. hebasto approved
  36. hebasto commented at 10:07 am on September 5, 2020: member

    re-ACK fa9ee52556f493e4a896e2570ca1a3102d777d9a, since my previous review:

    • applied @jnewbery’s patch
    • added @jnewbery as a co-author of the “refactor: Add IsRBFOptInEmptyMempool” commit
    • rebased
  37. jnewbery commented at 10:13 am on September 5, 2020: member
    utACK fa9ee52556
  38. MarcoFalke merged this on Sep 5, 2020
  39. MarcoFalke closed this on Sep 5, 2020

  40. MarcoFalke deleted the branch on Sep 5, 2020
  41. deadalnix referenced this in commit d4e8a4c13f on Jul 15, 2021
  42. DrahtBot locked this on Feb 15, 2022

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-12-19 00:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me