Merge #9380: Separate different uses of minimum fees

eb30d1a Introduce -dustrelayfee (Alex Morcos)
7b1add3 Introduce -incrementalrelayfee (Alex Morcos)
daec955 Introduce -blockmintxfee (Alex Morcos)
This commit is contained in:
Wladimir J. van der Laan 2017-01-16 19:32:51 +01:00
commit dd98f04538
No known key found for this signature in database
GPG Key ID: 74810B012346C9A6
12 changed files with 82 additions and 30 deletions

View File

@ -467,8 +467,11 @@ std::string HelpMessage(HelpMessageMode mode)
AppendParamsHelpMessages(strUsage, showDebug); AppendParamsHelpMessages(strUsage, showDebug);
strUsage += HelpMessageGroup(_("Node relay options:")); strUsage += HelpMessageGroup(_("Node relay options:"));
if (showDebug) if (showDebug) {
strUsage += HelpMessageOpt("-acceptnonstdtxn", strprintf("Relay and mine \"non-standard\" transactions (%sdefault: %u)", "testnet/regtest only; ", !Params(CBaseChainParams::TESTNET).RequireStandard())); strUsage += HelpMessageOpt("-acceptnonstdtxn", strprintf("Relay and mine \"non-standard\" transactions (%sdefault: %u)", "testnet/regtest only; ", !Params(CBaseChainParams::TESTNET).RequireStandard()));
strUsage += HelpMessageOpt("-incrementalrelayfee=<amt>", strprintf("Fee rate (in %s/kB) used to define cost of relay, used for mempool limiting and BIP 125 replacement. (default: %s)", CURRENCY_UNIT, FormatMoney(DEFAULT_INCREMENTAL_RELAY_FEE)));
strUsage += HelpMessageOpt("-dustrelayfee=<amt>", strprintf("Fee rate (in %s/kB) used to defined dust, the value of an output such that it will cost about 1/3 of its value in fees at this fee rate to spend it. (default: %s)", CURRENCY_UNIT, FormatMoney(DUST_RELAY_TX_FEE)));
}
strUsage += HelpMessageOpt("-bytespersigop", strprintf(_("Equivalent bytes per sigop in transactions for relay and mining (default: %u)"), DEFAULT_BYTES_PER_SIGOP)); strUsage += HelpMessageOpt("-bytespersigop", strprintf(_("Equivalent bytes per sigop in transactions for relay and mining (default: %u)"), DEFAULT_BYTES_PER_SIGOP));
strUsage += HelpMessageOpt("-datacarrier", strprintf(_("Relay and mine data carrier transactions (default: %u)"), DEFAULT_ACCEPT_DATACARRIER)); strUsage += HelpMessageOpt("-datacarrier", strprintf(_("Relay and mine data carrier transactions (default: %u)"), DEFAULT_ACCEPT_DATACARRIER));
strUsage += HelpMessageOpt("-datacarriersize", strprintf(_("Maximum size of data in data carrier transactions we relay and mine (default: %u)"), MAX_OP_RETURN_RELAY)); strUsage += HelpMessageOpt("-datacarriersize", strprintf(_("Maximum size of data in data carrier transactions we relay and mine (default: %u)"), MAX_OP_RETURN_RELAY));
@ -478,6 +481,7 @@ std::string HelpMessage(HelpMessageMode mode)
strUsage += HelpMessageOpt("-blockmaxweight=<n>", strprintf(_("Set maximum BIP141 block weight (default: %d)"), DEFAULT_BLOCK_MAX_WEIGHT)); strUsage += HelpMessageOpt("-blockmaxweight=<n>", strprintf(_("Set maximum BIP141 block weight (default: %d)"), DEFAULT_BLOCK_MAX_WEIGHT));
strUsage += HelpMessageOpt("-blockmaxsize=<n>", strprintf(_("Set maximum block size in bytes (default: %d)"), DEFAULT_BLOCK_MAX_SIZE)); strUsage += HelpMessageOpt("-blockmaxsize=<n>", strprintf(_("Set maximum block size in bytes (default: %d)"), DEFAULT_BLOCK_MAX_SIZE));
strUsage += HelpMessageOpt("-blockprioritysize=<n>", strprintf(_("Set maximum size of high-priority/low-fee transactions in bytes (default: %d)"), DEFAULT_BLOCK_PRIORITY_SIZE)); strUsage += HelpMessageOpt("-blockprioritysize=<n>", strprintf(_("Set maximum size of high-priority/low-fee transactions in bytes (default: %d)"), DEFAULT_BLOCK_PRIORITY_SIZE));
strUsage += HelpMessageOpt("-blockmintxfee=<amt>", strprintf(_("Set lowest fee rate (in %s/kB) for transactions to be included in block creation. (default: %s)"), CURRENCY_UNIT, FormatMoney(DEFAULT_BLOCK_MIN_TX_FEE)));
if (showDebug) if (showDebug)
strUsage += HelpMessageOpt("-blockversion=<n>", "Override block version to test forking scenarios"); strUsage += HelpMessageOpt("-blockversion=<n>", "Override block version to test forking scenarios");
@ -925,6 +929,15 @@ bool AppInitParameterInteraction()
int64_t nMempoolSizeMin = GetArg("-limitdescendantsize", DEFAULT_DESCENDANT_SIZE_LIMIT) * 1000 * 40; int64_t nMempoolSizeMin = GetArg("-limitdescendantsize", DEFAULT_DESCENDANT_SIZE_LIMIT) * 1000 * 40;
if (nMempoolSizeMax < 0 || nMempoolSizeMax < nMempoolSizeMin) if (nMempoolSizeMax < 0 || nMempoolSizeMax < nMempoolSizeMin)
return InitError(strprintf(_("-maxmempool must be at least %d MB"), std::ceil(nMempoolSizeMin / 1000000.0))); return InitError(strprintf(_("-maxmempool must be at least %d MB"), std::ceil(nMempoolSizeMin / 1000000.0)));
// incremental relay fee sets the minimimum 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 (IsArgSet("-incrementalrelayfee"))
{
CAmount n = 0;
if (!ParseMoney(GetArg("-incrementalrelayfee", ""), n))
return InitError(AmountErrMsg("incrementalrelayfee", GetArg("-incrementalrelayfee", "")));
incrementalRelayFee = CFeeRate(n);
}
// -par=0 means autodetect, but nScriptCheckThreads==0 means no concurrency // -par=0 means autodetect, but nScriptCheckThreads==0 means no concurrency
nScriptCheckThreads = GetArg("-par", DEFAULT_SCRIPTCHECK_THREADS); nScriptCheckThreads = GetArg("-par", DEFAULT_SCRIPTCHECK_THREADS);
@ -975,6 +988,29 @@ bool AppInitParameterInteraction()
return InitError(AmountErrMsg("minrelaytxfee", GetArg("-minrelaytxfee", ""))); return InitError(AmountErrMsg("minrelaytxfee", GetArg("-minrelaytxfee", "")));
// High fee check is done afterward in CWallet::ParameterInteraction() // High fee check is done afterward in CWallet::ParameterInteraction()
::minRelayTxFee = CFeeRate(n); ::minRelayTxFee = CFeeRate(n);
} 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 (IsArgSet("-blockmintxfee"))
{
CAmount n = 0;
if (!ParseMoney(GetArg("-blockmintxfee", ""), n))
return InitError(AmountErrMsg("blockmintxfee", GetArg("-blockmintxfee", "")));
}
// Feerate used to define dust. Shouldn't be changed lightly as old
// implementations may inadvertently create non-standard transactions
if (IsArgSet("-dustrelayfee"))
{
CAmount n = 0;
if (!ParseMoney(GetArg("-dustrelayfee", ""), n) || 0 == n)
return InitError(AmountErrMsg("dustrelayfee", GetArg("-dustrelayfee", "")));
dustRelayFee = CFeeRate(n);
} }
fRequireStandard = !GetBoolArg("-acceptnonstdtxn", !chainparams.RequireStandard()); fRequireStandard = !GetBoolArg("-acceptnonstdtxn", !chainparams.RequireStandard());

