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

feat: add max voting power per pool #191

Merged
merged 8 commits into from
May 27, 2024

Conversation

shifty11
Copy link
Contributor

@shifty11 shifty11 commented May 23, 2024

Summary by CodeRabbit

  • New Features

    • Introduced a new parameter MaxVotingPowerPerPool to manage the maximum voting power per pool.
  • Documentation

    • Updated API documentation to include the new max_voting_power_per_pool field.
  • Bug Fixes

    • Adjusted error message for ErrVotingPowerTooHigh to reflect the new voting power limits.
  • Refactor

    • Improved parameter setting logic in test scenarios for better maintainability and clarity.
  • Tests

    • Added new test cases to validate the functionality of the MaxVotingPowerPerPool parameter.

Copy link

coderabbitai bot commented May 23, 2024

Walkthrough

The recent updates focus on introducing and integrating the MaxVotingPowerPerPool parameter across various components of the system. This includes modifications to configuration files, test cases, and logic to ensure that no single staker can exceed the specified voting power within a pool. The changes enhance the system's robustness by enforcing voting power limits, thereby promoting fairer and more balanced pool governance.

Changes

File Path Change Summary
app/upgrades/v1_5/upgrade.go Added a TODO comment to migrate MaxVotingPowerPerPool in pool parameters.
docs/static/openapi.yml Added new field max_voting_power_per_pool with description under paths.
proto/kyve/pool/v1beta1/params.proto Introduced max_voting_power_per_pool field of type string in Params message.
x/bundles/keeper/abci_protocol_split_test.go, x/bundles/keeper/keeper_suite_inflation_splitting_test.go Refactored parameter setting for pool tests to use pooltypes.DefaultParams().
x/bundles/keeper/logic_bundles.go Updated AssertPoolCanRun method to compare highest delegation against calculated maximum delegation based on voting power.
x/bundles/keeper/logic_bundles_test.go Added new test cases for pool functionality related to node voting power.
x/bundles/types/errors.go Updated error message for ErrVotingPowerTooHigh.
x/bundles/types/expected_keepers.go Added GetMaxVotingPowerPerPool method to PoolKeeper interface.
x/pool/keeper/getters_params.go Introduced GetMaxVotingPowerPerPool function in Keeper struct.
x/pool/types/params.go Added maxVotingPowerPerPool parameter to Params struct and its validation.
x/pool/keeper/msg_server_update_params_test.go Added tests for updating MaxVotingPowerPerPool parameter with valid and invalid values.
x/pool/spec/05_params.md Documented new parameter MaxVotingPowerPerPool in pool module.

In the pools where votes align,
A balance struck, a power fine.
No single staker takes the throne,
For fairness now is widely known.
With limits set, the pools rejoice,
In harmony, they find their voice. 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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.

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 as 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 full the 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 help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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

