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(uibc): add missing params to MsgGovUpdateQuota #2370

Merged
merged 12 commits into from
Jan 2, 2024

Conversation

robert-zaremba
Copy link
Member

@robert-zaremba robert-zaremba commented Dec 27, 2023

Description

Summary by CodeRabbit

  • New Features

    • Expanded MsgGovUpdateQuota to include additional quota management fields.
    • Introduced ICS20Memo message with support for multiple message types.
  • Improvements

    • Enhanced validation logic in MsgGovUpdateQuota for better error handling.
    • Refined quota management with new parameters and validation checks.
  • Bug Fixes

    • Adjusted execution order for specific processes to ensure proper handling.
  • Documentation

    • Updated CHANGELOG.md to reflect new features, improvements, and bug fixes.

@robert-zaremba robert-zaremba requested a review from a team as a code owner December 27, 2023 15:39
Copy link
Contributor

coderabbitai bot commented Dec 27, 2023

Walkthrough

The updates across the Umee protocol files reflect a significant enhancement of the MsgGovUpdateQuota message, including new quota management fields. The uibc package has seen the addition of the ICS20Memo message, and utility functions for number checking have been introduced. Validation logic has been restructured in several locations to accumulate and return errors collectively, with new test cases added to ensure the correctness of these validations. The CHANGELOG captures the essence of these updates as new features and improvements.

Changes

File Path Change Summary
proto/umee/uibc/v1/tx.proto Extended MsgGovUpdateQuota with new quota fields.
proto/umee/uibc/v1/uibc.proto Added ICS20Memo message.
util/checkers/number.go
util/checkers/number_test.go
Introduced number checking functions and tests.
x/uibc/msg.go
x/uibc/msg_test.go
Updated ValidateBasic method and tests for MsgGovUpdateQuota.
x/uibc/quota/.../msg_server_test.go
x/uibc/quota/msg_server.go
x/uibc/quota/params.go
x/uibc/quota/params_test.go
Refactored quota management functions and tests.
CHANGELOG.md Documented new features, improvements, and bug fixes.

🐇
In the realm of code, changes abound,
Quotas adjust with a leap and a bound.
Bugs hop away, features align,
In Umee's update, all intertwine. 🌟
🐇

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 with CodeRabbit Bot (@coderabbitai)

  • You can directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
  • You can tag CodeRabbit on specific lines of code or entire files in the PR by tagging @coderabbitai in a comment. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • You can tag @coderabbitai in a PR comment and ask questions about the PR and the codebase. Examples:
    • @coderabbitai generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid.
    • @coderabbitai read the files in the src/scheduler package and generate 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.

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 a review. This is useful when automatic reviews are disabled for the repository.
  • @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.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between e3a9892 and 1df87a5.
Files ignored due to filter (3)
  • swagger/swagger.yaml
  • x/uibc/tx.pb.go
  • x/uibc/uibc.pb.go
Files selected for processing (10)
  • proto/umee/uibc/v1/tx.proto (1 hunks)
  • proto/umee/uibc/v1/uibc.proto (2 hunks)
  • util/checkers/number.go (1 hunks)
  • util/checkers/number_test.go (2 hunks)
  • x/uibc/msg.go (2 hunks)
  • x/uibc/msg_test.go (3 hunks)
  • x/uibc/quota/intest/msg_server_test.go (1 hunks)
  • x/uibc/quota/msg_server.go (1 hunks)
  • x/uibc/quota/params.go (3 hunks)
  • x/uibc/quota/params_test.go (1 hunks)
Additional comments: 16
proto/umee/uibc/v1/uibc.proto (1)
  • 12-15: The addition of the ICS20Memo message with a repeated field of type google.protobuf.Any is correct and follows protobuf best practices for defining messages that can contain a variety of types. Ensure that the consuming code properly handles the dynamic nature of Any types.
x/uibc/quota/msg_server.go (1)
  • 37-37: The refactoring to pass the entire msg object to UpdateQuotaParams is a good practice as it simplifies the function signature and allows for easier extension in the future. Ensure that the UpdateQuotaParams function is updated accordingly to handle the msg object.
util/checkers/number.go (2)
  • 56-61: The DecNotNegative function correctly checks if a sdk.Dec value is not negative. This is a good utility function that enhances code reusability.

  • 64-69: The DecPositive function correctly checks if a sdk.Dec value is positive. This function follows Go best practices and improves the maintainability of the code.

x/uibc/quota/params.go (2)
  • 32-41: The refactoring of UpdateQuotaParams to accept a MsgGovUpdateQuota object simplifies the function signature and allows for more straightforward updates to the quota parameters. Ensure that all fields of the MsgGovUpdateQuota are being validated and used correctly within the function.

  • 53-57: The validation logic within validateEmergencyQuotaParamsUpdate correctly checks if the new parameters are not increased by the emergency group. This follows the business logic as described and ensures that emergency updates do not inadvertently raise quotas.

x/uibc/msg.go (1)
  • 28-45: The use of a slice to accumulate validation errors in MsgGovUpdateQuota is a good practice as it allows for the collection of all errors before returning. This provides a more informative response to the caller. Ensure that the error messages are clear and that the validation logic is comprehensive.
x/uibc/quota/params_test.go (2)
  • 37-44: The mkParams function has been updated to include new quota parameters, which is necessary for testing the updated quota functionality. Ensure that the test cases cover a range of valid and invalid scenarios for these new parameters.

  • 48-65: The test cases have been correctly updated to include checks for the new quota parameters. It's important to ensure that the test cases cover both increases and decreases in quota parameters, as well as invalid updates that should be rejected.

util/checkers/number_test.go (1)
  • 86-92: The TestDecNotNegative function correctly tests the DecNotNegative utility function with both negative and non-negative sdk.Dec values. This ensures that the function behaves as expected.
x/uibc/msg_test.go (2)
  • 15-22: The TestMsgGovUpdateQuota function has been updated to include new fields in the validMsg struct, which is necessary for testing the updated MsgGovUpdateQuota message. Ensure that the test cases cover a range of valid and invalid scenarios for these new fields.

  • 64-73: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [39-70]

The new test case for invalid InflowOutflowQuotaBase is a good addition to ensure that the validation logic for the new quota fields is working as expected. It's important to have comprehensive test coverage for all new validation rules.

proto/umee/uibc/v1/tx.proto (1)
  • 60-77: The new fields inflow_outflow_quota_base, inflow_outflow_quota_rate, and inflow_outflow_token_quota_base are correctly defined with sequential protobuf field numbers starting from 7. Ensure that the custom type github.com/cosmos/cosmos-sdk/types.Dec is the appropriate choice for representing these quota values, as they are defined as strings but expected to hold decimal values.
x/uibc/quota/intest/msg_server_test.go (3)
  • 24-35: The test case "unauthorized to increase the quota" has been updated with the new quota fields and the error message has been changed to "unauthorized". Ensure that this error message accurately reflects the expected outcome of the test, especially in the context of the new quota parameters.

  • 40-49: In the test case "invalid quota in msg", the Total field has been changed from sdk.NewDec(100) to sdk.NewDec(10000), and new quota fields have been added. Verify that the error message "total quota must be greater than or equal to per_denom quota" is still valid in the context of the updated Total field and the new quota parameters.

  • 70-77: The last test case "valid update the new params again" has an updated QuotaDuration field with a significantly longer duration. Confirm that this new duration is intentional and correctly tests the functionality of the quota duration parameter.

Copy link

codecov bot commented Dec 27, 2023

Codecov Report

Attention: 124 lines in your changes are missing coverage. Please review.

Comparison is base (7f05ad4) 75.38% compared to head (02ef69d) 70.07%.
Report is 330 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2370      +/-   ##
==========================================
- Coverage   75.38%   70.07%   -5.32%     
==========================================
  Files         100      174      +74     
  Lines        8025    13009    +4984     
==========================================
+ Hits         6050     9116    +3066     
- Misses       1589     3288    +1699     
- Partials      386      605     +219     
Files Coverage Δ
ante/ante.go 66.66% <100.00%> (+18.45%) ⬆️
ante/fee.go 80.00% <100.00%> (+1.64%) ⬆️
ante/spam_prevention.go 75.92% <ø> (ø)
app/inflation/inflation.go 100.00% <100.00%> (ø)
app/upgradev3/migrations.go 84.21% <ø> (+5.94%) ⬆️
util/coin/utoken.go 100.00% <100.00%> (ø)
util/ibc/ibc.go 58.82% <ø> (ø)
util/sdkutil/events.go 0.00% <ø> (ø)
util/store/store.go 52.06% <ø> (+10.65%) ⬆️
util/store/unmarshal.go 42.85% <ø> (ø)
... and 40 more

