Skip to content
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

Court configs: new oracle court, edited spanish non-technical court #1848

Merged
merged 4 commits into from
Jan 24, 2025

Conversation

jaybuidl
Copy link
Member

@jaybuidl jaybuidl commented Jan 24, 2025

Changes

  • Breaking schema change for the policy JSON file
    • description renamed into purpose
    • summary renamed into rules
  • Policies format consistency
  • New Oracle court (KIP-72)
  • Edited the Spanish non-technical court into consumer disputes court
  • Scripts improvements
  • Styling

Before / After

image
image
image


PR-Codex overview

This PR focuses on updating court policies and configurations, enhancing styles, and modifying scripts for populating courts and policies. It introduces new courts, updates existing ones, and improves the user interface with style adjustments.

Detailed summary

  • Removed obsolete policy JSON files.
  • Updated font-weight in global-style.ts.
  • Modified court names and IDs in courts.v2.mainnet-neo.json and courts.v2.testnet.json.
  • Added new Oracle Court and updated Corte de Disputas de Consumo y Vecindad.
  • Changed jurorsForCourtJump from 30 to 31 in some courts.
  • Enhanced populatePolicyRegistry.ts to allow starting index and max courts.
  • Updated policy structure to include purpose and rules instead of description and summary.
  • Modified script for setting policy URIs to handle multiple input files.
  • Improved styles in Description.tsx for better readability.

The following files were skipped due to too many changes: contracts/config/policies.v2.mainnet-neo.json

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

Summary by CodeRabbit

  • New Features

    • Added five new courts: General Court, Curation, English Language, Corte de Disputas de Consumo y Vecindad, and Oracle Court.
    • Introduced new policy configurations for each court with detailed purpose and rules.
    • Added new scripts for populating courts and policies across different networks.
    • Introduced a new script for setting policy URIs and managing IPFS hashes.
  • Configuration Updates

    • Updated court parameters like minimum stake, juror fees, and court jump requirements.
    • Renamed existing courts and restructured policy descriptions.
    • Modified court hierarchy and added more specific court types.
  • Development Improvements

    • Enhanced court population and policy registry scripts.
    • Added flexibility for populating courts with new optional parameters.
    • Improved styling and presentation of court details.
    • Updated global styles for better readability.

Copy link
Contributor

coderabbitai bot commented Jan 24, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This pull request introduces comprehensive updates to court configurations across multiple environments (devnet, testnet, and mainnet-neo). The changes involve adding new courts like "General Court", "Curation", "English Language", "Corte de Disputas de Consumo y Vecindad", and "Oracle Court" to various JSON configuration files. The modifications include adjusting court parameters such as minimum stake, juror fees, and court jump thresholds. Additionally, the project's package scripts have been expanded to support populating these new court configurations, and related frontend components have been updated to accommodate the new court structure.

Changes

File Change Summary
contracts/config/courts.v2.*.json Added new courts: General Court, Curation, English Language, Corte de Disputas de Consumo y Vecindad, Oracle Court. Updated court parameters like minStake, feeForJuror, and jurorsForCourtJump.
contracts/config/policies.v2.*.json Restructured court descriptions, replacing description and summary with purpose and rules. Added detailed policies for new courts.
contracts/package.json Added new scripts for populating courts and policies across different environments.
contracts/scripts/populateCourts.ts Added optional start and reverse parameters for more flexible court population.
contracts/scripts/populatePolicyRegistry.ts Introduced optional start parameter for flexible policy population.
web/src/pages/Courts/CourtDetails/Description.tsx Updated interface and routing logic to match new court configuration structure.
web/src/styles/global-style.ts Changed <h2> font-weight from 400 to 600.
contracts/scripts/setPoliciesURIs.sh Introduced a new script for processing policy data and updating URIs.
contracts/config/policies.v2/Curation-Court-Policy.json Removed policy definition for the Curation Court.
contracts/config/policies.v2/English-Language-Court-Policy.json Removed policy definition for the English Language Court.
contracts/config/policies.v2/General-Court-Policy.json Removed policy document for the General Court.

Poem

🐰 Hop, hop, hooray! Courts are here to stay!
With new configs bright and bold
Disputes will now unfold
From General to Oracle's sway
Justice hops along its way! 🏛️

Possibly related PRs

Suggested Labels

Type: Feature🗿, Package: Contracts


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between e76fffc and 5af7b1b.

