Skip to content

Add txpool_content JSON-RPC method#10120

Merged
fab-10 merged 3 commits intobesu-eth:mainfrom
fab-10:txpool-content
Mar 30, 2026
Merged

Add txpool_content JSON-RPC method#10120
fab-10 merged 3 commits intobesu-eth:mainfrom
fab-10:txpool-content

Conversation

@fab-10
Copy link
Copy Markdown
Contributor

@fab-10 fab-10 commented Mar 27, 2026

Summary

Implements the spec-defined txpool_content JSON-RPC method. Given no parameters, returns all pending (executable) and queued (non-executable) transactions in the pool, grouped by sender address and then by nonce.

Related to #10111 (txpool_contentFrom).

Changes

  • TxPoolContent: RPC handler; splits each sender's transactions into pending (consecutive from account nonce) and queued (nonce gap) using the same logic as txpool_contentFrom
  • TransactionPoolContentResult: result type { pending: Map<address, Map<nonce, tx>>, queued: Map<address, Map<nonce, tx>> } matching TxpoolContent schema
  • PendingTransactions: added getPendingTransactionsBySender() to interface
  • TransactionsLayer: added getAllBySender() to interface, with Javadoc documenting the nonce-ordering invariant
  • AbstractTransactionsLayer: merges current-layer and next-layer sender maps, preserving nonce-ascending order per sender
  • EndLayer: base case returns Map.of()
  • LayeredPendingTransactions: implements getPendingTransactionsBySender() using getAllBySender() + getCurrentNonceFor() per sender (synchronized)
  • AbstractPendingTransactionsSorter: implements getPendingTransactionsBySender() from transactionsBySender TreeMap
  • DisabledPendingTransactions: no-op returns Map.of()

Test plan

  • TxPoolContentTest — 8 unit tests: empty pool, all-pending, all-queued, mixed split, multiple senders, default nonce=0, sender absent from pending map, nonce ordering preserved
  • Verify txpool_content response matches TxpoolContent schema from execution-apis spec

🤖 Generated with Claude Code

@fab-10 fab-10 force-pushed the txpool-content branch 2 times, most recently from 2463b67 to 44954f7 Compare March 27, 2026 14:56
@fab-10 fab-10 marked this pull request as ready for review March 27, 2026 15:21
Copilot AI review requested due to automatic review settings March 27, 2026 15:21
@fab-10 fab-10 mentioned this pull request Mar 27, 2026
1 task
Copy link
Copy Markdown
Contributor

@macfarla macfarla left a comment

Choose a reason for hiding this comment

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

Non-blocking: No test for getAllBySender merging across multiple layers in the layered pool - only the RPC handler is unit-tested. An integration or layer-level test for AbstractTransactionsLayer.getAllBySender with multiple layers would strengthen confidence in the merge logic

Copy link
Copy Markdown
Contributor

@usmansaleem usmansaleem left a comment

Choose a reason for hiding this comment

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

LGTM

@fab-10 fab-10 added doc-change-required Indicates an issue or PR that requires doc to be updated RPC labels Mar 30, 2026
fab-10 and others added 3 commits March 30, 2026 11:59
Implements the spec-defined `txpool_content` endpoint that returns all
pending and queued transactions in the pool, grouped by sender address
and nonce.

- Add `TxPoolContent` RPC handler and `TransactionPoolContentResult`
- Add `getPendingTransactionsBySender()` to `PendingTransactions` interface
- Add `getAllBySender()` to `TransactionsLayer` interface
- Implement in `LayeredPendingTransactions` and `AbstractPendingTransactionsSorter`
- Unit tests: 8 cases covering empty pool, all-pending, all-queued,
  mixed split, multiple senders, and nonce ordering

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
@fab-10
Copy link
Copy Markdown
Contributor Author

fab-10 commented Mar 30, 2026

Non-blocking: No test for getAllBySender merging across multiple layers in the layered pool - only the RPC handler is unit-tested. An integration or layer-level test for AbstractTransactionsLayer.getAllBySender with multiple layers would strengthen confidence in the merge logic

done, added a specific test scenario in LayersTest

@fab-10 fab-10 enabled auto-merge (squash) March 30, 2026 10:58
@fab-10 fab-10 merged commit 2e341e9 into besu-eth:main Mar 30, 2026
83 of 103 checks passed
@fab-10 fab-10 deleted the txpool-content branch March 30, 2026 13:17
@bgravenorst bgravenorst removed the doc-change-required Indicates an issue or PR that requires doc to be updated label Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants