Skip to content

chore: effective stake instead of specific court stake, and effective number of staked jurors (counting child courts) #1951

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 8 commits into from
Apr 15, 2025

Conversation

kemuru
Copy link
Contributor

@kemuru kemuru commented Apr 11, 2025

subgraph, frontend changes


PR-Codex overview

This PR primarily focuses on enhancing the handling of "effective" stakes and jurors in the Kleros subgraph, introducing new fields and updating functions to manage effective stakes more efficiently.

Detailed summary

  • Updated version in subgraph/package.json from 0.15.0 to 0.15.2.
  • Added effectiveNumberStakedJurors and effectiveStake fields in subgraph/core/schema.graphql.
  • Modified queries in web/src/hooks/queries/useHomePageQuery.ts to include first parameter for counters and courts.
  • Updated logic in web/src/pages/Courts/CourtDetails/Stats/stats.ts to use effectiveStake instead of stake.
  • Enhanced updateEffectiveStake function in subgraph/core/src/entities/Court.ts to accept a delta parameter.
  • Adjusted createCourtFromEvent to initialize effectiveNumberStakedJurors.
  • Changed updateJurorEffectiveStake to include a delta parameter and updated logic for effective juror stakes.
  • Updated calls to updateEffectiveStake and updateJurorEffectiveStake to pass the delta value.

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

Summary by CodeRabbit

  • New Features

    • The court details now display enhanced metrics for stake and active jurors, offering more accurate and insightful information.
    • Added new fields for effective number of staked jurors and effective stake in court details.
    • The stake summary on the court details page has been updated to calculate and present values based on the effective stake for clearer insights.
    • Improved data fetching limits on homepage queries for counters and courts to optimize performance.
  • Bug Fixes

    • Updated calculations for "PNK Staked" and "Active Jurors" to reflect the new effective metrics.
  • Chores

    • Minor version increment from 0.15.0 to 0.15.2.
    • Documentation punctuation correction in the web README.

Copy link
Contributor

coderabbitai bot commented Apr 11, 2025

Walkthrough

This update introduces two new fields, effectiveNumberStakedJurors and effectiveStake, into the GraphQL query CourtDetails within the useCourtDetails hook. The hook now fetches additional data without altering its overall logic. Additionally, the display logic in the stats configuration has been modified so that the "PNK Staked" entry uses data?.effectiveStake, and the "Active Jurors" entry uses data?.effectiveNumberStakedJurors. The subgraph schema and entity logic were updated to support incremental updates of these fields using delta values and recursive propagation through the court hierarchy. The homepage query and court overview chart were also adjusted to use effectiveStake instead of stake. The package version was bumped to reflect these enhancements.

Changes

File(s) Change Summary
web/src/hooks/queries/useCourtDetails.ts Added the effectiveNumberStakedJurors and effectiveStake fields to the GraphQL query CourtDetails.
web/src/pages/Courts/CourtDetails/Stats/stats.ts Updated getText and getSubtext for "PNK Staked" to use data?.effectiveStake, and for "Active Jurors" to use data?.effectiveNumberStakedJurors.
subgraph/core/schema.graphql Added effectiveNumberStakedJurors: BigInt! field to the Court entity in the GraphQL schema.
subgraph/core/src/entities/Court.ts Changed updateEffectiveStake method to accept a delta parameter and update recursively; initialized effectiveNumberStakedJurors to zero on court creation.
subgraph/core/src/entities/JurorTokensPerCourt.ts Modified updateJurorEffectiveStake to accept a delta parameter and update effective stake and juror count incrementally; updated updateJurorStake accordingly.
subgraph/package.json Updated version from "0.15.0" to "0.15.2".
web/src/hooks/queries/useHomePageQuery.ts Added first arguments to limit counters and courts query results; replaced stake with effectiveStake in courts selection.
web/src/pages/Home/CourtOverview/Chart.tsx Changed data processing to use effectiveStake instead of stake for staked PNK data.
web/README.md Added a missing period in the "Pre-Requisites" section.

Sequence Diagram(s)

sequenceDiagram
    participant UI as "Court Details Page"
    participant Hook as "useCourtDetails Hook"
    participant API as "GraphQL Server"
    participant Stats as "Stats Formatter"

    UI->>Hook: Request court details by ID
    Hook->>API: Execute GraphQL query (includes effectiveStake and effectiveNumberStakedJurors)
    API-->>Hook: Respond with court details (effectiveStake and effectiveNumberStakedJurors included)
    Hook-->>UI: Return full court details data
    UI->>Stats: Render stats using effectiveStake for "PNK Staked" and effectiveNumberStakedJurors for "Active Jurors"
Loading

Possibly related PRs

Suggested labels

Type: Enhancement :sparkles:, Package: Subgraph, Package: Web

Suggested reviewers

  • alcercu

Poem

In my coding warren I hop with delight,
Fetching effectiveStake in the query light.
Stats now sing a refined, new tune,
As data dashes under the silver moon.
Hoppy changes from me, your code-loving rabbit!
🐇💻✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between 28e85d6 and 0cc67e1.

