Skip to content

graphql: fix parameterized account fields and block logs#20539

Open
Keemosty12 wants to merge 5 commits into
erigontech:mainfrom
Keemosty12:graphql-fix-parameterized-fields
Open

graphql: fix parameterized account fields and block logs#20539
Keemosty12 wants to merge 5 commits into
erigontech:mainfrom
Keemosty12:graphql-fix-parameterized-fields

Conversation

@Keemosty12

Copy link
Copy Markdown
  • Fix the remaining parameterized GraphQL fields that were still bound to static struct fields.
  • Route Block.logs(filter), Log.account(block), Transaction.from(block), Transaction.to(block), Transaction.createdContract(block), and Block.miner(block) through resolvers so query arguments affect the returned data.
  • Preserve block context while building block, transaction, and log models so nested account lookups and block-scoped log filtering resolve against the intended block.
  • Add focused resolver tests for block log filtering and block-aware account resolution.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes several GraphQL fields that accept query arguments (e.g., block, filter) but were previously returning static struct data, ensuring nested account lookups and block-scoped log filtering resolve against the intended block context.

Changes:

  • Forces resolvers for parameterized fields (Block.logs(filter), Log.account(block), Transaction.from/to/createdContract(block), Block.miner(block), and Block.account(address)), so arguments affect returned data.
  • Preserves block/transaction context on constructed models (Transaction.Block, Log.Transaction, and Block.Logs) to support nested resolution and filtering.
  • Adds unit tests covering block log filtering and block-aware account resolution.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
cmd/rpcdaemon/graphql/graph/schema.resolvers.go Adds shared helpers and new resolvers for block/log/tx/account fields; threads block context through models and implements block log filtering.
cmd/rpcdaemon/graphql/graph/schema_resolvers_test.go Adds resolver-focused tests for log filtering and block-aware account resolution via a mock GraphQLAPI.
cmd/rpcdaemon/graphql/graph/schema.graphqls Adds @goField(forceResolver: true) on parameterized fields so gqlgen routes them through resolvers.
cmd/rpcdaemon/graphql/graph/generated.go Regenerates gqlgen output to wire new resolver interfaces and resolver-based field execution.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cmd/rpcdaemon/graphql/graph/schema.resolvers.go Outdated
Comment thread cmd/rpcdaemon/graphql/graph/schema.resolvers.go Outdated
@AskAlexSharov AskAlexSharov requested a review from lupin012 April 30, 2026 04:16
Comment thread cmd/rpcdaemon/graphql/graph/schema.resolvers.go Outdated
Comment thread cmd/rpcdaemon/graphql/graph/schema.resolvers.go Outdated
Comment thread cmd/rpcdaemon/graphql/graph/schema.resolvers.go Outdated
@Keemosty12 Keemosty12 requested a review from yperbasis as a code owner May 17, 2026 12:21
# Conflicts:
#	cmd/rpcdaemon/graphql/graph/generated.go
#	cmd/rpcdaemon/graphql/graph/schema.resolvers.go
#	cmd/rpcdaemon/graphql/graph/schema_resolvers_test.go
@Keemosty12

Copy link
Copy Markdown
Author

Thanks for the detailed review — addressed in 167c3b3228.

  • Added explicit overflow guards before any uint64 -> rpc.BlockNumber conversion (blockNum > math.MaxInt64) in both account resolution and Query.Block number parsing.
  • Consolidated the account-resolution helpers into resolveAccountAtBlock(...) + resolveAccountAtRequestedBlock(...) and aligned call sites.
  • Fixed topic-filter semantics by removing the eager len(filter.Topics) > len(log.Topics) rejection and checking bounds only when a non-empty topic alternative is evaluated (so patterns
    like [[topic0], []] behave correctly).
  • Kept the logs fallback meaningful by flattening transaction logs when obj.Logs is nil, and added tests for wildcard-topic behavior and nil-log fallback.

On the N+1 concern: agreed. I kept eager account loading in this PR to keep scope focused on correctness/behavioral fixes.

@yperbasis yperbasis added the RPC label May 18, 2026
@yperbasis yperbasis added this to the 3.6.0 milestone May 18, 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.

5 participants