Skip to content

fix(txpool): evict 2D pool transactions from the end of their lane - #9580

Open
klkvr wants to merge 2 commits into
mainfrom
fix/2d-pool-evict-lane-tail
Open

klkvr wants to merge 2 commits into
mainfrom
fix/2d-pool-evict-lane-tail

Conversation

@klkvr

@klkvr klkvr commented Nov 26, 2026

Copy link
Copy Markdown
Member

Pending eviction in the AA 2D pool removed the lowest-priority pending transaction wherever it sat in its lane and demoted every transaction after it, which were promoted again as soon as the gap was refilled.

Eviction now removes the last pending transaction of the selected lane, like the reth pool evicts a sender's highest nonce, so a lane's pending run stays contiguous and eviction never demotes. The extra queued-limit pass after pending eviction is no longer needed.

@tempoxyz-bot

tempoxyz-bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

👁️ Cyclops Security Review

✅ Reviewed 2c41e5f (latest) · Coverage: partial · no open findings · report
⚠️ Not checked: Removal of the second queued-limit check after pending eviction: ruled out without reading the cited code at this commit
ℹ️ Not verifiable from the source alone (needs running code or deployed state): The CPU cost of evicting a full 1024-tx lane from its tail was estimated, not measured in a release build. To verify it: A release-build benchmark of the AA2dPool add that fills a gap promoting max_tx (2 more in the report)

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nothing blocking. The comments below are optional suggestions. There is no need to push a fix for them before merging.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I reviewed the latest push and found no bugs. The follow-up commit fixes my earlier test nit: the new test now checks that the re-added tail is the one discarded. This changes pending-eviction policy in a crate with CODEOWNERS, so a human look is still worthwhile.

What was reviewed:

  • evict_2d_pending_tx: the pending run from descendant_txs(id) starts with the selected pending tx, so last() is always a pending tx in the same lane. remove_transaction_by_id updates pending count and size and clears the independent entry only when head and tail are the same tx.
  • Dropping the second queued-limit pass in discard(): neither path changes queued state any more. Removing a lane's tail demotes nothing, and expiring-nonce eviction never touched queued. demote_descendants still has another caller (line 1020), so it is not dead code.
  • Loop termination: every iteration removes one pending tx or breaks. A cheap head now causes its own lane to be removed from the tail end, which can discard more txs than the old remove-and-demote did (for example, all 5 attacker txs in the renamed test). Whether that trade-off is acceptable is a policy call for a human.
  • Not done: I did not run cargo +nightly fmt or the tests.
Extended reasoning...

The change touches only crates/transaction-pool/src/tt_2d_pool.rs. It changes how pending transactions are evicted in the AA 2D pool: the selected lane now loses its tail instead of losing the selected tx and demoting its descendants. The redundant queued-limit re-check is removed, and the tests are updated. It touches no auth, crypto or data-exposure code, and eviction policy is not consensus. Approval was ruled out because CODEOWNERS covers crates/transaction-pool/ and because this is a mempool eviction-policy decision. The earlier inline nit was addressed by commit 2c41e5f.

This branch has not been deployed

No deployments
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