Skip to content

avoid iterating over already selected txs#7664

Merged
sstanculeanu merged 8 commits into
feat/supernova-async-execfrom
optimize-txs-selection
Feb 5, 2026
Merged

avoid iterating over already selected txs#7664
sstanculeanu merged 8 commits into
feat/supernova-async-execfrom
optimize-txs-selection

Conversation

@AdoAdoAdo

@AdoAdoAdo AdoAdoAdo commented Feb 3, 2026

Copy link
Copy Markdown
Contributor

Reasoning behind the pull request

This pull request implements a selection offset mechanism to avoid re-iterating over transactions that have already been selected for proposed blocks. The feature tracks which transactions have been included in proposed blocks and maintains an offset per sender to skip those transactions during future selections.

Proposed changes

  • Added selectionOffset field to txListForSender to track the index from which selection should start
  • Refactored transaction insertion logic to separate index finding from insertion, enabling proper offset adjustment
  • Integrated offset management with the block proposal and replacement flows in the selection tracker

Testing procedure

Pre-requisites

Based on the Contributing Guidelines the PR author and the reviewers must check the following requirements are met:

  • was the PR targeted to the correct branch?
  • if this is a larger feature that probably needs more than one PR, is there a feat branch created?
  • if this is a feat branch merging, do all satellite projects have a proper tag inside go.mod?

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This pull request implements a selection offset mechanism to avoid re-iterating over transactions that have already been selected for proposed blocks. The feature tracks which transactions have been included in proposed blocks and maintains an offset per sender to skip those transactions during future selections.

Changes:

  • Added selectionOffset field to txListForSender to track the index from which selection should start
  • Refactored transaction insertion logic to separate index finding from insertion, enabling proper offset adjustment
  • Integrated offset management with the block proposal and replacement flows in the selection tracker

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
txcache/txListForSender.go Added selectionOffset field and methods to manage it (increment, decrement, reset); updated AddTx and removal methods to adjust offset
txcache/orderedTransactionsList.go Refactored insert method into findInsertionIndex and insertAt; added getAllFromIndex and findIndexByNonce helper methods
txcache/selection.go Updated acquireBunchesOfTransactions to use getTxsForSelection instead of getTxs, respecting the selection offset
txcache/txCache.go Added SetSelectionOffsetsByLastNonce and ResetSelectionOffsetsToNonce public methods; minor import reordering
txcache/selectionTracker.go Integrated offset updates after block proposal and removal, collecting sender nonces to reset offsets appropriately
txcache/trackedBlock.go Modified compileBreadcrumbs to return lastNoncePerSender map for offset updates
txcache/interface.go Extended txCacheForSelectionTracker interface with new offset management methods
txcache/*_test.go Updated tests to handle new return values and added comprehensive test coverage for offset functionality

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread txcache/txListForSender.go

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


// If transaction was inserted before the selection offset, increment offset to maintain position
if insertionIndex < listForSender.selectionOffset {
listForSender.selectionOffset++

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
listForSender.selectionOffset++
listForSender.incrementSelectionOffset(1)


// If removal is at index < offset, decrement offset
if i < listForSender.selectionOffset {
listForSender.selectionOffset--

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
listForSender.selectionOffset--
listForSender.decrementSelectionOffset(1)

@ssd04 ssd04 self-requested a review February 4, 2026 09:23
ssd04
ssd04 previously approved these changes Feb 4, 2026

@ssd04 ssd04 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

no other things from me

Comment on lines +170 to +173
func (listForSender *txListForSender) getTxsForSelection() []*WrappedTransaction {
listForSender.mutex.RLock()
defer listForSender.mutex.RUnlock()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

not for this PR: maybe to have the methods with mutex protection exported, not very clear from here what should be with mutex protection and what is used internally

@sstanculeanu sstanculeanu merged commit 9dd98b5 into feat/supernova-async-exec Feb 5, 2026
8 of 9 checks passed
@sstanculeanu sstanculeanu deleted the optimize-txs-selection branch February 5, 2026 11:23
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.

4 participants