Refs #46
PR: feat/21-mempool-monitor
File: crates/charon-scanner/src/mempool.rs
Function: MempoolMonitor::run()
Problem
The reconnect backoff is:
backoff = (backoff * 2).min(Duration::from_secs(30));
This is the same deterministic doubling pattern flagged for BlockListener in PR #32 (open issue: no jitter). Multiple bot instances (e.g. Docker Compose replicas: 2) or a future where MempoolMonitor and BlockListener both reconnect after the same RPC outage will fire reconnection attempts at exactly the same moment, creating a thundering herd.
The fix is the same as that required for BlockListener and should share a utility function to avoid future divergence.
Required fix
Add jitter: after doubling, add a random offset in range [0, backoff/2] using rand::thread_rng() or the tokio-equivalent. Extract a shared backoff_with_jitter(current, max) utility in charon-scanner so BlockListener, MempoolMonitor, and any future subscribers all use the same implementation.
Refs #46
PR: feat/21-mempool-monitor
File: crates/charon-scanner/src/mempool.rs
Function: MempoolMonitor::run()
Problem
The reconnect backoff is:
This is the same deterministic doubling pattern flagged for BlockListener in PR #32 (open issue: no jitter). Multiple bot instances (e.g. Docker Compose replicas: 2) or a future where MempoolMonitor and BlockListener both reconnect after the same RPC outage will fire reconnection attempts at exactly the same moment, creating a thundering herd.
The fix is the same as that required for BlockListener and should share a utility function to avoid future divergence.
Required fix
Add jitter: after doubling, add a random offset in range [0, backoff/2] using rand::thread_rng() or the tokio-equivalent. Extract a shared backoff_with_jitter(current, max) utility in charon-scanner so BlockListener, MempoolMonitor, and any future subscribers all use the same implementation.