aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormerge-script <fanquake@gmail.com>2024-06-03 09:59:54 +0100
committermerge-script <fanquake@gmail.com>2024-06-03 09:59:54 +0100
commite18accc5f518e229471f79d191196604abad254a (patch)
treea427d6c8845e3079f0bbd0fee7a7bbaf297151e1
parent457e1846d2bf6ef9d54b9ba1a330ba8bbff13091 (diff)
parent8defc182a31d828ad0f53ebf7e3be9e9cfc42d09 (diff)
Merge bitcoin/bitcoin#30186: fuzz: increase `txorphan` harness stability
8defc182a31d828ad0f53ebf7e3be9e9cfc42d09 scripted-diff: Replace nNextSweep with m_next_sweep (marcofleon) 0048680467e15037023ceae44bc2dc8309f82f39 increase txorphan harness stability (marcofleon) Pull request description: This moves `nNextSweep` from being a static variable in `LimitOrphans` to being a member of the `TxOrphanage` class. This improves the stability of the `txorphan` fuzz harness, as each orphanage (created every iteration) now has its own value for `nNextSweep`. ACKs for top commit: maflcko: utACK 8defc182a31d828ad0f53ebf7e3be9e9cfc42d09 dergoegge: Code review ACK 8defc182a31d828ad0f53ebf7e3be9e9cfc42d09 glozow: utACK 8defc182a31d828ad0f53ebf7e3be9e9cfc42d09, I can rebase on this pretty easily Tree-SHA512: 54d4a5074def764f6c895308b94e417662d2f21f157925421131745f22743907df59971f4ce545063658cd74ec133792cdd8df96ae3e69af8314e9b0ff899d48
-rw-r--r--src/txorphanage.cpp5
-rw-r--r--src/txorphanage.h3
2 files changed, 5 insertions, 3 deletions
diff --git a/src/txorphanage.cpp b/src/txorphanage.cpp
index 8e76c07b07..3eaf53939d 100644
--- a/src/txorphanage.cpp
+++ b/src/txorphanage.cpp
@@ -119,9 +119,8 @@ void TxOrphanage::LimitOrphans(unsigned int max_orphans, FastRandomContext& rng)
LOCK(m_mutex);
unsigned int nEvicted = 0;
- static NodeSeconds nNextSweep;
auto nNow{Now<NodeSeconds>()};
- if (nNextSweep <= nNow) {
+ if (m_next_sweep <= nNow) {
// Sweep out expired orphan pool entries:
int nErased = 0;
auto nMinExpTime{nNow + ORPHAN_TX_EXPIRE_TIME - ORPHAN_TX_EXPIRE_INTERVAL};
@@ -136,7 +135,7 @@ void TxOrphanage::LimitOrphans(unsigned int max_orphans, FastRandomContext& rng)
}
}
// Sweep again 5 minutes after the next entry that expires in order to batch the linear scan.
- nNextSweep = nMinExpTime + ORPHAN_TX_EXPIRE_INTERVAL;
+ m_next_sweep = nMinExpTime + ORPHAN_TX_EXPIRE_INTERVAL;
if (nErased > 0) LogPrint(BCLog::TXPACKAGES, "Erased %d orphan tx due to expiration\n", nErased);
}
while (m_orphans.size() > max_orphans)
diff --git a/src/txorphanage.h b/src/txorphanage.h
index 47becb447d..3054396b2d 100644
--- a/src/txorphanage.h
+++ b/src/txorphanage.h
@@ -105,6 +105,9 @@ protected:
/** Erase an orphan by wtxid */
int EraseTxNoLock(const Wtxid& wtxid) EXCLUSIVE_LOCKS_REQUIRED(m_mutex);
+
+ /** Timestamp for the next scheduled sweep of expired orphans */
+ NodeSeconds m_next_sweep GUARDED_BY(m_mutex){0s};
};
#endif // BITCOIN_TXORPHANAGE_H