refactor(bench): real-time tx generation with bounded buffer#2795
Draft
refactor(bench): real-time tx generation with bounded buffer#2795
Conversation
Replace batch-based generation/signing with continuous generation in a producer task. Transactions are generated, signed, and encoded one at a time with valid_before set immediately before signing. A bounded channel (size = sending concurrency) provides backpressure, keeping the buffer small and valid_before timestamps fresh. This fixes the 'valid_before too close to current time' errors that occurred when transactions sat in pre-signed batches waiting to be sent. Changes: - Remove batch-based pipeline (generate N, sign N, send N) - Add generate_transactions_to_channel: producer that continuously generates 1 tx at a time - Consumer drains channel with rate limiting and concurrent sending - Set valid_before right before signing (keeps it fresh) - Remove expiring_batch_secs CLI flag (no longer needed) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
808a37f to
57366d1
Compare
…nerate_transactions Pass TransactionCounters struct into generate_transactions to track per-type counts (tip20_transfers, swaps, orders, erc20_transfers) and log them after the stream is consumed. Restore descriptive comments from the pre-refactor code. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
57366d1 to
4d2c126
Compare
…uplicate tx hashes The tx_id counter was being created inside the repeat_with closure, resetting to 0 on every iteration. This caused all transactions to get the same priority fee bump (id=0), producing duplicate tx hashes and "already known" / "tx hash already seen" rejections. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Refactor the bench tool's expiring nonce transaction pipeline from batch-based generation to real-time, continuous generation with a small bounded buffer. This fixes
'valid_before' too close to current timeerrors by keeping transaction timestamps fresh.Problem: Transactions were pre-signed in large batches, then queued for sending. The gap between signing and sending could exceed the 25s expiry window, especially under network latency or CPU pressure.
Solution:
valid_beforeis set immediately before signing, keeping it freshChanges
send_transactions_with_counters(batch sender) with inline consumer usingstream::unfoldgenerate_transactions_to_channel: producer loop that sends to bounded channelvalid_before = now + expiry_secsright before signing (inside producer)expiring_batch_secsCLI flag (no longer needed for batch sizing)Test Plan
cargo build -p tempo-benchto verify compilationtempo-bench max-tps --helpto confirm CLI flagsvalid_beforeerrors occur🤖 Generated with Claude Code