View File

@ -95,12 +95,18 @@ BlockAssembler::BlockAssembler(const CChainParams& _chainparams)
nBlockMaxWeight = nBlockMaxSize * WITNESS_SCALE_FACTOR; nBlockMaxWeight = nBlockMaxSize * WITNESS_SCALE_FACTOR;
} }
} }
if (IsArgSet("-blockmintxfee")) {
CAmount n = 0;
ParseMoney(GetArg("-blockmintxfee", ""), n);
blockMinFeeRate = CFeeRate(n);
} else {
blockMinFeeRate = CFeeRate(DEFAULT_BLOCK_MIN_TX_FEE);
}
// Limit weight to between 4K and MAX_BLOCK_WEIGHT-4K for sanity: // Limit weight to between 4K and MAX_BLOCK_WEIGHT-4K for sanity:
nBlockMaxWeight = std::max((unsigned int)4000, std::min((unsigned int)(MAX_BLOCK_WEIGHT-4000), nBlockMaxWeight)); nBlockMaxWeight = std::max((unsigned int)4000, std::min((unsigned int)(MAX_BLOCK_WEIGHT-4000), nBlockMaxWeight));
// Limit size to between 1K and MAX_BLOCK_SERIALIZED_SIZE-1K for sanity: // Limit size to between 1K and MAX_BLOCK_SERIALIZED_SIZE-1K for sanity:
nBlockMaxSize = std::max((unsigned int)1000, std::min((unsigned int)(MAX_BLOCK_SERIALIZED_SIZE-1000), nBlockMaxSize)); nBlockMaxSize = std::max((unsigned int)1000, std::min((unsigned int)(MAX_BLOCK_SERIALIZED_SIZE-1000), nBlockMaxSize));
// Whether we need to account for byte usage (in addition to weight usage) // Whether we need to account for byte usage (in addition to weight usage)
fNeedSizeAccounting = (nBlockMaxSize < MAX_BLOCK_SERIALIZED_SIZE-1000); fNeedSizeAccounting = (nBlockMaxSize < MAX_BLOCK_SERIALIZED_SIZE-1000);
} }
@ -460,7 +466,7 @@ void BlockAssembler::addPackageTxs()
packageSigOpsCost = modit->nSigOpCostWithAncestors; packageSigOpsCost = modit->nSigOpCostWithAncestors;
} }
if (packageFees < ::minRelayTxFee.GetFee(packageSize)) { if (packageFees < blockMinFeeRate.GetFee(packageSize)) {
// Everything else we might consider has a lower fee rate // Everything else we might consider has a lower fee rate
return; return;
} }

