diff --git a/src/test/miner_tests.cpp b/src/test/miner_tests.cpp --- a/src/test/miner_tests.cpp +++ b/src/test/miner_tests.cpp @@ -37,10 +37,10 @@ EXCLUSIVE_LOCKS_REQUIRED(::cs_main, m_node.mempool->cs); bool TestSequenceLocks(const CTransaction &tx, int flags) EXCLUSIVE_LOCKS_REQUIRED(::cs_main, m_node.mempool->cs) { - CCoinsViewMemPool viewMempool( + CCoinsViewMemPool view_mempool( &m_node.chainman->ActiveChainstate().CoinsTip(), *m_node.mempool); return CheckSequenceLocks(m_node.chainman->ActiveChain().Tip(), - viewMempool, tx, flags); + view_mempool, tx, flags); } BlockAssembler AssemblerForTest(const CChainParams ¶ms); }; diff --git a/src/txmempool.h b/src/txmempool.h --- a/src/txmempool.h +++ b/src/txmempool.h @@ -942,7 +942,11 @@ public: CCoinsViewMemPool(CCoinsView *baseIn, const CTxMemPool &mempoolIn); bool GetCoin(const COutPoint &outpoint, Coin &coin) const override; - /** Add the coins created by this transaction. */ + /** + * Add the coins created by this transaction. These coins are only + * temporarily stored in m_temp_added and cannot be flushed to the back end. + * Only used for package validation. + */ void PackageAddTransaction(const CTransactionRef &tx); }; diff --git a/src/txmempool.cpp b/src/txmempool.cpp --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -584,13 +584,13 @@ const CTransaction &tx = it->GetTx(); LockPoints lp = it->GetLockPoints(); bool validLP = TestLockPointValidity(active_chainstate.m_chain, &lp); - CCoinsViewMemPool viewMempool(&active_chainstate.CoinsTip(), *this); + CCoinsViewMemPool view_mempool(&active_chainstate.CoinsTip(), *this); TxValidationState state; if (!ContextualCheckTransactionForCurrentBlock( active_chainstate.m_chain.Tip(), config.GetChainParams().GetConsensus(), tx, state, flags) || - !CheckSequenceLocks(active_chainstate.m_chain.Tip(), viewMempool, + !CheckSequenceLocks(active_chainstate.m_chain.Tip(), view_mempool, tx, flags, &lp, validLP)) { // Note if CheckSequenceLocks fails the LockPoints may still be // invalid. So it's critical that we remove the tx and not depend on diff --git a/src/validation.h b/src/validation.h --- a/src/validation.h +++ b/src/validation.h @@ -480,8 +480,12 @@ * @param[in] tip Chain tip to check tx sequence locks against. * For example, the tip of the current active chain. * @param[in] coins_view Any CCoinsView that provides access to the - * relevant coins for checking sequence locks. Any CCoinsView can be passed - * in; it is assumed to be consistent with the tip. + * relevant coins for checking sequence locks. For example, it can be a + * CCoinsViewCache that isn't connected to anything but contains all the + * relevant coins, or a CCoinsViewMemPool that is connected to the mempool + * and chainstate UTXO set. In the latter case, the caller is responsible + * for holding the appropriate locks to ensure that calls to GetCoin() + * return correct coins. * Simulates calling SequenceLocks() with data from the tip passed in. * Optionally stores in LockPoints the resulting height and time * calculated and the hash of the block needed for calculation or skips the