mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-27 03:33:27 -03:00
[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.
This commit is contained in:
parent
932564b9cf
commit
b048b275d9
9 changed files with 16 additions and 23 deletions
|
@ -49,7 +49,7 @@ static void AssembleBlock(benchmark::Bench& bench)
|
||||||
|
|
||||||
for (const auto& txr : txs) {
|
for (const auto& txr : txs) {
|
||||||
TxValidationState state;
|
TxValidationState state;
|
||||||
bool ret{::AcceptToMemoryPool(*test_setup.m_node.mempool, state, txr, nullptr /* plTxnReplaced */, false /* bypass_limits */, /* nAbsurdFee */ 0)};
|
bool ret{::AcceptToMemoryPool(*test_setup.m_node.mempool, state, txr, nullptr /* plTxnReplaced */, false /* bypass_limits */)};
|
||||||
assert(ret);
|
assert(ret);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2058,7 +2058,7 @@ void PeerManager::ProcessOrphanTx(std::set<uint256>& orphan_work_set)
|
||||||
TxValidationState state;
|
TxValidationState state;
|
||||||
std::list<CTransactionRef> removed_txn;
|
std::list<CTransactionRef> removed_txn;
|
||||||
|
|
||||||
if (AcceptToMemoryPool(m_mempool, state, porphanTx, &removed_txn, false /* bypass_limits */, 0 /* nAbsurdFee */)) {
|
if (AcceptToMemoryPool(m_mempool, state, porphanTx, &removed_txn, false /* bypass_limits */)) {
|
||||||
LogPrint(BCLog::MEMPOOL, " accepted orphan tx %s\n", orphanHash.ToString());
|
LogPrint(BCLog::MEMPOOL, " accepted orphan tx %s\n", orphanHash.ToString());
|
||||||
RelayTransaction(orphanHash, porphanTx->GetWitnessHash(), m_connman);
|
RelayTransaction(orphanHash, porphanTx->GetWitnessHash(), m_connman);
|
||||||
for (unsigned int i = 0; i < porphanTx->vout.size(); i++) {
|
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
|
||||||
// (older than our recency filter) if trying to DoS us, without any need
|
// (older than our recency filter) if trying to DoS us, without any need
|
||||||
// for witness malleation.
|
// for witness malleation.
|
||||||
if (!AlreadyHaveTx(GenTxid(/* is_wtxid=*/true, wtxid), m_mempool) &&
|
if (!AlreadyHaveTx(GenTxid(/* is_wtxid=*/true, wtxid), m_mempool) &&
|
||||||
AcceptToMemoryPool(m_mempool, state, ptx, &lRemovedTxn, false /* bypass_limits */, 0 /* nAbsurdFee */)) {
|
AcceptToMemoryPool(m_mempool, state, ptx, &lRemovedTxn, false /* bypass_limits */)) {
|
||||||
m_mempool.check(&::ChainstateActive().CoinsTip());
|
m_mempool.check(&::ChainstateActive().CoinsTip());
|
||||||
RelayTransaction(tx.GetHash(), tx.GetWitnessHash(), m_connman);
|
RelayTransaction(tx.GetHash(), tx.GetWitnessHash(), m_connman);
|
||||||
for (unsigned int i = 0; i < tx.vout.size(); i++) {
|
for (unsigned int i = 0; i < tx.vout.size(); i++) {
|
||||||
|
|
|
@ -55,7 +55,7 @@ TransactionError BroadcastTransaction(NodeContext& node, const CTransactionRef t
|
||||||
// First, call ATMP with test_accept and check the fee. If ATMP
|
// First, call ATMP with test_accept and check the fee. If ATMP
|
||||||
// fails here, return error immediately.
|
// fails here, return error immediately.
|
||||||
if (!AcceptToMemoryPool(*node.mempool, state, tx,
|
if (!AcceptToMemoryPool(*node.mempool, state, tx,
|
||||||
nullptr /* plTxnReplaced */, false /* bypass_limits */, /* absurdfee*/ 0, /* test_accept */ true, &fee)) {
|
nullptr /* plTxnReplaced */, false /* bypass_limits */, /* test_accept */ true, &fee)) {
|
||||||
return HandleATMPError(state, err_string);
|
return HandleATMPError(state, err_string);
|
||||||
} else if (fee > max_tx_fee) {
|
} else if (fee > max_tx_fee) {
|
||||||
return TransactionError::MAX_FEE_EXCEEDED;
|
return TransactionError::MAX_FEE_EXCEEDED;
|
||||||
|
@ -63,7 +63,7 @@ TransactionError BroadcastTransaction(NodeContext& node, const CTransactionRef t
|
||||||
}
|
}
|
||||||
// Try to submit the transaction to the mempool.
|
// Try to submit the transaction to the mempool.
|
||||||
if (!AcceptToMemoryPool(*node.mempool, state, tx,
|
if (!AcceptToMemoryPool(*node.mempool, state, tx,
|
||||||
nullptr /* plTxnReplaced */, false /* bypass_limits */, max_tx_fee)) {
|
nullptr /* plTxnReplaced */, false /* bypass_limits */)) {
|
||||||
return HandleATMPError(state, err_string);
|
return HandleATMPError(state, err_string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -951,7 +951,7 @@ static RPCHelpMan testmempoolaccept()
|
||||||
{
|
{
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
test_accept_res = AcceptToMemoryPool(mempool, state, std::move(tx),
|
test_accept_res = AcceptToMemoryPool(mempool, state, std::move(tx),
|
||||||
nullptr /* plTxnReplaced */, false /* bypass_limits */, max_raw_tx_fee, /* test_accept */ true, &fee);
|
nullptr /* plTxnReplaced */, false /* bypass_limits */, /* test_accept */ true, &fee);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check that fee does not exceed maximum fee
|
// Check that fee does not exceed maximum fee
|
||||||
|
|
|
@ -40,8 +40,7 @@ BOOST_FIXTURE_TEST_CASE(tx_mempool_reject_coinbase, TestChain100Setup)
|
||||||
false,
|
false,
|
||||||
AcceptToMemoryPool(*m_node.mempool, state, MakeTransactionRef(coinbaseTx),
|
AcceptToMemoryPool(*m_node.mempool, state, MakeTransactionRef(coinbaseTx),
|
||||||
nullptr /* plTxnReplaced */,
|
nullptr /* plTxnReplaced */,
|
||||||
true /* bypass_limits */,
|
true /* bypass_limits */));
|
||||||
0 /* nAbsurdFee */));
|
|
||||||
|
|
||||||
// Check that the transaction hasn't been added to mempool.
|
// Check that the transaction hasn't been added to mempool.
|
||||||
BOOST_CHECK_EQUAL(m_node.mempool->size(), initialPoolSize);
|
BOOST_CHECK_EQUAL(m_node.mempool->size(), initialPoolSize);
|
||||||
|
|
|
@ -30,7 +30,7 @@ BOOST_FIXTURE_TEST_CASE(tx_mempool_block_doublespend, TestChain100Setup)
|
||||||
|
|
||||||
TxValidationState state;
|
TxValidationState state;
|
||||||
return AcceptToMemoryPool(*m_node.mempool, state, MakeTransactionRef(tx),
|
return AcceptToMemoryPool(*m_node.mempool, state, MakeTransactionRef(tx),
|
||||||
nullptr /* plTxnReplaced */, true /* bypass_limits */, 0 /* nAbsurdFee */);
|
nullptr /* plTxnReplaced */, true /* bypass_limits */);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Create a double-spend of mature coinbase txn:
|
// Create a double-spend of mature coinbase txn:
|
||||||
|
|
|
@ -291,8 +291,7 @@ BOOST_AUTO_TEST_CASE(mempool_locks_reorg)
|
||||||
state,
|
state,
|
||||||
tx,
|
tx,
|
||||||
&plTxnReplaced,
|
&plTxnReplaced,
|
||||||
/* bypass_limits */ false,
|
/* bypass_limits */ false));
|
||||||
/* nAbsurdFee */ 0));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -384,7 +384,7 @@ static void UpdateMempoolForReorg(CTxMemPool& mempool, DisconnectedBlockTransact
|
||||||
TxValidationState stateDummy;
|
TxValidationState stateDummy;
|
||||||
if (!fAddToMempool || (*it)->IsCoinBase() ||
|
if (!fAddToMempool || (*it)->IsCoinBase() ||
|
||||||
!AcceptToMemoryPool(mempool, stateDummy, *it,
|
!AcceptToMemoryPool(mempool, stateDummy, *it,
|
||||||
nullptr /* plTxnReplaced */, true /* bypass_limits */, 0 /* nAbsurdFee */)) {
|
nullptr /* plTxnReplaced */, true /* bypass_limits */)) {
|
||||||
// If the transaction doesn't make it in to the mempool, remove any
|
// If the transaction doesn't make it in to the mempool, remove any
|
||||||
// transactions that depend on it (which would now be orphans).
|
// transactions that depend on it (which would now be orphans).
|
||||||
mempool.removeRecursive(**it, MemPoolRemovalReason::REORG);
|
mempool.removeRecursive(**it, MemPoolRemovalReason::REORG);
|
||||||
|
@ -463,7 +463,6 @@ public:
|
||||||
const int64_t m_accept_time;
|
const int64_t m_accept_time;
|
||||||
std::list<CTransactionRef>* m_replaced_transactions;
|
std::list<CTransactionRef>* m_replaced_transactions;
|
||||||
const bool m_bypass_limits;
|
const bool m_bypass_limits;
|
||||||
const CAmount& m_absurd_fee;
|
|
||||||
/*
|
/*
|
||||||
* Return any outpoints which were not previously present in the coins
|
* Return any outpoints which were not previously present in the coins
|
||||||
* cache, but were added as a result of validating the tx for mempool
|
* cache, but were added as a result of validating the tx for mempool
|
||||||
|
@ -558,7 +557,6 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
|
||||||
TxValidationState &state = args.m_state;
|
TxValidationState &state = args.m_state;
|
||||||
const int64_t nAcceptTime = args.m_accept_time;
|
const int64_t nAcceptTime = args.m_accept_time;
|
||||||
const bool bypass_limits = args.m_bypass_limits;
|
const bool bypass_limits = args.m_bypass_limits;
|
||||||
const CAmount& nAbsurdFee = args.m_absurd_fee;
|
|
||||||
std::vector<COutPoint>& coins_to_uncache = args.m_coins_to_uncache;
|
std::vector<COutPoint>& coins_to_uncache = args.m_coins_to_uncache;
|
||||||
|
|
||||||
// Alias what we need out of ws
|
// Alias what we need out of ws
|
||||||
|
@ -729,9 +727,6 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
|
||||||
// blocks
|
// blocks
|
||||||
if (!bypass_limits && !CheckFeeRate(nSize, nModifiedFees, state)) return false;
|
if (!bypass_limits && !CheckFeeRate(nSize, nModifiedFees, state)) return false;
|
||||||
|
|
||||||
if (nAbsurdFee && nFees > nAbsurdFee)
|
|
||||||
LogPrintf("Ignoring Absurdfee\n");
|
|
||||||
|
|
||||||
const CTxMemPool::setEntries setIterConflicting = m_pool.GetIterSet(setConflicts);
|
const CTxMemPool::setEntries setIterConflicting = m_pool.GetIterSet(setConflicts);
|
||||||
// Calculate in-mempool ancestors, up to a limit.
|
// Calculate in-mempool ancestors, up to a limit.
|
||||||
if (setConflicts.size() == 1) {
|
if (setConflicts.size() == 1) {
|
||||||
|
@ -1064,10 +1059,10 @@ bool MemPoolAccept::AcceptSingleTransaction(const CTransactionRef& ptx, ATMPArgs
|
||||||
/** (try to) add transaction to memory pool with a specified acceptance time **/
|
/** (try to) add transaction to memory pool with a specified acceptance time **/
|
||||||
static bool AcceptToMemoryPoolWithTime(const CChainParams& chainparams, CTxMemPool& pool, TxValidationState &state, const CTransactionRef &tx,
|
static bool AcceptToMemoryPoolWithTime(const CChainParams& chainparams, CTxMemPool& pool, TxValidationState &state, const CTransactionRef &tx,
|
||||||
int64_t nAcceptTime, std::list<CTransactionRef>* plTxnReplaced,
|
int64_t nAcceptTime, std::list<CTransactionRef>* plTxnReplaced,
|
||||||
bool bypass_limits, const CAmount nAbsurdFee, bool test_accept, CAmount* fee_out=nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
|
bool bypass_limits, bool test_accept, CAmount* fee_out=nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
|
||||||
{
|
{
|
||||||
std::vector<COutPoint> coins_to_uncache;
|
std::vector<COutPoint> coins_to_uncache;
|
||||||
MemPoolAccept::ATMPArgs args { chainparams, state, nAcceptTime, plTxnReplaced, bypass_limits, nAbsurdFee, coins_to_uncache, test_accept, fee_out };
|
MemPoolAccept::ATMPArgs args { chainparams, state, nAcceptTime, plTxnReplaced, bypass_limits, coins_to_uncache, test_accept, fee_out };
|
||||||
bool res = MemPoolAccept(pool).AcceptSingleTransaction(tx, args);
|
bool res = MemPoolAccept(pool).AcceptSingleTransaction(tx, args);
|
||||||
if (!res) {
|
if (!res) {
|
||||||
// Remove coins that were not present in the coins cache before calling ATMPW;
|
// Remove coins that were not present in the coins cache before calling ATMPW;
|
||||||
|
@ -1086,10 +1081,10 @@ static bool AcceptToMemoryPoolWithTime(const CChainParams& chainparams, CTxMemPo
|
||||||
|
|
||||||
bool AcceptToMemoryPool(CTxMemPool& pool, TxValidationState &state, const CTransactionRef &tx,
|
bool AcceptToMemoryPool(CTxMemPool& pool, TxValidationState &state, const CTransactionRef &tx,
|
||||||
std::list<CTransactionRef>* plTxnReplaced,
|
std::list<CTransactionRef>* plTxnReplaced,
|
||||||
bool bypass_limits, const CAmount nAbsurdFee, bool test_accept, CAmount* fee_out)
|
bool bypass_limits, bool test_accept, CAmount* fee_out)
|
||||||
{
|
{
|
||||||
const CChainParams& chainparams = Params();
|
const CChainParams& chainparams = Params();
|
||||||
return AcceptToMemoryPoolWithTime(chainparams, pool, state, tx, GetTime(), plTxnReplaced, bypass_limits, nAbsurdFee, test_accept, fee_out);
|
return AcceptToMemoryPoolWithTime(chainparams, pool, state, tx, GetTime(), plTxnReplaced, bypass_limits, test_accept, fee_out);
|
||||||
}
|
}
|
||||||
|
|
||||||
CTransactionRef GetTransaction(const CBlockIndex* const block_index, const CTxMemPool* const mempool, const uint256& hash, const Consensus::Params& consensusParams, uint256& hashBlock)
|
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)
|
||||||
if (nTime + nExpiryTimeout > nNow) {
|
if (nTime + nExpiryTimeout > nNow) {
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
AcceptToMemoryPoolWithTime(chainparams, pool, state, tx, nTime,
|
AcceptToMemoryPoolWithTime(chainparams, pool, state, tx, nTime,
|
||||||
nullptr /* plTxnReplaced */, false /* bypass_limits */, 0 /* nAbsurdFee */,
|
nullptr /* plTxnReplaced */, false /* bypass_limits */,
|
||||||
false /* test_accept */);
|
false /* test_accept */);
|
||||||
if (state.IsValid()) {
|
if (state.IsValid()) {
|
||||||
++count;
|
++count;
|
||||||
|
|
|
@ -201,7 +201,7 @@ void PruneBlockFilesManual(int nManualPruneHeight);
|
||||||
* @param[out] fee_out optional argument to return tx fee to the caller **/
|
* @param[out] fee_out optional argument to return tx fee to the caller **/
|
||||||
bool AcceptToMemoryPool(CTxMemPool& pool, TxValidationState &state, const CTransactionRef &tx,
|
bool AcceptToMemoryPool(CTxMemPool& pool, TxValidationState &state, const CTransactionRef &tx,
|
||||||
std::list<CTransactionRef>* plTxnReplaced,
|
std::list<CTransactionRef>* plTxnReplaced,
|
||||||
bool bypass_limits, const CAmount nAbsurdFee, bool test_accept=false, CAmount* fee_out=nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
bool bypass_limits, bool test_accept=false, CAmount* fee_out=nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
||||||
|
|
||||||
/** Get the BIP9 state for a given deployment at the current tip. */
|
/** Get the BIP9 state for a given deployment at the current tip. */
|
||||||
ThresholdState VersionBitsTipState(const Consensus::Params& params, Consensus::DeploymentPos pos);
|
ThresholdState VersionBitsTipState(const Consensus::Params& params, Consensus::DeploymentPos pos);
|
||||||
|
|
Loading…
Add table
Reference in a new issue