7 #include <chainparams.h>
25 .signals =
node.validation_signals.get(),
57 return strprintf(
"txns size %u does not match tx results size %u", txns.size(), result.
m_tx_results.size());
59 for (
const auto& tx : txns) {
60 const auto& wtxid = tx->GetWitnessHash();
62 return strprintf(
"result not found for tx %s", wtxid.ToString());
67 if (expect_valid && atmp_result.m_state.IsInvalid()) {
68 return strprintf(
"tx %s unexpectedly failed: %s", wtxid.ToString(), atmp_result.m_state.ToString());
72 if (atmp_result.m_replaced_transactions.has_value() != valid) {
73 return strprintf(
"tx %s result should %shave m_replaced_transactions",
74 wtxid.ToString(), valid ?
"" :
"not ");
79 if (atmp_result.m_base_fees.has_value() != (valid || mempool_entry)) {
80 return strprintf(
"tx %s result should %shave m_base_fees", wtxid.ToString(), valid || mempool_entry ?
"" :
"not ");
82 if (atmp_result.m_vsize.has_value() != (valid || mempool_entry)) {
83 return strprintf(
"tx %s result should %shave m_vsize", wtxid.ToString(), valid || mempool_entry ?
"" :
"not ");
88 if (atmp_result.m_other_wtxid.has_value() != diff_witness) {
89 return strprintf(
"tx %s result should %shave m_other_wtxid", wtxid.ToString(), diff_witness ?
"" :
"not ");
96 if (atmp_result.m_effective_feerate.has_value() != valid_or_reconsiderable) {
97 return strprintf(
"tx %s result should %shave m_effective_feerate",
98 wtxid.ToString(), valid ?
"" :
"not ");
100 if (atmp_result.m_wtxids_fee_calculations.has_value() != valid_or_reconsiderable) {
101 return strprintf(
"tx %s result should %shave m_effective_feerate",
102 wtxid.ToString(), valid ?
"" :
"not ");
109 return strprintf(
"tx %s should %sbe in mempool", wtxid.ToString(), txid_in_mempool ?
"" :
"not ");
114 return strprintf(
"wtxid %s should not be in mempool", wtxid.ToString());
125 for (
const auto& tx_info : tx_pool.
infoAll()) {
126 const auto& entry = *
Assert(tx_pool.
GetEntry(tx_info.tx->GetHash()));
127 if (tx_info.tx->nVersion == 3) {
132 if (entry.GetCountWithAncestors() > 1) {
135 const auto& parents = entry.GetMemPoolParentsConst();
136 Assert(parents.begin()->get().GetSharedTx()->nVersion == 3);
138 }
else if (entry.GetCountWithAncestors() > 1) {
140 for (
const auto& parent : entry.GetMemPoolParentsConst()) {
141 Assert(parent.get().GetSharedTx()->nVersion != 3);
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
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 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.
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.
void CheckMempoolV3Invariants(const CTxMemPool &tx_pool)
For every transaction in tx_pool, check v3 invariants:
static constexpr unsigned int V3_DESCENDANT_LIMIT
Maximum number of transactions including an unconfirmed tx and its descendants.
static constexpr int64_t V3_CHILD_MAX_VSIZE
Maximum sigop-adjusted virtual size of a tx which spends from an unconfirmed v3 transaction.
static constexpr unsigned int V3_ANCESTOR_LIMIT
Maximum number of transactions including a V3 tx and all its mempool ancestors.