Skip to content

Commit f838005

Browse files
committed
No longer allow "free" transactions
Remove -limitfreerelay and always enforce minRelayTxFee in the mempool (except from disconnected blocks) Remove -relaypriority, the option was only used for the ability to allow free transactions to be relayed regardless of their priority. Both notions no longer apply.
1 parent ad727f4 commit f838005

File tree

10 files changed

+10
-53
lines changed

10 files changed

+10
-53
lines changed

qa/rpc-tests/abandonconflict.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ def run_test(self):
8080

8181
# Restart the node with a higher min relay fee so the parent tx is no longer in mempool
8282
# TODO: redo with eviction
83-
# Note had to make sure tx did not have AllowFree priority
8483
stop_node(self.nodes[0],0)
8584
self.nodes[0]=start_node(0, self.options.tmpdir, ["-debug","-logtimemicros","-minrelaytxfee=0.0001"])
8685

qa/rpc-tests/smartfees.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,7 @@ def setup_network(self):
188188

189189
# Now we can connect the other nodes, didn't want to connect them earlier
190190
# so the estimates would not be affected by the splitting transactions
191-
# Node1 mines small blocks but that are bigger than the expected transaction rate,
192-
# and allows free transactions.
191+
# Node1 mines small blocks but that are bigger than the expected transaction rate.
193192
# NOTE: the CreateNewBlock code starts counting block size at 1,000 bytes,
194193
# (17k is room enough for 110 or so transactions)
195194
self.nodes.append(start_node(1, self.options.tmpdir,

src/init.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -444,8 +444,6 @@ std::string HelpMessage(HelpMessageMode mode)
444444
{
445445
strUsage += HelpMessageOpt("-logtimemicros", strprintf("Add microsecond precision to debug timestamps (default: %u)", DEFAULT_LOGTIMEMICROS));
446446
strUsage += HelpMessageOpt("-mocktime=<n>", "Replace actual time with <n> seconds since epoch (default: 0)");
447-
strUsage += HelpMessageOpt("-limitfreerelay=<n>", strprintf("Continuously rate-limit free transactions to <n>*1000 bytes per minute (default: %u)", DEFAULT_LIMITFREERELAY));
448-
strUsage += HelpMessageOpt("-relaypriority", strprintf("Require high priority for relaying free or low-fee transactions (default: %u)", DEFAULT_RELAYPRIORITY));
449447
strUsage += HelpMessageOpt("-maxsigcachesize=<n>", strprintf("Limit size of signature cache to <n> MiB (default: %u)", DEFAULT_MAX_SIG_CACHE_SIZE));
450448
strUsage += HelpMessageOpt("-maxtipage=<n>", strprintf("Maximum tip age in seconds to consider node in initial block download (default: %u)", DEFAULT_MAX_TIP_AGE));
451449
}
@@ -975,7 +973,7 @@ bool AppInitParameterInteraction()
975973
if (nConnectTimeout <= 0)
976974
nConnectTimeout = DEFAULT_CONNECT_TIMEOUT;
977975

978-
// Fee-per-kilobyte amount considered the same as "free"
976+
// Fee-per-kilobyte amount required for mempool acceptance and relay
979977
// If you are mining, be careful setting this:
980978
// if you set it to zero then
981979
// a transaction spammer can cheaply fill blocks using

src/net_processing.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1853,7 +1853,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
18531853
LogPrint("mempool", " invalid orphan tx %s\n", orphanHash.ToString());
18541854
}
18551855
// Has inputs but not accepted to mempool
1856-
// Probably non-standard or insufficient fee/priority
1856+
// Probably non-standard or insufficient fee
18571857
LogPrint("mempool", " removed orphan tx %s\n", orphanHash.ToString());
18581858
vEraseQueue.push_back(orphanHash);
18591859
if (!orphanTx.HasWitness() && !stateDummy.CorruptionPossible()) {
@@ -3249,9 +3249,8 @@ bool SendMessages(CNode* pto, CConnman& connman, const std::atomic<bool>& interr
32493249
static CFeeRate default_feerate(DEFAULT_MIN_RELAY_TX_FEE);
32503250
static FeeFilterRounder filterRounder(default_feerate);
32513251
CAmount filterToSend = filterRounder.round(currentFilter);
3252-
// If we don't allow free transactions, then we always have a fee filter of at least minRelayTxFee
3253-
if (GetArg("-limitfreerelay", DEFAULT_LIMITFREERELAY) <= 0)
3254-
filterToSend = std::max(filterToSend, ::minRelayTxFee.GetFeePerK());
3252+
// We always have a fee filter of at least minRelayTxFee
3253+
filterToSend = std::max(filterToSend, ::minRelayTxFee.GetFeePerK());
32553254
if (filterToSend != pto->lastSentFeeFilter) {
32563255
connman.PushMessage(pto, msgMaker.Make(NetMsgType::FEEFILTER, filterToSend));
32573256
pto->lastSentFeeFilter = filterToSend;

src/rpc/misc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ UniValue getinfo(const JSONRPCRequest& request)
6161
" \"keypoolsize\": xxxx, (numeric) how many new keys are pre-generated\n"
6262
" \"unlocked_until\": ttt, (numeric) the timestamp in seconds since epoch (midnight Jan 1 1970 GMT) that the wallet is unlocked for transfers, or 0 if the wallet is locked\n"
6363
" \"paytxfee\": x.xxxx, (numeric) the transaction fee set in " + CURRENCY_UNIT + "/kB\n"
64-
" \"relayfee\": x.xxxx, (numeric) minimum relay fee for non-free transactions in " + CURRENCY_UNIT + "/kB\n"
64+
" \"relayfee\": x.xxxx, (numeric) minimum relay fee for transactions in " + CURRENCY_UNIT + "/kB\n"
6565
" \"errors\": \"...\" (string) any error messages\n"
6666
"}\n"
6767
"\nExamples:\n"

src/rpc/net.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ UniValue getnetworkinfo(const JSONRPCRequest& request)
417417
" }\n"
418418
" ,...\n"
419419
" ],\n"
420-
" \"relayfee\": x.xxxxxxxx, (numeric) minimum relay fee for non-free transactions in " + CURRENCY_UNIT + "/kB\n"
420+
" \"relayfee\": x.xxxxxxxx, (numeric) minimum relay fee for transactions in " + CURRENCY_UNIT + "/kB\n"
421421
" \"incrementalfee\": x.xxxxxxxx, (numeric) minimum fee increment for mempool limiting or BIP 125 replacement in " + CURRENCY_UNIT + "/kB\n"
422422
" \"localaddresses\": [ (array) list of local addresses\n"
423423
" {\n"

src/txmempool.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,6 @@
3030
class CAutoFile;
3131
class CBlockIndex;
3232

33-
inline double AllowFreeThreshold()
34-
{
35-
return COIN * 144 / 250;
36-
}
37-
38-
inline bool AllowFree(double dPriority)
39-
{
40-
// Large (in bytes) low-priority (new, small-coin) transactions
41-
// need a fee.
42-
return dPriority > AllowFreeThreshold();
43-
}
44-
4533
/** Fake height value used in CCoins to signify they are only in the memory pool (since 0.8) */
4634
static const unsigned int MEMPOOL_HEIGHT = 0x7FFFFFFF;
4735

src/validation.cpp

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -753,32 +753,11 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState& state, const C
753753
CAmount mempoolRejectFee = pool.GetMinFee(GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000).GetFee(nSize);
754754
if (mempoolRejectFee > 0 && nModifiedFees < mempoolRejectFee) {
755755
return state.DoS(0, false, REJECT_INSUFFICIENTFEE, "mempool min fee not met", false, strprintf("%d < %d", nFees, mempoolRejectFee));
756-
} else if (GetBoolArg("-relaypriority", DEFAULT_RELAYPRIORITY) && nModifiedFees < ::minRelayTxFee.GetFee(nSize) && !AllowFree(entry.GetPriority(chainActive.Height() + 1))) {
757-
// Require that free transactions have sufficient priority to be mined in the next block.
758-
return state.DoS(0, false, REJECT_INSUFFICIENTFEE, "insufficient priority");
759756
}
760757

761-
// Continuously rate-limit free (really, very-low-fee) transactions
762-
// This mitigates 'penny-flooding' -- sending thousands of free transactions just to
763-
// be annoying or make others' transactions take longer to confirm.
764-
if (fLimitFree && nModifiedFees < ::minRelayTxFee.GetFee(nSize))
765-
{
766-
static CCriticalSection csFreeLimiter;
767-
static double dFreeCount;
768-
static int64_t nLastTime;
769-
int64_t nNow = GetTime();
770-
771-
LOCK(csFreeLimiter);
772-
773-
// Use an exponentially decaying ~10-minute window:
774-
dFreeCount *= pow(1.0 - 1.0/600.0, (double)(nNow - nLastTime));
775-
nLastTime = nNow;
776-
// -limitfreerelay unit is thousand-bytes-per-minute
777-
// At default rate it would take over a month to fill 1GB
778-
if (dFreeCount + nSize >= GetArg("-limitfreerelay", DEFAULT_LIMITFREERELAY) * 10 * 1000)
779-
return state.DoS(0, false, REJECT_INSUFFICIENTFEE, "rate limited free transaction");
780-
LogPrint("mempool", "Rate limit dFreeCount: %g => %g\n", dFreeCount, dFreeCount+nSize);
781-
dFreeCount += nSize;
758+
// No transactions are allowed below minRelayTxFee except from disconnected blocks
759+
if (fLimitFree && nModifiedFees < ::minRelayTxFee.GetFee(nSize)) {
760+
return state.DoS(0, false, REJECT_INSUFFICIENTFEE, "min relay fee not met");
782761
}
783762

784763
if (nAbsurdFee && nFees > nAbsurdFee)

src/validation.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,6 @@ static const int64_t BLOCK_DOWNLOAD_TIMEOUT_BASE = 1000000;
122122
/** Additional block download timeout per parallel downloading peer (i.e. 5 min) */
123123
static const int64_t BLOCK_DOWNLOAD_TIMEOUT_PER_PEER = 500000;
124124

125-
static const unsigned int DEFAULT_LIMITFREERELAY = 0;
126-
static const bool DEFAULT_RELAYPRIORITY = true;
127125
static const int64_t DEFAULT_MAX_TIP_AGE = 24 * 60 * 60;
128126
/** Maximum age of our tip in seconds for us to be considered current for fee estimation */
129127
static const int64_t MAX_FEE_ESTIMATION_TIP_AGE = 3 * 60 * 60;

src/wallet/wallet.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3842,9 +3842,6 @@ bool CWallet::ParameterInteraction()
38423842
bSpendZeroConfChange = GetBoolArg("-spendzeroconfchange", DEFAULT_SPEND_ZEROCONF_CHANGE);
38433843
fWalletRbf = GetBoolArg("-walletrbf", DEFAULT_WALLET_RBF);
38443844

3845-
if (GetBoolArg("-sendfreetransactions", false))
3846-
InitWarning("The argument -sendfreetransactions is no longer supported.");
3847-
38483845
return true;
38493846
}
38503847

0 commit comments

Comments
 (0)