Skip to content

Comments

refactor(bench): real-time tx generation with bounded buffer#2795

Draft
shekhirin wants to merge 4 commits intomainfrom
alexey/fix-valid-before-too-close
Draft

refactor(bench): real-time tx generation with bounded buffer#2795
shekhirin wants to merge 4 commits intomainfrom
alexey/fix-valid-before-too-close

Conversation

@shekhirin
Copy link
Contributor

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 time errors 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:

  • Producer task continuously generates, signs, and encodes one transaction at a time
  • Bounded channel (size = sending concurrency) provides backpressure
  • valid_before is set immediately before signing, keeping it fresh
  • Consumer drains channel with rate limiting and concurrent sending

Changes

  • Replace send_transactions_with_counters (batch sender) with inline consumer using stream::unfold
  • Add generate_transactions_to_channel: producer loop that sends to bounded channel
  • Set valid_before = now + expiry_secs right before signing (inside producer)
  • Remove expiring_batch_secs CLI flag (no longer needed for batch sizing)
  • Remove batch input cloning and pre-generation logic

Test Plan

  • cargo build -p tempo-bench to verify compilation
  • tempo-bench max-tps --help to confirm CLI flags
  • Run bench against a test network to verify no valid_before errors occur

🤖 Generated with Claude Code

shekhirin and others added 2 commits February 20, 2026 16:49
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>
@shekhirin shekhirin force-pushed the alexey/fix-valid-before-too-close branch from 808a37f to 57366d1 Compare February 20, 2026 18:12
…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>
@shekhirin shekhirin force-pushed the alexey/fix-valid-before-too-close branch from 57366d1 to 4d2c126 Compare February 20, 2026 21:49
…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>
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.

1 participant