Add txpool_inspect JSON-RPC method#10121
Merged
Merged
Conversation
97296fc to
dc42323
Compare
macfarla
reviewed
Mar 30, 2026
Contributor
macfarla
left a comment
There was a problem hiding this comment.
couple of nits and a query about TransactionPoolStatusResult class change
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>
Implements the spec-defined txpool_inspect endpoint that returns a textual summary of all pending and queued transactions, grouped by sender address and nonce. Each transaction is summarised as: "<to>: <value> wei + <gasLimit> gas × <gasPrice> wei" For contract creation the destination is "contract creation". EIP-1559 transactions use maxFeePerGas as the price field. Reuses AbstractTxPoolContent<String> so the pending/queued split and nonce-keyed map building are shared with txpool_content. Bug fixed: the original humanReadableView delegated to PendingTransaction.toTraceLog() which produces an internal debug format, not the spec-defined summary string. Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net> Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The spec does not enforce the free-text format of the summary string, so use PendingTransaction.toTraceLog() as the implementation. Update tests accordingly. Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net> Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… consistently - Extract `contentMap()` into `AbstractTxPoolContent` to eliminate duplication between `TxPoolContent` and `TxPoolInspect` - Use `ptx.getNonce()` in `renderPendingTransactions()` instead of `ptx.getTransaction().getNonce()` for consistency with the rest of the class - Fix `TxPoolInspectTest` to not stub `getTransaction()` since `TxPoolInspect` only uses `toTraceLog()` and `getNonce()` Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
…sResult - Remove `humanReadableView()` wrapper from `TxPoolInspect`; use `PendingTransaction::toTraceLog` directly as the method reference adds no value - Restore dedicated `TransactionPoolStatusResult` for `txpool_status` with hex-encoded getters, keeping `TransactionPoolResult<T>` for content/inspect methods only Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
macfarla
approved these changes
Mar 31, 2026
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
Stacks on top of #10120 (txpool_content), please review it firstImplements the spec-defined
txpool_inspectJSON-RPC method. Returns a textual summary of all pending and queued transactions in the pool, grouped by sender address and nonce.Some duplicated code was removed as part of this PR.
Since the content is free form and implementation dependent, Besu chose to return this output
Changes
TxPoolInspect: RPC handler, extendsAbstractTxPoolContent<String>; delegates the per-transaction summary toPendingTransaction.toTraceLog()(the spec does not enforce a specific free-text format)RpcMethod: addedTX_POOL_INSPECT("txpool_inspect")TxPoolJsonRpcMethods: registeredTxPoolInspectThe
humanReadableViewhelper isstaticto allow the unbound method referenceTxPoolInspect::humanReadableView, and package-private to allow direct unit testing.Test plan
TxPoolInspectTest— 6 unit tests: empty pool,humanReadableViewdelegation totoTraceLog(), all-pending, pending/queued split, result values are non-empty strings🤖 Generated with Claude Code