Repository navigation
p2p: clean up a 1p1c package child that is already in the mempool - #36578
instagibbs wants to merge 1 commit into
Conversation
|
Tested ACK b0dda32 on Windows. |
|
Not sure, the diff --git a/src/net_processing.cpp b/src/net_processing.cpp
index ae329489e6..f23303605f 100644
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -576,6 +576,8 @@ public:
/** Overridden from CValidationInterface. */
void ActiveTipChange(const CBlockIndex& new_tip, bool) override
EXCLUSIVE_LOCKS_REQUIRED(!m_tx_download_mutex);
+ void TransactionAddedToMempool(const NewMempoolTransactionInfo& tx, uint64_t mempool_sequence) override
+ EXCLUSIVE_LOCKS_REQUIRED(!m_tx_download_mutex);
void BlockConnected(const ChainstateRole& role, const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindexConnected) override
EXCLUSIVE_LOCKS_REQUIRED(!m_tx_download_mutex);
void BlockDisconnected(const std::shared_ptr<const CBlock> &block, const CBlockIndex* pindex) override
@@ -2190,6 +2192,12 @@ void PeerManagerImpl::ActiveTipChange(const CBlockIndex& new_tip, bool is_ibd)
}
}
+void PeerManagerImpl::TransactionAddedToMempool(const NewMempoolTransactionInfo& tx, uint64_t mempool_sequence)
+{
+ LOCK(m_tx_download_mutex);
+ m_txdownloadman.MempoolAcceptedTx(tx.info.m_tx);
+}
+
/**
* Evict orphan txn pool entries based on a newly connected
* block, remember the recently confirmed transactions, and delete tracked
diff --git a/test/functional/p2p_orphan_handling.py b/test/functional/p2p_orphan_handling.py
index b6e521dbe4..056bd72823 100755
--- a/test/functional/p2p_orphan_handling.py
+++ b/test/functional/p2p_orphan_handling.py
@@ -841,7 +841,7 @@ class OrphanHandlingTest(BitcoinTestFramework):
@cleanup
def test_orphan_in_mempool(self):
- self.log.info("Test that an orphan in the mempool is removed from the orphanage when found as the child of a 1p1c package")
+ self.log.info("Test that an orphan is removed from the orphanage when it enters the mempool other than through peer relay")
node = self.nodes[0]
parent = self.wallet.create_self_transfer(fee_rate=0)
child = self.wallet.create_self_transfer(utxo_to_spend=parent["new_utxo"])
@@ -854,12 +854,10 @@ class OrphanHandlingTest(BitcoinTestFramework):
peer.send_and_ping(msg_tx(child["tx"]))
assert tx_in_orphanage(node, child["tx"])
- # The child enters the mempool by RPC, which does not remove it from the orphanage.
+ # The child enters the mempool by RPC. Even though this is not through peer relay, it is
+ # still removed from the orphanage.
assert_equal(node.submitpackage([parent["hex"], child["hex"]])["package_msg"], "success")
- assert tx_in_orphanage(node, child["tx"])
-
- # The same parent version is paired with the orphan, which turns out to be in the mempool.
- peer.send_and_ping(msg_tx(parent_bad_wit))
+ node.syncwithvalidationinterfacequeue()
assert not tx_in_orphanage(node, child["tx"])
assert child["txid"] in node.getrawmempool()
|
This would not have been an open issue otherwise :)
I think if we're going to do that, we should simply have it call Another alternative to the synchronous piece in this PR would to have |
Seems better to me; is there something I am missing about why you take this approach in this PR? |
An orphan that enters the mempool other than through peer relay (e.g. by RPC) stays in the orphanage, so Find1P1CPackage can pick it as the child of a reconsiderable parent, and package evaluation then reports it as MEMPOOL_ENTRY, which hits Assume(false). Have Find1P1CPackage erase such children from the orphanage and skip them.
|
@ismaelsadeeq swtiched to the Find1P1CPackage strategy for now; can still be convinced the extra machinery to async sweep them and taking lock is worth it, but keeping strategy as is for now |
b0dda32 to
a93bdc8
Compare


An orphan that enters the mempool other than through peer relay (e.g. by
RPC) stays in the orphanage, so Find1P1CPackage can pick it as the child
of a reconsiderable parent, and package evaluation then reports it as
MEMPOOL_ENTRY, which hits Assume(false). Have Find1P1CPackage erase such
children from the orphanage and skip them.