chore: set up transaction input data tracking#1258
Conversation
WalkthroughAdds transaction identifier tracking: a new Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Action
participant TxCtx as TransactionContext
participant DB as Database
Client->>Action: invoke write action
Note right of TxCtx: assign `@txid` for transaction
Action->>DB: INSERT ... INTO `streams` (..., tx_id = `@txid`)
Action->>DB: INSERT ... INTO `primitive_events` (..., tx_id = `@txid`)
Action->>DB: INSERT ... INTO `taxonomies` (..., tx_id = `@txid`)
Action->>DB: INSERT ... INTO `metadata` (..., tx_id = `@txid`)
rect rgb(235,245,255)
Note right of DB: indexes on tx_id allow cross-table lookup
end
DB-->>Action: commit
Client->>DB: SELECT ... WHERE tx_id = <id>
DB-->>Client: rows from streams, primitive_events, taxonomies, metadata
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
tests/streams/attestation/attestation_request_test.go (1)
136-174: Consider renaming function to reflect the actual test scenario.The function name
runAttestationUnauthorizedBlockedsuggests authorization/role-based failure, but the test now validates insufficient balance failure for non-exempt users. This mismatch could confuse future maintainers.Consider renaming to something like
runAttestationInsufficientBalanceBlockedorrunAttestationNonExemptUserWithoutBalance:-func runAttestationUnauthorizedBlocked(t *testing.T, ctx context.Context, platform *kwilTesting.Platform, helper *AttestationTestHelper, actionName string) { - // Create a non-exempt user that does NOT have network_writer role (must pay 40 TRUF fee) +func runAttestationInsufficientBalanceBlocked(t *testing.T, ctx context.Context, platform *kwilTesting.Platform, helper *AttestationTestHelper, actionName string) { + // Create a non-exempt user without balance (cannot pay 40 TRUF fee)And update the call site on line 43:
t.Run("UnauthorizedUserBlocked", func(t *testing.T) { - runAttestationUnauthorizedBlocked(t, ctx, platform, helper, testActionName) + runAttestationInsufficientBalanceBlocked(t, ctx, platform, helper, testActionName) })
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
tests/streams/attestation/attestation_request_test.go(3 hunks)tests/streams/attestation/request_attestation_fee_test.go(5 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
tests/streams/attestation/attestation_request_test.go (1)
extensions/tn_utils/serialization.go (1)
EncodeActionArgs(45-76)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: lint
- GitHub Check: acceptance-test
🔇 Additional comments (6)
tests/streams/attestation/attestation_request_test.go (1)
137-174: Clarify the relationship between fee changes and transaction tracking.The PR title indicates "set up transaction input data tracking" and the AI summary mentions
tx_idcolumn additions, but this test file only contains updates related to non-exempt user fee enforcement. The connection between fee changes and transaction data tracking is not evident from the code or comments.Please clarify:
- Are the fee enforcement changes a prerequisite for transaction tracking functionality?
- Should this test file include validation of
tx_idpropagation in attestation requests?- Are these separate features that should be in different PRs?
tests/streams/attestation/request_attestation_fee_test.go (5)
104-104: LGTM!The comment update accurately reflects the shift from network_writer role-based exemption to non-exempt user fee enforcement.
105-135: LGTM!The test correctly validates non-exempt user fee behavior: grants 100 TRUF, requests attestation, and verifies 40 TRUF deduction. Comments accurately explain the non-exempt context.
138-157: LGTM!The test properly validates insufficient balance scenario: grants only 10 TRUF and confirms attestation fails with appropriate error message.
160-195: LGTM!The test effectively validates cumulative fee charging: 3 attestations with different time ranges correctly deduct 120 TRUF total (3 × 40). The use of varied time ranges to generate unique attestation hashes is a good testing practice.
198-277: LGTM!Both test functions are well-designed:
testAttestationLeaderReceivesFeescorrectly validates fee transfer to the block leadertestAttestationBalanceCorrectlyDeductedprovides excellent edge case coverage by testing exact balance consumption (80 TRUF for 2 attestations, then failure on 3rd)The test logic and balance arithmetic are accurate throughout.
Time Submission Status
|
resolves: https://github.com/trufnetwork/trufscan/issues/134
Summary by CodeRabbit
New Features
Tests
Chores