fix: remove redundant mempool lock in ChainImpl::isInMempool()
What changed, and why it matters
This commit removes a protective lock around a simple mempool check. The change is presented as a cleanup of a redundant lock, but removing synchronization around concurrent data structures can in theory introduce race conditions. There is no direct evidence in the commit or supplied materials that this causes a real exploitable bug.
Review whether `CTxMemPool::exists()` is safe to call without holding `mempool->cs`, and verify all callers of `isInMempool()` either already hold the lock or do not require atomicity. Consider adding an assertion or documentation if the lock is indeed unnecessary.
Security signals we found
Removal of a mutex lock around mempool membership check
Change touches consensus-adjacent mempool code
Commit message frames change as a redundancy fix rather than security issue
Evidence from the diff
The patch removes LOCK(m_node.mempool->cs) from ChainImpl::isInMempool() in src/node/interfaces.cpp, leaving only a call to m_node.mempool->exists(txid). The commit message claims the lock is redundant. Without the lock, the exists() call may race with mempool mutations. Whether exists() is internally thread-safe or whether callers already hold the lock is not stated in the provided materials. The change is a single-line removal in a defensive-security-relevant area (mempool concurrency).
Changed components
src/node/interfaces.cppChainImpl::isInMempool()mempool concurrency / lockingInspect captured patch +0 / −1
diff --git a/src/node/interfaces.cpp b/src/node/interfaces.cpp
index a2063634..ac817e01 100644
--- a/src/node/interfaces.cpp
+++ b/src/node/interfaces.cpp
@@ -658,7 +658,6 @@ public:
bool isInMempool(const Txid& txid) override
{
if (!m_node.mempool) return false;
- LOCK(m_node.mempool->cs);
return m_node.mempool->exists(txid);
}
bool hasDescendantsInMempool(const Txid& txid) override
Why this scored 11/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.