📒 Files selected for processing (15)
  • contracts/config/courts.v2.devnet.json (1 hunks)
  • contracts/config/courts.v2.mainnet-neo.json (2 hunks)
  • contracts/config/courts.v2.testnet.json (4 hunks)
  • contracts/config/policies.v2.devnet.json (1 hunks)
  • contracts/config/policies.v2.mainnet-neo.json (1 hunks)
  • contracts/config/policies.v2.testnet.json (1 hunks)
  • contracts/config/policies.v2/Curation-Court-Policy.json (0 hunks)
  • contracts/config/policies.v2/English-Language-Court-Policy.json (0 hunks)
  • contracts/config/policies.v2/General-Court-Policy.json (0 hunks)
  • contracts/package.json (1 hunks)
  • contracts/scripts/populateCourts.ts (4 hunks)
  • contracts/scripts/populatePolicyRegistry.ts (2 hunks)
  • contracts/scripts/setPoliciesURIs.sh (1 hunks)
  • web/src/pages/Courts/CourtDetails/Description.tsx (4 hunks)
  • web/src/styles/global-style.ts (1 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

🪧 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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. (Beta)
  • @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 Jan 24, 2025

Deploy Preview for kleros-v2-university ready!

Name Link
🔨 Latest commit 5af7b1b
🔍 Latest deploy log https://app.netlify.com/sites/kleros-v2-university/deploys/679406c5bc885a00084f7520
😎 Deploy Preview https://deploy-preview-1848--kleros-v2-university.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 site configuration.

Copy link

netlify bot commented Jan 24, 2025

Deploy Preview for kleros-v2-neo ready!

Name Link
🔨 Latest commit 5af7b1b
🔍 Latest deploy log https://app.netlify.com/sites/kleros-v2-neo/deploys/679406c5b2c5130008f99b24
😎 Deploy Preview https://deploy-preview-1848--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 site configuration.

Copy link

netlify bot commented Jan 24, 2025

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

Name Link
🔨 Latest commit 5af7b1b
🔍 Latest deploy log https://app.netlify.com/sites/kleros-v2-testnet-devtools/deploys/679406c53e415a00097fd087
😎 Deploy Preview https://deploy-preview-1848--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 site 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 (6)
contracts/scripts/populatePolicyRegistry.ts (1)

30-30: Add Parameter Validation for start

While adding an optional parameter start is a great enhancement for controlling which courts to populate, consider validating negative or out-of-bounds values more explicitly. By default, array slicing will return an empty array if start exceeds the array length, but surfacing a warning or error might preempt unintended behavior.

contracts/scripts/populateCourts.ts (2)

Line range hint 53-57: Validate Negative or Large start Values

Similar to the populate:policy-registry script, adding an optional start is beneficial. Consider explicitly warning or validating if start is negative or beyond the length of courtsV2, to prevent unintentional slices that yield no changes or partial changes.


153-162: Logging and Slicing Behavior

  1. Logging
    The log statement at line 156, “Keeping only the first X courts, starting from Y,” is a good aid. Consider adding an explicit log if no courts remain after slicing, for transparency.
  2. Reversing the Order
    Lines 159-162 properly check the reverse flag before inverting the array. This approach is clear and avoids reversing twice if reverse is false.
  3. Wait Between Calls
    The timeout uses 100ms between population calls. If usage scales or if there’s a need to minimize network overhead, you might parametrize this delay or allow skipping it in a hurry scenario.
contracts/config/policies.v2/Consumo-y-Vecindad.json (1)

1-6: Add Polish to Policy Summary

The newly introduced file thoroughly describes “Corte de Disputas de Consumo y Vecindad.” The content is clear and well-structured. However, the "summary" field is empty (line 4). Consider either removing it if not needed or adding a concise one-line summary to maintain consistency with other courts’ policies.

contracts/config/courts.v2.testnet.json (1)

19-26: Curation Court Parameter Tuning

The alpha of 3100 indicates a 31% penalty at final appeal, which is unique compared to the 50% in other courts. If that’s intentional to promote slightly more lenient or experimental curation decisions, it’s fine. Otherwise, review it for consistency.

contracts/config/policies.v2/Oracle-Court-Policy.json (1)

4-4: Consider adding guidelines for handling time-sensitive disputes.

The policy comprehensively covers various scenarios but could benefit from additional guidelines for handling time-sensitive prediction market disputes where delays in resolution could impact market outcomes.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4ed43ef and a847334.

📒 Files selected for processing (11)
  • contracts/config/courts.v2.devnet.json (3 hunks)
  • contracts/config/courts.v2.mainnet-neo.json (2 hunks)
  • contracts/config/courts.v2.testnet.json (4 hunks)
  • contracts/config/policies.v2.devnet.json (1 hunks)
  • contracts/config/policies.v2.mainnet-neo.json (1 hunks)
  • contracts/config/policies.v2.testnet.json (1 hunks)
  • contracts/config/policies.v2/Consumo-y-Vecindad.json (1 hunks)
  • contracts/config/policies.v2/Oracle-Court-Policy.json (1 hunks)
  • contracts/package.json (1 hunks)
  • contracts/scripts/populateCourts.ts (4 hunks)
  • contracts/scripts/populatePolicyRegistry.ts (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (12)
  • GitHub Check: Redirect rules - kleros-v2-testnet-devtools
  • GitHub Check: Redirect rules - kleros-v2-neo
  • GitHub Check: Header rules - kleros-v2-testnet-devtools
  • GitHub Check: Header rules - kleros-v2-neo
  • GitHub Check: Pages changed - kleros-v2-testnet-devtools
  • GitHub Check: Pages changed - kleros-v2-neo
  • GitHub Check: Redirect rules - kleros-v2-university
  • GitHub Check: Header rules - kleros-v2-university
  • GitHub Check: Pages changed - kleros-v2-university
  • GitHub Check: contracts-testing
  • GitHub Check: Analyze (javascript)
  • GitHub Check: dependency-review
🔇 Additional comments (24)
contracts/scripts/populatePolicyRegistry.ts (1)

98-102: Confirm Edge Cases for Array Slicing

The slicing logic correctly adjusts the slice range based on start and maxNumberOfCourts. However, consider the following edge cases:
• If start is larger than policiesV2.length, the resulting slice will be empty.
• If maxNumberOfCourts is negative (accidentally or otherwise), the calculation for end might be less than start.

Although JavaScript handles these gracefully by returning an empty slice, logging a notice when no policies are sliced could help retain clarity and prevent silent no-ops.

contracts/scripts/populateCourts.ts (2)

65-65: Ensure Reversed Population Won’t Break Parent-Child References

The reverse flag is a handy way to modify courts in descending order of IDs. However, creating or updating a child court before its parent exists might cause problems if the parent is not yet recognized on-chain. Double-check that all parent courts (like court ID 1) have been created before child courts are processed in reverse.


138-138: Directly Assigning courtsV2ArbitrumDevnet

Previously, courtsV2ArbitrumDevnet was transformed via parametersProductionToDev, but now you’re assigning it directly. Ensure that any environment-specific parameter overrides (e.g., for a dev environment) are intentionally not required in this new approach.

contracts/config/courts.v2.testnet.json (4)

Line range hint 3-17: Check High minStake and jurorsForCourtJump for General Court

The “General Court” has a relatively high minStake (150 ETH) and a large jurorsForCourtJump (511). Ensure this aligns with your testnet usage scenarios, especially if the main goal is to allow easier or more frequent testing of stake thresholds.


Line range hint 35-48: English Language Court Parameters

This configuration largely mirrors other specialized courts. The hiddenVotes flag is set to false, consistent with the notion of transparent deliberations in a language-specific context. No issues here.


49-65: Introducing “Corte de Disputas de Consumo y Vecindad”

Confirmed alignment with the newly added policy file. The parameters (alpha, minStake, feeForJuror, jurorsForCourtJump: 63) match the moderate-complexity usage described in the policy. Looks good.


66-80: Oracle Court as a Specialized Tier

The “Oracle Court” (ID 5) uses the same minStake as neighboring courts, but with a smaller jurorsForCourtJump: 31. Consider verifying that 31 jurors is sufficient to handle the advanced oracles-based context.

contracts/config/courts.v2.devnet.json (3)

7-7: Verify the significant reductions in minStake and feeForJuror values.

The minStake and feeForJuror values have been significantly reduced across multiple courts:

  • General Court: ~99.7% reduction in minStake, ~99.9% reduction in feeForJuror
  • Curation: ~99.6% reduction in minStake, ~99.9% reduction in feeForJuror
  • English Language: ~99.8% reduction in minStake, ~99.9% reduction in feeForJuror

These substantial reductions could significantly impact the court's economics and security. Please confirm if these reductions are intentional and have been properly analyzed for their impact on:

  1. Court security (lower stakes might increase vulnerability to attacks)
  2. Juror incentives (lower fees might reduce participation)
  3. Economic sustainability of the courts

Also applies to: 9-9, 23-23, 25-25, 39-39, 41-41


51-64: Review configuration for the new Spanish non-technical court.

The configuration for "Corte de Disputas de Consumo y Vecindad" looks reasonable with:

  • Appropriate parent court (General Court)
  • Standard minStake and feeForJuror values
  • Reasonable timesPerPeriod values for a consumer disputes court

67-80: Review configuration for the new Oracle court (KIP-72).

The configuration for "Oracle Court" looks reasonable with:

  • Appropriate parent court (General Court)
  • Standard minStake and feeForJuror values
  • Reasonable timesPerPeriod values for real-world event reporting
contracts/package.json (1)

55-60: LGTM! New scripts for court and policy population.

The added scripts follow consistent naming and implementation patterns for different networks:

  • populate:courts:* for court population
  • populate:policies:* for policy registry population
contracts/config/policies.v2/Oracle-Court-Policy.json (2)

2-3: LGTM! Clear court purpose definition.

The court purpose is well-defined and focused on real-world event reporting.


5-5: LGTM! Clear required skills definition.

The required skills are well-defined and appropriate for the court's purpose.

contracts/config/courts.v2.mainnet-neo.json (2)

Line range hint 451-465: LGTM! Renamed Spanish non-technical court.

The court name change from "Blockchain No Técnica" to "Corte de Disputas de Consumo y Vecindad" better reflects its purpose while maintaining its configuration.


467-480: LGTM! New Oracle court configuration.

The Oracle Court configuration is consistent with other environments and has appropriate values for mainnet:

  • Higher minStake (5000000000000000000000) for increased security
  • Standard feeForJuror (6900000000000000) for juror incentivization
  • Reasonable timesPerPeriod values for real-world event reporting
contracts/config/policies.v2.devnet.json (3)

11-11: LGTM! Improved court descriptions.

The descriptions for Curation and English Language courts have been improved:

  • Removed unnecessary line breaks
  • Added clearer guidelines for content disputes

Also applies to: 19-22


26-31: LGTM! Clear policy for Spanish non-technical court.

The policy for "Corte de Disputas de Consumo y Vecindad" is well-defined with:

  • Clear scope and purpose
  • Appropriate required skills
  • Relevant external resources

34-39: LGTM! Comprehensive Oracle court policy.

The Oracle Court policy is thorough and well-structured with:

  • Clear purpose and scope
  • Detailed arbitration guidelines
  • Appropriate required skills
contracts/config/policies.v2.testnet.json (4)

11-11: LGTM!

The formatting change to the description maintains the same semantic meaning.


19-19: LGTM! Clear policies added.

The added summary section improves clarity by specifying:

  • How to handle large content disputes (>10,000 words)
  • Policy on accepting different English variations

26-31: LGTM! Well-defined scope for Spanish civil disputes court.

The new court configuration is comprehensive with:

  • Clear purpose for handling civil and commercial disputes
  • Specific scope including consumer protection
  • Well-defined required skills
✅ Verification successful

IPFS URI verification successful - content matches policy configuration

The IPFS content at QmVnqEpQpAeYvdfuPjxnGEvZG7ui7kFz6hhaskpNRgpjk1 is accessible and contains the exact policy data as configured in the JSON file.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify the IPFS URI is accessible and contains the correct policy
curl -s "https://ipfs.io/ipfs/QmVnqEpQpAeYvdfuPjxnGEvZG7ui7kFz6hhaskpNRgpjk1"

Length of output: 1013


34-39: LGTM! Comprehensive Oracle court configuration.

The new Oracle court is well-defined with:

  • Clear purpose for real-world event reporting
  • Detailed policies for prediction market disputes
  • Specific guidelines for handling edge cases
  • Appropriate required skills for jurors
✅ Verification successful

IPFS content verification successful

The IPFS URI is accessible and its content exactly matches the Oracle Court configuration in the PR.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify the IPFS URI is accessible and contains the correct policy
curl -s "https://ipfs.io/ipfs/QmRNKyST212j2DLLkA7WDBDH65tcGAVxiTkJ54LsZkVat7"

Length of output: 8505

contracts/config/policies.v2.mainnet-neo.json (2)

224-229: LGTM! Consistent with testnet configuration.

The Spanish civil disputes court configuration maintains parity with the testnet version, successfully replacing the previous "Blockchain No Técnica" court.


232-237: LGTM! Consistent with testnet configuration.

The Oracle court configuration maintains parity with the testnet version, ensuring consistent behavior across networks.

coderabbitai[bot]
coderabbitai bot previously approved these changes Jan 24, 2025
Copy link

netlify bot commented Jan 24, 2025

Deploy Preview for kleros-v2-testnet ready!

Name Link
🔨 Latest commit 5af7b1b
🔍 Latest deploy log https://app.netlify.com/sites/kleros-v2-testnet/deploys/679406c58a17510008392ac6
😎 Deploy Preview https://deploy-preview-1848--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 site configuration.

coderabbitai[bot]
coderabbitai bot previously approved these changes Jan 24, 2025
@jaybuidl jaybuidl marked this pull request as ready for review January 24, 2025 21:23
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.

Caution

Inline review comments failed to post. This is likely due to GitHub's limits when posting large numbers of comments.

Actionable comments posted: 3

🧹 Nitpick comments (4)
contracts/scripts/setPoliciesURIs.sh (2)

3-7: Enhance input validation.

Consider adding these validations before processing:

  • Check if input files exist
  • Verify read/write permissions on input files
 if [ "$#" -lt 1 ]; then
     echo "Usage: $0 <input_policies_file1> [input_policies_file2 ...]"
     exit 1
 fi
+
+# Validate file existence and permissions
+for file in "$@"; do
+    if [ ! -f "$file" ]; then
+        echo "Error: File $file does not exist"
+        exit 1
+    fi
+    if [ ! -r "$file" ] || [ ! -w "$file" ]; then
+        echo "Error: Insufficient permissions for $file"
+        exit 1
+    fi
+done

1-2: Add comprehensive documentation.

Please add a documentation header that includes:

  1. Script purpose and functionality
  2. Prerequisites (IPFS daemon, jq)
  3. Usage examples
  4. Error handling behavior
 #!/bin/bash
 
+# setPoliciesURIs.sh
+#
+# Description:
+#   Updates policy JSON files with IPFS URIs for court configurations.
+#
+# Prerequisites:
+#   - IPFS daemon must be running
+#   - jq must be installed
+#
+# Usage:
+#   ./setPoliciesURIs.sh <input_policies_file1> [input_policies_file2 ...]
+#
+# Example:
+#   ./setPoliciesURIs.sh config/policies.v2.devnet.json
+#
+# Error Handling:
+#   - Creates backups before modifications
+#   - Validates JSON structure
+#   - Cleans up temporary files on failure
contracts/config/policies.v2.mainnet-neo.json (2)

231-237: Enhance readability of Oracle Court rules.

The Oracle Court configuration is comprehensive and well-structured. Consider the following improvements:

  1. Format examples consistently using markdown blockquotes for better readability
  2. Update examples to use more recent or future dates to avoid confusion (e.g., replace "2020 US presidential election" with "2024 US presidential election")

Apply this diff to improve example formatting:

     "rules": "The following rules are subsidiary and will apply only if no contrary provisions are outlined in the primary document or other rules or sources relevant to resolving the specific question. In such cases, jurors should adhere to these standard guidelines for resolution.\n### Refuse to Arbitrate\n\nThe following questions must resolve as \"Refuse to Arbitrate\":\n\n**1. Invalid answers:** Questions in which none of the answers are valid.\n\n
-*Refuse to Arbitrate: A Prediction Market question: \"Which movie will win the Best Picture award at the 2024 Oscars Academy Awards?\" with outcomes \"Barbie\" and \"Poor Things\" (the actual winner was \"Oppenheimer\").*\n\n
+> *Refuse to Arbitrate: A Prediction Market question: \"Which movie will win the Best Picture award at the 2024 Oscars Academy Awards?\" with outcomes \"Barbie\" and \"Poor Things\" (the actual winner was \"Oppenheimer\").*\n\n

234-234: Update examples to use more recent or future dates.

Several examples reference past events from 2020-2021. Consider updating these to use more recent or future dates to maintain relevance.

Examples to update:

  • "2020 US presidential election" → "2024 US presidential election"
  • "Copa America 2021" → "Copa America 2024"
  • "2021 Turing award" → "2024 Turing award"
🛑 Comments failed to post (3)
contracts/scripts/setPoliciesURIs.sh (3)

61-68: 🛠️ Refactor suggestion

Improve file update safety measures.

Add safeguards for file modifications:

  1. Create backup before modification
  2. Validate updated JSON structure
  3. Verify successful updates
 # Step 2: Update the input file with URIs
 echo "Updating URIs in $INPUT_FILE..."
+
+# Create backup
+cp "$INPUT_FILE" "${INPUT_FILE}.bak" || {
+    echo "Error: Failed to create backup"
+    cleanup
+}
+
 jq --slurpfile hashes "$HASHES_FILE" '
     map(. + {uri: ("/ipfs/" + ($hashes[0][.court | tostring]))})
-' "$INPUT_FILE" > "${INPUT_FILE}.tmp" && mv "${INPUT_FILE}.tmp" "$INPUT_FILE"
+' "$INPUT_FILE" > "${INPUT_FILE}.tmp" || {
+    echo "Error: Failed to update URIs"
+    mv "${INPUT_FILE}.bak" "$INPUT_FILE"
+    cleanup
+}
+
+# Validate updated JSON
+if ! jq empty "${INPUT_FILE}.tmp" 2>/dev/null; then
+    echo "Error: Invalid JSON after update"
+    mv "${INPUT_FILE}.bak" "$INPUT_FILE"
+    rm "${INPUT_FILE}.tmp"
+    cleanup
+fi
+
+mv "${INPUT_FILE}.tmp" "$INPUT_FILE"
 
 rm "$HASHES_FILE"
+rm "${INPUT_FILE}.bak"
 echo "Done! URIs updated in $INPUT_FILE"

Committable suggestion skipped: line range outside the PR's diff.


19-25: 🛠️ Refactor suggestion

Add error handling and cleanup mechanisms.

Several improvements needed for robustness:

  1. Handle directory creation failures
  2. Add cleanup on script interruption
  3. Sanitize directory path construction
+# Cleanup function
+cleanup() {
+    [ -f "$HASHES_FILE" ] && rm "$HASHES_FILE"
+    exit 1
+}
+
+# Set trap for cleanup
+trap cleanup INT TERM
+
 SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
-INPUT_FILE_WITHOUT_EXTENSION="${INPUT_FILE%.json}"
+# Sanitize input file name for directory creation
+INPUT_FILE_WITHOUT_EXTENSION=$(basename "${INPUT_FILE%.json}" | tr -cd '[:alnum:]-_')
 POLICIES_DIR="$SCRIPT_DIR/../$INPUT_FILE_WITHOUT_EXTENSION"
 HASHES_FILE=$(mktemp)
 
 echo "Creating $POLICIES_DIR directory..."
-mkdir -p $POLICIES_DIR
+mkdir -p "$POLICIES_DIR" || {
+    echo "Error: Failed to create directory $POLICIES_DIR"
+    cleanup
+}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

# Cleanup function
cleanup() {
    [ -f "$HASHES_FILE" ] && rm "$HASHES_FILE"
    exit 1
}

# Set trap for cleanup
trap cleanup INT TERM

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
# Sanitize input file name for directory creation
INPUT_FILE_WITHOUT_EXTENSION=$(basename "${INPUT_FILE%.json}" | tr -cd '[:alnum:]-_')
POLICIES_DIR="$SCRIPT_DIR/../$INPUT_FILE_WITHOUT_EXTENSION"
HASHES_FILE=$(mktemp)

echo "Creating $POLICIES_DIR directory..."
mkdir -p "$POLICIES_DIR" || {
    echo "Error: Failed to create directory $POLICIES_DIR"
    cleanup
}

32-57: ⚠️ Potential issue

Add IPFS availability check and improve error handling.

Critical improvements needed for security and reliability:

  1. Validate IPFS daemon availability
  2. Add error handling for JSON operations
  3. Prevent race conditions
  4. Validate policy content structure
+# Check IPFS daemon
+if ! ipfs swarm peers >/dev/null 2>&1; then
+    echo "Error: IPFS daemon is not running"
+    cleanup
+fi
+
+# Validate policy structure
+if ! jq -e 'all(has("name") and has("court"))' "$INPUT_FILE" >/dev/null 2>&1; then
+    echo "Error: Invalid policy structure in $INPUT_FILE"
+    cleanup
+fi
+
 jq -c '.[]' "$INPUT_FILE" | while read -r policy; do
-    name=$(echo "$policy" | jq -r '.name' | tr ' ' '-')
-    court=$(echo "$policy" | jq -r '.court')
+    # Extract and validate required fields
+    name=$(echo "$policy" | jq -r '.name // empty' | tr ' ' '-')
+    court=$(echo "$policy" | jq -r '.court // empty')
+    if [ -z "$name" ] || [ -z "$court" ]; then
+        echo "Error: Missing required fields in policy"
+        continue
+    fi
+
     policy_filepath="$POLICIES_DIR/${name}-Policy.json"
 
     # Remove the uri field if it exists and save to a temporary file
-    echo "$policy" | jq 'del(.uri)' > "$policy_filepath"
+    if ! echo "$policy" | jq 'del(.uri)' > "$policy_filepath"; then
+        echo "Error: Failed to process policy JSON"
+        continue
+    fi
     
     # Get IPFS hash
-    ipfs_hash=$(ipfs add -Q "$policy_filepath")
+    ipfs_hash=$(ipfs add --offline -Q "$policy_filepath")
     if [ -n "$ipfs_hash" ]; then
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

    # Check IPFS daemon
    if ! ipfs swarm peers >/dev/null 2>&1; then
        echo "Error: IPFS daemon is not running"
        cleanup
    fi

    # Validate policy structure
    if ! jq -e 'all(has("name") and has("court"))' "$INPUT_FILE" >/dev/null 2>&1; then
        echo "Error: Invalid policy structure in $INPUT_FILE"
        cleanup
    fi

    jq -c '.[]' "$INPUT_FILE" | while read -r policy; do
        # Extract and validate required fields
        name=$(echo "$policy" | jq -r '.name // empty' | tr ' ' '-')
        court=$(echo "$policy" | jq -r '.court // empty')
        if [ -z "$name" ] || [ -z "$court" ]; then
            echo "Error: Missing required fields in policy"
            continue
        fi

        policy_filepath="$POLICIES_DIR/${name}-Policy.json"

        # Remove the uri field if it exists and save to a temporary file
        if ! echo "$policy" | jq 'del(.uri)' > "$policy_filepath"; then
            echo "Error: Failed to process policy JSON"
            continue
        fi
        
        # Get IPFS hash
        ipfs_hash=$(ipfs add --offline -Q "$policy_filepath")
        if [ -n "$ipfs_hash" ]; then
            echo "Preparing $name Court ($court): ${name}-Policy.json"
            # Add comma for all but the first entry
            if [ "$first" = true ]; then
                first=false
            else
                echo "," >> "$HASHES_FILE"
            fi
            # Store the hash with court as key
            echo "\"$court\": \"$ipfs_hash\"" >> "$HASHES_FILE"
        else
            echo "Failed to get IPFS hash for ${name}-Policy.json"
            rm "$HASHES_FILE"
            continue 2
        fi
    done

Copy link

codeclimate bot commented Jan 24, 2025

Code Climate has analyzed commit 5af7b1b and detected 3 issues on this pull request.

Here's the issue category breakdown:

Category Count
Complexity 1
Duplication 2

View more on Code Climate.

@jaybuidl jaybuidl merged commit e1a8571 into dev Jan 24, 2025
22 of 26 checks passed
@jaybuidl jaybuidl deleted the feat/court-configs branch January 24, 2025 21:37
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: 3

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between e76fffc and ad79247.

📒 Files selected for processing (15)
  • contracts/config/courts.v2.devnet.json (3 hunks)
  • contracts/config/courts.v2.mainnet-neo.json (2 hunks)
  • contracts/config/courts.v2.testnet.json (4 hunks)
  • contracts/config/policies.v2.devnet.json (1 hunks)
  • contracts/config/policies.v2.mainnet-neo.json (1 hunks)
  • contracts/config/policies.v2.testnet.json (1 hunks)
  • contracts/config/policies.v2/Curation-Court-Policy.json (0 hunks)
  • contracts/config/policies.v2/English-Language-Court-Policy.json (0 hunks)
  • contracts/config/policies.v2/General-Court-Policy.json (0 hunks)
  • contracts/package.json (1 hunks)
  • contracts/scripts/populateCourts.ts (4 hunks)
  • contracts/scripts/populatePolicyRegistry.ts (2 hunks)
  • contracts/scripts/setPoliciesURIs.sh (1 hunks)
  • web/src/pages/Courts/CourtDetails/Description.tsx (4 hunks)
  • web/src/styles/global-style.ts (1 hunks)
💤 Files with no reviewable changes (3)
  • contracts/config/policies.v2/Curation-Court-Policy.json
  • contracts/config/policies.v2/General-Court-Policy.json
  • contracts/config/policies.v2/English-Language-Court-Policy.json
🚧 Files skipped from review as they are similar to previous changes (6)
  • web/src/styles/global-style.ts
  • contracts/config/courts.v2.mainnet-neo.json
  • contracts/scripts/setPoliciesURIs.sh
  • contracts/config/courts.v2.testnet.json
  • contracts/package.json
  • contracts/config/courts.v2.devnet.json
⏰ Context from checks skipped due to timeout of 90000ms (13)
  • 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: Redirect rules - kleros-v2-neo
  • GitHub Check: Header rules - kleros-v2-neo
  • GitHub Check: Pages changed - kleros-v2-neo
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (15)
web/src/pages/Courts/CourtDetails/Description.tsx (4)

25-50: Well-structured styling improvements!

The added styles establish a clear visual hierarchy and improve readability through consistent spacing and typography.


65-67: LGTM: Interface updated to match new policy structure.

The interface changes correctly reflect the migration from description/summary to purpose/rules fields.


75-75: LGTM: Tab visibility logic updated.

The visibility checks are correctly updated to use the new purpose and rules fields.

Also applies to: 87-87


118-120: LGTM: Routes updated to use new field names.

The route elements correctly use the new purpose and rules fields.

contracts/scripts/populatePolicyRegistry.ts (2)

30-30: LGTM: Added flexible court population control.

The start parameter allows for more granular control over court population.


98-102: LGTM: Slicing logic properly handles start parameter.

The implementation correctly:

  • Adds a warning about index shifting
  • Calculates the end index based on start and maxNumberOfCourts
  • Updates the log message to reflect the new parameters
contracts/scripts/populateCourts.ts (3)

53-53: LGTM: Enhanced court population control.

Added useful parameters:

  • start: For granular control over which courts to populate
  • reverse: For controlling population order, particularly useful for minStake updates

Also applies to: 65-65


138-138: LGTM: Simplified devnet court assignment.

Removed unnecessary transformation for devnet courts.


153-162: LGTM: Proper implementation of court selection and ordering.

The implementation correctly:

  • Handles court slicing with start parameter
  • Implements reverse functionality for ordered updates
  • Includes clear warning about index shifting
contracts/config/policies.v2.devnet.json (3)

4-7: LGTM: Existing courts updated to new structure.

The changes correctly:

  • Replace description with purpose
  • Replace summary with rules
  • Update URIs accordingly

Also applies to: 11-15, 19-23


26-32: LGTM: Spanish court properly configured.

The "Corte de Disputas de Consumo y Vecindad" court is well-defined with appropriate:

  • Purpose in Spanish
  • Required skills including consumer rights knowledge
  • Proper court ID and URI

34-39: LGTM: Oracle court properly configured.

The Oracle court implementation is comprehensive with:

  • Clear purpose for real-world event resolution
  • Detailed rules for handling prediction market cases
  • Well-defined required skills
  • Proper court ID and URI
contracts/config/policies.v2.testnet.json (1)

1-39: LGTM: Testnet policies mirror devnet configuration.

The changes maintain consistency with devnet, ensuring uniform court structure across environments.

contracts/config/policies.v2.mainnet-neo.json (2)

231-237: Excellent implementation of the Oracle court!

The Oracle court implementation is comprehensive and well-structured:

  • Clear purpose definition
  • Detailed rules with examples
  • Edge cases covered (invalid answers, multiple outcomes, prohibited questions)
  • Well-defined required skills

7-7: Verify accessibility and content of IPFS URIs.

Each court references an IPFS URI. These URIs should be verified to ensure:

  1. They are accessible
  2. Their content is consistent with the policy file

Also applies to: 14-14, 22-22, 29-29, 37-37, 45-45, 53-53, 61-61, 69-69, 77-77, 85-85, 93-93, 101-101, 109-109, 117-117, 125-125, 133-133, 141-141, 149-149, 157-157, 165-165, 173-173, 181-181, 189-189, 197-197, 205-205, 213-213, 221-221, 229-229, 237-237

✅ Verification successful

All IPFS URIs are accessible and contain valid content

All 30 IPFS URIs were successfully verified:

  • Each URI is accessible through the IPFS gateway
  • Content structure matches the policy file format
  • Content is consistent with the corresponding court entries
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify IPFS URIs are accessible and contain valid content

# Extract all IPFS URIs
echo "Checking IPFS URIs..."
grep -o '/ipfs/[a-zA-Z0-9]*' contracts/config/policies.v2.mainnet-neo.json | while read -r uri; do
  echo "Verifying $uri"
  # Try to fetch the content
  curl -s "https://ipfs.io$uri" > /dev/null
  if [ $? -eq 0 ]; then
    echo "✓ URI is accessible"
  else
    echo "✗ Failed to access $uri"
  fi
done

Length of output: 9257


Script:

#!/bin/bash
# Description: Fetch and examine content from IPFS URIs

# Extract first URI to check its content structure
FIRST_URI=$(grep -o '/ipfs/[a-zA-Z0-9]*' contracts/config/policies.v2.mainnet-neo.json | head -n 1)
echo "Examining content from $FIRST_URI..."
curl -s "https://ipfs.io$FIRST_URI" | jq '.'

# Get the policy file content for comparison
echo -e "\nComparing with policy file structure..."
cat contracts/config/policies.v2.mainnet-neo.json | jq '.'

Length of output: 45621

Comment on lines +105 to +106
"purpose": "In this subcourt, jurors will solve disputes involving quality of written content. This includes grammar and text logic.\n### Example\nContractor utilizes poor grammar in a sponsored article which doesn’t meet the standards as agreed in the contract.",
"rules": "- If the disputed content is of significant size (> 10 000 words), parties in the dispute should point out to specific parts of the content which are being disputed. Otherwise, jurors should refuse to arbitrate.\n- All variations of English (UK, US, Australia, etc) are to accepted unless a target audience is specifically mentioned in the contract. ",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Refactor translation courts to use correct examples and specific rules.

The purpose and rules sections are incorrectly copy-pasted from the English Language court. They should be updated to include translation-specific examples and rules.

For each translation court, update the purpose section to include translation-specific examples:

-"purpose": "In this subcourt, jurors will solve disputes involving quality of written content. This includes grammar and text logic.\n### Example\nContractor utilizes poor grammar in a sponsored article which doesn't meet the standards as agreed in the contract.",
+"purpose": "In this subcourt, jurors will solve disputes involving the quality of translations between [Language] and English.\n### Example\nA translation fails to accurately convey the meaning of technical terms in a whitepaper translation.",

And update the rules to be translation-specific:

-"rules": "- If the disputed content is of significant size (> 10 000 words), parties in the dispute should point out to specific parts of the content which are being disputed. Otherwise, jurors should refuse to arbitrate.\n- All variations of English (UK, US, Australia, etc) are to accepted unless a target audience is specifically mentioned in the contract. ",
+"rules": "- If the disputed translation is of significant size (> 10,000 words), parties must highlight specific passages that are being disputed.\n- Cultural context and idiomatic expressions should be appropriately adapted while maintaining the original meaning.\n- Technical terminology should be consistently translated using industry-standard terms.",

Also applies to: 113-114, 121-122, 129-130, 137-138, 145-146, 153-154, 161-162, 169-170

Comment on lines +81 to +82
"purpose": "",
"rules": "",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Complete missing purpose and rules fields.

The following courts have empty fields that should be completed to ensure clear guidance for jurors:

  • Data Analysis: missing purpose and rules
  • Statistical Modeling: missing purpose and rules
  • Curation (Medium): missing rules

Would you like me to help draft the missing content for these courts?

Also applies to: 89-90, 98-98

Comment on lines +224 to +229
"name": "Corte de Disputas de Consumo y Vecindad",
"purpose": "Esta corte está destinada a resolver una amplia variedad de disputas de complejidad baja a moderada, principalmente de carácter civil y comercial. La misma actúa como tribunal subsidiario para los casos en los que no exista otra corte más especializada o aplicable. Su alcance incluye, pero no se limita a:\n- Conflictos contractuales.\n- Reclamos por daños y perjuicios.\n- Reclamos de defensa del consumidor entre usuarios y empresas.",
"rules": "",
"requiredSkills": "- Familiaridad con los [derechos básicos del consumidor](https://buenosaires.gob.ar/principales-derechos-de-los-consumidores).\n- Comprensión de las prácticas comunes en entornos digitales y descentralizados.\n- Capacidad para evaluar de manera crítica y objetiva la autenticidad y relevancia de las pruebas presentadas.",
"court": 29,
"uri": "/ipfs/QmVxh7KmFrimGz6WMvLMRXZhwQFDoj28KEYLTpYoUTGwAj/xDai-Blockchain-No-Tecnica-Policy.json"
"uri": "/ipfs/Qmczrn2DgdKGnacdvKRYwCk7JkeyTCokdqQycWdetYrxGC"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add rules for the consumer disputes court.

The rules field is empty for "Corte de Disputas de Consumo y Vecindad". Consider adding specific guidelines for handling consumer and neighborhood disputes.

Add rules to guide jurors in handling these specific types of disputes:

-"rules": "",
+"rules": "- Los jurados deben considerar la legislación local de protección al consumidor como referencia.\n- En casos de disputas vecinales, se debe priorizar soluciones que mantengan la convivencia.\n- Para reclamos de daños, se requiere evidencia clara del perjuicio causado.\n- Los jurados deben verificar que las pruebas presentadas sean contemporáneas a los hechos reclamados.",
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"name": "Corte de Disputas de Consumo y Vecindad",
"purpose": "Esta corte está destinada a resolver una amplia variedad de disputas de complejidad baja a moderada, principalmente de carácter civil y comercial. La misma actúa como tribunal subsidiario para los casos en los que no exista otra corte más especializada o aplicable. Su alcance incluye, pero no se limita a:\n- Conflictos contractuales.\n- Reclamos por daños y perjuicios.\n- Reclamos de defensa del consumidor entre usuarios y empresas.",
"rules": "",
"requiredSkills": "- Familiaridad con los [derechos básicos del consumidor](https://buenosaires.gob.ar/principales-derechos-de-los-consumidores).\n- Comprensión de las prácticas comunes en entornos digitales y descentralizados.\n- Capacidad para evaluar de manera crítica y objetiva la autenticidad y relevancia de las pruebas presentadas.",
"court": 29,
"uri": "/ipfs/QmVxh7KmFrimGz6WMvLMRXZhwQFDoj28KEYLTpYoUTGwAj/xDai-Blockchain-No-Tecnica-Policy.json"
"uri": "/ipfs/Qmczrn2DgdKGnacdvKRYwCk7JkeyTCokdqQycWdetYrxGC"
"name": "Corte de Disputas de Consumo y Vecindad",
"purpose": "Esta corte está destinada a resolver una amplia variedad de disputas de complejidad baja a moderada, principalmente de carácter civil y comercial. La misma actúa como tribunal subsidiario para los casos en los que no exista otra corte más especializada o aplicable. Su alcance incluye, pero no se limita a:\n- Conflictos contractuales.\n- Reclamos por daños y perjuicios.\n- Reclamos de defensa del consumidor entre usuarios y empresas.",
"rules": "- Los jurados deben considerar la legislación local de protección al consumidor como referencia.\n- En casos de disputas vecinales, se debe priorizar soluciones que mantengan la convivencia.\n- Para reclamos de daños, se requiere evidencia clara del perjuicio causado.\n- Los jurados deben verificar que las pruebas presentadas sean contemporáneas a los hechos reclamados.",
"requiredSkills": "- Familiaridad con los [derechos básicos del consumidor](https://buenosaires.gob.ar/principales-derechos-de-los-consumidores).\n- Comprensión de las prácticas comunes en entornos digitales y descentralizados.\n- Capacidad para evaluar de manera crítica y objetiva la autenticidad y relevancia de las pruebas presentadas.",
"court": 29,
"uri": "/ipfs/Qmczrn2DgdKGnacdvKRYwCk7JkeyTCokdqQycWdetYrxGC"

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