Skip to content

eth: add eth_getRawTransactionBy* methods to spec#836

Open
manusw7 wants to merge 4 commits into
ethereum:mainfrom
manusw7:feat/eth-raw-transaction-by-methods
Open

eth: add eth_getRawTransactionBy* methods to spec#836
manusw7 wants to merge 4 commits into
ethereum:mainfrom
manusw7:feat/eth-raw-transaction-by-methods

Conversation

@manusw7

@manusw7 manusw7 commented Jun 26, 2026

Copy link
Copy Markdown

Summary

Adds eth_getRawTransactionByHash, eth_getRawTransactionByBlockHashAndIndex, and eth_getRawTransactionByBlockNumberAndIndex to src/eth/transaction.yaml.

Also aligns debug_getRawTransaction in src/debug/getters.yaml with the same convention: its result schema becomes oneOf: [notFound, bytes] so it returns null when the transaction is not found.

These three methods are implemented by all major execution clients (Geth, Nethermind, Besu, Reth) but were absent from the spec.

Rationale

The structured counterparts (eth_getTransactionByHash / ByBlockHashAndIndex / ByBlockNumberAndIndex) are already specified with oneOf: [notFound, TransactionInfo] — returning null when the transaction is not found. The raw variants should follow the same convention.

Geth currently returns "0x" for not-found (a Go nil-slice serialisation artifact, not an intentional choice). A companion PR fixes this: ethereum/go-ethereum#35227. Nethermind, Reth, and Besu already return null.

Changes

Three new method entries in src/eth/transaction.yaml, inserted between eth_getTransactionByBlockNumberAndIndex and eth_getTransactionReceipt:

  • eth_getRawTransactionByHash — same param as the structured variant; result oneOf: [notFound, bytes]
  • eth_getRawTransactionByBlockHashAndIndex — same params as the structured variant; result oneOf: [notFound, bytes]; error 4444
  • eth_getRawTransactionByBlockNumberAndIndex — same params as the structured variant; result oneOf: [notFound, bytes]; error 4444
  • debug_getRawTransaction (src/debug/getters.yaml) — result schema changed from bytes to oneOf: [notFound, bytes], matching the eth_getRawTransaction* variants. Adds a get-notfound-tx test asserting null.

Each entry mirrors the structure of its eth_getTransactionBy* counterpart exactly, only swapping TransactionInfo for bytes in the result schema.

Add eth_getRawTransactionByHash, eth_getRawTransactionByBlockHashAndIndex,
and eth_getRawTransactionByBlockNumberAndIndex to src/eth/transaction.yaml.

These methods are implemented by all major clients (Geth, Nethermind, Besu,
Reth) but were absent from the spec. Each method mirrors its structured
eth_getTransactionBy* counterpart in params and error codes, returning
oneOf: [notFound, bytes] (null when not found, RLP-encoded hex when found).
Block-indexed variants include error code 4444 (Pruned history unavailable).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@MysticRyuujin

MysticRyuujin commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Hey @manusw7 - we need tests - to get tests we need something in generators and a make fill to populate the .io files

You can, in theory, point the PR at your branch via updating the go.mod to show that when the go-etheruem PR lands, the spec is good and the tests will pass in the CI.

manusw7 and others added 2 commits June 26, 2026 15:48
…Transaction not-found

Add MethodTests vars for eth_getRawTransactionByHash,
eth_getRawTransactionByBlockHashAndIndex, and
eth_getRawTransactionByBlockNumberAndIndex. Each covers found, not-found,
and (where applicable) out-of-range-index cases.

Also add a get-notfound-tx test to the existing DebugGetRawTransaction.

The 7 not-found .io fixtures are hand-written with result:null since
upstream geth currently returns "0x" for missing raw txs; the spec
(oneOf: [notFound, bytes]) requires null.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Use a replace directive to swap in manusw7/go-ethereum@fix/raw-tx-null-not-found,
which returns *hexutil.Bytes (null) instead of hexutil.Bytes ("0x") for missing
transactions. This lets `make fill` generate the correct null responses in the
eth_getRawTransactionBy* and debug_getRawTransaction .io test fixtures.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@manusw7

manusw7 commented Jun 26, 2026

Copy link
Copy Markdown
Author

You can, in theory, point the PR at your branch via updating the go.mod so that make fill uses the patched geth

Done — I've added a replace directive in tools/go.mod pointing at my fork:

replace github.com/ethereum/go-ethereum => github.com/manusw7/go-ethereum v1.17.4-0.20260626133832-33e1d84d16d0

The fork branch is manusw7/go-ethereum@fix/raw-tx-null-not-found, which changes the four affected functions to return *hexutil.Bytes instead of hexutil.Bytes so that nil (not-found) serialises to JSON null rather than "0x".

Running make fill with this replace now generates all .io fixture files correctly.

Once the go-ethereum PR is merged and a new release tagged, this replace directive can be dropped and go.mod updated to the release version.

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