mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-02 09:46:52 -05:00
Remove ::incrementalRelayFee and ::minRelayTxFee globals
This commit is contained in:
parent
fa148602e6
commit
fa9cba7afb
17 changed files with 77 additions and 57 deletions
|
@ -3,7 +3,7 @@
|
|||
**Policy** (Mempool or Transaction Relay Policy) is the node's set of validation rules, in addition
|
||||
to consensus, enforced for unconfirmed transactions before submitting them to the mempool. These
|
||||
rules are local to the node and configurable (e.g. `-minrelaytxfee`, `-limitancestorsize`,
|
||||
`-incrementalRelayFee`). Policy may include restrictions on the transaction itself, the transaction
|
||||
`-incrementalrelayfee`). Policy may include restrictions on the transaction itself, the transaction
|
||||
in relation to the current chain tip, and the transaction in relation to the node's mempool
|
||||
contents. Policy is *not* applied to transactions in blocks.
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ This set of rules is similar but distinct from BIP125.
|
|||
Bitcoin Core implementation.
|
||||
|
||||
* The incremental relay feerate used to calculate the required additional fees is distinct from
|
||||
`minRelayTxFee` and configurable using `-incrementalrelayfee`
|
||||
`-minrelaytxfee` and configurable using `-incrementalrelayfee`
|
||||
([PR #9380](https://github.com/bitcoin/bitcoin/pull/9380)).
|
||||
|
||||
* RBF enabled by default in the wallet GUI as of **v0.18.1** ([PR
|
||||
|
|
|
@ -81,7 +81,7 @@ If any transactions in the package are already in the mempool, they are not subm
|
|||
("deduplicated") and are thus excluded from this calculation.
|
||||
|
||||
To meet the two feerate requirements of a mempool, i.e., the pre-configured minimum relay feerate
|
||||
(`minRelayTxFee`) and the dynamic mempool minimum feerate, the total package feerate is used instead
|
||||
(`-minrelaytxfee`) and the dynamic mempool minimum feerate, the total package feerate is used instead
|
||||
of the individual feerate. The individual transactions are allowed to be below the feerate
|
||||
requirements if the package meets the feerate requirements. For example, the parent(s) in the
|
||||
package can pay no fees but be paid for by the child.
|
||||
|
|
23
src/init.cpp
23
src/init.cpp
|
@ -935,16 +935,6 @@ bool AppInitParameterInteraction(const ArgsManager& args, bool use_syscall_sandb
|
|||
LogPrintf("Warning: nMinimumChainWork set below default value of %s\n", chainparams.GetConsensus().nMinimumChainWork.GetHex());
|
||||
}
|
||||
|
||||
// incremental relay fee sets the minimum feerate increase necessary for BIP 125 replacement in the mempool
|
||||
// and the amount the mempool min fee increases above the feerate of txs evicted due to mempool limiting.
|
||||
if (args.IsArgSet("-incrementalrelayfee")) {
|
||||
if (std::optional<CAmount> inc_relay_fee = ParseMoney(args.GetArg("-incrementalrelayfee", ""))) {
|
||||
::incrementalRelayFee = CFeeRate{inc_relay_fee.value()};
|
||||
} else {
|
||||
return InitError(AmountErrMsg("incrementalrelayfee", args.GetArg("-incrementalrelayfee", "")));
|
||||
}
|
||||
}
|
||||
|
||||
// block pruning; get the amount of disk space (in MiB) to allot for block & undo files
|
||||
int64_t nPruneArg = args.GetIntArg("-prune", 0);
|
||||
if (nPruneArg < 0) {
|
||||
|
@ -973,19 +963,6 @@ bool AppInitParameterInteraction(const ArgsManager& args, bool use_syscall_sandb
|
|||
return InitError(Untranslated("peertimeout must be a positive integer."));
|
||||
}
|
||||
|
||||
if (args.IsArgSet("-minrelaytxfee")) {
|
||||
if (std::optional<CAmount> min_relay_fee = ParseMoney(args.GetArg("-minrelaytxfee", ""))) {
|
||||
// High fee check is done afterward in CWallet::Create()
|
||||
::minRelayTxFee = CFeeRate{min_relay_fee.value()};
|
||||
} else {
|
||||
return InitError(AmountErrMsg("minrelaytxfee", args.GetArg("-minrelaytxfee", "")));
|
||||
}
|
||||
} else if (incrementalRelayFee > ::minRelayTxFee) {
|
||||
// Allow only setting incrementalRelayFee to control both
|
||||
::minRelayTxFee = incrementalRelayFee;
|
||||
LogPrintf("Increasing minrelaytxfee to %s to match incrementalrelayfee\n",::minRelayTxFee.ToString());
|
||||
}
|
||||
|
||||
// Sanity check argument for min fee for including tx in block
|
||||
// TODO: Harmonize which arguments need sanity checking and where that happens
|
||||
if (args.IsArgSet("-blockmintxfee")) {
|
||||
|
|
|
@ -6,6 +6,9 @@
|
|||
|
||||
#include <kernel/mempool_limits.h>
|
||||
|
||||
#include <policy/feerate.h>
|
||||
#include <policy/policy.h>
|
||||
|
||||
#include <chrono>
|
||||
#include <cstdint>
|
||||
|
||||
|
@ -33,6 +36,9 @@ struct MemPoolOptions {
|
|||
int check_ratio{0};
|
||||
int64_t max_size_bytes{DEFAULT_MAX_MEMPOOL_SIZE_MB * 1'000'000};
|
||||
std::chrono::seconds expiry{std::chrono::hours{DEFAULT_MEMPOOL_EXPIRY_HOURS}};
|
||||
CFeeRate incremental_relay_feerate{DEFAULT_INCREMENTAL_RELAY_FEE};
|
||||
/** A fee rate smaller than this is considered zero fee (for relaying, mining and transaction creation) */
|
||||
CFeeRate min_relay_feerate{DEFAULT_MIN_RELAY_TX_FEE};
|
||||
bool require_standard{true};
|
||||
bool full_rbf{DEFAULT_MEMPOOL_FULL_RBF};
|
||||
MemPoolLimits limits{};
|
||||
|
|
|
@ -8,7 +8,12 @@
|
|||
#include <kernel/mempool_options.h>
|
||||
|
||||
#include <chainparams.h>
|
||||
#include <consensus/amount.h>
|
||||
#include <logging.h>
|
||||
#include <policy/feerate.h>
|
||||
#include <tinyformat.h>
|
||||
#include <util/error.h>
|
||||
#include <util/moneystr.h>
|
||||
#include <util/system.h>
|
||||
#include <util/translation.h>
|
||||
|
||||
|
@ -39,6 +44,29 @@ std::optional<bilingual_str> ApplyArgsManOptions(const ArgsManager& argsman, con
|
|||
|
||||
if (auto hours = argsman.GetIntArg("-mempoolexpiry")) mempool_opts.expiry = std::chrono::hours{*hours};
|
||||
|
||||
// incremental relay fee sets the minimum feerate increase necessary for BIP 125 replacement in the mempool
|
||||
// and the amount the mempool min fee increases above the feerate of txs evicted due to mempool limiting.
|
||||
if (argsman.IsArgSet("-incrementalrelayfee")) {
|
||||
if (std::optional<CAmount> inc_relay_fee = ParseMoney(argsman.GetArg("-incrementalrelayfee", ""))) {
|
||||
mempool_opts.incremental_relay_feerate = CFeeRate{inc_relay_fee.value()};
|
||||
} else {
|
||||
return AmountErrMsg("incrementalrelayfee", argsman.GetArg("-incrementalrelayfee", ""));
|
||||
}
|
||||
}
|
||||
|
||||
if (argsman.IsArgSet("-minrelaytxfee")) {
|
||||
if (std::optional<CAmount> min_relay_feerate = ParseMoney(argsman.GetArg("-minrelaytxfee", ""))) {
|
||||
// High fee check is done afterward in CWallet::Create()
|
||||
mempool_opts.min_relay_feerate = CFeeRate{min_relay_feerate.value()};
|
||||
} else {
|
||||
return AmountErrMsg("minrelaytxfee", argsman.GetArg("-minrelaytxfee", ""));
|
||||
}
|
||||
} else if (mempool_opts.incremental_relay_feerate > mempool_opts.min_relay_feerate) {
|
||||
// Allow only setting incremental fee to control both
|
||||
mempool_opts.min_relay_feerate = mempool_opts.incremental_relay_feerate;
|
||||
LogPrintf("Increasing minrelaytxfee to %s to match incrementalrelayfee\n", mempool_opts.min_relay_feerate.ToString());
|
||||
}
|
||||
|
||||
mempool_opts.require_standard = !argsman.GetBoolArg("-acceptnonstdtxn", !chainparams.RequireStandard());
|
||||
if (!chainparams.IsTestChain() && !mempool_opts.require_standard) {
|
||||
return strprintf(Untranslated("acceptnonstdtxn is not currently supported for %s chain"), chainparams.NetworkIDString());
|
||||
|
|
|
@ -4759,8 +4759,8 @@ void PeerManagerImpl::MaybeSendFeefilter(CNode& pto, Peer& peer, std::chrono::mi
|
|||
}
|
||||
if (current_time > peer.m_next_send_feefilter) {
|
||||
CAmount filterToSend = g_filter_rounder.round(currentFilter);
|
||||
// We always have a fee filter of at least minRelayTxFee
|
||||
filterToSend = std::max(filterToSend, ::minRelayTxFee.GetFeePerK());
|
||||
// We always have a fee filter of at least the min relay fee
|
||||
filterToSend = std::max(filterToSend, m_mempool.m_min_relay_feerate.GetFeePerK());
|
||||
if (filterToSend != peer.m_fee_filter_sent) {
|
||||
m_connman.PushMessage(&pto, CNetMsgMaker(pto.GetCommonVersion()).Make(NetMsgType::FEEFILTER, filterToSend));
|
||||
peer.m_fee_filter_sent = filterToSend;
|
||||
|
|
|
@ -676,8 +676,16 @@ public:
|
|||
if (!m_node.mempool) return {};
|
||||
return m_node.mempool->GetMinFee();
|
||||
}
|
||||
CFeeRate relayMinFee() override { return ::minRelayTxFee; }
|
||||
CFeeRate relayIncrementalFee() override { return ::incrementalRelayFee; }
|
||||
CFeeRate relayMinFee() override
|
||||
{
|
||||
if (!m_node.mempool) return CFeeRate{DEFAULT_MIN_RELAY_TX_FEE};
|
||||
return m_node.mempool->m_min_relay_feerate;
|
||||
}
|
||||
CFeeRate relayIncrementalFee() override
|
||||
{
|
||||
if (!m_node.mempool) return CFeeRate{DEFAULT_INCREMENTAL_RELAY_FEE};
|
||||
return m_node.mempool->m_incremental_relay_feerate;
|
||||
}
|
||||
CFeeRate relayDustFee() override { return ::dustRelayFee; }
|
||||
bool havePruned() override
|
||||
{
|
||||
|
|
|
@ -47,8 +47,8 @@ static constexpr unsigned int MAX_STANDARD_TAPSCRIPT_STACK_ITEM_SIZE{80};
|
|||
static constexpr unsigned int MAX_STANDARD_P2WSH_SCRIPT_SIZE{3600};
|
||||
/** The maximum size of a standard ScriptSig */
|
||||
static constexpr unsigned int MAX_STANDARD_SCRIPTSIG_SIZE{1650};
|
||||
/** Min feerate for defining dust. Historically this has been based on the
|
||||
* minRelayTxFee, however changing the dust limit changes which transactions are
|
||||
/** Min feerate for defining dust.
|
||||
* Changing the dust limit changes which transactions are
|
||||
* standard and should be done with care and ideally rarely. It makes sense to
|
||||
* only increase the dust limit after prior releases were already not creating
|
||||
* outputs below the new threshold */
|
||||
|
|
|
@ -9,7 +9,5 @@
|
|||
#include <policy/policy.h>
|
||||
|
||||
bool fIsBareMultisigStd = DEFAULT_PERMIT_BAREMULTISIG;
|
||||
CFeeRate incrementalRelayFee = CFeeRate(DEFAULT_INCREMENTAL_RELAY_FEE);
|
||||
CFeeRate dustRelayFee = CFeeRate(DUST_RELAY_TX_FEE);
|
||||
CFeeRate minRelayTxFee = CFeeRate(DEFAULT_MIN_RELAY_TX_FEE);
|
||||
unsigned int nBytesPerSigOp = DEFAULT_BYTES_PER_SIGOP;
|
||||
|
|
|
@ -14,11 +14,7 @@
|
|||
|
||||
class CTransaction;
|
||||
|
||||
// Policy settings which are configurable at runtime.
|
||||
extern CFeeRate incrementalRelayFee;
|
||||
extern CFeeRate dustRelayFee;
|
||||
/** A fee rate smaller than this is considered zero fee (for relaying, mining and transaction creation) */
|
||||
extern CFeeRate minRelayTxFee;
|
||||
extern unsigned int nBytesPerSigOp;
|
||||
extern bool fIsBareMultisigStd;
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
#include <core_io.h>
|
||||
#include <policy/feerate.h>
|
||||
#include <policy/fees.h>
|
||||
#include <policy/settings.h>
|
||||
#include <rpc/protocol.h>
|
||||
#include <rpc/request.h>
|
||||
#include <rpc/server.h>
|
||||
|
@ -88,7 +87,7 @@ static RPCHelpMan estimatesmartfee()
|
|||
CFeeRate feeRate{fee_estimator.estimateSmartFee(conf_target, &feeCalc, conservative)};
|
||||
if (feeRate != CFeeRate(0)) {
|
||||
CFeeRate min_mempool_feerate{mempool.GetMinFee()};
|
||||
CFeeRate min_relay_feerate{::minRelayTxFee};
|
||||
CFeeRate min_relay_feerate{mempool.m_min_relay_feerate};
|
||||
feeRate = std::max({feeRate, min_mempool_feerate, min_relay_feerate});
|
||||
result.pushKV("feerate", ValueFromAmount(feeRate.GetFeePerK()));
|
||||
} else {
|
||||
|
|
|
@ -666,9 +666,9 @@ UniValue MempoolInfoToJSON(const CTxMemPool& pool)
|
|||
ret.pushKV("usage", (int64_t)pool.DynamicMemoryUsage());
|
||||
ret.pushKV("total_fee", ValueFromAmount(pool.GetTotalFee()));
|
||||
ret.pushKV("maxmempool", pool.m_max_size_bytes);
|
||||
ret.pushKV("mempoolminfee", ValueFromAmount(std::max(pool.GetMinFee(), ::minRelayTxFee).GetFeePerK()));
|
||||
ret.pushKV("minrelaytxfee", ValueFromAmount(::minRelayTxFee.GetFeePerK()));
|
||||
ret.pushKV("incrementalrelayfee", ValueFromAmount(::incrementalRelayFee.GetFeePerK()));
|
||||
ret.pushKV("mempoolminfee", ValueFromAmount(std::max(pool.GetMinFee(), pool.m_min_relay_feerate).GetFeePerK()));
|
||||
ret.pushKV("minrelaytxfee", ValueFromAmount(pool.m_min_relay_feerate.GetFeePerK()));
|
||||
ret.pushKV("incrementalrelayfee", ValueFromAmount(pool.m_incremental_relay_feerate.GetFeePerK()));
|
||||
ret.pushKV("unbroadcastcount", uint64_t{pool.GetUnbroadcastTxs().size()});
|
||||
ret.pushKV("fullrbf", pool.m_full_rbf);
|
||||
return ret;
|
||||
|
|
|
@ -645,8 +645,11 @@ static RPCHelpMan getnetworkinfo()
|
|||
obj.pushKV("connections_out", node.connman->GetNodeCount(ConnectionDirection::Out));
|
||||
}
|
||||
obj.pushKV("networks", GetNetworksInfo());
|
||||
obj.pushKV("relayfee", ValueFromAmount(::minRelayTxFee.GetFeePerK()));
|
||||
obj.pushKV("incrementalfee", ValueFromAmount(::incrementalRelayFee.GetFeePerK()));
|
||||
if (node.mempool) {
|
||||
// Those fields can be deprecated, to be replaced by the getmempoolinfo fields
|
||||
obj.pushKV("relayfee", ValueFromAmount(node.mempool->m_min_relay_feerate.GetFeePerK()));
|
||||
obj.pushKV("incrementalfee", ValueFromAmount(node.mempool->m_incremental_relay_feerate.GetFeePerK()));
|
||||
}
|
||||
UniValue localAddresses(UniValue::VARR);
|
||||
{
|
||||
LOCK(g_maplocalhost_mutex);
|
||||
|
|
|
@ -458,6 +458,8 @@ CTxMemPool::CTxMemPool(const Options& opts)
|
|||
minerPolicyEstimator{opts.estimator},
|
||||
m_max_size_bytes{opts.max_size_bytes},
|
||||
m_expiry{opts.expiry},
|
||||
m_incremental_relay_feerate{opts.incremental_relay_feerate},
|
||||
m_min_relay_feerate{opts.min_relay_feerate},
|
||||
m_require_standard{opts.require_standard},
|
||||
m_full_rbf{opts.full_rbf},
|
||||
m_limits{opts.limits}
|
||||
|
@ -1118,12 +1120,12 @@ CFeeRate CTxMemPool::GetMinFee(size_t sizelimit) const {
|
|||
rollingMinimumFeeRate = rollingMinimumFeeRate / pow(2.0, (time - lastRollingFeeUpdate) / halflife);
|
||||
lastRollingFeeUpdate = time;
|
||||
|
||||
if (rollingMinimumFeeRate < (double)incrementalRelayFee.GetFeePerK() / 2) {
|
||||
if (rollingMinimumFeeRate < (double)m_incremental_relay_feerate.GetFeePerK() / 2) {
|
||||
rollingMinimumFeeRate = 0;
|
||||
return CFeeRate(0);
|
||||
}
|
||||
}
|
||||
return std::max(CFeeRate(llround(rollingMinimumFeeRate)), incrementalRelayFee);
|
||||
return std::max(CFeeRate(llround(rollingMinimumFeeRate)), m_incremental_relay_feerate);
|
||||
}
|
||||
|
||||
void CTxMemPool::trackPackageRemoved(const CFeeRate& rate) {
|
||||
|
@ -1147,7 +1149,7 @@ void CTxMemPool::TrimToSize(size_t sizelimit, std::vector<COutPoint>* pvNoSpends
|
|||
// to have 0 fee). This way, we don't allow txn to enter mempool with feerate
|
||||
// equal to txn which were removed with no block in between.
|
||||
CFeeRate removed(it->GetModFeesWithDescendants(), it->GetSizeWithDescendants());
|
||||
removed += incrementalRelayFee;
|
||||
removed += m_incremental_relay_feerate;
|
||||
trackPackageRemoved(removed);
|
||||
maxFeeRateRemoved = std::max(maxFeeRateRemoved, removed);
|
||||
|
||||
|
|
|
@ -568,6 +568,8 @@ public:
|
|||
|
||||
const int64_t m_max_size_bytes;
|
||||
const std::chrono::seconds m_expiry;
|
||||
const CFeeRate m_incremental_relay_feerate;
|
||||
const CFeeRate m_min_relay_feerate;
|
||||
const bool m_require_standard;
|
||||
const bool m_full_rbf;
|
||||
|
||||
|
@ -703,11 +705,11 @@ public:
|
|||
void CalculateDescendants(txiter it, setEntries& setDescendants) const EXCLUSIVE_LOCKS_REQUIRED(cs);
|
||||
|
||||
/** The minimum fee to get into the mempool, which may itself not be enough
|
||||
* for larger-sized transactions.
|
||||
* The incrementalRelayFee policy variable is used to bound the time it
|
||||
* takes the fee rate to go back down all the way to 0. When the feerate
|
||||
* would otherwise be half of this, it is set to 0 instead.
|
||||
*/
|
||||
* for larger-sized transactions.
|
||||
* The m_incremental_relay_feerate policy variable is used to bound the time it
|
||||
* takes the fee rate to go back down all the way to 0. When the feerate
|
||||
* would otherwise be half of this, it is set to 0 instead.
|
||||
*/
|
||||
CFeeRate GetMinFee() const {
|
||||
return GetMinFee(m_max_size_bytes);
|
||||
}
|
||||
|
|
|
@ -646,8 +646,9 @@ private:
|
|||
return state.Invalid(TxValidationResult::TX_MEMPOOL_POLICY, "mempool min fee not met", strprintf("%d < %d", package_fee, mempoolRejectFee));
|
||||
}
|
||||
|
||||
if (package_fee < ::minRelayTxFee.GetFee(package_size)) {
|
||||
return state.Invalid(TxValidationResult::TX_MEMPOOL_POLICY, "min relay fee not met", strprintf("%d < %d", package_fee, ::minRelayTxFee.GetFee(package_size)));
|
||||
if (package_fee < m_pool.m_min_relay_feerate.GetFee(package_size)) {
|
||||
return state.Invalid(TxValidationResult::TX_MEMPOOL_POLICY, "min relay fee not met",
|
||||
strprintf("%d < %d", package_fee, m_pool.m_min_relay_feerate.GetFee(package_size)));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -841,7 +842,7 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
|
|||
return state.Invalid(TxValidationResult::TX_NOT_STANDARD, "bad-txns-too-many-sigops",
|
||||
strprintf("%d", nSigOpsCost));
|
||||
|
||||
// No individual transactions are allowed below minRelayTxFee and mempool min fee except from
|
||||
// No individual transactions are allowed below the min relay feerate and mempool min feerate except from
|
||||
// disconnected blocks and transactions in a package. Package transactions will be checked using
|
||||
// package feerate later.
|
||||
if (!bypass_limits && !args.m_package_feerates && !CheckFeeRate(ws.m_vsize, ws.m_modified_fees, state)) return false;
|
||||
|
@ -959,7 +960,7 @@ bool MemPoolAccept::ReplacementChecks(Workspace& ws)
|
|||
ws.m_conflicting_size += it->GetTxSize();
|
||||
}
|
||||
if (const auto err_string{PaysForRBF(ws.m_conflicting_fees, ws.m_modified_fees, ws.m_vsize,
|
||||
::incrementalRelayFee, hash)}) {
|
||||
m_pool.m_incremental_relay_feerate, hash)}) {
|
||||
return state.Invalid(TxValidationResult::TX_MEMPOOL_POLICY, "insufficient fee", *err_string);
|
||||
}
|
||||
return true;
|
||||
|
|
Loading…
Add table
Reference in a new issue