-
Notifications
You must be signed in to change notification settings - Fork 12
statechanges: Remove txHash and use tx TOID to reference transactions table
#480
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
Draft
aditya1702
wants to merge
32
commits into
txhash-remove-ops
Choose a base branch
from
txhash-remove-statechanges
base: txhash-remove-ops
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+958
−611
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Remove tx_hash column and its FK constraint to transactions(hash) - Add FK constraint on to_id referencing transactions(to_id) - Remove idx_state_changes_tx_hash index
The tx_hash is redundant since to_id can be used to look up transactions.
Transaction can be looked up via to_id, so txHash is redundant.
Updated calls in: - effects.go - token_transfer.go - contract_deploy.go - contracts/sac.go
- Remove txHashes slice and loop assignment - Update INSERT query to remove tx_hash column - Shift parameter indices accordingly - Update BatchCopy column list and row values - Update BatchGetByAccountAddress to use subquery for tx_hash filter
- BatchGetByTxHash -> BatchGetByToID (uses to_id instead of tx_hash) - BatchGetByTxHashes -> BatchGetByToIDs (uses to_ids array instead of tx_hashes) - Update queries to use to_id for filtering and partitioning
- Change StateChangeColumnsKey.TxHash to ToID (int64) - Rename stateChangesByTxHashLoader to stateChangesByToIDLoader - Update dataloader to use BatchGetByToID/BatchGetByToIDs - Update key extraction functions to use ToID
- Change loaderKey.TxHash to loaderKey.ToID (use obj.ToID instead of obj.Hash) - Call StateChangesByToIDLoader instead of StateChangesByTxHashLoader
- Remove TxHash from test state change structs - Update INSERT statements to remove tx_hash column - Update filter tests to check ToID instead of TxHash - Rename BatchGetByTxHash/TxHashes tests to BatchGetByToID/ToIDs - Remove TxHash assertions from effects and contract_deploy tests - Update buildStateChange helper function signature
- Update createTestStateChange helper in ingest_test.go - Remove TxHash from state change struct in statechange_resolvers_test.go
The sc3 state change previously had to_id=3 but only transactions with to_id=1 and to_id=2 exist. Changed to to_id=1 with state_change_order=2 to reference an existing transaction while avoiding PK conflict.
- Use valid to_id values that reference existing transactions - Remove tx_hash from transactions_test.go INSERT - Adjust test expectations to match updated test data
- Update PK from (to_id, state_change_order) to (to_id, operation_id, state_change_order) - Add partial index on operation_id for non-zero values - Enables proper FK semantics where to_id always references transaction to_id
- Add OperationID field to StateChangeCursor for 3-part cursor - Update GetCursor() method to include OperationID
- For operation changes: derive ToID from OperationID using TOID bitmask (&^ 0xFFF) - For fee changes: use transaction's to_id directly - This ensures FK constraint to transactions table is always valid
- Add operation_id to cursor columns in all queries - Update ordering to use (to_id, operation_id, state_change_order) - Update pagination predicates to use 3-column comparison - Update ON CONFLICT clause for 3-part PK - Update returned ID format to include operation_id
- Add scOpIDs parameter to all BatchGetByStateChangeIDs functions - Update tuple format from (to_id, state_change_order) to (to_id, operation_id, state_change_order) - Update state_change_id format to include operation_id
- Change format from to_id-state_change_order to to_id-operation_id-state_change_order - Return toIDs, opIDs, orders instead of toIDs, orders
- Update account_loaders.go to pass scOpIDs to BatchGetByStateChangeIDs - Update operation_loaders.go to pass scOpIDs to BatchGetByStateChangeIDs - Update transaction_loaders.go to pass scOpIDs to BatchGetByStateChangeIDs
- Update resolveStateChangeAccount/Operation/Transaction to accept operationID - Update all statechange resolvers to pass operationID to helper functions - Update cursor format from to_id:state_change_order to to_id:operation_id:state_change_order - Update parseStateChangeCursor to parse 3-part format
- Update statechanges_test.go: wantIDs format, verification queries, cursor tests - Update accounts_test.go: BatchGetByStateChangeIDs to use 3-part format - Update operations_test.go: BatchGetByStateChangeIDs to use 3-part format - Update transactions_test.go: BatchGetByStateChangeIDs to use 3-part format - Update test_utils.go: ToID derived from OperationID using TOID bitmask
statechanges: Remove txHash and use tx TOIDstatechanges: Remove txHash and use tx TOID to reference transactions table
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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