@@ -407,21 +407,17 @@ static void UpdateMempoolForReorg(CTxMemPool& mempool, DisconnectedBlockTransact
407
407
// Used to avoid mempool polluting consensus critical paths if CCoinsViewMempool
408
408
// were somehow broken and returning the wrong scriptPubKeys
409
409
static bool CheckInputsFromMempoolAndCache (const CTransaction& tx, TxValidationState& state, const CCoinsViewCache& view, const CTxMemPool& pool,
410
- unsigned int flags, PrecomputedTransactionData& txdata) EXCLUSIVE_LOCKS_REQUIRED(cs_main) {
410
+ unsigned int flags, PrecomputedTransactionData& txdata) EXCLUSIVE_LOCKS_REQUIRED(cs_main, pool.cs ) {
411
411
AssertLockHeld (cs_main);
412
-
413
- // pool.cs should be locked already, but go ahead and re-take the lock here
414
- // to enforce that mempool doesn't change between when we check the view
415
- // and when we actually call through to CheckInputScripts
416
- LOCK (pool.cs );
412
+ AssertLockHeld (pool.cs );
417
413
418
414
assert (!tx.IsCoinBase ());
419
415
for (const CTxIn& txin : tx.vin ) {
420
416
const Coin& coin = view.AccessCoin (txin.prevout );
421
417
422
- // AcceptToMemoryPoolWorker has already checked that the coins are
423
- // available, so this shouldn't fail. If the inputs are not available
424
- // here then return false.
418
+ // This coin was checked in PreChecks and MemPoolAccept
419
+ // has been holding cs_main since then.
420
+ Assume (!coin. IsSpent ());
425
421
if (coin.IsSpent ()) return false ;
426
422
427
423
// Check equivalence for available inputs.
@@ -502,21 +498,21 @@ class MemPoolAccept
502
498
503
499
// Run the script checks using our policy flags. As this can be slow, we should
504
500
// only invoke this on transactions that have otherwise passed policy checks.
505
- bool PolicyScriptChecks (ATMPArgs& args, const Workspace& ws, PrecomputedTransactionData& txdata) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
501
+ bool PolicyScriptChecks (ATMPArgs& args, const Workspace& ws, PrecomputedTransactionData& txdata) EXCLUSIVE_LOCKS_REQUIRED(cs_main, m_pool.cs );
506
502
507
503
// Re-run the script checks, using consensus flags, and try to cache the
508
504
// result in the scriptcache. This should be done after
509
505
// PolicyScriptChecks(). This requires that all inputs either be in our
510
506
// utxo set or in the mempool.
511
- bool ConsensusScriptChecks (ATMPArgs& args, const Workspace& ws, PrecomputedTransactionData &txdata) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
507
+ bool ConsensusScriptChecks (ATMPArgs& args, const Workspace& ws, PrecomputedTransactionData &txdata) EXCLUSIVE_LOCKS_REQUIRED(cs_main, m_pool.cs );
512
508
513
509
// Try to add the transaction to the mempool, removing any conflicts first.
514
510
// Returns true if the transaction is in the mempool after any size
515
511
// limiting is performed, false otherwise.
516
512
bool Finalize (ATMPArgs& args, Workspace& ws) EXCLUSIVE_LOCKS_REQUIRED(cs_main, m_pool.cs);
517
513
518
514
// Compare a package's feerate against minimum allowed.
519
- bool CheckFeeRate (size_t package_size, CAmount package_fee, TxValidationState& state)
515
+ bool CheckFeeRate (size_t package_size, CAmount package_fee, TxValidationState& state) EXCLUSIVE_LOCKS_REQUIRED(cs_main, m_pool.cs)
520
516
{
521
517
CAmount mempoolRejectFee = m_pool.GetMinFee (gArgs .GetArg (" -maxmempool" , DEFAULT_MAX_MEMPOOL_SIZE) * 1000000 ).GetFee (package_size);
522
518
if (mempoolRejectFee > 0 && package_fee < mempoolRejectFee) {
0 commit comments