Skip to content

rpc/graphql: implement transaction resolver, fix Long scalar and pre-Byzantium status #20916

Merged
lupin012 merged 4 commits intomainfrom
lupin012/fix_grphql_getTransaction
Apr 30, 2026
Merged

rpc/graphql: implement transaction resolver, fix Long scalar and pre-Byzantium status #20916
lupin012 merged 4 commits intomainfrom
lupin012/fix_grphql_getTransaction

Conversation

@lupin012
Copy link
Copy Markdown
Contributor

New implementations

  • transaction(hash): implemented transaction lookup by hash (was panicking)
  • block(hash): implemented block lookup by hash (was unimplemented)
  • block.transactionAt(index): implemented with proper bounds checking (was panicking)

Bug fixes

  • transaction.type: changed schema from Int to Long so EIP-1559/EIP-4844
    transactions return "0x2" / "0x3" (hex) instead of 2 / 3 (decimal),
    matching the GraphQL spec
  • transaction.status: pre-Byzantium blocks now correctly return "0x0" instead
    of null (pre-Byzantium receipts carry PostState instead of Status)
  • transaction.gas, transaction.maxFeePerGas, transaction.maxPriorityFeePerGas,
    transaction.accessList: fields were missing from the receipt map and are now
    populated correctly

Hive simulator fix

  • Added HIVE_CANCUN_TIMESTAMP to the client environment map in the GraphQL hive
    simulator. Without it, Erigon rejected Cancun blocks during chain import,
    truncating the canonical chain at block 29 and causing ~10 tests to fail
    (withdrawals, Shanghai/Cancun block queries, block range queries).

Tests

  • Added unit tests for the new Long scalar (marshal/unmarshal)
  • Added unit tests for nil guards in the convertData helpers
  • Added unit tests for transactionAt bounds checking
  • Added unit tests for transaction invalid hash error handling

…ium status

- Implement queryResolver.Transaction (getTransaction by hash)
- Implement queryResolver.Block hash path (getBlockByHash)
- Add GetBlockDetailsByHash and GetBlockNumberForTx to GraphQLAPI
- Change Transaction.type schema from Int to Long so EIP-1559 txns
  return "0x2" (hex) instead of 2 (decimal), matching the spec
- Default status=0 for pre-Byzantium receipts (PostState path)
- Add custom Long scalar with hex marshal/unmarshal
- Add nil guards to all three convertData helpers
- Refactor block/tx building into resolver_helpers.go
- Pre-allocate Logs, Topics, Transactions, Ommers, Withdrawals slices
- Add unit tests: scalar marshal/unmarshal, helper nil guards,
  TransactionAt bounds, Transaction invalid hash

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@lupin012 lupin012 changed the title rpc/graphql: implement getTransaction* rpc/graphql: implement transaction resolver, fix Long scalar and pre-Byzantium status Apr 29, 2026
@lupin012 lupin012 marked this pull request as ready for review April 29, 2026 19:14
@AskAlexSharov AskAlexSharov enabled auto-merge April 30, 2026 04:06
@AskAlexSharov AskAlexSharov added this pull request to the merge queue Apr 30, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Apr 30, 2026
@lupin012 lupin012 enabled auto-merge April 30, 2026 09:23
@lupin012 lupin012 added this pull request to the merge queue Apr 30, 2026
Merged via the queue into main with commit 4b281ce Apr 30, 2026
67 of 69 checks passed
@lupin012 lupin012 deleted the lupin012/fix_grphql_getTransaction branch April 30, 2026 13:29
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