[rpc] [tests] mempoolminfee should not drop below minRelayTxFee #11410

pull mess110 wants to merge 1 commits into bitcoin:master from mess110:add_minrelaytxfee_to_getmempoolinfo changing 6 files +39 −40
  1. mess110 commented at 10:53 PM on September 27, 2017: contributor

    #6941

    I tested this in wallet.py. Please advise if you think there is a better place where to test this (for example a more comprehensive new test which checks getmempoolinfo)

  2. fanquake added the label RPC/REST/ZMQ on Sep 27, 2017
  3. fanquake added the label Tests on Sep 27, 2017
  4. mess110 force-pushed on Sep 27, 2017
  5. promag commented at 8:37 PM on September 28, 2017: member

    utACK d4e253e.

  6. TheBlueMatt commented at 11:30 PM on September 28, 2017: member

    I think we should just replace mempoolminfee with max(mempoolminfee, minrelayfee) as we no longer support priority/free-relay txn that will likely not be mined (so the original arguments for separating them no longer hold).

  7. sipa commented at 12:34 AM on September 29, 2017: member

    Agree with @TheBlueMatt.

  8. mess110 commented at 3:34 PM on September 29, 2017: contributor

    Thanks for the feedback.

    We already do max between rollingMinimumFeeRate and incrementalRelayFee in https://github.com/bitcoin/bitcoin/blob/master/src/txmempool.cpp#L1002, but there are cases when we return 0:

    To solve this, (imo) we have a few options:

    1. Do max between the mempool.GetMinFee(maxmempool) and ::minRelayTxFee in https://github.com/bitcoin/bitcoin/blob/master/src/rpc/blockchain.cpp#L1328
    2. Do the max in https://github.com/bitcoin/bitcoin/blob/master/src/txmempool.cpp#L981

    Option 1 seems like the least behavior changing because it is there for the RPC interface. I am not sure weather option 2 is desired because it might alter some behavior, but it does seem like the correct place where to put it.

    At the moment, I am leaning towards option 1. I want to ask for some advice, which option do you think is better 1 or 2?

  9. MarcoFalke commented at 4:54 PM on September 29, 2017: member

    If you create the new method (option 2), you should also use it in the other places where GetMinFee is called and remove the (now obsolete) std::max from them. If you only plan to use it in getmempoolinfo, you could as well just do the std::max there (option 1).

  10. morcos commented at 5:12 PM on September 29, 2017: member

    I think I agree with @sipa and @TheBlueMatt. There are still a couple of differences between minRelayTxFee and mempoolMinFee. One I can thing of now is the wallet will allow you to create a transaction below mempoolMinFee but not below minRelayTxFee. But I think if we carefully went through the code to see where either of them were used we might find that there is no point in ever returning a mempoolMinFee below the minRelayTxFee. In which case we could do as suggested.

    • Line 984 is a bug as this should still have been maxed with minIncrementalRelayFee, so the test before that could just be reversed and used to guard executing the bulk of the function so there is no early return.
    • Line 999 could just go away and not early return
    • Line 1002 could be changed to max with minRelayTxFee (but also max with minIncrementalRelayFee).

    Then we may be able to simplify other places in the code that check both like AcceptToMemoryPool.

  11. mess110 force-pushed on Sep 29, 2017
  12. mess110 force-pushed on Sep 29, 2017
  13. mess110 renamed this:
    [rpc] [tests] Add minrelaytxfee to getmempoolinfo
    [rpc] [tests] mempoolminfee should not drop below minRelayTxFee
    on Sep 29, 2017
  14. mess110 force-pushed on Sep 29, 2017
  15. mess110 force-pushed on Sep 29, 2017
  16. mess110 force-pushed on Sep 30, 2017
  17. mess110 commented at 11:11 PM on September 30, 2017: contributor

    Rebased

  18. in src/validation.cpp:627 in 52711b9aa8 outdated
     623 | @@ -624,11 +624,6 @@ static bool AcceptToMemoryPoolWorker(const CChainParams& chainparams, CTxMemPool
     624 |              return state.DoS(0, false, REJECT_INSUFFICIENTFEE, "mempool min fee not met", false, strprintf("%d < %d", nFees, mempoolRejectFee));
     625 |          }
     626 |  
     627 | -        // No transactions are allowed below minRelayTxFee except from disconnected blocks
    


    ryanofsky commented at 2:51 PM on October 2, 2017:

    Maybe preserve this comment (move it up by mempoolRejectFee check).

    Also maybe drop the mempoolRejectFee > 0 check above which seems impossible to hit now (and confusing & unnecessary previously).


    mess110 commented at 3:18 PM on October 2, 2017:

    Thanks for the review, fixed

  19. ryanofsky commented at 2:55 PM on October 2, 2017: member

    utACK 52711b9aa8c35b6f9d275fde7206bdb2276ce201

    Catching up here, but I guess the original version of this PR added minrelaytxfee as a new field returned by getmempoolinfo, while the new version instead incorporates it into the existing mempoolminfee field as suggested by Matt.

    This is implemented by changing CTxMemPool::GetMinFee to now return the max of the rolling minimum with minrelaytxfee. There are also two bugfixes to CTxMemPool::GetMinFee to make it consistently also max with incrementalRelayFee instead of skipping this when the rolling minimum is 0.

    A side effect of changing CTxMemPool::GetMinFee is that validation code now returns a "mempool min fee not met" error instead of "min relay fee not met" when fee is below minrelaytxfee, so there is also a test update and simplification to the validation code in the PR.

  20. MarcoFalke added the label TX fees and policy on Oct 2, 2017
  21. MarcoFalke removed the label Tests on Oct 2, 2017
  22. mess110 force-pushed on Oct 2, 2017
  23. MarcoFalke commented at 3:19 PM on October 2, 2017: member

    You can remove GetRequiredFee in src/wallet/fees.cpp now.

  24. in src/validation.cpp:622 in 9423369fab outdated
     618 | @@ -619,16 +619,12 @@ static bool AcceptToMemoryPoolWorker(const CChainParams& chainparams, CTxMemPool
     619 |              return state.DoS(0, false, REJECT_NONSTANDARD, "bad-txns-too-many-sigops", false,
     620 |                  strprintf("%d", nSigOpsCost));
     621 |  
     622 | +        // No transactions are allowed below minRelayTxFee except from disconnected blocks
    


    ryanofsky commented at 3:27 PM on October 2, 2017:

    Should probably say mempool min fee instead of minRelayTxFee.

  25. ryanofsky commented at 3:30 PM on October 2, 2017: member

    utACK 9423369fabb9ad13769a594f8b7b2ed5b655170c

    I don't think this directly relates to GetRequiredFee. There are still a number of calls to it, and it seems worth keeping.

  26. mess110 force-pushed on Oct 2, 2017
  27. mess110 commented at 3:36 PM on October 2, 2017: contributor

    @ryanofsky fixed, thx @MarcoFalke prefer to do that in a different PR. Is that fine? Will create a different issue if that is ok.

  28. MarcoFalke commented at 4:01 PM on October 2, 2017: member

    To elaborate a bit: Previously, when calling GetMinimumFee and the resulting fee was smaller than the minRelayTxFee, the reason for increasing the fee would always be FeeReason::REQUIRED. Now, the reason for increasing the fee would depend on whether paytxfee (would result in FeeReason::REQUIRED) was used or smart fee estimation (would result in FeeReason::MEMPOOL_MIN). With your changes, I'd prefer to set FeeReason::MEMPOOL_MIN in all cases where the mempool min fee is not met (including minRelayTxFee). Thus, removing the call to GetRequiredFee in GetMinimumFee makes sense to me.

    I know that those are just internal debugging details, so I am fine if this is done in a follow up pull.

  29. ryanofsky commented at 4:52 PM on October 2, 2017: member

    Removing the call to GetRequiredFee in GetMinimumFee does seem like the correct thing to do here (and the change would only be harder to understand in another context). I just didn't think GetRequiredFee should be removed entirely.

  30. mess110 force-pushed on Oct 2, 2017
  31. mess110 force-pushed on Oct 2, 2017
  32. mess110 commented at 7:58 PM on October 2, 2017: contributor

    Oh, ok, now I understand. I removed the GetRequiredFee code from GetMinimumFee

  33. mess110 force-pushed on Oct 2, 2017
  34. in src/wallet/fees.cpp:65 in 4a331eafba outdated
      67 | -    if (required_fee > fee_needed) {
      68 | -        fee_needed = required_fee;
      69 | -        if (feeCalc) feeCalc->reason = FeeReason::REQUIRED;
      70 | -    }
      71 | -    // But always obey the maximum
      72 | +    // And always obey the maximum
    


    MarcoFalke commented at 8:16 PM on October 2, 2017:

    You'd still need to set it to minTxFee in case the current fee is smaller than that (Also set the FeeReason appropriately)

    Also, I'd suggest to move GetMinFee down, so that it is applied when paytxfee is set.

  35. mess110 force-pushed on Oct 2, 2017
  36. [rpc] [tests] mempoolminfee should not drop below minRelayTxFee
    The ::minRelayTxFee is accounted for in CTxMemPool::GetMinFee so the
    validation for '66: min relay fee not met' is no longer required.
    65d2c68d4d
  37. mess110 force-pushed on Oct 2, 2017
  38. mess110 commented at 2:55 PM on October 3, 2017: contributor

    After repeated runs of ./test/functional/test_runner.py fundrawtransaction, I have my doubts that the code in https://github.com/bitcoin/bitcoin/pull/11410/files#diff-ca74c4b28865382863b8fe7633a85cd6 is correct.

    Sometimes, I get this error:

    ..........................................................................................................................................................................
    fundrawtransaction.py failed, Duration: 85 s
    
    stdout:
    2017-10-03 14:51:58.853000 TestFramework (INFO): Initializing test directory /tmp/bitcoin_test_runner_20171003_175158/fundrawtransaction_49
    {'936dc7485b7e275eed5d7a4fa4f2f5b26b7ffb180a05fc7d28a395ba07b006b8'}
    {'936dc7485b7e275eed5d7a4fa4f2f5b26b7ffb180a05fc7d28a395ba07b006b8'}
    {'936dc7485b7e275eed5d7a4fa4f2f5b26b7ffb180a05fc7d28a395ba07b006b8'}
    set()
    2017-10-03 14:53:21.925000 TestFramework (ERROR): Assertion failed
    Traceback (most recent call last):
      File "/home/whoami/pr0n/bitcoin/test/functional/test_framework/test_framework.py", line 117, in main
        self.run_test()
      File "/home/whoami/pr0n/bitcoin/test/functional/fundrawtransaction.py", line 505, in run_test
        self.sync_all()
      File "/home/whoami/pr0n/bitcoin/test/functional/test_framework/test_framework.py", line 326, in sync_all
        sync_mempools(group)
      File "/home/whoami/pr0n/bitcoin/test/functional/test_framework/util.py", line 401, in sync_mempools
        raise AssertionError("Mempool sync failed")
    AssertionError: Mempool sync failed
    2017-10-03 14:53:21.926000 TestFramework (INFO): Stopping nodes
    2017-10-03 14:53:24.184000 TestFramework (WARNING): Not cleaning up dir /tmp/bitcoin_test_runner_20171003_175158/fundrawtransaction_49
    2017-10-03 14:53:24.184000 TestFramework (ERROR): Test failed. Test logging available at /tmp/bitcoin_test_runner_20171003_175158/fundrawtransaction_49/test_framework.log
    

    NOTE: on master, this doesn't happen. Need to investigate

  39. in src/txmempool.cpp:984 in 65d2c68d4d
     979 | @@ -980,26 +980,25 @@ const CTxMemPool::setEntries & CTxMemPool::GetMemPoolChildren(txiter entry) cons
     980 |  
     981 |  CFeeRate CTxMemPool::GetMinFee(size_t sizelimit) const {
     982 |      LOCK(cs);
     983 | -    if (!blockSinceLastRollingFeeBump || rollingMinimumFeeRate == 0)
     984 | -        return CFeeRate(llround(rollingMinimumFeeRate));
    


    MarcoFalke commented at 10:44 AM on October 5, 2017:

    <strike>I don't feel entirely happy that a bug fix is part of a mostly refactoring commit. Would you mind to split up those bug fixes to a separate (minimal) commit and pull request?


    mess110 commented at 12:06 PM on October 5, 2017:

    No, I think that is a great idea. Should help me with digging as well. Will do

  40. mess110 closed this on Oct 5, 2017

  41. laanwj referenced this in commit 9bad8d6472 on Dec 23, 2017
  42. virtload referenced this in commit a3d18e61fa on Apr 4, 2018
  43. PastaPastaPasta referenced this in commit a3d6179f99 on Jan 17, 2020
  44. PastaPastaPasta referenced this in commit 3b2be135e8 on Jan 22, 2020
  45. PastaPastaPasta referenced this in commit d7e6d2889f on Jan 22, 2020
  46. PastaPastaPasta referenced this in commit 1a1807463c on Jan 29, 2020
  47. PastaPastaPasta referenced this in commit 1bb00b2f43 on Jan 29, 2020
  48. PastaPastaPasta referenced this in commit 33e89864b5 on Jan 29, 2020
  49. PastaPastaPasta referenced this in commit b8c5d5d7ea on Jan 31, 2020
  50. ckti referenced this in commit 50b8a7d1ad on Mar 28, 2021
  51. DrahtBot 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-04-13 15:15 UTC

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