View File

@ -143,6 +143,7 @@ private:
bool fIncludeWitness; bool fIncludeWitness;
unsigned int nBlockMaxWeight, nBlockMaxSize; unsigned int nBlockMaxWeight, nBlockMaxSize;
bool fNeedSizeAccounting; bool fNeedSizeAccounting;
CFeeRate blockMinFeeRate;
// Information on the current status of the block // Information on the current status of the block
uint64_t nBlockWeight; uint64_t nBlockWeight;

View File

@ -105,7 +105,7 @@ bool IsStandardTx(const CTransaction& tx, std::string& reason, const bool witnes
else if ((whichType == TX_MULTISIG) && (!fIsBareMultisigStd)) { else if ((whichType == TX_MULTISIG) && (!fIsBareMultisigStd)) {
reason = "bare-multisig"; reason = "bare-multisig";
return false; return false;
} else if (txout.IsDust(::minRelayTxFee)) { } else if (txout.IsDust(dustRelayFee)) {
reason = "dust"; reason = "dust";
return false; return false;
} }
@ -206,6 +206,8 @@ bool IsWitnessStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs)
return true; return true;
} }
CFeeRate incrementalRelayFee = CFeeRate(DEFAULT_INCREMENTAL_RELAY_FEE);
CFeeRate dustRelayFee = CFeeRate(DUST_RELAY_TX_FEE);
unsigned int nBytesPerSigOp = DEFAULT_BYTES_PER_SIGOP; unsigned int nBytesPerSigOp = DEFAULT_BYTES_PER_SIGOP;
int64_t GetVirtualTransactionSize(int64_t nWeight, int64_t nSigOpCost) int64_t GetVirtualTransactionSize(int64_t nWeight, int64_t nSigOpCost)

View File

