Skip to content

Universal Gated Dispute Kit and Shutter Gated Dispute Kit #2045

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 2 commits into from
Jul 19, 2025

Conversation

jaybuidl
Copy link
Member

@jaybuidl jaybuidl commented Jul 19, 2025

PR-Codex overview

This PR enhances the Kleros arbitration system by introducing new dispute kits, including DisputeKitGated and DisputeKitGatedShutter, which implement token gating for jurors using ERC-20, ERC-721, and ERC-1155 tokens. It also adds a TestERC1155 contract for testing purposes.

Detailed summary

  • Added DisputeKitGated and DisputeKitGatedShutter contracts for token gating.
  • Introduced TestERC1155 contract with minting, burning, and ownership management.
  • Updated deployTokens.ts to include deployERC1155 function.
  • Modified hardhat.config.ts to streamline account management.
  • Enhanced tests in dispute-kit-gated.ts for different token types.
  • Adjusted DisputeKitClassic to accommodate new dispute kits and events.
  • Updated event expectations in test cases to reflect new dispute kit functionalities.

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

Summary by CodeRabbit

  • New Features
    • Introduced two new dispute kits: DisputeKitGated and DisputeKitGatedShutter, offering token-gated juror selection and shielded voting.
    • Added a new proxy contract for DisputeKitGatedShutter.
    • Added a new ERC1155 test token contract and deployment utility.
  • Improvements
    • DisputeKitGated now supports dynamic, per-dispute token gating extracted from dispute data for enhanced flexibility.
    • Updated DisputeKitShutter documentation to highlight shielded voting.
    • Standardized network account configuration to use a single private key.
  • Tests
    • Added comprehensive tests covering token gating scenarios with ERC20, ERC721, and ERC1155 tokens.
    • Integrated the new dispute kits into existing test suites.

Copy link

netlify bot commented Jul 19, 2025

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

Name Link
🔨 Latest commit 3bca47c
🔍 Latest deploy log https://app.netlify.com/projects/kleros-v2-university/deploys/687be736b4b8260008dcba30

Copy link
Contributor

coderabbitai bot commented Jul 19, 2025

Walkthrough

This update refactors the DisputeKitGated contract to dynamically extract token gating parameters from dispute extraData instead of storing them, adds the DisputeKitGatedShutterProxy, updates deployment scripts and tests to support the new dispute kits, modifies the DisputeKitShutter NatSpec comment, and simplifies Arbitrum network configuration for private keys. It also introduces the new DisputeKitGatedShutter and TestERC1155 contracts and adds a utility to deploy ERC1155 tokens.

Changes

File(s) Change Summary
contracts/src/arbitration/dispute-kits/DisputeKitGated.sol Removed stored gating variables; gating info now parsed from dispute extraData; removed governance setters; added decoding func.
contracts/src/arbitration/dispute-kits/DisputeKitGatedShutter.sol Added new contract implementing shielded voting with token gating, vote commitments, and vote reveals.
contracts/src/proxy/KlerosProxies.sol Added new DisputeKitGatedShutterProxy contract inheriting from UUPSProxy.
contracts/deploy/00-home-chain-arbitration.ts Deployed and enabled DisputeKitGated and DisputeKitGatedShutter using Courts.GENERAL constant instead of hardcoded IDs.
contracts/deploy/utils/deployTokens.ts Added deployERC1155 utility function for deploying ERC1155 test tokens.
contracts/src/token/TestERC1155.sol Added new TestERC1155 contract with minting and burning controlled by owner.
contracts/test/arbitration/dispute-kit-gated.ts Added new test suite for DisputeKitGated covering token gating, staking, dispute creation, and juror drawing.
contracts/test/arbitration/index.ts Extended tests to deploy and assert on DisputeKitGated and DisputeKitGatedShutter alongside existing dispute kits.
contracts/src/arbitration/dispute-kits/DisputeKitShutter.sol Updated NatSpec comment to replace "Shutter-specific event" with "shielded voting" description.
contracts/hardhat.config.ts Simplified Arbitrum network configs to use a single private key from PRIVATE_KEY env var, removing multi-key support.
contracts/test/arbitration/draw.ts Added a blank line for formatting; no logic changes.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant KlerosCore
    participant DisputeKitGated

    User->>KlerosCore: createDispute(extraData)
    KlerosCore->>DisputeKitGated: drawJuror(juror, disputeId)
    DisputeKitGated->>DisputeKitGated: extraDataToTokenInfo(extraData)
    alt tokenGate is set
        DisputeKitGated->>Juror: checkTokenBalance(tokenGate, tokenId, isERC1155)
        alt juror passes gate
            DisputeKitGated-->>KlerosCore: juror eligible
        else juror fails gate
            DisputeKitGated-->>KlerosCore: juror ineligible
        end
    else no tokenGate
        DisputeKitGated-->>KlerosCore: juror eligible
    end