... and 113 files with indirect coverage changes

util/checkers/number.go Outdated Show resolved Hide resolved
x/uibc/msg.go Outdated Show resolved Hide resolved
x/uibc/msg.go Outdated Show resolved Hide resolved
x/uibc/msg_test.go Outdated Show resolved Hide resolved
Copy link
Member

@toteki toteki left a comment

Choose a reason for hiding this comment

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

See comments / Otherwise approved

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.

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 1df87a5 and 4962d3c.
Files selected for processing (3)
  • CHANGELOG.md (1 hunks)
  • x/uibc/msg.go (2 hunks)
  • x/uibc/msg_test.go (3 hunks)
Additional comments: 5
x/uibc/msg.go (3)
  • 5-5: The addition of the errors package is appropriate for the updated error handling logic in the ValidateBasic method.

  • 28-46: The refactoring of the ValidateBasic method to accumulate errors is a good practice, allowing for more comprehensive error reporting. Ensure that all calls to DecPositive and DecNotNegative correctly pass the errs slice for error accumulation.

  • 46-46: Verify that the errors.Join function is correctly implemented and available within the project's dependencies, as it is not part of the standard Go library.

x/uibc/msg_test.go (2)
  • 15-22: The addition of new fields InflowOutflowQuotaBase, InflowOutflowTokenQuotaBase, and InflowOutflowQuotaRate to the validMsg struct in the TestMsgGovUpdateQuota function aligns with the updated message structure.

  • 64-73: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [39-70]

The new test case "invalid inflow outflow quota base with respect to per denom" correctly tests the validation logic for the InflowOutflowTokenQuotaBase field. Ensure that the error message is complete and matches the expected validation error.

CHANGELOG.md Outdated Show resolved Hide resolved
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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 4962d3c and 62eaabe.
Files selected for processing (1)
  • CHANGELOG.md (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • CHANGELOG.md

Copy link
Collaborator

@gsk967 gsk967 left a comment

Choose a reason for hiding this comment

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

LGTM

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.

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 62eaabe and 320e178.
Files selected for processing (2)
  • util/checkers/number.go (1 hunks)
  • x/uibc/msg.go (2 hunks)
Additional comments: 3
util/checkers/number.go (2)
  • 56-61: The function DecNotNegative correctly checks if the sdk.Dec value is not negative. However, the check for IsNil may not be necessary if sdk.Dec cannot be nil. Confirm if sdk.Dec has a nil state.

  • 64-69: The function DecPositive correctly checks if the sdk.Dec value is positive. Similar to DecNotNegative, ensure that sdk.Dec can have a nil state before checking with IsNil.

x/uibc/msg.go (1)
  • 28-45: The refactoring of the ValidateBasic method to accumulate errors using errors.Join is a good practice as it allows for the collection of all validation errors. Ensure that the errors package supports the Join function as expected.

x/uibc/msg.go Show resolved Hide resolved
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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 320e178 and 3e95cd2.
Files ignored due to filter (1)
  • swagger/swagger.yaml
Files selected for processing (2)
  • CHANGELOG.md (1 hunks)
  • util/checkers/number_test.go (2 hunks)
Additional comments: 6
util/checkers/number_test.go (2)
  • 6-6: The addition of the Cosmos SDK import statement is necessary for the new test cases that involve SDK types.

  • 86-92: The new test function TestDecNotNegative correctly tests for non-negativity of decimal numbers using the DecNotNegative function.

CHANGELOG.md (4)
  • 51-53: New queries and handlers have been added as per the PR objectives and AI-generated summaries.

  • 58-58: The missing parameters for uic/MsgGovUpdateQuota have been documented, aligning with the PR's objectives.

  • 62-62: The order of execution for metoken endblocker and oracle has been adjusted, which is a bug fix and should improve the system's reliability.

  • 63-63: The inflow amount to registered tokens has been fixed to prevent the inflow amount from being overridden, as mentioned in the PR objectives.

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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 3e95cd2 and 02ef69d.
Files selected for processing (1)
  • CHANGELOG.md (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • CHANGELOG.md

@robert-zaremba robert-zaremba added this pull request to the merge queue Jan 2, 2024
Merged via the queue into main with commit 87c612f Jan 2, 2024
27 of 29 checks passed
@robert-zaremba robert-zaremba deleted the robert/uibc-quota-update branch January 2, 2024 19:52
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.

4 participants