-
Notifications
You must be signed in to change notification settings - Fork 12
operations, operations_accounts: Remove txHash from operations table and build tx TOID using operation ID
#479
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: txhash-remove-txns
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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_hashcolumn and foreign key fromoperationstable schema - Updated all queries to use TOID range-based lookups (
id > to_id AND id < to_id + 4096) instead oftx_hashequality - Removed
TxHashfield fromtypes.Operationstruct and updated all processors, tests, and GraphQL resolvers - Changed dataloader from
OperationsByTxHashLoadertoOperationsByToIDLoaderusing 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.
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
allif the changes are broad or impact many packages.Thoroughness
Release