📒 Files selected for processing (1)
  • web/README.md (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • web/README.md
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Redirect rules - kleros-v2-testnet
  • GitHub Check: Header rules - kleros-v2-testnet
  • GitHub Check: Pages changed - kleros-v2-testnet

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

@kemuru kemuru changed the title chore: use effectivestake instead of specific stake in court page chore: effective stake instead of specific court stake, and effective number of staked jurors (counting child courts) Apr 11, 2025
Copy link

netlify bot commented Apr 11, 2025

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

Name Link
🔨 Latest commit 0cc67e1
🔍 Latest deploy log https://app.netlify.com/sites/kleros-v2-neo/deploys/67fe56861dc08f0008c098ef

Copy link

netlify bot commented Apr 11, 2025

Deploy Preview for kleros-v2-testnet ready!

Name Link
🔨 Latest commit 0cc67e1
🔍 Latest deploy log https://app.netlify.com/sites/kleros-v2-testnet/deploys/67fe56866daf3e000822236a
😎 Deploy Preview https://deploy-preview-1951--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.

Copy link

netlify bot commented Apr 11, 2025

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

Name Link
🔨 Latest commit 0cc67e1
🔍 Latest deploy log https://app.netlify.com/sites/kleros-v2-university/deploys/67fe5686bc685600082d9de5

coderabbitai[bot]
coderabbitai bot previously approved these changes Apr 11, 2025
Copy link

netlify bot commented Apr 11, 2025

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

Name Link
🔨 Latest commit 0cc67e1
🔍 Latest deploy log https://app.netlify.com/sites/kleros-v2-testnet-devtools/deploys/67fe5686ef6210000871b045
😎 Deploy Preview https://deploy-preview-1951--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.

@kemuru kemuru marked this pull request as ready for review April 11, 2025 21:22
@kemuru kemuru requested a review from a team as a code owner April 11, 2025 21:22
coderabbitai[bot]
coderabbitai bot previously approved these changes Apr 11, 2025
coderabbitai[bot]
coderabbitai bot previously approved these changes Apr 14, 2025
@kemuru kemuru requested a review from alcercu April 14, 2025 15:12
coderabbitai[bot]
coderabbitai bot previously approved these changes Apr 15, 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: 0

🧹 Nitpick comments (1)
web/src/hooks/queries/useHomePageQuery.ts (1)

14-14: Pagination limit added to counters query

Adding a first: 1000 limit to the counters query is a good practice to prevent potentially large data transfers. This improves query performance and reduces network load.

Consider implementing proper pagination with cursor-based navigation if you expect the number of counters to grow beyond 1000 in the future.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between b738406 and cdcfa3a.

📒 Files selected for processing (1)
  • web/src/hooks/queries/useHomePageQuery.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (12)
  • GitHub Check: Redirect rules - kleros-v2-university
  • GitHub Check: Redirect rules - kleros-v2-neo
  • GitHub Check: Header rules - kleros-v2-university
  • GitHub Check: Header rules - kleros-v2-neo
  • GitHub Check: Pages changed - kleros-v2-university
  • GitHub Check: Pages changed - kleros-v2-neo
  • GitHub Check: Redirect rules - kleros-v2-testnet-devtools
  • GitHub Check: Header rules - kleros-v2-testnet-devtools
  • GitHub Check: Pages changed - kleros-v2-testnet-devtools
  • GitHub Check: contracts-testing
  • GitHub Check: SonarCloud
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (1)
web/src/hooks/queries/useHomePageQuery.ts (1)

22-22: Pagination limit added to courts query

Adding a first: 1000 limit to the courts query aligns with the changes made to the counters query and follows GraphQL best practices for query optimization.

This change complements the new effectiveStake and effectiveNumberStakedJurors fields introduced in the schema, ensuring consistent data fetching patterns across the application.

coderabbitai[bot]
coderabbitai bot previously approved these changes Apr 15, 2025
coderabbitai[bot]
coderabbitai bot previously approved these changes Apr 15, 2025
alcercu
alcercu previously approved these changes Apr 15, 2025
Copy link
Contributor

@alcercu alcercu left a comment

Choose a reason for hiding this comment

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

lgtm

@kemuru kemuru dismissed stale reviews from alcercu and coderabbitai[bot] via 28e85d6 April 15, 2025 12:22
@kemuru kemuru requested a review from alcercu April 15, 2025 12:22
coderabbitai[bot]
coderabbitai bot previously approved these changes Apr 15, 2025
Copy link

codeclimate bot commented Apr 15, 2025

Code Climate has analyzed commit 0cc67e1 and detected 2 issues on this pull request.

Here's the issue category breakdown:

Category Count
Style 2

View more on Code Climate.

Copy link
Contributor

@alcercu alcercu left a comment

Choose a reason for hiding this comment

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

lgtm

@alcercu alcercu merged commit 04f316d into dev Apr 15, 2025
16 of 26 checks passed
@kemuru kemuru deleted the chore/true-court-stake-and-active-jurors branch April 16, 2025 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants