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

chore: rename uibc quota params #2332

Merged
merged 13 commits into from
Nov 20, 2023
Merged

chore: rename uibc quota params #2332

merged 13 commits into from
Nov 20, 2023

Conversation

robert-zaremba
Copy link
Member

@robert-zaremba robert-zaremba commented Nov 20, 2023

Description

  • Improve Quota docs
  • rename uibc fields in genesis and params

Summary by CodeRabbit

  • New Features

    • Introduced a new mechanism for tracking inflows and outflows of tokens with resettable metrics and defined quotas.
  • Improvements

    • Upgraded to Cosmos SDK v0.47 for enhanced performance and stability.
    • Adjusted governance parameters to refine the initial deposit ratio for proposals.
  • Refactor

    • Renamed fields related to inflow and outflow sums for clarity and consistency.
    • Updated quota management logic to align with the new naming conventions.
  • Documentation

    • Updated the README to reflect changes in the tracking and management of token inflows and outflows.
  • Bug Fixes

    • Corrected the handling of zero-value quota parameters to prevent unintended behavior.

@robert-zaremba robert-zaremba requested a review from a team as a code owner November 20, 2023 16:36
Copy link
Contributor

coderabbitai bot commented Nov 20, 2023

Walkthrough

The recent updates in the umee-network/umee codebase involve a series of renaming actions, primarily changing TotalOutflowSum to OutflowSum and TotalInflowSum to InflowSum across various files. These changes streamline the naming convention for inflow and outflow sums within the IBC transfer module. Additionally, the Cosmos SDK has been upgraded to v0.47, and governance parameters have been adjusted, specifically the MinInitialDepositRatio set to 0.1.

Changes

File Path Change Summary
proto/umee/uibc/v1/genesis.proto, proto/umee/uibc/v1/quota.proto,
x/uibc/genesis.go, x/uibc/quota/keeper/genesis.go,
x/uibc/quota/keeper/quota.go, x/uibc/quota/keeper/quota_test.go,
x/uibc/genesis_test.go, x/uibc/client/tests/cli_test.go
Renamed total_outflow_sum to outflow_sum and total_inflow_sum to inflow_sum.
x/uibc/params.go, x/uibc/quota/keeper/params_test.go Renamed inflow_outflow_quota_token_base to inflow_outflow_token_quota_base.
x/uibc/README.md Updated documentation to reflect new tracking and quota mechanisms for inflows and outflows.
CHANGELOG.md Documented renaming of fields, Cosmos SDK upgrade to v0.47, and adjustment of MinInitialDepositRatio.
app/upgrades.go, x/uibc/quota/keeper/migrations.go Updated function names and calls to align with the new naming convention.

🐇 In the code where bytes do dance,
Renames prance and enhance the stance.
As autumn leaves fall, we upgrade with glee,
A hop and a skip in the versioning spree! 🍂🚀


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • If you reply to a review comment from CodeRabbit, the bot will automatically respond.
  • To engage with CodeRabbit bot directly around the specific lines of code in the PR, mention @coderabbitai in your review comment
  • Note: Review comments are made on code diffs or files, not on the PR overview.
  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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.

Note: For conversation with the bot, please use the review comments on code diffs or files.

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

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 2573b37 and f0fbd5e.
Files selected for processing (3)
  • proto/umee/uibc/v1/genesis.proto (2 hunks)
  • proto/umee/uibc/v1/quota.proto (1 hunks)
  • x/uibc/README.md (1 hunks)
Files skipped from review due to trivial changes (1)
  • proto/umee/uibc/v1/genesis.proto
Additional comments: 1
proto/umee/uibc/v1/quota.proto (1)
  • 42-49: The renaming of the field from inflow_outflow_quota_base to inflow_outflow_token_quota_base is consistent with the summary provided and improves the clarity of the field's purpose. It is important to ensure that all references to this field in the codebase, including any serialization or deserialization logic, are updated to reflect the new name. Additionally, any documentation or comments that reference this field should be revised accordingly.

x/uibc/README.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: 9

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between f0fbd5e and 0f89f6b.
Files ignored due to filter (3)
  • swagger/swagger.yaml
  • x/uibc/genesis.pb.go
  • x/uibc/quota.pb.go
Files selected for processing (11)
  • CHANGELOG.md (1 hunks)
  • app/upgrades.go (1 hunks)
  • x/uibc/client/tests/cli_test.go (1 hunks)
  • x/uibc/genesis.go (3 hunks)
  • x/uibc/genesis_test.go (1 hunks)
  • x/uibc/params.go (2 hunks)
  • x/uibc/quota/keeper/genesis.go (2 hunks)
  • x/uibc/quota/keeper/migrations.go (1 hunks)
  • x/uibc/quota/keeper/params_test.go (1 hunks)
  • x/uibc/quota/keeper/quota.go (5 hunks)
  • x/uibc/quota/keeper/quota_test.go (3 hunks)
Files skipped from review due to trivial changes (4)
  • x/uibc/genesis_test.go
  • x/uibc/params.go
  • x/uibc/quota/keeper/migrations.go
  • x/uibc/quota/keeper/params_test.go
Additional comments: 10
x/uibc/client/tests/cli_test.go (1)
  • 22-28: The update from TotalOutflowSum to OutflowSum in the uibcGenState struct is consistent with the renaming described in the pull request summary. This change should be cross-verified with the rest of the codebase to ensure that all references to the old field name have been updated accordingly. Additionally, ensure that the logic that depends on this field is still correct after the renaming.
app/upgrades.go (1)
  • 124-130: The MigrateOutflowSum method is called without any arguments, but it is not clear from the context whether this method requires arguments to perform the migration. If the method signature has changed to accept parameters, this call will fail at runtime. Please verify that the method signature for MigrateOutflowSum matches this call and that it does not require any additional parameters to function correctly.
CHANGELOG.md (2)
  • 55-56: The changelog correctly documents the upgrade of the Cosmos SDK to v0.47 and the setting of gov/v1 MinInitialDepositRatio to 0.1. However, it would be beneficial to include a brief explanation of the implications of these changes for users or developers, especially if they introduce any breaking changes or significant behavior modifications in the system. This can help stakeholders understand the impact of the upgrade and the new deposit ratio setting.

  • 60-60: The renaming of TotalOutflowSum to OutflowSum and TotalInflowSum to InflowSum is documented under the "Breaking Changes" section. It is important to ensure that all references to these fields in the codebase, including documentation, comments, and test cases, have been updated to reflect the new names to avoid any inconsistencies or errors.

x/uibc/genesis.go (2)
  • 11-15: The renaming of TotalOutflowSum to OutflowSum in the GenesisState struct is consistent with the pull request's goal of simplifying field names. This change should be cross-checked throughout the codebase to ensure that all references to this field are updated accordingly.

  • 20-25: The DefaultGenesisState function has been updated to reflect the new field names OutflowSum and InflowSum. It is important to ensure that these changes are also reflected in any serialization formats (e.g., JSON, YAML) and that any external systems or documentation that rely on the previous field names are updated.

x/uibc/quota/keeper/quota.go (4)
  • 121-126: The function ResetAllQuotas has been updated to use SetOutflowSum instead of the previous SetTotalOutflowSum. Ensure that all references and logic related to the total outflow sum have been updated accordingly throughout the codebase to maintain consistency and avoid any potential bugs due to the renaming.

  • 150-156: The logic within CheckAndUpdateQuota has been updated to use the new field name InflowOutflowTokenQuotaBase instead of the previous InflowOutflowQuotaTokenBase. Ensure that the renaming is consistent across the entire codebase and that all references to the old field name have been updated to prevent any issues.

  • 168-173: The function CheckAndUpdateQuota has been updated to use SetOutflowSum instead of the previous SetTotalOutflowSum. Ensure that the logic for updating the total outflow sum is consistent with the new naming convention and that all references to the old function have been updated accordingly.

  • 225-230: The function UndoUpdateQuota has been updated to use SetOutflowSum instead of the previous SetTotalOutflowSum. Ensure that the logic for subtracting from the total outflow sum is consistent with the new naming convention and that all references to the old function have been updated accordingly.

x/uibc/quota/keeper/genesis.go Outdated Show resolved Hide resolved
x/uibc/quota/keeper/genesis.go Outdated Show resolved Hide resolved
x/uibc/quota/keeper/genesis.go Outdated Show resolved Hide resolved
x/uibc/genesis.go Outdated Show resolved Hide resolved
x/uibc/genesis.go Outdated Show resolved Hide resolved
x/uibc/quota/keeper/quota_test.go Outdated Show resolved Hide resolved
x/uibc/quota/keeper/quota_test.go Show resolved Hide resolved
x/uibc/quota/keeper/quota_test.go Outdated Show resolved Hide resolved
Copy link

codecov bot commented Nov 20, 2023

Codecov Report

Merging #2332 (2e32191) into main (7f05ad4) will decrease coverage by 5.11%.
Report is 298 commits behind head on main.
The diff coverage is 66.08%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2332      +/-   ##
==========================================
- Coverage   75.38%   70.28%   -5.11%     
==========================================
  Files         100      170      +70     
  Lines        8025    12659    +4634     
==========================================
+ Hits         6050     8897    +2847     
- Misses       1589     3158    +1569     
- Partials      386      604     +218     
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 103 files with indirect coverage changes

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.

Pre Appoving , I added small comments

x/uibc/README.md Show resolved Hide resolved
x/uibc/README.md Show resolved Hide resolved
x/uibc/README.md Show resolved Hide resolved
x/uibc/README.md Show resolved Hide resolved
x/uibc/README.md Show resolved Hide resolved
x/uibc/quota/keeper/genesis.go 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: 11

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 0f89f6b and 6b7d6c2.
Files selected for processing (6)
  • CHANGELOG.md (1 hunks)
  • x/uibc/README.md (1 hunks)
  • x/uibc/genesis.go (2 hunks)
  • x/uibc/quota/keeper/genesis.go (2 hunks)
  • x/uibc/quota/keeper/quota.go (6 hunks)
  • x/uibc/quota/keeper/quota_test.go (5 hunks)
Files skipped from review due to trivial changes (1)
  • x/uibc/quota/keeper/genesis.go
Additional comments: 7
x/uibc/genesis.go (2)
  • 10-25: The changes to the NewGenesisState and DefaultGenesisState functions correctly reflect the renaming of the fields from TotalOutflowSum to OutflowSum and TotalInflowSum to InflowSum. This aligns with the pull request's goal of simplifying the naming conventions. It is important to ensure that all references to these fields in the codebase are updated to prevent any compilation errors or runtime issues.

  • 52-57: The validation logic has been correctly updated to check for negative values of OutflowSum and InflowSum. This is a crucial check to ensure the integrity of the genesis state. It is also consistent with the renaming of the fields and maintains the logic of the previous implementation.

CHANGELOG.md (1)
  • 55-56: The changelog correctly reflects the updates to the Cosmos SDK version and the setting of MinInitialDepositRatio. However, it would be beneficial to include the renaming of fields in the GenesisState and Params structures as part of the breaking changes section, as these are likely to affect downstream systems and require attention from developers integrating with the UIBC module.
x/uibc/README.md (4)
  • 26-26: The documentation mentions the use of x/oracle AvgKeeper to measure token average USD value over a 16-hour window. This is a critical piece of information for understanding how inflows and outflows are calculated. It's important to ensure that the AvgKeeper implementation is robust and that the 16-hour window is a suitable length of time for accurate measurements. If the window is too short, it may not capture enough data for a reliable average; if too long, it may not reflect recent price changes quickly enough.

  • 32-38: The renaming of total_inflow_sum to inflow_sum and total_outflow_sum to outflow_sum is reflected correctly in the documentation. This change simplifies the naming and makes it more intuitive. However, it is crucial to ensure that all references to these fields in the codebase, including comments and documentation, are updated to prevent confusion.

  • 47-52: The conditions for outflow transfers are well-documented, providing clear rules for when a transfer can occur. It's important to ensure that the logic in the code matches these documented rules exactly to prevent any unintended behavior. Additionally, the use of params.total_quota and params.token_quota should be carefully managed to avoid any potential overflow issues when performing calculations with these parameters.

  • 60-60: The documentation clarifies that tokens not registered in the x/leverage Token Registry are not subject to quota limits. This is an important exception that should be highlighted to ensure that users are aware of which tokens are affected by the quota mechanism. It may also be worth considering the implications of this for new tokens or tokens that are deregistered, as it could affect the overall security and risk management of the system.

x/uibc/quota/keeper/quota_test.go Show resolved Hide resolved
x/uibc/quota/keeper/quota_test.go Show resolved Hide resolved
x/uibc/quota/keeper/quota_test.go Show resolved Hide resolved
x/uibc/quota/keeper/quota_test.go Show resolved Hide resolved
x/uibc/quota/keeper/quota_test.go Show resolved Hide resolved
x/uibc/quota/keeper/quota.go Outdated Show resolved Hide resolved
x/uibc/quota/keeper/quota.go Show resolved Hide resolved
x/uibc/quota/keeper/quota.go Outdated Show resolved Hide resolved
x/uibc/quota/keeper/quota.go Outdated Show resolved Hide resolved
x/uibc/quota/keeper/quota.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: 12

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 6b7d6c2 and 2e32191.
Files selected for processing (8)
  • x/uibc/README.md (1 hunks)
  • x/uibc/genesis_test.go (1 hunks)
  • x/uibc/quota/keeper/genesis.go (2 hunks)
  • x/uibc/quota/keeper/grpc_query.go (1 hunks)
  • x/uibc/quota/keeper/keys.go (1 hunks)
  • x/uibc/quota/keeper/migrations.go (1 hunks)
  • x/uibc/quota/keeper/quota.go (7 hunks)
  • x/uibc/quota/keeper/unit_test.go (1 hunks)
