Skip to content

Commit 67bb714

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. (cherry picked from commit 9e9a928496995a45191970e881c1c07cab05c78d)
1 parent 2409462 commit 67bb714

9 files changed

+16
-23
lines changed

src/bench/block_assemble.cpp

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2022,7 +2022,7 @@ void static ProcessOrphanTx(CConnman& connman, CTxMemPool& mempool, std::set<uin
20222022
TxValidationState orphan_state;
20232023

20242024
if (setMisbehaving.count(fromPeer)) continue;
2025-
if (AcceptToMemoryPool(mempool, orphan_state, porphanTx, &removed_txn, false /* bypass_limits */, 0 /* nAbsurdFee */)) {
2025+
if (AcceptToMemoryPool(mempool, orphan_state, porphanTx, &removed_txn, false /* bypass_limits */)) {
20262026
LogPrint(BCLog::MEMPOOL, " accepted orphan tx %s\n", orphanHash.ToString());
20272027
RelayTransaction(orphanHash, porphanTx->GetWitnessHash(), connman);
20282028
for (unsigned int i = 0; i < orphanTx.vout.size(); i++) {
@@ -2978,7 +2978,7 @@ void ProcessMessage(
29782978
// (older than our recency filter) if trying to DoS us, without any need
29792979
// for witness malleation.
29802980
if (!AlreadyHave(CInv(MSG_WTX, wtxid), mempool) &&
2981-
AcceptToMemoryPool(mempool, state, ptx, &lRemovedTxn, false /* bypass_limits */, 0 /* nAbsurdFee */)) {
2981+
AcceptToMemoryPool(mempool, state, ptx, &lRemovedTxn, false /* bypass_limits */)) {
29822982
mempool.check(&::ChainstateActive().CoinsTip());
29832983
RelayTransaction(tx.GetHash(), tx.GetWitnessHash(), connman);
29842984
for (unsigned int i = 0; i < tx.vout.size(); i++) {

src/node/transaction.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ TransactionError BroadcastTransaction(NodeContext& node, const CTransactionRef t
4040
TxValidationState state;
4141
CAmount fee;
4242
bool test_accepted = AcceptToMemoryPool(*node.mempool, state, std::move(tx),
43-
nullptr /* plTxnReplaced */, false /* bypass_limits */, /* absurdfee*/ 0, /* test_accept */ true, &fee);
43+
nullptr /* plTxnReplaced */, false /* bypass_limits */, /* test_accept */ true, &fee);
4444
if (test_accepted) {
4545
if (max_tx_fee && fee > max_tx_fee) {
4646
return TransactionError::MAX_FEE_EXCEEDED;
4747
}
4848
}
4949
// Transaction fee is acceptable. Submit the transaction.
5050
if (!AcceptToMemoryPool(*node.mempool, state, std::move(tx),
51-
nullptr /* plTxnReplaced */, false /* bypass_limits */, max_tx_fee)) {
51+
nullptr /* plTxnReplaced */, false /* bypass_limits */)) {
5252
err_string = state.ToString();
5353
if (state.IsInvalid()) {
5454
if (state.GetResult() == TxValidationResult::TX_MISSING_INPUTS) {

src/rpc/rawtransaction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -929,7 +929,7 @@ static UniValue testmempoolaccept(const JSONRPCRequest& request)
929929
{
930930
LOCK(cs_main);
931931
test_accept_res = AcceptToMemoryPool(mempool, state, std::move(tx),
932-
nullptr /* plTxnReplaced */, false /* bypass_limits */, max_raw_tx_fee, /* test_accept */ true, &fee);
932+
nullptr /* plTxnReplaced */, false /* bypass_limits */, /* test_accept */ true, &fee);
933933
}
934934

935935
// Check that fee does not exceed maxfee

src/test/txvalidation_tests.cpp

Lines changed: 1 addition & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 2 deletions
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

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ static void UpdateMempoolForReorg(DisconnectedBlockTransactions& disconnectpool,
386386
TxValidationState stateDummy;
387387
if (!fAddToMempool || (*it)->IsCoinBase() ||
388388
!AcceptToMemoryPool(mempool, stateDummy, *it,
389-
nullptr /* plTxnReplaced */, true /* bypass_limits */, 0 /* nAbsurdFee */)) {
389+
nullptr /* plTxnReplaced */, true /* bypass_limits */)) {
390390
// If the transaction doesn't make it in to the mempool, remove any
391391
// transactions that depend on it (which would now be orphans).
392392
mempool.removeRecursive(**it, MemPoolRemovalReason::REORG);
@@ -465,7 +465,6 @@ class MemPoolAccept
465465
const int64_t m_accept_time;
466466
std::list<CTransactionRef>* m_replaced_transactions;
467467
const bool m_bypass_limits;
468-
const CAmount& m_absurd_fee;
469468
/*
470469
* Return any outpoints which were not previously present in the coins
471470
* cache, but were added as a result of validating the tx for mempool
@@ -560,7 +559,6 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
560559
TxValidationState &state = args.m_state;
561560
const int64_t nAcceptTime = args.m_accept_time;
562561
const bool bypass_limits = args.m_bypass_limits;
563-
const CAmount& nAbsurdFee = args.m_absurd_fee;
564562
std::vector<COutPoint>& coins_to_uncache = args.m_coins_to_uncache;
565563

566564
// Alias what we need out of ws
@@ -732,9 +730,6 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
732730
// blocks
733731
if (!bypass_limits && !CheckFeeRate(nSize, nModifiedFees, state)) return false;
734732

735-
if (nAbsurdFee && nFees > nAbsurdFee)
736-
LogPrintf("Ignoring Absurdfee\n");
737-
738733
const CTxMemPool::setEntries setIterConflicting = m_pool.GetIterSet(setConflicts);
739734
// Calculate in-mempool ancestors, up to a limit.
740735
if (setConflicts.size() == 1) {
@@ -1067,10 +1062,10 @@ bool MemPoolAccept::AcceptSingleTransaction(const CTransactionRef& ptx, ATMPArgs
10671062
/** (try to) add transaction to memory pool with a specified acceptance time **/
10681063
static bool AcceptToMemoryPoolWithTime(const CChainParams& chainparams, CTxMemPool& pool, TxValidationState &state, const CTransactionRef &tx,
10691064
int64_t nAcceptTime, std::list<CTransactionRef>* plTxnReplaced,
1070-
bool bypass_limits, const CAmount nAbsurdFee, bool test_accept, CAmount* fee_out=nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
1065+
bool bypass_limits, bool test_accept, CAmount* fee_out=nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
10711066
{
10721067
std::vector<COutPoint> coins_to_uncache;
1073-
MemPoolAccept::ATMPArgs args { chainparams, state, nAcceptTime, plTxnReplaced, bypass_limits, nAbsurdFee, coins_to_uncache, test_accept, fee_out };
1068+
MemPoolAccept::ATMPArgs args { chainparams, state, nAcceptTime, plTxnReplaced, bypass_limits, coins_to_uncache, test_accept, fee_out };
10741069
bool res = MemPoolAccept(pool).AcceptSingleTransaction(tx, args);
10751070
if (!res) {
10761071
// Remove coins that were not present in the coins cache before calling ATMPW;
@@ -1089,10 +1084,10 @@ static bool AcceptToMemoryPoolWithTime(const CChainParams& chainparams, CTxMemPo
10891084

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

10981093
CTransactionRef GetTransaction(const CBlockIndex* const block_index, const CTxMemPool* const mempool, const uint256& hash, const Consensus::Params& consensusParams, uint256& hashBlock)
@@ -5083,7 +5078,7 @@ bool LoadMempool(CTxMemPool& pool)
50835078
if (nTime + nExpiryTimeout > nNow) {
50845079
LOCK(cs_main);
50855080
AcceptToMemoryPoolWithTime(chainparams, pool, state, tx, nTime,
5086-
nullptr /* plTxnReplaced */, false /* bypass_limits */, 0 /* nAbsurdFee */,
5081+
nullptr /* plTxnReplaced */, false /* bypass_limits */,
50875082
false /* test_accept */);
50885083
if (state.IsValid()) {
50895084
++count;

src/validation.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ void PruneBlockFilesManual(int nManualPruneHeight);
204204
* optionally takes an argument to return tx fee to the caller **/
205205
bool AcceptToMemoryPool(CTxMemPool& pool, TxValidationState &state, const CTransactionRef &tx,
206206
std::list<CTransactionRef>* plTxnReplaced,
207-
bool bypass_limits, const CAmount nAbsurdFee, bool test_accept=false, CAmount* fee_out=nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
207+
bool bypass_limits, bool test_accept=false, CAmount* fee_out=nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
208208

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

0 commit comments

Comments
 (0)