Skip to content

spammer: remove delay in tps mode to achieve 1sec loop timing#454

Merged
zeroXbrock merged 5 commits intoflashbots:mainfrom
bitwiseguy:ss/improve-tps-timing
Feb 13, 2026
Merged

spammer: remove delay in tps mode to achieve 1sec loop timing#454
zeroXbrock merged 5 commits intoflashbots:mainfrom
bitwiseguy:ss/improve-tps-timing

Conversation

@bitwiseguy
Copy link
Contributor

Overview

This pr contains a few changes related to the spam tps mode.

Remove artificial per-tx/per-batch delay in execute_spam

Previously, txs were spaced evenly over 1 second (micros_per_task sleep 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 during RemoveConfirmed handling. This led to a data loss bug because those txs were dropped before dump_cache could write them to the DB, so they'd never appear in the run_txs table at all. Now unconfirmed txs stay in cache until dump_cache, which properly records them with NULL end_timestamp/block_number/gas_used and their error string preserved.

Per-block flush: instead of batching all pending blocks into one RemoveConfirmed message, 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_cache

done_flushing now 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).

@zeroXbrock
Copy link
Member

Thanks @bitwiseguy -- totally agree with the changes, and it works great, but I'm getting this error sometimes:

flush_cache error for block 506: Db(Internal("failed to execute query: unable to open database file"))

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.

@zeroXbrock
Copy link
Member

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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, this design is much simpler

Copy link
Member

@zeroXbrock zeroXbrock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another big improvement! Thanks @bitwiseguy

@zeroXbrock
Copy link
Member

zeroXbrock commented Feb 13, 2026

beautiful, completely smooth

gas-per-block

@zeroXbrock zeroXbrock merged commit 698508f into flashbots:main Feb 13, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants