-
Notifications
You must be signed in to change notification settings - Fork 49
fix(subgraph): handle-batched-disputes-request-events #2010
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
Conversation
WalkthroughThe update enhances the log filtering logic in the Changes
Poem
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Code Climate has analyzed commit f370669 and detected 6 issues on this pull request. Here's the issue category breakdown:
View more on Code Climate. |
✅ Deploy Preview for kleros-v2-testnet ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
❌ Deploy Preview for kleros-v2-university failed. Why did it fail? →
|
|
✅ Deploy Preview for kleros-v2-neo ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
subgraph/core/src/entities/Dispute.ts (1)
67-70
: Consider extracting common dispute ID validation logic.While the current implementation is correct, there's some code duplication in the dispute ID validation logic. Consider extracting this into a helper function to improve maintainability:
+function findDisputeEventIndex( + logs: ethereum.Log[], + signature: ByteArray, + topicIndex: i32, + targetDisputeId: BigInt +): i32 { + for (let i = 0; i < logs.length; i++) { + let log = logs[i]; + if (log.topics.length > topicIndex && log.topics[0] == signature) { + let decodedId = ethereum.decode("uint256", log.topics[topicIndex]); + if (decodedId != null && targetDisputeId.equals(decodedId.toBigInt())) { + return i; + } + } + } + return -1; +}Then use it as:
- // For DisputeRequestSignature - let disputeRequestEventIndex = -1; - for (let i = 0; i < logs.length; i++) { - let log = logs[i]; - if (log.topics.length > 2 && log.topics[0] == DisputeRequestSignature) { - // 3rd indexed argument in event is _arbitratorDisputeId - let decodedId = ethereum.decode("uint256", log.topics[2]); - if (decodedId != null && coreDisputeId.equals(decodedId.toBigInt())) { - disputeRequestEventIndex = i; - break; - } - } - } + const disputeRequestEventIndex = findDisputeEventIndex(logs, DisputeRequestSignature, 2, coreDisputeId);Also applies to: 81-84
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
subgraph/core/src/entities/Dispute.ts
(1 hunks)subgraph/package.json
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
- GitHub Check: SonarCloud
- GitHub Check: contracts-testing
- GitHub Check: Analyze (javascript)
- GitHub Check: Mend Security Check
🔇 Additional comments (4)
subgraph/core/src/entities/Dispute.ts (3)
60-60
: Good addition for precise dispute matching.Storing the core dispute ID in a variable improves code readability and sets up the enhanced filtering logic that follows.
63-75
: Excellent enhancement for handling batched dispute events.The new filtering logic significantly improves precision by validating both event signature and dispute ID. This prevents issues in batched transactions where multiple dispute events might be present. The implementation correctly:
- Validates topic array length before accessing elements
- Decodes the dispute ID from the correct indexed topic (position 2)
- Performs proper null checks on decoded values
- Uses early break for efficiency
77-89
: Consistent and correct implementation for cross-chain disputes.The cross-chain dispute filtering follows the same robust pattern as the standard dispute filtering, correctly accessing the dispute ID from topic[3] (4th indexed argument) as indicated by the comment. The logic is consistent and handles the different topic index appropriately.
subgraph/package.json (1)
3-3
: Appropriate version bump for the enhancement.The patch version increment from 0.15.2 to 0.15.3 correctly follows semantic versioning for the bug fix that improves batched dispute event handling.
✅ Deploy Preview for kleros-v2-testnet-devtools ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
PR-Codex overview
This PR updates the
version
inpackage.json
and modifies the event log handling inDispute.ts
to enhance the identification ofDisputeRequestSignature
andCrossChainDisputeIncomingSignature
events by using loops instead offindIndex
.Detailed summary
version
from0.15.2
to0.15.3
insubgraph/package.json
.coreDisputeId
to capture the dispute ID from event parameters inDispute.ts
.findIndex
with loops to find indices ofDisputeRequestSignature
andCrossChainDisputeIncomingSignature
events.coreDisputeId
.Summary by CodeRabbit