Skip to content

Commit fa9cba7

Browse files
author
MacroFake
committed
Remove ::incrementalRelayFee and ::minRelayTxFee globals
1 parent fa14860 commit fa9cba7

17 files changed

+77
-57
lines changed

doc/policy/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
**Policy** (Mempool or Transaction Relay Policy) is the node's set of validation rules, in addition
44
to consensus, enforced for unconfirmed transactions before submitting them to the mempool. These
55
rules are local to the node and configurable (e.g. `-minrelaytxfee`, `-limitancestorsize`,
6-
`-incrementalRelayFee`). Policy may include restrictions on the transaction itself, the transaction
6+
`-incrementalrelayfee`). Policy may include restrictions on the transaction itself, the transaction
77
in relation to the current chain tip, and the transaction in relation to the node's mempool
88
contents. Policy is *not* applied to transactions in blocks.
99

doc/policy/mempool-replacements.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ This set of rules is similar but distinct from BIP125.
7171
Bitcoin Core implementation.
7272

7373
* The incremental relay feerate used to calculate the required additional fees is distinct from
74-
`minRelayTxFee` and configurable using `-incrementalrelayfee`
74+
`-minrelaytxfee` and configurable using `-incrementalrelayfee`
7575
([PR #9380](https://github.com/bitcoin/bitcoin/pull/9380)).
7676

7777
* RBF enabled by default in the wallet GUI as of **v0.18.1** ([PR

doc/policy/packages.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ If any transactions in the package are already in the mempool, they are not subm
8181
("deduplicated") and are thus excluded from this calculation.
8282

8383
To meet the two feerate requirements of a mempool, i.e., the pre-configured minimum relay feerate
84-
(`minRelayTxFee`) and the dynamic mempool minimum feerate, the total package feerate is used instead
84+
(`-minrelaytxfee`) and the dynamic mempool minimum feerate, the total package feerate is used instead
8585
of the individual feerate. The individual transactions are allowed to be below the feerate
8686
requirements if the package meets the feerate requirements. For example, the parent(s) in the
8787
package can pay no fees but be paid for by the child.

src/init.cpp

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -935,16 +935,6 @@ bool AppInitParameterInteraction(const ArgsManager& args, bool use_syscall_sandb
935935
LogPrintf("Warning: nMinimumChainWork set below default value of %s\n", chainparams.GetConsensus().nMinimumChainWork.GetHex());
936936
}
937937

938-
// incremental relay fee sets the minimum feerate increase necessary for BIP 125 replacement in the mempool
939-
// and the amount the mempool min fee increases above the feerate of txs evicted due to mempool limiting.
940-
if (args.IsArgSet("-incrementalrelayfee")) {
941-
if (std::optional<CAmount> inc_relay_fee = ParseMoney(args.GetArg("-incrementalrelayfee", ""))) {
942-
::incrementalRelayFee = CFeeRate{inc_relay_fee.value()};
943-
} else {
944-
return InitError(AmountErrMsg("incrementalrelayfee", args.GetArg("-incrementalrelayfee", "")));
945-
}
946-
}
947-
948938
// block pruning; get the amount of disk space (in MiB) to allot for block & undo files
949939
int64_t nPruneArg = args.GetIntArg("-prune", 0);
950940
if (nPruneArg < 0) {
@@ -973,19 +963,6 @@ bool AppInitParameterInteraction(const ArgsManager& args, bool use_syscall_sandb
973963
return InitError(Untranslated("peertimeout must be a positive integer."));
974964
}
975965

976-
if (args.IsArgSet("-minrelaytxfee")) {
977-
if (std::optional<CAmount> min_relay_fee = ParseMoney(args.GetArg("-minrelaytxfee", ""))) {
978-
// High fee check is done afterward in CWallet::Create()
979-
::minRelayTxFee = CFeeRate{min_relay_fee.value()};
980-
} else {
981-
return InitError(AmountErrMsg("minrelaytxfee", args.GetArg("-minrelaytxfee", "")));
982-
}
983-
} else if (incrementalRelayFee > ::minRelayTxFee) {
984-
// Allow only setting incrementalRelayFee to control both
985-
::minRelayTxFee = incrementalRelayFee;
986-
LogPrintf("Increasing minrelaytxfee to %s to match incrementalrelayfee\n",::minRelayTxFee.ToString());
987-
}
988-
989966
// Sanity check argument for min fee for including tx in block
990967
// TODO: Harmonize which arguments need sanity checking and where that happens
991968
if (args.IsArgSet("-blockmintxfee")) {

src/kernel/mempool_options.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
#include <kernel/mempool_limits.h>
88

9+
#include <policy/feerate.h>
10+
#include <policy/policy.h>
11+
912
#include <chrono>
1013
#include <cstdint>
1114

@@ -33,6 +36,9 @@ struct MemPoolOptions {
3336
int check_ratio{0};
3437
int64_t max_size_bytes{DEFAULT_MAX_MEMPOOL_SIZE_MB * 1'000'000};
3538
std::chrono::seconds expiry{std::chrono::hours{DEFAULT_MEMPOOL_EXPIRY_HOURS}};
39+
CFeeRate incremental_relay_feerate{DEFAULT_INCREMENTAL_RELAY_FEE};
40+
/** A fee rate smaller than this is considered zero fee (for relaying, mining and transaction creation) */
41+
CFeeRate min_relay_feerate{DEFAULT_MIN_RELAY_TX_FEE};
3642
bool require_standard{true};
3743
bool full_rbf{DEFAULT_MEMPOOL_FULL_RBF};
3844
MemPoolLimits limits{};

src/mempool_args.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@
88
#include <kernel/mempool_options.h>
99

1010
#include <chainparams.h>
11+
#include <consensus/amount.h>
12+
#include <logging.h>
13+
#include <policy/feerate.h>
1114
#include <tinyformat.h>
15+
#include <util/error.h>
16+
#include <util/moneystr.h>
1217
#include <util/system.h>
1318
#include <util/translation.h>
1419

@@ -39,6 +44,29 @@ std::optional<bilingual_str> ApplyArgsManOptions(const ArgsManager& argsman, con
3944

4045
if (auto hours = argsman.GetIntArg("-mempoolexpiry")) mempool_opts.expiry = std::chrono::hours{*hours};
4146

47+
// incremental relay fee sets the minimum feerate increase necessary for BIP 125 replacement in the mempool
48+
// and the amount the mempool min fee increases above the feerate of txs evicted due to mempool limiting.
49+
if (argsman.IsArgSet("-incrementalrelayfee")) {
50+
if (std::optional<CAmount> inc_relay_fee = ParseMoney(argsman.GetArg("-incrementalrelayfee", ""))) {
51+
mempool_opts.incremental_relay_feerate = CFeeRate{inc_relay_fee.value()};
52+
} else {
53+
return AmountErrMsg("incrementalrelayfee", argsman.GetArg("-incrementalrelayfee", ""));
54+
}
55+
}
56+
57+
if (argsman.IsArgSet("-minrelaytxfee")) {
58+
if (std::optional<CAmount> min_relay_feerate = ParseMoney(argsman.GetArg("-minrelaytxfee", ""))) {
59+
// High fee check is done afterward in CWallet::Create()
60+
mempool_opts.min_relay_feerate = CFeeRate{min_relay_feerate.value()};
61+
} else {
62+
return AmountErrMsg("minrelaytxfee", argsman.GetArg("-minrelaytxfee", ""));
63+
}
64+
} else if (mempool_opts.incremental_relay_feerate > mempool_opts.min_relay_feerate) {
65+
// Allow only setting incremental fee to control both
66+
mempool_opts.min_relay_feerate = mempool_opts.incremental_relay_feerate;
67+
LogPrintf("Increasing minrelaytxfee to %s to match incrementalrelayfee\n", mempool_opts.min_relay_feerate.ToString());
68+
}
69+
4270
mempool_opts.require_standard = !argsman.GetBoolArg("-acceptnonstdtxn", !chainparams.RequireStandard());
4371
if (!chainparams.IsTestChain() && !mempool_opts.require_standard) {
4472
return strprintf(Untranslated("acceptnonstdtxn is not currently supported for %s chain"), chainparams.NetworkIDString());

src/net_processing.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4759,8 +4759,8 @@ void PeerManagerImpl::MaybeSendFeefilter(CNode& pto, Peer& peer, std::chrono::mi
47594759
}
47604760
if (current_time > peer.m_next_send_feefilter) {
47614761
CAmount filterToSend = g_filter_rounder.round(currentFilter);
4762-
// We always have a fee filter of at least minRelayTxFee
4763-
filterToSend = std::max(filterToSend, ::minRelayTxFee.GetFeePerK());
4762+
// We always have a fee filter of at least the min relay fee
4763+
filterToSend = std::max(filterToSend, m_mempool.m_min_relay_feerate.GetFeePerK());
47644764
if (filterToSend != peer.m_fee_filter_sent) {
47654765
m_connman.PushMessage(&pto, CNetMsgMaker(pto.GetCommonVersion()).Make(NetMsgType::FEEFILTER, filterToSend));
47664766
peer.m_fee_filter_sent = filterToSend;

src/node/interfaces.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -676,8 +676,16 @@ class ChainImpl : public Chain
676676
if (!m_node.mempool) return {};
677677
return m_node.mempool->GetMinFee();
678678
}
679-
CFeeRate relayMinFee() override { return ::minRelayTxFee; }
680-
CFeeRate relayIncrementalFee() override { return ::incrementalRelayFee; }
679+
CFeeRate relayMinFee() override
680+
{
681+
if (!m_node.mempool) return CFeeRate{DEFAULT_MIN_RELAY_TX_FEE};
682+
return m_node.mempool->m_min_relay_feerate;
683+
}
684+
CFeeRate relayIncrementalFee() override
685+
{
686+
if (!m_node.mempool) return CFeeRate{DEFAULT_INCREMENTAL_RELAY_FEE};
687+
return m_node.mempool->m_incremental_relay_feerate;
688+
}
681689
CFeeRate relayDustFee() override { return ::dustRelayFee; }
682690
bool havePruned() override
683691
{

src/policy/policy.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ static constexpr unsigned int MAX_STANDARD_TAPSCRIPT_STACK_ITEM_SIZE{80};
4747
static constexpr unsigned int MAX_STANDARD_P2WSH_SCRIPT_SIZE{3600};
4848
/** The maximum size of a standard ScriptSig */
4949
static constexpr unsigned int MAX_STANDARD_SCRIPTSIG_SIZE{1650};
50-
/** Min feerate for defining dust. Historically this has been based on the
51-
* minRelayTxFee, however changing the dust limit changes which transactions are
50+
/** Min feerate for defining dust.
51+
* Changing the dust limit changes which transactions are
5252
* standard and should be done with care and ideally rarely. It makes sense to
5353
* only increase the dust limit after prior releases were already not creating
5454
* outputs below the new threshold */

src/policy/settings.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,5 @@
99
#include <policy/policy.h>
1010

1111
bool fIsBareMultisigStd = DEFAULT_PERMIT_BAREMULTISIG;
12-
CFeeRate incrementalRelayFee = CFeeRate(DEFAULT_INCREMENTAL_RELAY_FEE);
1312
CFeeRate dustRelayFee = CFeeRate(DUST_RELAY_TX_FEE);
14-
CFeeRate minRelayTxFee = CFeeRate(DEFAULT_MIN_RELAY_TX_FEE);
1513
unsigned int nBytesPerSigOp = DEFAULT_BYTES_PER_SIGOP;

0 commit comments

Comments
 (0)