Skip to content

Conversation

@aditya1702
Copy link
Contributor

What

[TODO: Short statement about what is changing.]

Why

[TODO: Why this change is being made. Include any context required to understand the why.]

Known limitations

[TODO or N/A]

Issue that this PR addresses

[TODO: Attach the link to the GitHub issue or task. Include the priority of the task here in addition to the link.]

Checklist

PR Structure

  • It is not possible to break this PR down into smaller PRs.
  • This PR does not mix refactoring changes with feature changes.
  • This PR's title starts with name of package that is most changed in the PR, or all if the changes are broad or impact many packages.

Thoroughness

  • This PR adds tests for the new functionality or fixes.
  • All updated queries have been tested (refer to this check if the data set returned by the updated query is expected to be same as the original one).

Release

  • This is not a breaking change.
  • This is ready to be tested in development.
  • The new functionality is gated with a feature flag if this is not ready for production.

Copy link

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

This PR removes the tx_hash column and foreign key constraint from the operations table, replacing the direct transaction hash reference with a TOID (Transaction/Operation ID) encoding scheme. Operations are now associated with transactions by deriving the transaction's ToID from the operation ID using bit masking (id &^ 0xFFF in Go, id & ~x'FFF'::bigint in SQL).

Changes:

  • Removed tx_hash column and foreign key from operations table schema
  • Updated all queries to use TOID range-based lookups (id > to_id AND id < to_id + 4096) instead of tx_hash equality
  • Removed TxHash field from types.Operation struct and updated all processors, tests, and GraphQL resolvers
  • Changed dataloader from OperationsByTxHashLoader to OperationsByToIDLoader using TOID bit masking

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
internal/db/migrations/2025-06-10.3-create_indexer_table_operations.sql Removes tx_hash column, foreign key constraint, and associated indexes from operations table
internal/indexer/types/types.go Removes TxHash field from Operation struct
internal/indexer/processors/utils.go Removes TxHash assignment in ConvertOperation function
internal/indexer/processors/utils_test.go Updates test assertions to remove TxHash field
internal/data/operations.go Replaces BatchGetByTxHash(es) methods with BatchGetByToID(s) using TOID range queries
internal/data/operations_test.go Updates all tests to use ToID-based lookups with proper TOID ranges (multiples of 4096)
internal/data/transactions.go Updates BatchGetByOperationIDs to join using TOID bit masking instead of tx_hash
internal/data/transactions_test.go Updates tests with proper TOID values for transaction-operation relationships
internal/data/accounts_test.go Updates test data setup to use proper TOID ranges
internal/serve/graphql/dataloaders/operation_loaders.go Replaces hash-based dataloader with ToID-based dataloader using bit masking
internal/serve/graphql/dataloaders/loaders.go Renames loader from OperationsByTxHashLoader to OperationsByToIDLoader
internal/serve/graphql/resolvers/transaction.resolvers.go Updates resolver to use ToID instead of Hash for loading operations
internal/serve/graphql/resolvers/test_utils.go Updates test setup to derive tx_hash from operation IDs using toid.Parse
internal/serve/graphql/resolvers/*.go (tests) Updates all GraphQL resolver tests to work with ToID-based operations
internal/services/ingest_test.go Updates test helpers and cleanup logic for operations without tx_hash
internal/indexer/indexer_buffer_test.go Removes TxHash from test operation creation

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

@aditya1702 aditya1702 marked this pull request as ready for review February 1, 2026 23:45
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