Files skipped from review due to trivial changes (2)
  • x/uibc/quota/keeper/keys.go
  • x/uibc/quota/keeper/unit_test.go
Additional comments: 7
x/uibc/quota/keeper/grpc_query.go (1)
  • 37-43: The code has been updated to reflect the renaming of the method from GetTotalOutflow() to GetOutflowSum(). Ensure that the new method GetOutflowSum() is correctly implemented and that it provides the same functionality as the previous method, or that any changes in functionality are intentional and documented. Additionally, verify that all references to the old method name have been updated across the entire codebase to prevent any broken functionality.
x/uibc/genesis_test.go (1)
  • 19-20: The test case is correctly checking for negative amounts in the Outflows field. It is important to ensure that similar validation is performed in the actual Validate method of the GenesisState to prevent invalid state initialization.
x/uibc/quota/keeper/genesis.go (1)
  • 35-42: The ExportGenesis function has been correctly updated to reflect the renamed fields OutflowSum and InflowSum. This change should be cross-checked with other parts of the codebase to ensure that all references to these fields are consistent with the new naming convention.
x/uibc/quota/keeper/migrations.go (1)
  • 14-17: The function MigrateOutflowSum is part of the migration logic. It's crucial to ensure that this migration is idempotent and can be run multiple times without causing issues. Additionally, it should be verified that the migration is covered by tests to ensure that it behaves as expected when transitioning from v6.1.0 to v6.2.
x/uibc/README.md (1)
  • 26-26: The documentation mentions the use of x/oracle AvgKeeper for measuring token value in USD. It's important to ensure that the AvgKeeper is robust against price manipulation and provides a reliable measure of token value. This is critical for the correct functioning of the quota system, as it relies on the USD value of inflows and outflows.
x/uibc/quota/keeper/quota.go (2)
  • 121-132: The previous comment regarding error handling in ResetAllQuotas is still valid. The SetOutflowSum and SetInflowSum functions are called without checking for errors. The code should be updated to handle potential errors from these functions.
- k.SetOutflowSum(zero)
- k.SetInflowSum(zero)
+ if err := k.SetOutflowSum(zero); err != nil {
+     return err
+ }
+ if err := k.SetInflowSum(zero); err != nil {
+     return err
+ }
  • 260-267: The previous comment regarding error handling in RecordIBCInflow is still valid. The SetTokenInflow and SetInflowSum functions are called without checking for errors. The code should be updated to handle potential errors from these functions.
- k.SetTokenInflow(tokenInflow)
- k.SetInflowSum(totalInflowSum.Add(inflowInUSD))
+ if err := k.SetTokenInflow(tokenInflow); err != nil {
+     return channeltypes.NewErrorAcknowledgement(err)
+ }
+ if err := k.SetInflowSum(totalInflowSum.Add(inflowInUSD)); err != nil {
+     return channeltypes.NewErrorAcknowledgement(err)
+ }

x/uibc/genesis_test.go Show resolved Hide resolved
x/uibc/quota/keeper/genesis.go Show resolved Hide resolved
x/uibc/quota/keeper/genesis.go Show resolved Hide resolved
x/uibc/quota/keeper/migrations.go Show resolved Hide resolved
x/uibc/quota/keeper/migrations.go Show resolved Hide resolved
x/uibc/README.md Show resolved Hide resolved
x/uibc/README.md Show resolved Hide resolved
x/uibc/quota/keeper/quota.go Show resolved Hide resolved
x/uibc/quota/keeper/quota.go Show resolved Hide resolved
x/uibc/quota/keeper/quota.go Show resolved Hide resolved
@robert-zaremba robert-zaremba added this pull request to the merge queue Nov 20, 2023
Merged via the queue into main with commit 6f4b1f1 Nov 20, 2023
25 of 28 checks passed
@robert-zaremba robert-zaremba deleted the robert/quota-improvement branch November 20, 2023 17:36
This was referenced Apr 19, 2024
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