@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

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 1303bc2 and ad6d50d.
Files ignored due to path filters (1)
  • x/pool/types/params.pb.go is excluded by !**/*.pb.go
Files selected for processing (11)
  • app/upgrades/v1_5/upgrade.go (1 hunks)
  • docs/static/openapi.yml (1 hunks)
  • proto/kyve/pool/v1beta1/params.proto (1 hunks)
  • x/bundles/keeper/abci_protocol_split_test.go (1 hunks)
  • x/bundles/keeper/keeper_suite_inflation_splitting_test.go (12 hunks)
  • x/bundles/keeper/logic_bundles.go (1 hunks)
  • x/bundles/keeper/logic_bundles_test.go (3 hunks)
  • x/bundles/types/errors.go (1 hunks)
  • x/bundles/types/expected_keepers.go (1 hunks)
  • x/pool/keeper/getters_params.go (1 hunks)
  • x/pool/types/params.go (3 hunks)
Files skipped from review due to trivial changes (3)
  • app/upgrades/v1_5/upgrade.go
  • docs/static/openapi.yml
  • x/bundles/types/errors.go
Additional comments not posted (21)
proto/kyve/pool/v1beta1/params.proto (1)

23-27: The addition of max_voting_power_per_pool is correctly implemented with appropriate protobuf annotations.

x/pool/keeper/getters_params.go (1)

31-34: The implementation of GetMaxVotingPowerPerPool follows the established pattern for getters and correctly retrieves the new parameter.

x/pool/types/params.go (1)

14-16: The additions related to MaxVotingPowerPerPool in the Params struct, including default value, constructor, and validation, are correctly implemented and follow best practices.

Also applies to: 21-26, 35-35, 49-52

x/bundles/types/expected_keepers.go (1)

26-26: The addition of GetMaxVotingPowerPerPool to the PoolKeeper interface is correctly implemented, ensuring consistency across different implementations.

x/bundles/keeper/abci_protocol_split_test.go (1)

33-36: Refactoring the parameter setting to use DefaultParams in the test setup improves maintainability and ensures that changes to default parameters are consistently reflected in tests.

x/bundles/keeper/logic_bundles.go (1)

48-52: The integration of MaxVotingPowerPerPool in the AssertPoolCanRun method is correctly implemented, ensuring that the pool's voting power constraints are enforced based on the new parameter.

x/bundles/keeper/logic_bundles_test.go (3)

22-24: Ensure the new test cases cover all scenarios for the MaxVotingPowerPerPool constraint.


255-316: The test case correctly simulates a scenario where the voting power of one node is exactly 40%, and asserts that no error should occur. This aligns well with the new MaxVotingPowerPerPool constraint.


318-383: The test case effectively tests the scenario where a node's voting power exceeds the 40% limit, and correctly expects the ErrVotingPowerTooHigh error. This is a crucial test for validating the enforcement of the MaxVotingPowerPerPool constraint.

x/bundles/keeper/keeper_suite_inflation_splitting_test.go (12)

117-120: Refactor to use DefaultParams enhances consistency and maintainability.

This change simplifies the parameter setup by using DefaultParams, which is beneficial for maintaining consistency across tests and simplifying future modifications.


197-200: Refactor to use DefaultParams enhances consistency and maintainability.

This change simplifies the parameter setup by using DefaultParams, which is beneficial for maintaining consistency across tests and simplifying future modifications.


290-293: Refactor to use DefaultParams enhances consistency and maintainability.

This change simplifies the parameter setup by using DefaultParams, which is beneficial for maintaining consistency across tests and simplifying future modifications.


383-386: Refactor to use DefaultParams enhances consistency and maintainability.

This change simplifies the parameter setup by using DefaultParams, which is beneficial for maintaining consistency across tests and simplifying future modifications.


489-492: Refactor to use DefaultParams enhances consistency and maintainability.

This change simplifies the parameter setup by using DefaultParams, which is beneficial for maintaining consistency across tests and simplifying future modifications.


596-599: Refactor to use DefaultParams enhances consistency and maintainability.

This change simplifies the parameter setup by using DefaultParams, which is beneficial for maintaining consistency across tests and simplifying future modifications.


703-706: Refactor to use DefaultParams enhances consistency and maintainability.

This change simplifies the parameter setup by using DefaultParams, which is beneficial for maintaining consistency across tests and simplifying future modifications.


808-811: Refactor to use DefaultParams enhances consistency and maintainability.

This change simplifies the parameter setup by using DefaultParams, which is beneficial for maintaining consistency across tests and simplifying future modifications.


915-918: Refactor to use DefaultParams enhances consistency and maintainability.

This change simplifies the parameter setup by using DefaultParams, which is beneficial for maintaining consistency across tests and simplifying future modifications.


1022-1025: Refactor to use DefaultParams enhances consistency and maintainability.

This change simplifies the parameter setup by using DefaultParams, which is beneficial for maintaining consistency across tests and simplifying future modifications.


1127-1130: Refactor to use DefaultParams enhances consistency and maintainability.

This change simplifies the parameter setup by using DefaultParams, which is beneficial for maintaining consistency across tests and simplifying future modifications.


1234-1237: Refactor to use DefaultParams enhances consistency and maintainability.

This change simplifies the parameter setup by using DefaultParams, which is beneficial for maintaining consistency across tests and simplifying future modifications.

Copy link
Member

@troykessler troykessler left a comment

Choose a reason for hiding this comment

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

Please also add the max voting per pool parameter in the x/bundles/keeper/msg_server_update_params_test.go test file

@shifty11 shifty11 requested a review from troykessler May 23, 2024 12:55
Copy link
Member

@troykessler troykessler left a comment

Choose a reason for hiding this comment

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

Finally, add the new pool parameter to the x/pool/spec/05_params.md spec file, else everything looks good

@shifty11
Copy link
Contributor Author

Please also add the max voting per pool parameter in the x/bundles/keeper/msg_server_update_params_test.go test file

You mean in x/pool/keeper/msg_server_update_params_test.go ? There are no param changes in the bundles module... so not sure what to add there.

@shifty11 shifty11 requested a review from troykessler May 27, 2024 12:09
Copy link

@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

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between ad6d50d and 8fe9f29.
Files selected for processing (2)
  • x/pool/keeper/msg_server_update_params_test.go (9 hunks)
  • x/pool/spec/05_params.md (1 hunks)
Files skipped from review due to trivial changes (1)
  • x/pool/spec/05_params.md
Additional comments not posted (10)
x/pool/keeper/msg_server_update_params_test.go (10)

68-68: Ensure the default value for MaxVotingPowerPerPool is correctly set and tested.


138-138: Verify that the MaxVotingPowerPerPool parameter is correctly updated when all parameters are updated at once.


173-173: Confirm that the MaxVotingPowerPerPool remains unchanged when no parameters are updated.


204-204: Check that the MaxVotingPowerPerPool remains unaffected by an invalid formatted payload.


241-241: Ensure that updating other parameters does not inadvertently affect the MaxVotingPowerPerPool.


272-272: Confirm that an invalid value for another parameter does not impact the MaxVotingPowerPerPool.


309-309: Check that the MaxVotingPowerPerPool remains unchanged when updating another parameter.


340-340: Ensure that the MaxVotingPowerPerPool remains unchanged when an invalid value for another parameter is provided.


377-377: Validate that the MaxVotingPowerPerPool is correctly updated to a valid value.


408-408: Confirm that an invalid value for MaxVotingPowerPerPool is correctly handled and does not update the parameter.

@troykessler
Copy link
Member

Please also add the max voting per pool parameter in the x/bundles/keeper/msg_server_update_params_test.go test file

You mean in x/pool/keeper/msg_server_update_params_test.go ? There are no param changes in the bundles module... so not sure what to add there.

Yep you're right, all good then

@shifty11 shifty11 merged commit 0823dd8 into main May 27, 2024
5 checks passed
@shifty11 shifty11 deleted the rapha/add-max-voting-power-per-pool branch May 27, 2024 13:50
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