@ -20,6 +20,8 @@ static const unsigned int DEFAULT_BLOCK_MAX_SIZE = 750000;
static const unsigned int DEFAULT_BLOCK_PRIORITY_SIZE = 0; static const unsigned int DEFAULT_BLOCK_PRIORITY_SIZE = 0;
/** Default for -blockmaxweight, which controls the range of block weights the mining code will create **/ /** Default for -blockmaxweight, which controls the range of block weights the mining code will create **/
static const unsigned int DEFAULT_BLOCK_MAX_WEIGHT = 3000000; static const unsigned int DEFAULT_BLOCK_MAX_WEIGHT = 3000000;
/** Default for -blockmintxfee, which sets the minimum feerate for a transaction in blocks created by mining code **/
static const unsigned int DEFAULT_BLOCK_MIN_TX_FEE = 1000;
/** The maximum weight for transactions we're willing to relay/mine */ /** The maximum weight for transactions we're willing to relay/mine */
static const unsigned int MAX_STANDARD_TX_WEIGHT = 400000; static const unsigned int MAX_STANDARD_TX_WEIGHT = 400000;
/** Maximum number of signature check operations in an IsStandard() P2SH script */ /** Maximum number of signature check operations in an IsStandard() P2SH script */
@ -28,6 +30,8 @@ static const unsigned int MAX_P2SH_SIGOPS = 15;
static const unsigned int MAX_STANDARD_TX_SIGOPS_COST = MAX_BLOCK_SIGOPS_COST/5; static const unsigned int MAX_STANDARD_TX_SIGOPS_COST = MAX_BLOCK_SIGOPS_COST/5;
/** Default for -maxmempool, maximum megabytes of mempool memory usage */ /** Default for -maxmempool, maximum megabytes of mempool memory usage */
static const unsigned int DEFAULT_MAX_MEMPOOL_SIZE = 300; static const unsigned int DEFAULT_MAX_MEMPOOL_SIZE = 300;
/** Default for -incrementalrelayfee, which sets the minimum feerate increase for mempool limiting or BIP 125 replacement **/
static const unsigned int DEFAULT_INCREMENTAL_RELAY_FEE = 1000;
/** Default for -bytespersigop */ /** Default for -bytespersigop */
static const unsigned int DEFAULT_BYTES_PER_SIGOP = 20; static const unsigned int DEFAULT_BYTES_PER_SIGOP = 20;
/** The maximum number of witness stack items in a standard P2WSH script */ /** The maximum number of witness stack items in a standard P2WSH script */
@ -36,6 +40,12 @@ static const unsigned int MAX_STANDARD_P2WSH_STACK_ITEMS = 100;
static const unsigned int MAX_STANDARD_P2WSH_STACK_ITEM_SIZE = 80; static const unsigned int MAX_STANDARD_P2WSH_STACK_ITEM_SIZE = 80;
/** The maximum size of a standard witnessScript */ /** The maximum size of a standard witnessScript */
static const unsigned int MAX_STANDARD_P2WSH_SCRIPT_SIZE = 3600; static const unsigned int MAX_STANDARD_P2WSH_SCRIPT_SIZE = 3600;
/** Min feerate for defining dust. Historically this has been the same as the
* minRelayTxFee, however 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 */
static const unsigned int DUST_RELAY_TX_FEE = 1000;
/** /**
* Standard script verification flags that standard transactions will comply * Standard script verification flags that standard transactions will comply
* with. However scripts violating these flags may still be present in valid * with. However scripts violating these flags may still be present in valid
@ -83,6 +93,8 @@ bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs)
*/ */
bool IsWitnessStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs); bool IsWitnessStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs);
extern CFeeRate incrementalRelayFee;
extern CFeeRate dustRelayFee;
extern unsigned int nBytesPerSigOp; extern unsigned int nBytesPerSigOp;
/** Compute the virtual transaction size (weight reinterpreted as bytes). */ /** Compute the virtual transaction size (weight reinterpreted as bytes). */

View File

