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)
[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-
mess110 commented at 10:53 PM on September 27, 2017: contributor
- fanquake added the label RPC/REST/ZMQ on Sep 27, 2017
- fanquake added the label Tests on Sep 27, 2017
- mess110 force-pushed on Sep 27, 2017
-
promag commented at 8:37 PM on September 28, 2017: member
utACK d4e253e.
-
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).
-
sipa commented at 12:34 AM on September 29, 2017: member
Agree with @TheBlueMatt.
-
mess110 commented at 3:34 PM on September 29, 2017: contributor
Thanks for the feedback.
We already do max between
rollingMinimumFeeRateandincrementalRelayFeein https://github.com/bitcoin/bitcoin/blob/master/src/txmempool.cpp#L1002, but there are cases when we return 0:- https://github.com/bitcoin/bitcoin/blob/master/src/txmempool.cpp#L999
- https://github.com/bitcoin/bitcoin/blob/master/src/txmempool.cpp#L984
To solve this, (imo) we have a few options:
- Do max between the
mempool.GetMinFee(maxmempool)and::minRelayTxFeein https://github.com/bitcoin/bitcoin/blob/master/src/rpc/blockchain.cpp#L1328 - Do the max in https://github.com/bitcoin/bitcoin/blob/master/src/txmempool.cpp#L981
- for this I would suggest to create a new method in https://github.com/bitcoin/bitcoin/blob/master/src/txmempool.cpp which returns the max between
GetMinFeeand::minRelayTxFeeso we don't do 3 max statements (one for each return) - or do max in the 3 returns of the method
- for this I would suggest to create a new method in https://github.com/bitcoin/bitcoin/blob/master/src/txmempool.cpp which returns the max between
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?
-
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
GetMinFeeis called and remove the (now obsolete)std::maxfrom them. If you only plan to use it ingetmempoolinfo, you could as well just do thestd::maxthere (option 1). -
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.
- mess110 force-pushed on Sep 29, 2017
- mess110 force-pushed on Sep 29, 2017
- mess110 renamed this:
[rpc] [tests] Add minrelaytxfee to getmempoolinfo
[rpc] [tests] mempoolminfee should not drop below minRelayTxFee
on Sep 29, 2017 - mess110 force-pushed on Sep 29, 2017
- mess110 force-pushed on Sep 29, 2017
- mess110 force-pushed on Sep 30, 2017
-
mess110 commented at 11:11 PM on September 30, 2017: contributor
Rebased
-
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 > 0check 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
ryanofsky commented at 2:55 PM on October 2, 2017: memberutACK 52711b9aa8c35b6f9d275fde7206bdb2276ce201
Catching up here, but I guess the original version of this PR added
minrelaytxfeeas a new field returned bygetmempoolinfo, while the new version instead incorporates it into the existingmempoolminfeefield as suggested by Matt.This is implemented by changing
CTxMemPool::GetMinFeeto now return the max of the rolling minimum withminrelaytxfee. There are also two bugfixes to CTxMemPool::GetMinFee to make it consistently also max withincrementalRelayFeeinstead 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 belowminrelaytxfee, so there is also a test update and simplification to the validation code in the PR.MarcoFalke added the label TX fees and policy on Oct 2, 2017MarcoFalke removed the label Tests on Oct 2, 2017mess110 force-pushed on Oct 2, 2017MarcoFalke commented at 3:19 PM on October 2, 2017: memberYou can remove
GetRequiredFeein src/wallet/fees.cpp now.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.
ryanofsky commented at 3:30 PM on October 2, 2017: memberutACK 9423369fabb9ad13769a594f8b7b2ed5b655170c
I don't think this directly relates to GetRequiredFee. There are still a number of calls to it, and it seems worth keeping.
mess110 force-pushed on Oct 2, 2017mess110 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.
MarcoFalke commented at 4:01 PM on October 2, 2017: memberTo elaborate a bit: Previously, when calling
GetMinimumFeeand the resulting fee was smaller than theminRelayTxFee, the reason for increasing the fee would always beFeeReason::REQUIRED. Now, the reason for increasing the fee would depend on whetherpaytxfee(would result inFeeReason::REQUIRED) was used or smart fee estimation (would result inFeeReason::MEMPOOL_MIN). With your changes, I'd prefer to setFeeReason::MEMPOOL_MINin all cases where the mempool min fee is not met (including minRelayTxFee). Thus, removing the call toGetRequiredFeeinGetMinimumFeemakes 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.
ryanofsky commented at 4:52 PM on October 2, 2017: memberRemoving 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.
mess110 force-pushed on Oct 2, 2017mess110 force-pushed on Oct 2, 2017mess110 commented at 7:58 PM on October 2, 2017: contributorOh, ok, now I understand. I removed the
GetRequiredFeecode fromGetMinimumFeemess110 force-pushed on Oct 2, 2017in 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.
mess110 force-pushed on Oct 2, 201765d2c68d4d[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.
mess110 force-pushed on Oct 2, 2017mess110 commented at 2:55 PM on October 3, 2017: contributorAfter 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.logNOTE: on
master, this doesn't happen. Need to investigatein 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
mess110 closed this on Oct 5, 2017laanwj referenced this in commit 9bad8d6472 on Dec 23, 2017virtload referenced this in commit a3d18e61fa on Apr 4, 2018PastaPastaPasta referenced this in commit a3d6179f99 on Jan 17, 2020PastaPastaPasta referenced this in commit 3b2be135e8 on Jan 22, 2020PastaPastaPasta referenced this in commit d7e6d2889f on Jan 22, 2020PastaPastaPasta referenced this in commit 1a1807463c on Jan 29, 2020PastaPastaPasta referenced this in commit 1bb00b2f43 on Jan 29, 2020PastaPastaPasta referenced this in commit 33e89864b5 on Jan 29, 2020PastaPastaPasta referenced this in commit b8c5d5d7ea on Jan 31, 2020ckti referenced this in commit 50b8a7d1ad on Mar 28, 2021DrahtBot 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