Skip to content

Commit b048b27

Browse files
jnewberyglozow
authored andcommitted
[validation] Remove absurdfee from accepttomempool
Mempool behavior should not be user-specific. Checking that txfee is acceptable should be the responsibility of the wallet or client, not the mempool.
1 parent 932564b commit b048b27

9 files changed

+16
-23
lines changed

src/bench/block_assemble.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ static void AssembleBlock(benchmark::Bench& bench)
4949

5050
for (const auto& txr : txs) {
5151
TxValidationState state;
52-
bool ret{::AcceptToMemoryPool(*test_setup.m_node.mempool, state, txr, nullptr /* plTxnReplaced */, false /* bypass_limits */, /* nAbsurdFee */ 0)};
52+
bool ret{::AcceptToMemoryPool(*test_setup.m_node.mempool, state, txr, nullptr /* plTxnReplaced */, false /* bypass_limits */)};
5353
assert(ret);
5454
}
5555
}

src/net_processing.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -2058,7 +2058,7 @@ void PeerManager::ProcessOrphanTx(std::set<uint256>& orphan_work_set)
20582058
TxValidationState state;
20592059
std::list<CTransactionRef> removed_txn;
20602060

2061-
if (AcceptToMemoryPool(m_mempool, state, porphanTx, &removed_txn, false /* bypass_limits */, 0 /* nAbsurdFee */)) {
2061+
if (AcceptToMemoryPool(m_mempool, state, porphanTx, &removed_txn, false /* bypass_limits */)) {
20622062
LogPrint(BCLog::MEMPOOL, " accepted orphan tx %s\n", orphanHash.ToString());
20632063
RelayTransaction(orphanHash, porphanTx->GetWitnessHash(), m_connman);
20642064
for (unsigned int i = 0; i < porphanTx->vout.size(); i++) {
@@ -3014,7 +3014,7 @@ void PeerManager::ProcessMessage(CNode& pfrom, const std::string& msg_type, CDat
30143014
// (older than our recency filter) if trying to DoS us, without any need
30153015
// for witness malleation.
30163016
if (!AlreadyHaveTx(GenTxid(/* is_wtxid=*/true, wtxid), m_mempool) &&
3017-
AcceptToMemoryPool(m_mempool, state, ptx, &lRemovedTxn, false /* bypass_limits */, 0 /* nAbsurdFee */)) {
3017+
AcceptToMemoryPool(m_mempool, state, ptx, &lRemovedTxn, false /* bypass_limits */)) {
30183018
m_mempool.check(&::ChainstateActive().CoinsTip());
30193019
RelayTransaction(tx.GetHash(), tx.GetWitnessHash(), m_connman);
30203020
for (unsigned int i = 0; i < tx.vout.size(); i++) {

src/node/transaction.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,15 @@ TransactionError BroadcastTransaction(NodeContext& node, const CTransactionRef t
5555
// First, call ATMP with test_accept and check the fee. If ATMP
5656
// fails here, return error immediately.
5757
if (!AcceptToMemoryPool(*node.mempool, state, tx,
58-
nullptr /* plTxnReplaced */, false /* bypass_limits */, /* absurdfee*/ 0, /* test_accept */ true, &fee)) {
58+
nullptr /* plTxnReplaced */, false /* bypass_limits */, /* test_accept */ true, &fee)) {
5959
return HandleATMPError(state, err_string);
6060
} else if (fee > max_tx_fee) {
6161
return TransactionError::MAX_FEE_EXCEEDED;
6262
}
6363
}
6464
// Try to submit the transaction to the mempool.
6565
if (!AcceptToMemoryPool(*node.mempool, state, tx,
66-
nullptr /* plTxnReplaced */, false /* bypass_limits */, max_tx_fee)) {
66+
nullptr /* plTxnReplaced */, false /* bypass_limits */)) {
6767
return HandleATMPError(state, err_string);
6868
}
6969

src/rpc/rawtransaction.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -951,7 +951,7 @@ static RPCHelpMan testmempoolaccept()
951951
{
952952
LOCK(cs_main);
953953
test_accept_res = AcceptToMemoryPool(mempool, state, std::move(tx),
954-
nullptr /* plTxnReplaced */, false /* bypass_limits */, max_raw_tx_fee, /* test_accept */ true, &fee);
954+
nullptr /* plTxnReplaced */, false /* bypass_limits */, /* test_accept */ true, &fee);
955955
}
956956

957957
// Check that fee does not exceed maximum fee

src/test/txvalidation_tests.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ BOOST_FIXTURE_TEST_CASE(tx_mempool_reject_coinbase, TestChain100Setup)
4040
false,
4141
AcceptToMemoryPool(*m_node.mempool, state, MakeTransactionRef(coinbaseTx),
4242
nullptr /* plTxnReplaced */,
43-
true /* bypass_limits */,
44-
0 /* nAbsurdFee */));
43+
true /* bypass_limits */));
4544