Loading

Possibly related PRs

  • DisputeKit with token gating #1804: Introduces the original DisputeKitGated contract with fixed storage gating parameters, which this PR refactors to use dynamic extraData decoding.

Suggested reviewers

  • alcercu

Poem

In the warren of smart contracts bright,
New gates for jurors come to light.
No more storage, just extraData flair—
Dynamic checks for those who dare!
With proxies and tests, the code hops on,
A rabbit’s delight—refactor done! 🐇✨

✨ 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

netlify bot commented Jul 19, 2025

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

Name Link
🔨 Latest commit 3bca47c
🔍 Latest deploy log https://app.netlify.com/projects/kleros-v2-testnet-devtools/deploys/687be736bafacc00084533ca
😎 Deploy Preview https://deploy-preview-2045--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.

Copy link

netlify bot commented Jul 19, 2025

Deploy Preview for kleros-v2-testnet ready!

Name Link
🔨 Latest commit 3bca47c
🔍 Latest deploy log https://app.netlify.com/projects/kleros-v2-testnet/deploys/687be73611d4c90008305f0d
😎 Deploy Preview https://deploy-preview-2045--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.

const arbitrationCost = await core["arbitrationCost(bytes)"](extraData);

// Warning: this dispute cannot be executed, in reality it should be created by an arbitrable contract, not an EOA.
const tx = await core["createDispute(uint256,bytes)"](2, extraData, { value: arbitrationCost }).then((tx) =>

Check notice

Code scanning / SonarCloud

Unused assignments should be removed Low test

Remove this useless assignment to variable "tx". See more on SonarQube Cloud
Copy link

netlify bot commented Jul 19, 2025

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

Name Link
🔨 Latest commit 3bca47c
🔍 Latest deploy log https://app.netlify.com/projects/kleros-v2-neo/deploys/687be736a2552f0009f0d4bf

@jaybuidl jaybuidl force-pushed the feat/universal-gated-dk branch from b1e385d to 9d19c70 Compare July 19, 2025 15:42
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

♻️ Duplicate comments (1)
contracts/test/arbitration/dispute-kit-gated.ts (1)

108-110: Remove unused variable assignment.

The variable tx is assigned but never used afterwards, as flagged by static analysis.

Apply this diff to fix the unused assignment:

-    const tx = await core["createDispute(uint256,bytes)"](2, extraData, { value: arbitrationCost }).then((tx) =>
-      tx.wait()
-    );
+    await core["createDispute(uint256,bytes)"](2, extraData, { value: arbitrationCost }).then((tx) => tx.wait());
🧹 Nitpick comments (1)
contracts/test/arbitration/dispute-kit-gated.ts (1)

127-133: Complete the test assertions.

The test case is properly structured but missing the final assertions to validate the expected behavior.

The TODO comment indicates missing expectations. Consider adding assertions to verify:

  • Jurors are drawn successfully
  • Token gating requirements are met
  • Event emissions are correct

Would you like me to help generate the missing assertions for this test?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b1e385d and 9d19c70.

📒 Files selected for processing (8)
  • contracts/deploy/00-home-chain-arbitration.ts (2 hunks)
  • contracts/hardhat.config.ts (2 hunks)
  • contracts/src/arbitration/dispute-kits/DisputeKitGated.sol (3 hunks)
  • contracts/src/arbitration/dispute-kits/DisputeKitShutter.sol (1 hunks)
  • contracts/src/proxy/KlerosProxies.sol (1 hunks)
  • contracts/test/arbitration/dispute-kit-gated.ts (1 hunks)
  • contracts/test/arbitration/draw.ts (1 hunks)
  • contracts/test/arbitration/index.ts (4 hunks)
✅ Files skipped from review due to trivial changes (1)
  • contracts/src/arbitration/dispute-kits/DisputeKitShutter.sol
🚧 Files skipped from review as they are similar to previous changes (6)
  • contracts/test/arbitration/draw.ts
  • contracts/src/proxy/KlerosProxies.sol
  • contracts/hardhat.config.ts
  • contracts/deploy/00-home-chain-arbitration.ts
  • contracts/test/arbitration/index.ts
  • contracts/src/arbitration/dispute-kits/DisputeKitGated.sol
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: tractorss
PR: kleros/kleros-v2#1982
File: web/src/pages/Resolver/Landing/index.tsx:62-62
Timestamp: 2025-05-15T06:50:40.859Z
Learning: In the Landing component, it's safe to pass `dispute?.dispute?.arbitrated.id as 0x${string}` to `usePopulatedDisputeData` without additional null checks because the hook internally handles undefined parameters through its `isEnabled` flag and won't execute the query unless all required data is available.
Learnt from: Harman-singh-waraich
PR: kleros/kleros-v2#1703
File: web/src/hooks/queries/usePopulatedDisputeData.ts:58-61
Timestamp: 2024-10-14T13:58:25.708Z
Learning: In `web/src/hooks/queries/usePopulatedDisputeData.ts`, the query and subsequent logic only execute when `disputeData.dispute?.arbitrableChainId` and `disputeData.dispute?.externalDisputeId` are defined, so `initialContext` properties based on these values are safe to use without additional null checks.
contracts/test/arbitration/dispute-kit-gated.ts (9)
Learnt from: Harman-singh-waraich
PR: kleros/kleros-v2#1703
File: web/src/hooks/queries/usePopulatedDisputeData.ts:58-61
Timestamp: 2024-10-14T13:58:25.708Z
Learning: In `web/src/hooks/queries/usePopulatedDisputeData.ts`, the query and subsequent logic only execute when `disputeData.dispute?.arbitrableChainId` and `disputeData.dispute?.externalDisputeId` are defined, so `initialContext` properties based on these values are safe to use without additional null checks.
Learnt from: Harman-singh-waraich
PR: kleros/kleros-v2#1744
File: web/src/hooks/useGenesisBlock.ts:9-31
Timestamp: 2024-11-19T05:31:48.701Z
Learning: In `useGenesisBlock.ts`, within the `useEffect` hook, the conditions (`isKlerosUniversity`, `isKlerosNeo`, `isTestnetDeployment`) are mutually exclusive, so multiple imports won't execute simultaneously, and race conditions are not a concern.
Learnt from: Harman-singh-waraich
PR: kleros/kleros-v2#1703
File: kleros-sdk/src/sdk.ts:1-3
Timestamp: 2024-10-22T10:23:15.789Z
Learning: In `kleros-sdk/src/sdk.ts`, the `PublicClient` type is used and should not be flagged as unused.
Learnt from: Harman-singh-waraich
PR: kleros/kleros-v2#1716
File: web-devtools/src/app/(main)/dispute-template/CustomContextInputs.tsx:29-42
Timestamp: 2024-10-28T05:55:12.728Z
Learning: In the `CustomContextInputs` component located at `web-devtools/src/app/(main)/dispute-template/CustomContextInputs.tsx`, the `DisputeRequestParams` array is used to exclude certain variables from the custom input since they are already provided in a preceding component. Therefore, converting it to a type is unnecessary.
Learnt from: jaybuidl
PR: kleros/kleros-v2#1647
File: web/src/context/NewDisputeContext.tsx:0-0
Timestamp: 2024-10-08T16:23:56.290Z
Learning: The `delete` operator is used in the `constructDisputeTemplate` function in `web/src/context/NewDisputeContext.tsx` to remove the `policyURI` field if it is an empty string.
Learnt from: jaybuidl
PR: kleros/kleros-v2#1647
File: web/src/context/NewDisputeContext.tsx:0-0
Timestamp: 2024-07-25T11:58:27.058Z
Learning: The `delete` operator is used in the `constructDisputeTemplate` function in `web/src/context/NewDisputeContext.tsx` to remove the `policyURI` field if it is an empty string.
Learnt from: Harman-singh-waraich
PR: kleros/kleros-v2#1755
File: kleros-app/src/lib/atlas/hooks/useSessionStorage.ts:3-12
Timestamp: 2024-11-21T05:38:11.576Z
Learning: In the `useSessionStorage` hook in `kleros-app/src/lib/atlas/hooks/useSessionStorage.ts`, the error handling in the `catch` block covers cases where `window` is undefined or `sessionStorage` throws an exception, so additional checks are unnecessary.
Learnt from: jaybuidl
PR: kleros/kleros-v2#1746
File: contracts/config/courts.v2.mainnet-neo.json:167-170
Timestamp: 2024-11-19T16:31:08.965Z
Learning: In `contracts/config/courts.v2.mainnet-neo.json`, the `minStake` parameter is denominated in PNK, not ETH.
Learnt from: tractorss
PR: kleros/kleros-v2#1982
File: web/src/pages/Resolver/Landing/index.tsx:62-62
Timestamp: 2025-05-15T06:50:40.859Z
Learning: In the Landing component, it's safe to pass `dispute?.dispute?.arbitrated.id as 0x${string}` to `usePopulatedDisputeData` without additional null checks because the hook internally handles undefined parameters through its `isEnabled` flag and won't execute the query unless all required data is available.
🪛 GitHub Check: SonarCloud
contracts/test/arbitration/dispute-kit-gated.ts

[notice] 108-108: Unused assignments should be removed

Remove this useless assignment to variable "tx".

See more on SonarQube Cloud

⏰ 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). (11)
  • GitHub Check: Redirect rules - kleros-v2-university
  • GitHub Check: Header rules - kleros-v2-university
  • GitHub Check: Pages changed - kleros-v2-university
  • GitHub Check: Redirect rules - kleros-v2-testnet
  • GitHub Check: Redirect rules - kleros-v2-testnet
  • GitHub Check: Header rules - kleros-v2-testnet
  • GitHub Check: Header rules - kleros-v2-testnet
  • GitHub Check: Pages changed - kleros-v2-testnet
  • GitHub Check: Pages changed - kleros-v2-testnet
  • GitHub Check: Analyze (javascript)
  • GitHub Check: contracts-testing
🔇 Additional comments (5)
contracts/test/arbitration/dispute-kit-gated.ts (5)

1-10: LGTM!

The imports are well-structured and appropriate for a Hardhat test suite. The ESLint disable comments are standard practice for test files.


11-47: Well-structured test setup with deterministic randomness.

The test setup properly uses deployment fixtures and implements deterministic randomness for reproducible tests. The constant definitions and contract initialization follow best practices.


49-64: Correct implementation of extraData encoding.

The function properly packs token gating parameters and encodes them according to the contract's expected format. The comments clearly explain the packing structure.


66-107: Comprehensive test helper with proper validation.

The function correctly implements the complete flow from juror staking to dispute creation, with appropriate balance checks and extraData validation.


111-125: Proper sortition phase management.

The function correctly advances blockchain time and phases to enable juror drawing. The implementation follows the expected sortition flow.

coderabbitai[bot]
coderabbitai bot previously approved these changes Jul 19, 2025
Copy link

@jaybuidl jaybuidl marked this pull request as ready for review July 19, 2025 18:44
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

♻️ Duplicate comments (1)
contracts/test/arbitration/dispute-kit-gated.ts (1)

134-134: Remove unused assignment to variable tx.

The assignment to tx is not used after this line. You can simplify this by removing the assignment.

