Skip to content

Conversation

jaybuidl
Copy link
Member

@jaybuidl jaybuidl commented Oct 8, 2025

Resolves #2168


PR-Codex overview

This PR focuses on simplifying the DisputeRequest event by removing the _externalDisputeID parameter across multiple contracts, improving code clarity and consistency while retaining the essential functionality.

Detailed summary

  • Removed _externalDisputeID from DisputeRequest in KlerosGovernor.sol, DisputeResolver.sol, DisputeResolverRuler.sol, ArbitrableExample.sol, and HomeGateway.sol.
  • Updated event signatures in IArbitrableV2.sol and IEvidence.sol to reflect the removal of _externalDisputeID.
  • Adjusted function parameters in submitEvidence to use _arbitratorDisputeID instead of _externalDisputeID.
  • Modified tests in draw.ts, ruler.ts, and index.ts to align with the new event structure and removed references to _externalDisputeID.

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

Summary by CodeRabbit

  • New Features
    • Added a Ruling event to arbitrable interfaces for clearer outcome tracking.
  • Refactor
    • Streamlined dispute-related events by removing local/external dispute IDs and standardizing on arbitrator dispute ID.
    • Simplified gateway dispute creation parameters (fewer arguments) and aligned event payloads accordingly.
  • Documentation
    • Updated parameter names and comments to reflect the new dispute ID conventions.
  • Tests
    • Adjusted test suites to match updated event shapes and simplified dispute creation inputs.

Copy link
Contributor

coderabbitai bot commented Oct 8, 2025

Walkthrough

This PR removes the external/local dispute ID from events and APIs across arbitration, evidence, and gateway contracts. Event and function parameters are updated to use the arbitrator dispute ID where applicable. Interfaces and tests are aligned with the new event shapes. A Ruling event is added to IArbitrableV2.

Changes

Cohort / File(s) Summary of changes
Interfaces
contracts/src/arbitration/interfaces/IArbitrableV2.sol, contracts/src/arbitration/interfaces/IEvidence.sol
Dropped _externalDisputeID from DisputeRequest; added Ruling event to IArbitrableV2. Renamed IEvidence.Evidence param to _arbitratorDisputeID.
Governor
contracts/src/arbitration/KlerosGovernor.sol
DisputeRequest emit shortened: removed session index/local ID; now (arbitrator, disputeID, templateId).
Arbitrables & Resolvers
contracts/src/arbitration/arbitrables/ArbitrableExample.sol, contracts/src/arbitration/arbitrables/DisputeResolver.sol, contracts/src/arbitration/devtools/DisputeResolverRuler.sol
Removed computation/use of local/external dispute IDs in DisputeRequest emits; events now (arbitrator, arbitratorDisputeID, templateId). Public event declarations updated accordingly.
Evidence Modules
contracts/src/arbitration/evidence/EvidenceModule.sol, contracts/src/arbitration/evidence/ModeratedEvidenceModule.sol
submitEvidence param renamed to _arbitratorDisputeID; emits updated. ModeratedEvidence event’s dispute ID now _arbitratorDisputeID; emits updated to use evidenceData.disputeID. Adjusted DisputeRequest emit shape.
Gateway
contracts/src/gateway/HomeGateway.sol, contracts/src/gateway/interfaces/IHomeGateway.sol
Removed externalDisputeID from DisputeRequest and CrossChainDisputeIncoming emits. RelayCreateDisputeParams struct dropped externalDisputeID. relayCreateDispute tuple arity reduced.
Tests — Arbitration
contracts/test/arbitration/draw.ts, contracts/test/arbitration/ruler.ts
Updated relayCreateDispute payload (removed one uint256). Adjusted DisputeRequest expectations to 3 args (arbitrator, disputeID, templateId).
Tests — Evidence & Integration
contracts/test/evidence/index.ts, contracts/test/integration/index.ts
Evidence assertions now use _arbitratorDisputeID. Removed expectations around external/local dispute IDs. Updated relayCreateDispute tuple and DisputeRequest arg counts.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant A as Arbitrable Contract
  participant ARB as IArbitratorV2
  participant U as User

  U->>A: createDispute(..., templateId)
  A->>ARB: createDispute(choices, extraData) [value: cost]
  ARB-->>A: returns arbitratorDisputeID
  A-->>A: update local state
  A-->>U: emit DisputeRequest(arbitrator, arbitratorDisputeID, templateId)

  U->>A: submitEvidence(arbitratorDisputeID, evidence)
  A-->>U: emit Evidence(arbitratorDisputeID, user, evidence)

  ARB-->>A: rule(disputeID, ruling)
  A-->>U: emit Ruling(arbitrator, disputeID, ruling)