4645
// Check that the transaction hasn't been added to mempool.
4746
BOOST_CHECK_EQUAL(m_node.mempool->size(), initialPoolSize);

src/test/txvalidationcache_tests.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ BOOST_FIXTURE_TEST_CASE(tx_mempool_block_doublespend, TestChain100Setup)
3030

3131
TxValidationState state;
3232
return AcceptToMemoryPool(*m_node.mempool, state, MakeTransactionRef(tx),
33-
nullptr /* plTxnReplaced */, true /* bypass_limits */, 0 /* nAbsurdFee */);
33+
nullptr /* plTxnReplaced */, true /* bypass_limits */);
3434
};
3535

3636
// Create a double-spend of mature coinbase txn:

src/test/validation_block_tests.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,7 @@ BOOST_AUTO_TEST_CASE(mempool_locks_reorg)
291291
state,
292292
tx,
293293
&plTxnReplaced,
294-
/* bypass_limits */ false,
295-
/* nAbsurdFee */ 0));
294+
/* bypass_limits */ false));
296295
}
297296
}
298297

src/validation.cpp

+6-11
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ static void UpdateMempoolForReorg(CTxMemPool& mempool, DisconnectedBlockTransact
384384
TxValidationState stateDummy;
385385
if (!fAddToMempool || (*it)->IsCoinBase() ||
386386
!AcceptToMemoryPool(mempool, stateDummy, *it,
387-
nullptr /* plTxnReplaced */, true /* bypass_limits */, 0 /* nAbsurdFee */)) {
387+
nullptr /* plTxnReplaced */, true /* bypass_limits */)) {
388388
// If the transaction doesn't make it in to the mempool, remove any
389389
// transactions that depend on it (which would now be orphans).
390390
mempool.removeRecursive(**it, MemPoolRemovalReason::REORG);
@@ -463,7 +463,6 @@ class MemPoolAccept
463463
const int64_t m_accept_time;
464464
std::list<CTransactionRef>* m_replaced_transactions;
465465
const bool m_bypass_limits;
466-
const CAmount& m_absurd_fee;
467466
/*
468467
* Return any outpoints which were not previously present in the coins
469468
* cache, but were added as a result of validating the tx for mempool
@@ -558,7 +557,6 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
558557
TxValidationState &state = args.m_state;
559558
const int64_t nAcceptTime = args.m_accept_time;
560559
const bool bypass_limits = args.m_bypass_limits;
561-
const CAmount& nAbsurdFee = args.m_absurd_fee;
562560
std::vector<COutPoint>& coins_to_uncache = args.m_coins_to_uncache;
563561

564562
// Alias what we need out of ws
@@ -729,9 +727,6 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
729727
// blocks
730728
if (!bypass_limits && !CheckFeeRate(nSize, nModifiedFees, state)) return false;
731729

732-
if (nAbsurdFee && nFees > nAbsurdFee)
733-
LogPrintf("Ignoring Absurdfee\n");
734-
735730
const CTxMemPool::setEntries setIterConflicting = m_pool.GetIterSet(setConflicts);
736731
// Calculate in-mempool ancestors, up to a limit.
737732
if (setConflicts.size() == 1) {
@@ -1064,10 +1059,10 @@ bool MemPoolAccept::AcceptSingleTransaction(const CTransactionRef& ptx, ATMPArgs
10641059
/** (try to) add transaction to memory pool with a specified acceptance time **/
10651060
static bool AcceptToMemoryPoolWithTime(const CChainParams& chainparams, CTxMemPool& pool, TxValidationState &state, const CTransactionRef &tx,
10661061
int64_t nAcceptTime, std::list<CTransactionRef>* plTxnReplaced,
1067-
bool bypass_limits, const CAmount nAbsurdFee, bool test_accept, CAmount* fee_out=nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
1062+
bool bypass_limits, bool test_accept, CAmount* fee_out=nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
10681063
{
10691064
std::vector<COutPoint> coins_to_uncache;
1070-
MemPoolAccept::ATMPArgs args { chainparams, state, nAcceptTime, plTxnReplaced, bypass_limits, nAbsurdFee, coins_to_uncache, test_accept, fee_out };
1065+
MemPoolAccept::ATMPArgs args { chainparams, state, nAcceptTime, plTxnReplaced, bypass_limits, coins_to_uncache, test_accept, fee_out };
10711066
bool res = MemPoolAccept(pool).AcceptSingleTransaction(tx, args);
10721067
if (!res) {
10731068
// Remove coins that were not present in the coins cache before calling ATMPW;
@@ -1086,10 +1081,10 @@ static bool AcceptToMemoryPoolWithTime(const CChainParams& chainparams, CTxMemPo
10861081

10871082
bool AcceptToMemoryPool(CTxMemPool& pool, TxValidationState &state, const CTransactionRef &tx,
10881083
std::list<CTransactionRef>* plTxnReplaced,
1089-
bool bypass_limits, const CAmount nAbsurdFee, bool test_accept, CAmount* fee_out)
1084+
bool bypass_limits, bool test_accept, CAmount* fee_out)
10901085
{
10911086
const CChainParams& chainparams = Params();
1092-
return AcceptToMemoryPoolWithTime(chainparams, pool, state, tx, GetTime(), plTxnReplaced, bypass_limits, nAbsurdFee, test_accept, fee_out);
1087+
return AcceptToMemoryPoolWithTime(chainparams, pool, state, tx, GetTime(), plTxnReplaced, bypass_limits, test_accept, fee_out);
10931088
}
10941089

10951090
CTransactionRef GetTransaction(const CBlockIndex* const block_index, const CTxMemPool* const mempool, const uint256& hash, const Consensus::Params& consensusParams, uint256& hashBlock)
@@ -5078,7 +5073,7 @@ bool LoadMempool(CTxMemPool& pool)
50785073
if (nTime + nExpiryTimeout > nNow) {
50795074
LOCK(cs_main);
50805075
AcceptToMemoryPoolWithTime(chainparams, pool, state, tx, nTime,
5081-
nullptr /* plTxnReplaced */, false /* bypass_limits */, 0 /* nAbsurdFee */,
5076+
nullptr /* plTxnReplaced */, false /* bypass_limits */,
50825077
false /* test_accept */);
50835078
if (state.IsValid()) {
50845079
++count;

src/validation.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ void PruneBlockFilesManual(int nManualPruneHeight);
201201
* @param[out] fee_out optional argument to return tx fee to the caller **/
202202
bool AcceptToMemoryPool(CTxMemPool& pool, TxValidationState &state, const CTransactionRef &tx,
203203
std::list<CTransactionRef>* plTxnReplaced,
204-
bool bypass_limits, const CAmount nAbsurdFee, bool test_accept=false, CAmount* fee_out=nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
204+
bool bypass_limits, bool test_accept=false, CAmount* fee_out=nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
205205

206206
/** Get the BIP9 state for a given deployment at the current tip. */
207207
ThresholdState VersionBitsTipState(const Consensus::Params& params, Consensus::DeploymentPos pos);

0 commit comments

Comments
 (0)