7 #include <chainparams.h>
26 .signals =
node.validation_signals.get(),
58 return strprintf(
"txns size %u does not match tx results size %u", txns.size(), result.
m_tx_results.size());
60 for (
const auto& tx : txns) {
61 const auto& wtxid = tx->GetWitnessHash();
63 return strprintf(
"result not found for tx %s", wtxid.ToString());
68 if (expect_valid && atmp_result.m_state.IsInvalid()) {
69 return strprintf(
"tx %s unexpectedly failed: %s", wtxid.ToString(), atmp_result.m_state.ToString());
74 return strprintf(
"tx %s result replaced too many transactions",
79 if (!atmp_result.m_replaced_transactions.empty() &&
80 atmp_result.m_wtxids_fee_calculations.has_value() && atmp_result.m_wtxids_fee_calculations.value().size() > 2) {
81 return strprintf(
"tx %s was part of a too-large package RBF subpackage",
85 if (!atmp_result.m_replaced_transactions.empty() && mempool) {
88 if (atmp_result.m_wtxids_fee_calculations.has_value() && atmp_result.m_wtxids_fee_calculations.value().size() == 2) {
90 if (cluster.size() != 2)
return strprintf(
"tx %s has too many ancestors or descendants for a package rbf", wtxid.ToString());
96 if (atmp_result.m_base_fees.has_value() != (valid || mempool_entry)) {
97 return strprintf(
"tx %s result should %shave m_base_fees", wtxid.ToString(), valid || mempool_entry ?
"" :
"not ");
99 if (atmp_result.m_vsize.has_value() != (valid || mempool_entry)) {
100 return strprintf(
"tx %s result should %shave m_vsize", wtxid.ToString(), valid || mempool_entry ?
"" :
"not ");
105 if (atmp_result.m_other_wtxid.has_value() != diff_witness) {
106 return strprintf(
"tx %s result should %shave m_other_wtxid", wtxid.ToString(), diff_witness ?
"" :
"not ");
113 if (atmp_result.m_effective_feerate.has_value() != valid_or_reconsiderable) {
114 return strprintf(
"tx %s result should %shave m_effective_feerate",
115 wtxid.ToString(), valid ?
"" :
"not ");
117 if (atmp_result.m_wtxids_fee_calculations.has_value() != valid_or_reconsiderable) {
118 return strprintf(
"tx %s result should %shave m_effective_feerate",
119 wtxid.ToString(), valid ?
"" :
"not ");
126 return strprintf(
"tx %s should %sbe in mempool", wtxid.ToString(), txid_in_mempool ?
"" :
"not ");
131 return strprintf(
"wtxid %s should not be in mempool", wtxid.ToString());
134 for (
const auto& tx_ref : atmp_result.m_replaced_transactions) {
136 return strprintf(
"tx %s should not be in mempool as it was replaced", tx_ref->GetWitnessHash().ToString());
147 for (
const auto& tx_info : tx_pool.
infoAll()) {
148 const auto& entry = *
Assert(tx_pool.
GetEntry(tx_info.tx->GetHash()));
160 if (entry.GetCountWithAncestors() > 1) {
163 const auto& parents = entry.GetMemPoolParentsConst();
166 }
else if (entry.GetCountWithAncestors() > 1) {
168 for (
const auto& parent : entry.GetMemPoolParentsConst()) {
const CChainParams & Params()
Return the currently selected parameters.
#define Assert(val)
Identity function.
CTxMemPoolEntry stores data about the corresponding transaction, as well as data about all in-mempool...
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
RecursiveMutex cs
This mutex needs to be locked when accessing mapTx or other members that are guarded by it.
std::vector< TxMempoolInfo > infoAll() const
std::vector< txiter > GatherClusters(const std::vector< uint256 > &txids) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Collect the entire cluster of connected transactions for each transaction in txids.
bool exists(const GenTxid >xid) const
const CTxMemPoolEntry * GetEntry(const Txid &txid) const LIFETIMEBOUND EXCLUSIVE_LOCKS_REQUIRED(cs)
static GenTxid Wtxid(const uint256 &hash)
static GenTxid Txid(const uint256 &hash)
std::string ToString() const
@ TX_RECONSIDERABLE
fails some policy, but might be acceptable if submitted in a (different) package
util::Result< void > ApplyArgsManOptions(const ArgsManager &args, BlockManager::Options &opts)
std::vector< CTransactionRef > Package
A package is an ordered list of transactions.
@ PCKG_POLICY
The package itself is invalid (e.g. too many transactions).
static constexpr uint32_t MAX_REPLACEMENT_CANDIDATES
Maximum number of transactions that can be replaced by RBF (Rule #5).
static CTransactionRef MakeTransactionRef(Tx &&txIn)
std::shared_ptr< const CTransaction > CTransactionRef
A mutable version of CTransaction.
@ DIFFERENT_WITNESS
Valid, transaction was already in the mempool.
@ INVALID
Fully validated, valid.
Validation result for package mempool acceptance.
PackageValidationState m_state
std::map< uint256, MempoolAcceptResult > m_tx_results
Map from wtxid to finished MempoolAcceptResults.
CTxMemPoolEntry FromTx(const CMutableTransaction &tx) const
Options struct containing options for constructing a CTxMemPool.
NodeContext struct containing references to chain state and connection state.
void CheckMempoolTRUCInvariants(const CTxMemPool &tx_pool)
For every transaction in tx_pool, check TRUC invariants:
CTxMemPool::Options MemPoolOptionsForTest(const NodeContext &node)
std::optional< std::string > CheckPackageMempoolAcceptResult(const Package &txns, const PackageMempoolAcceptResult &result, bool expect_valid, const CTxMemPool *mempool)
Check expected properties for every PackageMempoolAcceptResult, regardless of value.
static constexpr unsigned int TRUC_DESCENDANT_LIMIT
Maximum number of transactions including an unconfirmed tx and its descendants.
static constexpr int64_t TRUC_CHILD_MAX_VSIZE
Maximum sigop-adjusted virtual size of a tx which spends from an unconfirmed TRUC transaction.
static constexpr decltype(CTransaction::version) TRUC_VERSION
static constexpr int64_t TRUC_MAX_VSIZE
Maximum sigop-adjusted virtual size of all v3 transactions.
static constexpr unsigned int TRUC_ANCESTOR_LIMIT
Maximum number of transactions including a TRUC tx and all its mempool ancestors.