@ -15,7 +15,8 @@
#include "wallet/coincontrol.h" #include "wallet/coincontrol.h"
#include "init.h" #include "init.h"
#include "validation.h" // For minRelayTxFee #include "policy/policy.h"
#include "validation.h" // For mempool
#include "wallet/wallet.h" #include "wallet/wallet.h"
#include <boost/assign/list_of.hpp> // for 'map_list_of()' #include <boost/assign/list_of.hpp> // for 'map_list_of()'
@ -432,7 +433,7 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
{ {
CTxOut txout(amount, (CScript)std::vector<unsigned char>(24, 0)); CTxOut txout(amount, (CScript)std::vector<unsigned char>(24, 0));
txDummy.vout.push_back(txout); txDummy.vout.push_back(txout);
if (txout.IsDust(::minRelayTxFee)) if (txout.IsDust(dustRelayFee))
fDust = true; fDust = true;
} }
} }
@ -545,10 +546,10 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
if (nChange > 0 && nChange < MIN_CHANGE) if (nChange > 0 && nChange < MIN_CHANGE)
{ {
CTxOut txout(nChange, (CScript)std::vector<unsigned char>(24, 0)); CTxOut txout(nChange, (CScript)std::vector<unsigned char>(24, 0));
if (txout.IsDust(::minRelayTxFee)) if (txout.IsDust(dustRelayFee))
{ {
if (CoinControlDialog::fSubtractFeeFromAmount) // dust-change will be raised until no dust if (CoinControlDialog::fSubtractFeeFromAmount) // dust-change will be raised until no dust
nChange = txout.GetDustThreshold(::minRelayTxFee); nChange = txout.GetDustThreshold(dustRelayFee);
else else
{ {
nPayFee += nChange; nPayFee += nChange;

View File

@ -11,7 +11,7 @@
#include "primitives/transaction.h" #include "primitives/transaction.h"
#include "init.h" #include "init.h"
#include "validation.h" // For minRelayTxFee #include "policy/policy.h"
#include "protocol.h" #include "protocol.h"
#include "script/script.h" #include "script/script.h"
#include "script/standard.h" #include "script/standard.h"
@ -257,7 +257,7 @@ bool isDust(const QString& address, const CAmount& amount)
CTxDestination dest = CBitcoinAddress(address.toStdString()).Get(); CTxDestination dest = CBitcoinAddress(address.toStdString()).Get();
CScript script = GetScriptForDestination(dest); CScript script = GetScriptForDestination(dest);
CTxOut txOut(amount, script); CTxOut txOut(amount, script);
return txOut.IsDust(::minRelayTxFee); return txOut.IsDust(dustRelayFee);
} }
QString HtmlEscape(const QString& str, bool fMultiLine) QString HtmlEscape(const QString& str, bool fMultiLine)

View File

@ -10,7 +10,7 @@
#include "base58.h" #include "base58.h"
#include "chainparams.h" #include "chainparams.h"
#include "validation.h" // For minRelayTxFee #include "policy/policy.h"
#include "ui_interface.h" #include "ui_interface.h"
#include "util.h" #include "util.h"
#include "wallet/wallet.h" #include "wallet/wallet.h"
@ -582,7 +582,7 @@ bool PaymentServer::processPaymentRequest(const PaymentRequestPlus& request, Sen
// Extract and check amounts // Extract and check amounts
CTxOut txOut(sendingTo.second, sendingTo.first); CTxOut txOut(sendingTo.second, sendingTo.first);
if (txOut.IsDust(::minRelayTxFee)) { if (txOut.IsDust(dustRelayFee)) {
Q_EMIT message(tr("Payment request error"), tr("Requested payment amount of %1 is too small (considered dust).") Q_EMIT message(tr("Payment request error"), tr("Requested payment amount of %1 is too small (considered dust).")
.arg(BitcoinUnits::formatWithUnit(optionsModel->getDisplayUnit(), sendingTo.second)), .arg(BitcoinUnits::formatWithUnit(optionsModel->getDisplayUnit(), sendingTo.second)),
CClientUIInterface::MSG_ERROR); CClientUIInterface::MSG_ERROR);

View File

@ -690,7 +690,7 @@ BOOST_AUTO_TEST_CASE(test_IsStandard)
BOOST_CHECK(IsStandardTx(t, reason)); BOOST_CHECK(IsStandardTx(t, reason));
// Check dust with default relay fee: // Check dust with default relay fee:
CAmount nDustThreshold = 182 * minRelayTxFee.GetFeePerK()/1000 * 3; CAmount nDustThreshold = 182 * dustRelayFee.GetFeePerK()/1000 * 3;
BOOST_CHECK_EQUAL(nDustThreshold, 546); BOOST_CHECK_EQUAL(nDustThreshold, 546);
// dust: // dust:
t.vout[0].nValue = nDustThreshold - 1; t.vout[0].nValue = nDustThreshold - 1;
@ -701,14 +701,14 @@ BOOST_AUTO_TEST_CASE(test_IsStandard)
// Check dust with odd relay fee to verify rounding: // Check dust with odd relay fee to verify rounding:
// nDustThreshold = 182 * 1234 / 1000 * 3 // nDustThreshold = 182 * 1234 / 1000 * 3
minRelayTxFee = CFeeRate(1234); dustRelayFee = CFeeRate(1234);
// dust: // dust:
t.vout[0].nValue = 672 - 1; t.vout[0].nValue = 672 - 1;
BOOST_CHECK(!IsStandardTx(t, reason)); BOOST_CHECK(!IsStandardTx(t, reason));
// not dust: // not dust:
t.vout[0].nValue = 672; t.vout[0].nValue = 672;
BOOST_CHECK(IsStandardTx(t, reason)); BOOST_CHECK(IsStandardTx(t, reason));
minRelayTxFee = CFeeRate(DEFAULT_MIN_RELAY_TX_FEE); dustRelayFee = CFeeRate(DUST_RELAY_TX_FEE);
t.vout[0].scriptPubKey = CScript() << OP_1; t.vout[0].scriptPubKey = CScript() << OP_1;
BOOST_CHECK(!IsStandardTx(t, reason)); BOOST_CHECK(!IsStandardTx(t, reason));

View File

@ -359,7 +359,6 @@ CTxMemPool::CTxMemPool(const CFeeRate& _minReasonableRelayFee) :
nCheckFrequency = 0; nCheckFrequency = 0;
minerPolicyEstimator = new CBlockPolicyEstimator(_minReasonableRelayFee); minerPolicyEstimator = new CBlockPolicyEstimator(_minReasonableRelayFee);
minReasonableRelayFee = _minReasonableRelayFee;
} }
CTxMemPool::~CTxMemPool() CTxMemPool::~CTxMemPool()
@ -1076,12 +1075,12 @@ CFeeRate CTxMemPool::GetMinFee(size_t sizelimit) const {
rollingMinimumFeeRate = rollingMinimumFeeRate / pow(2.0, (time - lastRollingFeeUpdate) / halflife); rollingMinimumFeeRate = rollingMinimumFeeRate / pow(2.0, (time - lastRollingFeeUpdate) / halflife);
lastRollingFeeUpdate = time; lastRollingFeeUpdate = time;
if (rollingMinimumFeeRate < (double)minReasonableRelayFee.GetFeePerK() / 2) { if (rollingMinimumFeeRate < (double)incrementalRelayFee.GetFeePerK() / 2) {
rollingMinimumFeeRate = 0; rollingMinimumFeeRate = 0;
return CFeeRate(0); return CFeeRate(0);
} }
} }
return std::max(CFeeRate(rollingMinimumFeeRate), minReasonableRelayFee); return std::max(CFeeRate(rollingMinimumFeeRate), incrementalRelayFee);
} }
void CTxMemPool::trackPackageRemoved(const CFeeRate& rate) { void CTxMemPool::trackPackageRemoved(const CFeeRate& rate) {
@ -1105,7 +1104,7 @@ void CTxMemPool::TrimToSize(size_t sizelimit, std::vector<uint256>* pvNoSpendsRe
// to have 0 fee). This way, we don't allow txn to enter mempool with feerate // 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. // equal to txn which were removed with no block in between.
CFeeRate removed(it->GetModFeesWithDescendants(), it->GetSizeWithDescendants()); CFeeRate removed(it->GetModFeesWithDescendants(), it->GetSizeWithDescendants());
removed += minReasonableRelayFee; removed += incrementalRelayFee;
trackPackageRemoved(removed); trackPackageRemoved(removed);
maxFeeRateRemoved = std::max(maxFeeRateRemoved, removed); maxFeeRateRemoved = std::max(maxFeeRateRemoved, removed);

View File

@ -423,8 +423,6 @@ private:
uint64_t totalTxSize; //!< sum of all mempool tx's virtual sizes. Differs from serialized tx size since witness data is discounted. Defined in BIP 141. uint64_t totalTxSize; //!< sum of all mempool tx's virtual sizes. Differs from serialized tx size since witness data is discounted. Defined in BIP 141.
uint64_t cachedInnerUsage; //!< sum of dynamic memory usage of all the map elements (NOT the maps themselves) uint64_t cachedInnerUsage; //!< sum of dynamic memory usage of all the map elements (NOT the maps themselves)
CFeeRate minReasonableRelayFee;
mutable int64_t lastRollingFeeUpdate; mutable int64_t lastRollingFeeUpdate;
mutable bool blockSinceLastRollingFeeBump; mutable bool blockSinceLastRollingFeeBump;
mutable double rollingMinimumFeeRate; //!< minimum fee to get into the pool, decreases exponentially mutable double rollingMinimumFeeRate; //!< minimum fee to get into the pool, decreases exponentially
@ -503,9 +501,6 @@ public:
std::map<uint256, std::pair<double, CAmount> > mapDeltas; std::map<uint256, std::pair<double, CAmount> > mapDeltas;
/** Create a new CTxMemPool. /** Create a new CTxMemPool.
* minReasonableRelayFee should be a feerate which is, roughly, somewhere
* around what it "costs" to relay a transaction around the network and
* below which we would reasonably say a transaction has 0-effective-fee.
*/ */
CTxMemPool(const CFeeRate& _minReasonableRelayFee); CTxMemPool(const CFeeRate& _minReasonableRelayFee);
~CTxMemPool(); ~CTxMemPool();
@ -588,7 +583,7 @@ public:
/** The minimum fee to get into the mempool, which may itself not be enough /** The minimum fee to get into the mempool, which may itself not be enough
* for larger-sized transactions. * for larger-sized transactions.
* The minReasonableRelayFee constructor arg is used to bound the time it * 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 * 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. * would otherwise be half of this, it is set to 0 instead.
*/ */

View File

@ -2341,7 +2341,7 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt
} }
} }
if (txout.IsDust(::minRelayTxFee)) if (txout.IsDust(dustRelayFee))
{ {
if (recipient.fSubtractFeeFromAmount && nFeeRet > 0) if (recipient.fSubtractFeeFromAmount && nFeeRet > 0)
{ {
@ -2419,16 +2419,16 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt
// We do not move dust-change to fees, because the sender would end up paying more than requested. // We do not move dust-change to fees, because the sender would end up paying more than requested.
// This would be against the purpose of the all-inclusive feature. // This would be against the purpose of the all-inclusive feature.
// So instead we raise the change and deduct from the recipient. // So instead we raise the change and deduct from the recipient.
if (nSubtractFeeFromAmount > 0 && newTxOut.IsDust(::minRelayTxFee)) if (nSubtractFeeFromAmount > 0 && newTxOut.IsDust(dustRelayFee))
{ {
CAmount nDust = newTxOut.GetDustThreshold(::minRelayTxFee) - newTxOut.nValue; CAmount nDust = newTxOut.GetDustThreshold(dustRelayFee) - newTxOut.nValue;
newTxOut.nValue += nDust; // raise change until no more dust newTxOut.nValue += nDust; // raise change until no more dust
for (unsigned int i = 0; i < vecSend.size(); i++) // subtract from first recipient for (unsigned int i = 0; i < vecSend.size(); i++) // subtract from first recipient
{ {
if (vecSend[i].fSubtractFeeFromAmount) if (vecSend[i].fSubtractFeeFromAmount)
{ {
txNew.vout[i].nValue -= nDust; txNew.vout[i].nValue -= nDust;
if (txNew.vout[i].IsDust(::minRelayTxFee)) if (txNew.vout[i].IsDust(dustRelayFee))
{ {
strFailReason = _("The transaction amount is too small to send after the fee has been deducted"); strFailReason = _("The transaction amount is too small to send after the fee has been deducted");
return false; return false;
@ -2440,7 +2440,7 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt
// Never create dust outputs; if we would, just // Never create dust outputs; if we would, just
// add the dust to the fee. // add the dust to the fee.
if (newTxOut.IsDust(::minRelayTxFee)) if (newTxOut.IsDust(dustRelayFee))
{ {
nChangePosInOut = -1; nChangePosInOut = -1;
nFeeRet += nChange; nFeeRet += nChange;