Skip to content

fix: don't remove kicked out validators in ping()#8

Merged
linguists merged 3 commits intomainfrom
fix/keep-kicked-out-validator
Jun 26, 2025
Merged

fix: don't remove kicked out validators in ping()#8
linguists merged 3 commits intomainfrom
fix/keep-kicked-out-validator

Conversation

@linguists
Copy link
Copy Markdown
Contributor

@linguists linguists commented Jun 25, 2025

Currently the kicked out validators are removed from the votes.

We'd like to keep their votes and update the stake to 0 if they're kicked out, so their stake will counted after they rejoined the validator set.

Summary by CodeRabbit

  • Bug Fixes

    • Votes with zero stake are now retained in the votes map after validator removal or stake changes.
  • Tests

    • Updated test expectations to reflect that votes with zero stake remain in the voting contract's state.
    • Adjusted vote count assertions following voting and unstaking actions to match updated behavior.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Jun 25, 2025

Walkthrough

The changes update the logic in the ping method to retain votes with zero stake in the votes map, removing the previous condition that excluded them. Corresponding unit tests were updated to expect votes with zero stake to remain, adjusting assertions on the number of votes present after validator removal or unstaking actions.

Changes

File(s) Change Summary
src/lib.rs Modified ping method to update votes in place, retaining zero-stake entries; updated test assertions to reflect vote retention and validator re-adding.
tests/test_vote.rs Adjusted test to expect votes with zero stake to remain in the votes map after unstaking.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant VotingContract

    User->>VotingContract: Call ping()
    VotingContract->>VotingContract: Iterate existing votes
    alt For each validator vote
        VotingContract->>VotingContract: Update stake to current (including zero)
    end
    VotingContract-->>User: Return updated votes map (including zero stakes)
Loading

Possibly related PRs

Poem

A rabbit hopped through lines of code,
Where zero stakes once hit the road.
Now every vote, both big and small,
Remains within the voting hall.
A test or two, a gentle tweak—
The votes persist, though stakes are weak!
🐇


📜 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 01d71ca and 2e8e82e.

📒 Files selected for processing (1)
  • src/lib.rs (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/lib.rs
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Tests
  • GitHub Check: Code Linter
  • GitHub Check: Build
  • GitHub Check: Analyze (actions)
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 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 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
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between a42e490 and 18d394a.

📒 Files selected for processing (2)
  • src/lib.rs (2 hunks)
  • tests/test_vote.rs (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Tests
  • GitHub Check: Build
  • GitHub Check: Code Linter
  • GitHub Check: Analyze (actions)
🔇 Additional comments (2)
src/lib.rs (1)

498-498: Test assertion correctly reflects the new behavior.

The updated assertion expects 1 vote to remain after a validator is removed and ping is called, which correctly reflects the new behavior of retaining zero-stake votes. This change aligns with the code modification at line 80.

tests/test_vote.rs (1)

496-496: Test correctly validates the new zero-stake vote retention behavior.

The updated assertion expecting 2 votes aligns perfectly with the code changes in src/lib.rs. After unstaking from the first pool and voting on the second pool, both votes should be retained:

  1. First pool's vote with zero stake (retained by ping method)
  2. Second pool's vote with positive stake (newly added)

This test change ensures the new behavior is properly validated and prevents regressions.

@linguists linguists changed the title fix: keep kicked out validator fix: keep kicked out validator's vote Jun 25, 2025
@linguists linguists changed the title fix: keep kicked out validator's vote fix: don't remove kicked out validator in ping() Jun 25, 2025
@linguists linguists changed the title fix: don't remove kicked out validator in ping() fix: don't remove kicked out validators in ping() Jun 25, 2025
@linguists linguists merged commit a6c56c5 into main Jun 26, 2025
7 checks passed
@linguists linguists deleted the fix/keep-kicked-out-validator branch June 26, 2025 03:01
@coderabbitai coderabbitai bot mentioned this pull request Jul 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants