Skip to content

Commit

Permalink
Added delay to reproduce issue 29806.
Browse files Browse the repository at this point in the history
A small delay introduced in the lambdas of TransactionAddedToMempool and TransactionRemovedFromMempool is used to mimic the delayed execution of the tasks they schedule. In an actual run, the delay would be with the thread and not the lambda, but it was easier to demonstrate the effects of a delay doing it this way.
  • Loading branch information
Randy808 committed Apr 29, 2024
1 parent 19865a8 commit f39144d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/validationinterface.cpp
Expand Up @@ -186,7 +186,12 @@ void ValidationSignals::UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlo
void ValidationSignals::TransactionAddedToMempool(const NewMempoolTransactionInfo& tx, uint64_t mempool_sequence)
{
auto event = [tx, mempool_sequence, this] {
m_internals->Iterate([&](CValidationInterface& callbacks) { callbacks.TransactionAddedToMempool(tx, mempool_sequence); });
m_internals->Iterate([&](CValidationInterface& callbacks) {
[&, tx, mempool_sequence] {
UninterruptibleSleep(40ms);
return callbacks.TransactionAddedToMempool(tx, mempool_sequence);
}();
});
};
ENQUEUE_AND_LOG_EVENT(event, "%s: txid=%s wtxid=%s", __func__,
tx.info.m_tx->GetHash().ToString(),
Expand All @@ -195,7 +200,12 @@ void ValidationSignals::TransactionAddedToMempool(const NewMempoolTransactionInf

void ValidationSignals::TransactionRemovedFromMempool(const CTransactionRef& tx, MemPoolRemovalReason reason, uint64_t mempool_sequence) {
auto event = [tx, reason, mempool_sequence, this] {
m_internals->Iterate([&](CValidationInterface& callbacks) { callbacks.TransactionRemovedFromMempool(tx, reason, mempool_sequence); });
m_internals->Iterate([&](CValidationInterface& callbacks) {
[&, tx, mempool_sequence] {
UninterruptibleSleep(40ms);
return callbacks.TransactionRemovedFromMempool(tx, reason, mempool_sequence);
}();
});
};
ENQUEUE_AND_LOG_EVENT(event, "%s: txid=%s wtxid=%s reason=%s", __func__,
tx->GetHash().ToString(),
Expand Down
1 change: 1 addition & 0 deletions test/functional/wallet_backwards_compatibility.py
Expand Up @@ -174,6 +174,7 @@ def run_test(self):
tx4_id = node_master.bumpfee(tx3_id)["txid"]
# Abandon transaction, but don't confirm
node_master.abandontransaction(tx3_id)
self.sync_mempools()

# w2: wallet with private keys disabled, created on master: update this
# test when default wallets private keys disabled can no longer be
Expand Down

0 comments on commit f39144d

Please sign in to comment.