Skip to content

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

Merged
merged 1 commit into from
May 27, 2025

Conversation

tractorss
Copy link
Contributor

@tractorss tractorss commented May 27, 2025

PR-Codex overview

This PR updates the version in package.json and modifies the event log handling in Dispute.ts to enhance the identification of DisputeRequestSignature and CrossChainDisputeIncomingSignature events by using loops instead of findIndex.

Detailed summary

  • Updated version from 0.15.2 to 0.15.3 in subgraph/package.json.
  • Added coreDisputeId to capture the dispute ID from event parameters in Dispute.ts.
  • Replaced findIndex with loops to find indices of DisputeRequestSignature and CrossChainDisputeIncomingSignature events.
  • Improved decoding of event topics to match the coreDisputeId.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Summary by CodeRabbit

  • Bug Fixes
    • Improved event log matching for dispute requests to ensure accurate identification based on dispute ID.
  • Chores
    • Updated the package version to 0.15.3.

@tractorss tractorss requested a review from a team as a code owner May 27, 2025 00:00
Copy link
Contributor

coderabbitai bot commented May 27, 2025

Walkthrough

The update enhances the log filtering logic in the updateDisputeRequestData function to ensure event logs are matched using both event signature and dispute ID, rather than only by signature. Additionally, the package version in package.json is incremented from 0.15.2 to 0.15.3.

Changes

File(s) Change Summary
subgraph/core/src/entities/Dispute.ts Refined event log search in updateDisputeRequestData to require matching both event signature and dispute ID.
subgraph/package.json Incremented package version from 0.15.2 to 0.15.3.

Poem

A hop through logs, more careful now,
Matching IDs, not just the how.
A version bump, a tidy sweep,
Ensuring data’s filtered deep.
In code we trust, in hops we cheer,
Another change, the path is clear!
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

codeclimate bot commented May 27, 2025

Code Climate has analyzed commit f370669 and detected 6 issues on this pull request.

Here's the issue category breakdown:

Category Count
Duplication 2
Style 4

View more on Code Climate.

Copy link

netlify bot commented May 27, 2025

Deploy Preview for kleros-v2-testnet ready!

Name Link
🔨 Latest commit
🔍 Latest deploy log https://app.netlify.com/projects/kleros-v2-testnet/deploys/6835d4d20a454d6dce22458a
😎 Deploy Preview https://deploy-preview-2010--kleros-v2-testnet.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link

netlify bot commented May 27, 2025

Deploy Preview for kleros-v2-university failed. Why did it fail? →

Name Link
🔨 Latest commit f370669
🔍 Latest deploy log https://app.netlify.com/projects/kleros-v2-university/deploys/6835008efb55d90008792152

Copy link

Copy link

netlify bot commented May 27, 2025

Deploy Preview for kleros-v2-neo ready!

Name Link
🔨 Latest commit
🔍 Latest deploy log https://app.netlify.com/projects/kleros-v2-neo/deploys/683506e92c0ad7ca0898e866
😎 Deploy Preview https://deploy-preview-2010--kleros-v2-neo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

📥 Commits

Reviewing files that changed from the base of the PR and between 349783f and f370669.

📒 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.

Copy link

netlify bot commented May 27, 2025

Deploy Preview for kleros-v2-testnet-devtools ready!

Name Link
🔨 Latest commit f370669
🔍 Latest deploy log https://app.netlify.com/projects/kleros-v2-testnet-devtools/deploys/6835008ebb2968000820c482
😎 Deploy Preview https://deploy-preview-2010--kleros-v2-testnet-devtools.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@kemuru kemuru self-requested a review May 27, 2025 09:07
@jaybuidl jaybuidl merged commit 3f532d2 into dev May 27, 2025
21 of 26 checks passed
@jaybuidl jaybuidl deleted the fix/subgraph-batch-dispute-handling branch May 27, 2025 16:26
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.

3 participants