[Mempool] Fix mempool limiting and replace-by-fee for PrioritiseTransaction #7062

pull sdaftuar wants to merge 4 commits into bitcoin:master from sdaftuar:fix-mempool-limiting changing 8 files +211 −92
  1. sdaftuar commented at 5:36 PM on November 19, 2015: member

    This fixes the behavior of the mempool limiting to respect any fee deltas applied via PrioritiseTransaction.

    (Note that the first 5 commits here are introduced by @morcos in #6898.)

    It also includes a couple other fixes relating to PrioritiseTransaction:

    • Updates RBF logic
    • Updates mempool acceptance logic
  2. morcos cross-referenced this on Nov 19, 2015 from issue Rewrite CreateNewBlock by morcos
  3. sdaftuar commented at 8:11 PM on November 19, 2015: member

    This will create merge conflicts for #6871 -- let's try to get that reviewed and merged first, and I can resolve the merge conflicts in this PR afterward.

  4. jonasschnelli added the label Mempool on Nov 20, 2015
  5. petertodd commented at 8:35 PM on November 20, 2015: contributor

    Note that this leaks information about what transactions you've prioritised to the outside world even more so than before. Probably unavoidable right now, but in the long run it'd be better if we had a separate mempool for mining that kept priority deltas. Transactions themselves can be shared across both mempools and reference counted.

  6. in src/rpcblockchain.cpp:None in f60b9035c8 outdated
     251 |              "    \"startingpriority\" : n, (numeric) priority when transaction entered pool\n"
     252 |              "    \"currentpriority\" : n,  (numeric) transaction priority now\n"
     253 |              "    \"descendantcount\" : n,  (numeric) number of in-mempool descendant transactions (including this one)\n"
     254 |              "    \"descendantsize\" : n,   (numeric) size of in-mempool descendants (including this one)\n"
     255 | -            "    \"descendantfees\" : n,   (numeric) fees of in-mempool descendants (including this one)\n"
     256 | +            "    \"descendantfees\" : n,   (numeric) modified fees of in-mempool descendants (including this one)\n"
    


    petertodd commented at 8:36 PM on November 20, 2015:

    The term "modified fees" won't mean anything to the reader. How about "fees of in-mempool descendants (including this one) with priority deltas applied"


    sdaftuar commented at 1:25 PM on November 24, 2015:

    I was trying to make a reference to the term "modifedfee" which I added above without having to redefine the concept, what if I just do: "modified fees (see above) of in-mempool descendants (including this one)"

  7. petertodd commented at 8:43 PM on November 20, 2015: contributor

    Otherwise, utACK, though will want to recheck rebased version once #6871 is merged of course.

  8. sdaftuar force-pushed on Nov 30, 2015
  9. sdaftuar renamed this:
    [Mempool] Fix mempool limiting for PrioritiseTransaction
    [Mempool] Fix mempool limiting and replace-by-fee for PrioritiseTransaction
    on Nov 30, 2015
  10. sdaftuar commented at 9:55 PM on November 30, 2015: member

    Rebased. @petertodd This pull has now been updated to use fee deltas for the replace-by-fee calculation, and the replace-by-fee rpc test has been updated to exercise that logic. (I cherry-picked #7137, so if that gets merged first I'll rebase this one, or I can close that pull if that's easier.)

  11. in qa/rpc-tests/replace-by-fee.py:None in 4b0c38c310 outdated
      71 | +            if (mempool_size == new_size):
      72 | +                # We might have stuck transactions; assume that
      73 | +                # the transactions we needed mined were mined, and
      74 | +                # don't worry about what is left.
      75 | +                break
      76 | +            mempool_size = new_size
    


    petertodd commented at 1:50 AM on December 1, 2015:

    FYI, I've found bugs before by erroring out if any txs are stuck; not sure this is a good idea.


    sdaftuar commented at 2:57 PM on December 1, 2015:

    Fair enough -- I ran into an issue where the really large transaction created in one of the tests was too big to mined, but I should be able to rework that test and make this check error out instead.

  12. sdaftuar force-pushed on Dec 1, 2015
  13. sdaftuar commented at 5:57 PM on December 1, 2015: member

    Rebased and changed rpc test to error out if the mempool ends up with stuck transactions.

  14. sdaftuar force-pushed on Dec 1, 2015
  15. sdaftuar commented at 7:34 PM on December 1, 2015: member

    Rebased now that #6898 is merged

  16. laanwj added this to the milestone 0.12.0 on Dec 2, 2015
  17. sdaftuar force-pushed on Dec 2, 2015
  18. sdaftuar commented at 4:28 PM on December 2, 2015: member

    Updated so that now mempool acceptance is also determined by including a transaction's fee delta from PrioritiseTransaction.

    In doing so, I realized that GetMinRelayFee is not very useful, so I scrapped it. With the DEFAULT_BLOCK_PRIORITY_SIZE set to 0, this function was stopping all free transactions from making it in (unless they were prioritised using PrioritiseTransaction). Scrapping it means that there is a behavior change from before, where now we will allow in transactions between 50kb and 100kb that are free as long as they have sufficient priority. Given that when the mempool is full we don't allow free transactions at all, and given that we expire things after 3 days, I think this should be okay.

    EDIT: Actually, there's a bug in GetMinRelayFee so that the comparison with DEFAULT_BLOCK_PRIORITY_SIZE was incorrect; the comparison is comparing two things as unsigned int's, but the right hand side is negative... So this test isn't preventing anything from getting into the mempool now that the DEFAULT_BLOCK_PRIORITY_SIZE is 0.

    if (nBytes < (DEFAULT_BLOCK_PRIORITY_SIZE - 1000))      
            nMinFee = 0;
    
  19. morcos commented at 4:50 PM on December 2, 2015: member

    utACK (modulo comment above)

  20. sdaftuar force-pushed on Dec 2, 2015
  21. sdaftuar commented at 5:59 PM on December 2, 2015: member

    Addressed @morcos' nit (and squashed into first commit).

  22. Fix mempool limiting for PrioritiseTransaction
    Redo the feerate index to be based on mining score, rather than fee.
    
    Update mempool_packages.py to test prioritisetransaction's effect on
    package scores.
    eb306664e7
  23. Update replace-by-fee logic to use fee deltas 9ef2a25603
  24. Use fee deltas for determining mempool acceptance 27fae3484c
  25. Remove GetMinRelayFee
    One test in AcceptToMemoryPool was to compare a transaction's fee
    agains the value returned by GetMinRelayFee. This value was zero for
    all small transactions.  For larger transactions (between
    DEFAULT_BLOCK_PRIORITY_SIZE and MAX_STANDARD_TX_SIZE), this function
    was preventing low fee transactions from ever being accepted.
    
    With this function removed, we will now allow transactions in that range
    with fees (including modifications via PrioritiseTransaction) below
    the minRelayTxFee, provided that they have sufficient priority.
    901b01d674
  26. laanwj commented at 4:13 PM on December 21, 2015: member

    utACK

  27. laanwj merged this on Dec 21, 2015
  28. laanwj closed this on Dec 21, 2015

  29. laanwj referenced this in commit c24337964f on Dec 21, 2015
  30. laanwj referenced this in commit 12c469b236 on Dec 21, 2015
  31. sdaftuar cross-referenced this on Jan 18, 2016 from issue [Tests] Eliminate race condition in mempool_packages.py by sdaftuar
  32. luke-jr cross-referenced this on Feb 13, 2016 from issue Bugfix: Rename descendantfees to descendantmodfees by luke-jr
  33. therealyingtong cross-referenced this on May 6, 2020 from issue Backport removal of Coin Age Priority by therealyingtong
  34. furszy cross-referenced this on Aug 20, 2020 from issue Up to CTransactionRef point back ports to do list. by furszy
  35. furszy cross-referenced this on Dec 31, 2020 from issue [NET] Inv, mempool and validation improvements by furszy
  36. furszy referenced this in commit 1f010c0969 on Jan 23, 2021
  37. bitcoin locked this on Sep 8, 2021

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: 2026-05-20 06:55 UTC