7 #include <chainparams.h> 56 return strprintf(
"txns size %u does not match tx results size %u", txns.size(), result.
m_tx_results.size());
58 for (
const auto& tx : txns) {
59 const auto& wtxid = tx->GetWitnessHash();
61 return strprintf(
"result not found for tx %s", wtxid.ToString());
66 if (expect_valid && atmp_result.m_state.IsInvalid()) {
67 return strprintf(
"tx %s unexpectedly failed: %s", wtxid.ToString(), atmp_result.m_state.ToString());
71 if (atmp_result.m_replaced_transactions.has_value() != valid) {
72 return strprintf(
"tx %s result should %shave m_replaced_transactions",
73 wtxid.ToString(), valid ?
"" :
"not ");
78 if (atmp_result.m_base_fees.has_value() != (valid || mempool_entry)) {
79 return strprintf(
"tx %s result should %shave m_base_fees", wtxid.ToString(), valid || mempool_entry ?
"" :
"not ");
81 if (atmp_result.m_vsize.has_value() != (valid || mempool_entry)) {
82 return strprintf(
"tx %s result should %shave m_vsize", wtxid.ToString(), valid || mempool_entry ?
"" :
"not ");
87 if (atmp_result.m_other_wtxid.has_value() != diff_witness) {
88 return strprintf(
"tx %s result should %shave m_other_wtxid", wtxid.ToString(), diff_witness ?
"" :
"not ");
95 if (atmp_result.m_effective_feerate.has_value() != valid_or_reconsiderable) {
96 return strprintf(
"tx %s result should %shave m_effective_feerate",
97 wtxid.ToString(), valid ?
"" :
"not ");
99 if (atmp_result.m_wtxids_fee_calculations.has_value() != valid_or_reconsiderable) {
100 return strprintf(
"tx %s result should %shave m_effective_feerate",
101 wtxid.ToString(), valid ?
"" :
"not ");
108 return strprintf(
"tx %s should %sbe in mempool", wtxid.ToString(), txid_in_mempool ?
"" :
"not ");
113 return strprintf(
"wtxid %s should not be in mempool", wtxid.ToString());
124 for (
const auto& tx_info : tx_pool.
infoAll()) {
125 const auto& entry = *
Assert(tx_pool.
GetEntry(tx_info.tx->GetHash()));
126 if (tx_info.tx->nVersion == 3) {
131 if (entry.GetCountWithAncestors() > 1) {
134 const auto& parents = entry.GetMemPoolParentsConst();
135 Assert(parents.begin()->get().GetSharedTx()->nVersion == 3);
137 }
else if (entry.GetCountWithAncestors() > 1) {
139 for (
const auto& parent : entry.GetMemPoolParentsConst()) {
140 Assert(parent.get().GetSharedTx()->nVersion != 3);
std::shared_ptr< const CTransaction > CTransactionRef
static GenTxid Wtxid(const uint256 &hash)
std::vector< TxMempoolInfo > infoAll() const
The package itself is invalid (e.g. too many transactions).
Valid, transaction was already in the mempool.
bool exists(const GenTxid >xid) const
std::vector< CTransactionRef > Package
A package is an ordered list of transactions.
std::map< uint256, MempoolAcceptResult > m_tx_results
Map from wtxid to finished MempoolAcceptResults.
CTxMemPoolEntry FromTx(const CMutableTransaction &tx) const
util::Result< void > ApplyArgsManOptions(const ArgsManager &args, BlockManager::Options &opts)
CTxMemPoolEntry stores data about the corresponding transaction, as well as data about all in-mempool...
NodeContext struct containing references to chain state and connection state.
Validation result for package mempool acceptance.
std::string ToString() const
void CheckMempoolV3Invariants(const CTxMemPool &tx_pool)
For every transaction in tx_pool, check v3 invariants:
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.
fails some policy, but might be acceptable if submitted in a (different) package
static CTransactionRef MakeTransactionRef(Tx &&txIn)
static constexpr int64_t V3_CHILD_MAX_VSIZE
Maximum sigop-adjusted virtual size of a tx which spends from an unconfirmed v3 transaction.
PackageValidationState m_state
const CTxMemPoolEntry * GetEntry(const Txid &txid) const LIFETIMEBOUND EXCLUSIVE_LOCKS_REQUIRED(cs)
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
const CChainParams & Params()
Return the currently selected parameters.
static constexpr unsigned int V3_DESCENDANT_LIMIT
Maximum number of transactions including an unconfirmed tx and its descendants.
A mutable version of CTransaction.
static constexpr unsigned int V3_ANCESTOR_LIMIT
Maximum number of transactions including a V3 tx and all its mempool ancestors.
Options struct containing options for constructing a CTxMemPool.
static GenTxid Txid(const uint256 &hash)
RecursiveMutex cs
This mutex needs to be locked when accessing mapTx or other members that are guarded by it...
#define Assert(val)
Identity function.
CTxMemPool::Options MemPoolOptionsForTest(const NodeContext &node)