-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
refactor(x/gov): swap vote alias #19718
Conversation
WalkthroughWalkthroughThe changes focus on enhancing the Cosmos SDK's voting experience by reordering and renaming vote options for better clarity and consistency across different voting modes. These adjustments include updating names to descriptive ones, revising test cases and error messages to align with the changes, and ensuring compatibility and interchangeability of voting options in multiple choice proposals. Changes
Assessment against linked issues
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 5
Configuration used: .coderabbit.yml
Files selected for processing (6)
- api/cosmos/gov/v1/gov.pulsar.go (3 hunks)
- x/gov/client/utils/utils_test.go (1 hunks)
- x/gov/keeper/msg_server_test.go (5 hunks)
- x/gov/proto/cosmos/gov/v1/gov.proto (1 hunks)
- x/gov/types/v1/gov.pb.go (3 hunks)
- x/gov/types/v1/vote_test.go (1 hunks)
Additional comments: 10
x/gov/types/v1/vote_test.go (1)
- 14-61: The test function
TestVoteAlias
is well-structured and covers scenarios for valid votes, valid vote aliases, and invalid votes. However, there are a couple of points to consider:
- The test case for "valid vote alias" (lines 33-42) uses
VOTE_OPTION_ONE
as an option, which according to the PR objectives and summaries, should have been removed or replaced. This might indicate either an inconsistency in the PR's implementation or an outdated test case. Please verify the current state of vote options and update the test case accordingly.- It's good practice to also include a test case for deserialization success, where you assert the deserialized object (
vote
) against theexpected
field of the test case to ensure that the unmarshalling not only doesn't produce an error but also results in the correct object state.x/gov/proto/cosmos/gov/v1/gov.proto (1)
- 38-51: The changes to the
VoteOption
enum introduce aliases for vote options, allowing "VOTE_OPTION_ONE", "VOTE_OPTION_TWO", etc., to have the same numeric values as "VOTE_OPTION_YES", "VOTE_OPTION_ABSTAIN", and so on. This approach aligns with the PR's objective to improve the voting experience by making vote options interchangeable. However, there are a few considerations:
- Ensure that the introduction of aliases does not introduce ambiguity or confusion for developers and users. Clear documentation and comments in the code explaining the rationale and usage of these aliases would be beneficial.
- Verify that all parts of the system that consume these vote options can handle aliases correctly, especially in serialization and deserialization logic, to prevent any unexpected behavior.
x/gov/keeper/msg_server_test.go (5)
- 729-729: The error message for a zero weight vote option seems to be hardcoded with specific values. Consider using dynamic values based on the test case inputs to make the test more flexible and maintainable.
- 741-741: Similar to the previous comment, the error message for a negative weight vote option is hardcoded. It's advisable to use dynamic values derived from the test inputs for better test maintainability.
- 754-754: The error message for an individual weight greater than 1 but with a total weight equal to 1 is hardcoded. Using dynamic values from the test inputs would enhance the test's flexibility and maintainability.
- 1371-1371: The error message for a zero weight in the
TestLegacyVoteWeighted
test is hardcoded. Consider using dynamic values based on the test case inputs for improved test maintainability.- 1386-1386: Similar to previous comments, the error message for a negative weight in the
TestLegacyVoteWeighted
test is hardcoded. Using dynamic values from the test inputs would make the test more maintainable.x/gov/types/v1/gov.pb.go (3)
- 84-97: The constants
VOTE_OPTION_ONE
,VOTE_OPTION_TWO
,VOTE_OPTION_THREE
, andVOTE_OPTION_FOUR
have been removed as part of the refactor. This change aligns with the PR's objective to simplify the vote options by using more descriptive names and removing less meaningful numerical options. This should enhance clarity and usability in the governance module.- 104-124: The mappings in
VoteOption_name
andVoteOption_value
have been updated to reflect the removal of numerical vote options and the reordering of existing options. This update is crucial for ensuring that the enum values and their string representations remain consistent and accurate, which is essential for both internal processing and user interfaces.- 1424-1444: > 📝 NOTE
This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [1325-1441]
The decrease in the size of the
fileDescriptor_e05cb1c0d030febb
byte slice is a direct result of the changes made to theVoteOption
enum, including the removal of certain options and the update to mappings. This change is expected and indicates that the generated file descriptor accurately reflects the current state of the.proto
file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 0
Configuration used: .coderabbit.yml
Files selected for processing (1)
- x/gov/types/v1/vote_test.go (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- x/gov/types/v1/vote_test.go
@coderabbitai shut up |
Tip For best results, initiate chat on the files or code changes. I understand. If you have any further questions or need assistance in the future, feel free to reach out. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Description
ref: #19228
The rationale of this change is to not introduce a signing change in textual until we fix #19228 for all platforms.
Swapping the alias vs default only changes how the enum is marshalled, but a user can still sign (using sign mode direct) using both options.
This allows us as well to use the latest api in v0.50 without unforeseen consequences.
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!
in the type prefix if API or client breaking changeCHANGELOG.md
Reviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
I have...
Summary by CodeRabbit
New Features
Refactor
Bug Fixes
Tests