Loading
sequenceDiagram
  autonumber
  participant FG as Foreign Chain Arbitrable
  participant HG as HomeGateway
  participant ARB as Home Arbitrator

  FG->>HG: relayCreateDispute(params: (blockHash, chainID, arbitrable, foreignDisputeID, templateId, choices, extraData))
  HG->>ARB: createDispute(choices, extraData) [value: cost]
  ARB-->>HG: returns disputeID
  HG-->>FG: emit CrossChainDisputeIncoming(arbitrator, foreignChainID, foreignArbitrable, foreignDisputeID, disputeID, templateId)
  HG-->>FG: emit DisputeRequest(arbitrator, disputeID, templateId)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • unknownunknown1

Poem

A nibble of code, a hop through IDs,
I dropped the extra, kept just the keys.
Evidence now follows the arbitrator’s lead—
Simple footprints for every need.
Thump-thump! Events align in time,
Fewer crumbs, a cleaner rhyme. 🐇✨

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title “Removal of externalDisputeID” directly and concisely summarizes the primary change in the pull request by highlighting the removal of the externalDisputeID parameter across the codebase without extraneous detail. It is clear and specific enough for a reviewer to understand the main focus at a glance.
Linked Issues Check ✅ Passed The changes fully implement the objectives of issue #2168 by replacing externalDisputeID with arbitratorDisputeID in IEvidence.Evidence and removing externalDisputeID from IArbitrable.DisputeRequest, and they consistently apply this removal across relevant contracts and tests.
Out of Scope Changes Check ✅ Passed All modifications in the pull request relate to removing or renaming the externalDisputeID parameter in contracts, interfaces, events, and tests, with no unrelated or out-of-scope changes introduced.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/no-external-dispute-id

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

sonarqubecloud bot commented Oct 8, 2025

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: 1

🧹 Nitpick comments (6)
contracts/test/evidence/index.ts (2)

265-268: Destructure only the emitted args (3) for DisputeRequest.

The event now emits 3 params; drop the unused fourth binding for clarity.

-      let [_arbitrator, _disputeID, _templateId, _templateUri] = getEmittedEvent("DisputeRequest", receipt).args;
+      let [_arbitrator, _disputeID, _templateId] = getEmittedEvent("DisputeRequest", receipt).args;

170-180: Rename test title to remove “external dispute id”.

Terminology drift; suggest “same evidence twice for the same evidence group ID” or similar.

contracts/src/arbitration/evidence/ModeratedEvidenceModule.sol (2)

73-84: Event rename is correct; add note about pre-dispute sentinel.

ModeratedEvidence now uses _arbitratorDisputeID. Please extend the NatSpec to state that it can be 0 when emitted before a dispute exists.


217-218: Pre-dispute emission uses 0 as _arbitratorDisputeID.

Intentional and matches tests. Consider documenting this behavior in the contract header to guide indexers/clients.

contracts/test/integration/index.ts (2)

115-115: Avoid magic number; assert with the decoded disputeId.

Use the decoded disputeId variable for robustness.

-    await expect(tx).to.emit(arbitrable, "DisputeRequest").withArgs(foreignGateway.target, 1, 0);
+    await expect(tx).to.emit(arbitrable, "DisputeRequest").withArgs(foreignGateway.target, disputeId, 0);

128-139: Strengthen the HomeGateway DisputeRequest assertion.

Currently only checks that it emits. Also validate key args to catch regressions.

-    ).to.emit(homeGateway, "DisputeRequest");
+    ).to.emit(homeGateway, "DisputeRequest")
+     // Arbitrator should be the core; other args can be matched loosely if dynamic.
+     .withArgs(core.target, anyValue, anyValue);
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e21d261 and cf59b86.

📒 Files selected for processing (14)
  • contracts/src/arbitration/KlerosGovernor.sol (1 hunks)
  • contracts/src/arbitration/arbitrables/ArbitrableExample.sol (2 hunks)
  • contracts/src/arbitration/arbitrables/DisputeResolver.sol (1 hunks)
  • contracts/src/arbitration/devtools/DisputeResolverRuler.sol (1 hunks)
  • contracts/src/arbitration/evidence/EvidenceModule.sol (1 hunks)
  • contracts/src/arbitration/evidence/ModeratedEvidenceModule.sol (3 hunks)
  • contracts/src/arbitration/interfaces/IArbitrableV2.sol (1 hunks)
  • contracts/src/arbitration/interfaces/IEvidence.sol (1 hunks)
  • contracts/src/gateway/HomeGateway.sol (2 hunks)
  • contracts/src/gateway/interfaces/IHomeGateway.sol (0 hunks)
  • contracts/test/arbitration/draw.ts (1 hunks)
  • contracts/test/arbitration/ruler.ts (3 hunks)
  • contracts/test/evidence/index.ts (2 hunks)
  • contracts/test/integration/index.ts (2 hunks)
💤 Files with no reviewable changes (1)
  • contracts/src/gateway/interfaces/IHomeGateway.sol
⏰ 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: Analyze (javascript)
  • GitHub Check: hardhat-tests
🔇 Additional comments (15)
contracts/src/arbitration/interfaces/IEvidence.sol (1)

8-11: LGTM! Parameter rename improves clarity.

The rename from _externalDisputeID to _arbitratorDisputeID accurately reflects that this is the internal arbitrator's dispute identifier, not an external/local ID. The documentation and event signature are updated consistently.

contracts/src/gateway/HomeGateway.sol (1)

194-203: Consistent event signature update in the ERC20 fee overload.

The same event signature changes are correctly applied in the ERC20 fee payment overload, maintaining consistency across both relayCreateDispute variants.

contracts/src/arbitration/KlerosGovernor.sol (1)

306-306: LGTM! Event emission updated to match the new 3-parameter signature.

The DisputeRequest event emission has been correctly updated to remove the session index parameter, aligning with the updated IArbitrableV2 interface.

contracts/test/arbitration/ruler.ts (3)

100-102: LGTM! Test expectations correctly updated.

The test correctly expects the new 3-parameter DisputeRequest event signature (arbitrator, disputeID, templateId), removing the localDisputeID parameter.


124-126: LGTM! Consistent test update.

Test expectations correctly updated to match the new event signature.


142-142: LGTM! Consistent test update.

Test expectations correctly updated to match the new event signature.

contracts/test/arbitration/draw.ts (1)

157-169: LGTM! Test updated to match the new RelayCreateDisputeParams structure.

The relayCreateDispute call has been correctly updated to use a 7-parameter tuple instead of 8, removing the externalDisputeID field. The tuple structure now matches:

  • foreignBlockHash (bytes32)
  • foreignChainID (uint256)
  • foreignArbitrable (address)
  • foreignDisputeID (uint256)
  • templateId (uint256)
  • choices (uint256)
  • extraData (bytes)
contracts/src/arbitration/arbitrables/ArbitrableExample.sol (2)

126-126: LGTM! Event emission updated to the new 3-parameter signature.

The DisputeRequest event emission has been correctly updated to emit (arbitrator, disputeID, templateId) instead of the previous 4-parameter signature.


146-146: LGTM! Consistent update in the ERC20 fee overload.

The event emission is correctly updated in the ERC20 fee payment variant as well, maintaining consistency across both createDispute overloads.

contracts/src/arbitration/devtools/DisputeResolverRuler.sol (1)

49-49: LGTM! Event emission updated correctly.

The DisputeRequest event emission has been updated to the new 3-parameter signature (arbitrator, arbitratorDisputeID, templateId), removing the localDisputeID parameter.

contracts/src/arbitration/evidence/EvidenceModule.sol (1)

61-64: LGTM! Consistent parameter rename throughout the function.

The parameter has been consistently renamed from _externalDisputeID to _arbitratorDisputeID in the documentation, function signature, and event emission, aligning with the updated IEvidence interface.

contracts/src/arbitration/arbitrables/DisputeResolver.sol (1)

137-137: DisputeRequest arity aligned; looks good.

Emission matches the updated IArbitrableV2 event (arbitrator, arbitratorDisputeID, templateId).

contracts/test/evidence/index.ts (1)

157-160: Assertion update is correct.

Using _disputeID=0 for pre-dispute ModeratedEvidence aligns with the new event semantics.

If intended, please document that pre-dispute emissions use 0 as a sentinel for _arbitratorDisputeID, so indexers don’t misinterpret it as a real dispute ID.

contracts/src/arbitration/evidence/ModeratedEvidenceModule.sol (1)

268-268: DisputeRequest emission updated; looks good.

Three-argument payload (arbitrator, disputeID, templateId) aligns with IArbitrableV2.

contracts/src/arbitration/interfaces/IArbitrableV2.sol (1)

21-21: No leftover references to externalDisputeID/evidenceGroupID or old DisputeRequest signature All tests and contracts now use the updated 3-argument event.

Copy link

netlify bot commented Oct 8, 2025

Deploy Preview for kleros-v2-testnet ready!

Name Link
🔨 Latest commit cf59b86
🔍 Latest deploy log https://app.netlify.com/projects/kleros-v2-testnet/deploys/68e6b038a6412e00089b7442
😎 Deploy Preview https://deploy-preview-2169--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.

@jaybuidl jaybuidl merged commit f70050e into dev Oct 8, 2025
10 of 12 checks passed
@jaybuidl jaybuidl deleted the feat/no-external-dispute-id branch October 8, 2025 18:53
Copy link

netlify bot commented Oct 8, 2025

Deploy Preview for kleros-v2-neo ready!

Name Link
🔨 Latest commit cf59b86
🔍 Latest deploy log https://app.netlify.com/projects/kleros-v2-neo/deploys/68e6b038a497a3000844b5b8
😎 Deploy Preview https://deploy-preview-2169--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

netlify bot commented Oct 8, 2025

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

Name Link
🔨 Latest commit cf59b86
🔍 Latest deploy log https://app.netlify.com/projects/kleros-v2-testnet-devtools/deploys/68e6b03862d4a300081181e8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove externalDisputeID as pre-dispute evidence submission is not needed anymore

1 participant