Skip to content

Add txpool_contentFrom JSON-RPC method#10111

Merged
fab-10 merged 1 commit intobesu-eth:mainfrom
fab-10:txpool-contentFrom
Mar 27, 2026
Merged

Add txpool_contentFrom JSON-RPC method#10111
fab-10 merged 1 commit intobesu-eth:mainfrom
fab-10:txpool-contentFrom

Conversation

@fab-10
Copy link
Copy Markdown
Contributor

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

Summary

Implements the txpool_contentFrom JSON-RPC method as defined in the execution-apis spec.

Given a sender address, returns the pending (executable) and queued (non-executable) transactions for that address, split by nonce continuity from the account's current on-chain nonce.

Example response:

{
  "pending": {
    "0": { "nonce": "0x0", "from": "0x123...", ... },
    "1": { "nonce": "0x1", "from": "0x123...", ... }
  },
  "queued": {
    "3": { "nonce": "0x3", "from": "0x123...", ... }
  }
}

Changes

  • Add TX_POOL_CONTENT_FROM to RpcMethod enum
  • Add TxPoolContentFrom handler and TransactionPoolContentFromResult result type
  • Register the method in TxPoolJsonRpcMethods
  • Add getPendingTransactionsForSender(Address) and getCurrentNonceForSender(Address) to the PendingTransactions interface with implementations in LayeredPendingTransactions, AbstractPendingTransactionsSorter, and DisabledPendingTransactions

Test plan

  • Unit tests in TxPoolContentFromTest cover:
    • Empty transaction pool for sender
    • All transactions executable (no nonce gap) → all pending
    • All transactions queued (gap at start)
    • Mixed pending + queued split
    • Account with no on-chain state (nonce defaults to 0)
    • Account with non-zero current nonce
    • Missing address parameter returns InvalidJsonRpcParameters

🤖 Generated with Claude Code

@fab-10 fab-10 force-pushed the txpool-contentFrom branch 2 times, most recently from 0e5e561 to 3dac9e5 Compare March 26, 2026 13:39
@fab-10 fab-10 marked this pull request as ready for review March 26, 2026 14:03
Copilot AI review requested due to automatic review settings March 26, 2026 14:03
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Implements the txpool_contentFrom JSON-RPC method to return pending vs queued transactions for a given sender, split by nonce continuity from the sender’s on-chain nonce.

Changes:

  • Added txpool_contentFrom to the JSON-RPC method registry and RpcMethod enum.
  • Extended the transaction pool APIs to retrieve a sender’s transactions and current nonce.
  • Added result/handler types plus a new unit test suite validating nonce-gap splitting behavior.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/sorter/PendingTransactionsForSender.java Adds current-nonce accessor and adjusts synchronization while reading sender txs
ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/sorter/AbstractPendingTransactionsSorter.java Implements new per-sender pending tx and current nonce retrieval methods
ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/layered/LayeredPendingTransactions.java Plumbs per-sender pending tx and current nonce through layered pool implementation
ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPool.java Exposes per-sender pending tx list and current nonce from the pool
ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/PendingTransactions.java Extends interface with per-sender tx retrieval and current-nonce lookup
ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/DisabledPendingTransactions.java Provides empty implementations for new interface methods
ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/TxPoolContentFromTest.java Adds unit tests for txpool_contentFrom behavior
ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/TxPoolJsonRpcMethods.java Registers new TxPoolContentFrom RPC method
ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/TransactionPoolContentFromResult.java Adds JSON result type for pending/queued-by-nonce response
ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/TxPoolContentFrom.java Implements txpool_contentFrom handler and nonce-gap splitting logic
ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/RpcMethod.java Adds TX_POOL_CONTENT_FROM enum entry

@fab-10 fab-10 force-pushed the txpool-contentFrom branch 2 times, most recently from 01741ac to 1c74e8f Compare March 26, 2026 14:42
@fab-10 fab-10 added doc-change-required Indicates an issue or PR that requires doc to be updated RPC labels Mar 26, 2026
@fab-10 fab-10 force-pushed the txpool-contentFrom branch 3 times, most recently from 0f6a35c to 2b57973 Compare March 26, 2026 19:43
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.

couple of nits, otherwise LGTM

Implements the txpool_contentFrom method as defined in the execution-apis
spec. Given a sender address, returns the pending (executable) and queued
(non-executable) transactions for that address split by nonce continuity
from the account's current on-chain nonce.

- Add TX_POOL_CONTENT_FROM to RpcMethod enum
- Add TxPoolContentFrom handler and TransactionPoolContentFromResult
- Register the method in TxPoolJsonRpcMethods
- Add getPendingTransactionsForSender and getCurrentNonceForSender to the
  PendingTransactions interface with implementations in all concrete classes
- Add unit tests covering empty pool, all-pending, all-queued, mixed split,
  absent account nonce, non-zero base nonce, and missing param error cases

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
@fab-10 fab-10 force-pushed the txpool-contentFrom branch from 2b57973 to 67b50b6 Compare March 27, 2026 09:21
@fab-10 fab-10 enabled auto-merge (squash) March 27, 2026 09:24
@fab-10 fab-10 merged commit 530f182 into besu-eth:main Mar 27, 2026
54 of 84 checks passed
@fab-10 fab-10 deleted the txpool-contentFrom branch March 27, 2026 10:04
@fab-10 fab-10 mentioned this pull request Mar 27, 2026
2 tasks
@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