Skip to content

Commit 4b281ce

Browse files
lupin012claudeAskAlexSharov
authored
rpc/graphql: implement transaction resolver, fix Long scalar and pre-Byzantium status (#20916)
### 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 Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> Co-authored-by: Alex Sharov <AskAlexSharov@gmail.com>
1 parent e4ed80c commit 4b281ce

12 files changed

Lines changed: 747 additions & 258 deletions

File tree

cmd/rpcdaemon/graphql/gqlgen.yml

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ models:
6060
- github.com/99designs/gqlgen/graphql.Int32
6161
Long:
6262
model:
63-
- github.com/99designs/gqlgen/graphql.Uint64
63+
- github.com/erigontech/erigon/cmd/rpcdaemon/graphql/graph/scalar.Uint64
6464
BigInt:
6565
model:
6666
- github.com/99designs/gqlgen/graphql.String
@@ -77,13 +77,17 @@ models:
7777
model:
7878
- github.com/99designs/gqlgen/graphql.String
7979
- github.com/99designs/gqlgen/graphql.Uint64
80-
# Block:
81-
# fields:
82-
# logs:
83-
# resolver: true # force a resolver to be generated
84-
# ommers:
85-
# resolver: true # force a resolver to be generated
86-
# transactions:
87-
# resolver: true # force a resolver to be generated
80+
Block:
81+
fields:
82+
transactionAt:
83+
resolver: true
84+
account:
85+
resolver: true
86+
Transaction:
87+
fields:
88+
from:
89+
resolver: true
90+
to:
91+
resolver: true
8892

8993
omit_getters: true

0 commit comments

Comments
 (0)