-    const tx = await core["createDispute(uint256,bytes)"](2, extraData, { value: arbitrationCost }).then((tx) =>
-      tx.wait()
-    );
+    await core["createDispute(uint256,bytes)"](2, extraData, { value: arbitrationCost }).then((tx) => tx.wait());
🧹 Nitpick comments (3)
contracts/src/token/TestERC1155.sol (2)

19-21: Consider providing a meaningful URI for token metadata.

The constructor initializes the ERC1155 with an empty URI string. For testing purposes, consider providing a placeholder URI or documenting that metadata is not required for these tests.

-    constructor() ERC1155("") {
+    constructor() ERC1155("https://example.com/token/{id}.json") {
         owner = msg.sender;
     }

13-13: Remove unused variable.

The _nextTokenId variable is declared but never used in the contract. Consider removing it to reduce gas costs and code complexity.

-    uint256 private _nextTokenId;
contracts/deploy/utils/deployTokens.ts (1)

69-81: Remove unused parameter.

The name parameter is accepted but not used in the deployment. The TestERC1155 contract constructor doesn't take any arguments.

 export const deployERC1155 = async (
   hre: HardhatRuntimeEnvironment,
   deployer: string,
-  name: string,
   ticker: string
 ): Promise<Contract> => {
   return getContractOrDeploy(hre, ticker, {
     from: deployer,
     contract: "TestERC1155",
     args: [],
     log: true,
   });
 };
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9d19c70 and 3bca47c.

📒 Files selected for processing (4)
  • contracts/deploy/utils/deployTokens.ts (1 hunks)
  • contracts/src/arbitration/dispute-kits/DisputeKitGatedShutter.sol (1 hunks)
  • contracts/src/token/TestERC1155.sol (1 hunks)
  • contracts/test/arbitration/dispute-kit-gated.ts (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: tractorss
PR: kleros/kleros-v2#1982
File: web/src/pages/Resolver/Landing/index.tsx:62-62
Timestamp: 2025-05-15T06:50:40.859Z
Learning: In the Landing component, it's safe to pass `dispute?.dispute?.arbitrated.id as 0x${string}` to `usePopulatedDisputeData` without additional null checks because the hook internally handles undefined parameters through its `isEnabled` flag and won't execute the query unless all required data is available.
Learnt from: Harman-singh-waraich
PR: kleros/kleros-v2#1703
File: web/src/hooks/queries/usePopulatedDisputeData.ts:58-61
Timestamp: 2024-10-14T13:58:25.708Z
Learning: In `web/src/hooks/queries/usePopulatedDisputeData.ts`, the query and subsequent logic only execute when `disputeData.dispute?.arbitrableChainId` and `disputeData.dispute?.externalDisputeId` are defined, so `initialContext` properties based on these values are safe to use without additional null checks.
contracts/test/arbitration/dispute-kit-gated.ts (5)
Learnt from: Harman-singh-waraich
PR: kleros/kleros-v2#1703
File: web/src/hooks/queries/usePopulatedDisputeData.ts:58-61
Timestamp: 2024-10-14T13:58:25.708Z
Learning: In `web/src/hooks/queries/usePopulatedDisputeData.ts`, the query and subsequent logic only execute when `disputeData.dispute?.arbitrableChainId` and `disputeData.dispute?.externalDisputeId` are defined, so `initialContext` properties based on these values are safe to use without additional null checks.
Learnt from: Harman-singh-waraich
PR: kleros/kleros-v2#1744
File: web/src/hooks/useGenesisBlock.ts:9-31
Timestamp: 2024-11-19T05:31:48.701Z
Learning: In `useGenesisBlock.ts`, within the `useEffect` hook, the conditions (`isKlerosUniversity`, `isKlerosNeo`, `isTestnetDeployment`) are mutually exclusive, so multiple imports won't execute simultaneously, and race conditions are not a concern.
Learnt from: Harman-singh-waraich
PR: kleros/kleros-v2#1703
File: kleros-sdk/src/sdk.ts:1-3
Timestamp: 2024-10-22T10:23:15.789Z
Learning: In `kleros-sdk/src/sdk.ts`, the `PublicClient` type is used and should not be flagged as unused.
Learnt from: jaybuidl
PR: kleros/kleros-v2#1647
File: web/src/context/NewDisputeContext.tsx:0-0
Timestamp: 2024-10-08T16:23:56.290Z
Learning: The `delete` operator is used in the `constructDisputeTemplate` function in `web/src/context/NewDisputeContext.tsx` to remove the `policyURI` field if it is an empty string.
Learnt from: jaybuidl
PR: kleros/kleros-v2#1647
File: web/src/context/NewDisputeContext.tsx:0-0
Timestamp: 2024-07-25T11:58:27.058Z
Learning: The `delete` operator is used in the `constructDisputeTemplate` function in `web/src/context/NewDisputeContext.tsx` to remove the `policyURI` field if it is an empty string.
🧬 Code Graph Analysis (1)
contracts/deploy/utils/deployTokens.ts (1)
contracts/deploy/utils/getContractOrDeploy.ts (1)
  • getContractOrDeploy (6-20)
🪛 GitHub Check: SonarCloud
contracts/test/arbitration/dispute-kit-gated.ts

[notice] 134-134: Unused assignments should be removed

Remove this useless assignment to variable "tx".

See more on SonarQube Cloud

⏰ 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). (3)
  • GitHub Check: Redirect rules - kleros-v2-testnet
  • GitHub Check: Header rules - kleros-v2-testnet
  • GitHub Check: Pages changed - kleros-v2-testnet
🔇 Additional comments (15)
contracts/src/token/TestERC1155.sol (2)

27-30: LGTM: Secure access control implementation.

The ownerOnly modifier correctly restricts access to sensitive functions and provides clear error messaging.


44-63: LGTM: Proper delegation to OpenZeppelin's internal functions.

The mint and burn functions correctly delegate to the secure internal implementations from the base ERC1155 contract while maintaining proper access control.

contracts/test/arbitration/dispute-kit-gated.ts (5)

75-90: LGTM: Well-designed extraData encoding function.

The encodeExtraData function correctly packs the token gating parameters according to the expected format. The solidityPacked call properly handles the address and boolean flag packing.


92-151: LGTM: Comprehensive staking and drawing helper function.

The stakeAndDraw function properly simulates the complete flow of juror staking, dispute creation, phase transitions, and drawing. The use of deterministic RNG and proper event verification enhances test reliability.


153-198: LGTM: Thorough DAI token gating tests.

Both test cases properly verify the token gating logic - ensuring no jurors are drawn without DAI balance and only token holders are selected when they have balance. The verification of locked PNK amounts adds good coverage.


200-245: LGTM: Comprehensive ERC721 token gating tests.

The ERC721 tests follow the same pattern as DAI tests and properly verify token ownership requirements for juror selection.


247-292: LGTM: Complete ERC1155 token gating tests.

The ERC1155 tests properly validate token ID-specific ownership requirements, which is crucial for ERC1155 token gating functionality.

contracts/src/arbitration/dispute-kits/DisputeKitGatedShutter.sol (8)

7-21: LGTM: Well-defined interfaces for token balance checking.

The interfaces correctly define the balanceOf functions for both standard tokens (ERC-20/ERC-721) and ERC-1155 tokens, providing type safety for the gating logic.


55-65: LGTM: Proper initialization and upgradeability setup.

The constructor correctly disables initializers for the proxy pattern, and the initialize function properly calls the base class initializer with the reinitializer modifier.


90-99: LGTM: Secure shielded voting commit function.

The castCommitShutter function properly delegates to the base _castCommit and emits the appropriate event with encrypted vote data for shielded voting.


101-113: LGTM: Proper vote reveal implementation.

The castVoteShutter function correctly retrieves the juror address and delegates to the base _castVote function, maintaining the security of the reveal phase.


126-133: LGTM: Secure vote hashing implementation.

The hashVote function properly hashes the justification first, then combines all parameters using abi.encode, providing security against hash collision attacks.


152-153: Good defensive programming with length check.

The function correctly validates that _extraData has sufficient length before attempting to read from it, preventing potential out-of-bounds reads.


167-188: LGTM: Robust token gating implementation.

The _postDrawCheck function properly:

  1. Calls the parent implementation first
  2. Extracts token gating parameters from extraData
  3. Handles the case where no token gate is specified
  4. Uses appropriate interfaces for different token types

The logic correctly distinguishes between ERC-1155 and ERC-20/ERC-721 tokens.


149-164: Assembly parameter extraction is correctly guarded
The length check (_extraData.length < 160) and the use of offsets 0x80 (tokenGate / isERC1155) and 0xA0 (tokenId) match the ABI-encoded bytes layout, preventing out-of-bounds reads. No security issues detected.

• File: contracts/src/arbitration/dispute-kits/DisputeKitGatedShutter.sol
Lines: 149–164

@jaybuidl jaybuidl merged commit 358a621 into dev Jul 19, 2025
17 of 25 checks passed
@jaybuidl jaybuidl deleted the feat/universal-gated-dk branch July 19, 2025 19:58
@coderabbitai coderabbitai bot mentioned this pull request Jul 19, 2025
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.

1 participant