spammer: remove delay in tps mode to achieve 1sec loop timing#454
spammer: remove delay in tps mode to achieve 1sec loop timing#454zeroXbrock merged 5 commits intoflashbots:mainfrom
Conversation
|
Thanks @bitwiseguy -- totally agree with the changes, and it works great, but I'm getting this error sometimes: It only seems to be happening on this branch, but I can't find a reason why your changes would affect the DB. Strange error... I'll keep digging into it, just wanted to update you. |
Fixed. I think the issue was that when I set tps really high, without the small time buffer between all the txs, the swarm of tx results trying to write to the DB was clogging the tx pool and causing connection errors. Implemented a few fixes in the sqlite_db crate to manage high load. Works without error now! |
| } | ||
|
|
||
| /// Send one batch of spam txs evenly over one second. | ||
| /// Send one batch of spam txs as fast as possible. |
There was a problem hiding this comment.
nice, I had a feeling this was causing issues
| let mut last_cache_len = usize::MAX; | ||
| let mut last_progress = Instant::now(); | ||
| loop { | ||
| let cache_len = self.tx_actor().done_flushing().await?; |
There was a problem hiding this comment.
nice, this design is much simpler
zeroXbrock
left a comment
There was a problem hiding this comment.
another big improvement! Thanks @bitwiseguy

Overview
This pr contains a few changes related to the spam tps mode.
Remove artificial per-tx/per-batch delay in
execute_spamPreviously, txs were spaced evenly over 1 second (
micros_per_tasksleep for individual sends, micros_per_batch for batch RPC). Now they're sent as fast as possible. The overhead of preparing, signing, and sending already consumes time, so the artificial delay was pushing the loop well beyond 1sec, preventing contender from achieving its intended TPS target.Remove per-tx timeout eviction from TxActor cache; process blocks individually
Removed
is_tx_timed_out_ms: the old code silently evicted timed-out txs from the cache duringRemoveConfirmedhandling. This led to a data loss bug because those txs were dropped beforedump_cachecould write them to the DB, so they'd never appear in therun_txstable at all. Now unconfirmed txs stay in cache untildump_cache, which properly records them with NULLend_timestamp/block_number/gas_usedand their error string preserved.Per-block flush: instead of batching all pending blocks into one
RemoveConfirmedmessage, the flush loop now processes each block individually and refreshes the cache snapshot after each. This avoids redundantly scanning already-confirmed txs in subsequent blocks.Progress-based timeout in
dump_tx_cachedone_flushingnow returns the cache length (not a bool), and the timeout resets whenever the cache shrinks. This prevents premature timeout when many txs are confirming steadily but slowly (e.g., 10k txs draining over 60s would have hit the old fixed timeout).