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(x/bank): Allow value with slashes in DenomMetadata #22543

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

JoowonYun
Copy link
Contributor

@JoowonYun JoowonYun commented Nov 18, 2024

Description

Closes: #22542

DenomMetadata does not work properly with slash.
Because of this, we have two RPCs that do the same thing. #16852
The solution to this has already been discussed below. cosmos/ibc-go#3045


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.

  • included the correct type prefix in the PR title, you can find examples of the prefixes below:
  • confirmed ! in the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • reviewed "Files changed" and left comments if necessary
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • updated the relevant documentation or specification, including comments for documenting Go code
  • confirmed all CI checks have passed

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.

Please see Pull Request Reviewer section in the contributing guide for more information on how to review a pull request.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic, API design and naming, documentation is accurate, tests and test coverage

Summary by CodeRabbit

  • New Features

    • Introduced a new message type, MsgBurn, for burning coins.
    • Added a resolve_denom field to enhance balance queries.
  • Improvements

    • Enhanced error handling in several coin transfer methods.
    • Updated routing options for DenomMetadata and DenomOwners RPC methods to support wildcard matching.
  • Bug Fixes

    • Resolved issues with negative spendable balances and improved balance reporting.
  • Breaking Changes

    • Removed DenomMetadataByQueryString RPC and updated several method signatures for better clarity.

Copy link
Contributor

coderabbitai bot commented Nov 18, 2024

📝 Walkthrough
📝 Walkthrough

Walkthrough

The pull request updates the Cosmos SDK's changelog and modifies the query.proto file in the cosmos.bank.v1beta1 package. Key changes include the introduction of the MsgBurn message type, enhancements to error handling in various coin-related methods, and the removal of the DenomMetadataByQueryString RPC method. The routing for DenomMetadata and DenomOwners has been updated to support wildcard matching, and a new field resolve_denom has been added to the QueryAllBalancesRequest message.

Changes

File Change Summary
x/bank/CHANGELOG.md Updated to include new features, improvements, bug fixes, breaking changes, and method signature updates.
x/bank/proto/cosmos/bank/v1beta1/query.proto Updated HTTP routing for DenomMetadata and DenomOwners, added resolve_denom field, removed DenomMetadataByQueryString.

Assessment against linked issues

Objective Addressed Explanation
Support slash in DenomMetadata RPC (#22542)

Possibly related PRs

Suggested labels

C:x/bank/v2

Suggested reviewers

  • julienrbrt
  • sontrinh16
  • akhilkumarpilli
  • kocubinski

📜 Recent review details

Configuration used: .coderabbit.yml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between e97e236 and 90bd3e5.

⛔ Files ignored due to path filters (2)
  • x/bank/types/query.pb.go is excluded by !**/*.pb.go
  • x/bank/types/query.pb.gw.go is excluded by !**/*.pb.gw.go
📒 Files selected for processing (3)
  • api/cosmos/bank/v1beta1/query.pulsar.go (2 hunks)
  • x/bank/CHANGELOG.md (1 hunks)
  • x/bank/proto/cosmos/bank/v1beta1/query.proto (2 hunks)
🔥 Files not summarized due to errors (1)
  • api/cosmos/bank/v1beta1/query.pulsar.go: Error: Server error: no LLM provider could handle the message
🚧 Files skipped from review as they are similar to previous changes (2)
  • x/bank/CHANGELOG.md
  • x/bank/proto/cosmos/bank/v1beta1/query.proto
🧰 Additional context used
📓 Path-based instructions (1)
api/cosmos/bank/v1beta1/query.pulsar.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

🔇 Additional comments (3)
api/cosmos/bank/v1beta1/query.pulsar.go (3)

14700-14711: LGTM! Consistent wildcard pattern usage.

The updated DenomMetadata endpoint now correctly supports denoms with slashes using the {denom=**} pattern.


14735-14747: LGTM! Consistent wildcard pattern usage.

The DenomOwners endpoint has been updated to use the same {denom=**} pattern, maintaining consistency with the DenomMetadata endpoint.


14711-14725: 🛠️ Refactor suggestion

Consider removing the redundant DenomMetadataByQueryString endpoint.

This endpoint serves the same purpose as the DenomMetadata endpoint, which now supports denoms with slashes. Having two endpoints for the same functionality increases maintenance overhead and could lead to confusion.


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>, please review it.
    • 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 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 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.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 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.

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.

@JoowonYun JoowonYun force-pushed the JoowonYun/22542-fix-rpc-denommetadata branch from bdde8a4 to b6ab249 Compare November 18, 2024 09:07
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.

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (5)
x/bank/CHANGELOG.md (2)

46-46: Enhance the bug fix description for better clarity.

The current entry could be more descriptive. Consider expanding it to:

-* [#22543](https://github.com/cosmos/cosmos-sdk/pull/22543) Fix `DenomMetadata` rpc allow value with slashes
+* [#22543](https://github.com/cosmos/cosmos-sdk/pull/22543) Fix `DenomMetadata` RPC to properly handle denom values containing slashes (e.g., ibc/xxx). Fixes #22542

59-59: Add context to the API breaking change.

The current entry should explain the rationale for removing the RPC. Consider expanding it to:

-* [#22543](https://github.com/cosmos/cosmos-sdk/pull/22543) Drop `DenomMetadataByQueryString` rpc
+* [#22543](https://github.com/cosmos/cosmos-sdk/pull/22543) Remove redundant `DenomMetadataByQueryString` RPC as its functionality is now handled by the improved `DenomMetadata` RPC
CHANGELOG.md (3)

Line range hint 1-1: Add version table at the top of changelog

Consider adding a version table at the top of the changelog that summarizes all versions with their release dates and major highlights. This would make it easier for users to quickly navigate to relevant versions.


Line range hint 13-13: Standardize version date formats

The date formats are inconsistent across versions. Some use YYYY-MM-DD format while others use Month DD, YYYY. Standardize all dates to use YYYY-MM-DD format for consistency.

Also applies to: 1124-1124


Line range hint 1124-1126: Add missing version numbers in Previous Releases section

The "Previous Releases" section should list the version numbers that are included in the linked changelog, rather than just linking to "previous versions".

📜 Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between fbd725d and b6ab249f59b78f6bd3401fdc450059764bd14478.

⛔ Files ignored due to path filters (3)
  • api/cosmos/bank/v1beta1/query_grpc.pb.go is excluded by !**/*.pb.go
  • x/bank/types/query.pb.go is excluded by !**/*.pb.go
  • x/bank/types/query.pb.gw.go is excluded by !**/*.pb.gw.go
📒 Files selected for processing (5)
  • CHANGELOG.md (1 hunks)
  • x/bank/CHANGELOG.md (2 hunks)
  • x/bank/keeper/grpc_query.go (0 hunks)
  • x/bank/keeper/grpc_query_test.go (0 hunks)
  • x/bank/proto/cosmos/bank/v1beta1/query.proto (2 hunks)
💤 Files with no reviewable changes (2)
  • x/bank/keeper/grpc_query.go
  • x/bank/keeper/grpc_query_test.go
🧰 Additional context used
📓 Path-based instructions (2)
CHANGELOG.md (1)

Pattern **/*.md: "Assess the documentation for misspellings, grammatical errors, missing documentation and correctness"

x/bank/CHANGELOG.md (1)

Pattern **/*.md: "Assess the documentation for misspellings, grammatical errors, missing documentation and correctness"

🔇 Additional comments (3)
x/bank/proto/cosmos/bank/v1beta1/query.proto (2)

80-80: LGTM: DenomMetadata path now supports slashes

The updated path parameter syntax {denom=**} correctly enables querying denoms containing slashes (e.g., "ibc/abc"), fixing the issue described in #22542.


98-98: LGTM: Consistent path parameter handling for DenomOwners

Good consistency improvement by applying the same {denom=**} syntax to the DenomOwners endpoint, ensuring uniform handling of denom values containing slashes.

CHANGELOG.md (1)

Line range hint 15-1123: LGTM on changelog content and organization

The changelog content is well organized by version and properly categorizes changes into Features, Improvements, Bug Fixes, and Breaking Changes. The descriptions are clear and provide good detail about the changes made.

@JoowonYun JoowonYun changed the title fix: Allow value with slashes in DenomMetadata fix(x/bank): Allow value with slashes in DenomMetadata Nov 18, 2024
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.

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (5)
x/bank/CHANGELOG.md (1)

46-46: Enhance the bug fix description with more context.

The current description "Fix DenomMetadata rpc allow value with slashes" could be more descriptive. Consider expanding it to:

-* [#22543](https://github.com/cosmos/cosmos-sdk/pull/22543) Fix `DenomMetadata` rpc allow value with slashes
+* [#22543](https://github.com/cosmos/cosmos-sdk/pull/22543) Fix `DenomMetadata` RPC to properly handle denom values containing slashes (e.g., ibc/... or tokenfactory/...). This issue affected SDK versions 0.47, 0.50, and main.
x/bank/proto/cosmos/bank/v1beta1/query.proto (1)

80-80: LGTM! Good solution for handling denoms with slashes

The updated HTTP routing pattern using {denom=**} is an elegant solution that allows the DenomMetadata endpoint to support denoms containing slashes (e.g., ibc/tokenfactory denoms) while maintaining a clean API design.

This change eliminates the need for a separate query endpoint, reducing API complexity and improving maintainability.

CHANGELOG.md (3)

Line range hint 1-1: Add title to the changelog file

The file should start with a clear title like "# Changelog" to follow standard changelog conventions.

+ # Changelog

Line range hint 12-15: Improve version header formatting

The version header should include a release date in a consistent format. The current format varies between versions.

- ## [v0.47.16](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.47.16) - 2024-09-20
+ ## [v0.47.16](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.47.16) - 2024-09-20

Line range hint 785-790: Fix inconsistent section headers

The "Bug Fixes" section uses different header styles across versions (### vs ##). Standardize the header levels.

- ### Bug Fixes
+ ## Bug Fixes
📜 Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between fbd725d and b6ab249.

⛔ Files ignored due to path filters (3)
  • api/cosmos/bank/v1beta1/query_grpc.pb.go is excluded by !**/*.pb.go
  • x/bank/types/query.pb.go is excluded by !**/*.pb.go
  • x/bank/types/query.pb.gw.go is excluded by !**/*.pb.gw.go
📒 Files selected for processing (5)
  • CHANGELOG.md (1 hunks)
  • x/bank/CHANGELOG.md (2 hunks)
  • x/bank/keeper/grpc_query.go (0 hunks)
  • x/bank/keeper/grpc_query_test.go (0 hunks)
  • x/bank/proto/cosmos/bank/v1beta1/query.proto (2 hunks)
💤 Files with no reviewable changes (2)
  • x/bank/keeper/grpc_query.go
  • x/bank/keeper/grpc_query_test.go
🧰 Additional context used
📓 Path-based instructions (2)
CHANGELOG.md (1)

Pattern **/*.md: "Assess the documentation for misspellings, grammatical errors, missing documentation and correctness"

x/bank/CHANGELOG.md (1)

Pattern **/*.md: "Assess the documentation for misspellings, grammatical errors, missing documentation and correctness"

🔇 Additional comments (2)
x/bank/proto/cosmos/bank/v1beta1/query.proto (1)

98-98: LGTM! Consistent handling of denoms with slashes

Good catch on applying the same pattern to the DenomOwners endpoint. This maintains consistency across the API for handling denoms with slashes.

CHANGELOG.md (1)

Line range hint 1-2000: LGTM for remaining content

The rest of the changelog content is well-structured and provides clear, detailed information about changes in each version. The categorization of changes (Features, Improvements, Bug Fixes, etc.) is consistent and helpful.

@@ -55,6 +56,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* [#19477](https://github.com/cosmos/cosmos-sdk/pull/19477) `appmodule.Environment` is passed to bank `NewKeeper`
* [#19627](https://github.com/cosmos/cosmos-sdk/pull/19627) The genesis api has been updated to match `appmodule.HasGenesis`.
* [#19740](https://github.com/cosmos/cosmos-sdk/pull/19740) `InitGenesis` and `ExportGenesis` module code and keeper code do not panic but return errors.
* [#22543](https://github.com/cosmos/cosmos-sdk/pull/22543) Drop `DenomMetadataByQueryString` rpc
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add migration guidance for the removed RPC.

The removal of DenomMetadataByQueryString RPC is a breaking change that requires migration guidance. Consider expanding the entry to:

-* [#22543](https://github.com/cosmos/cosmos-sdk/pull/22543) Drop `DenomMetadataByQueryString` rpc
+* [#22543](https://github.com/cosmos/cosmos-sdk/pull/22543) Remove `DenomMetadataByQueryString` RPC as its functionality is now supported by the enhanced `DenomMetadata` RPC. Users should migrate to using `DenomMetadata` RPC which now properly handles denom values containing slashes.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
* [#22543](https://github.com/cosmos/cosmos-sdk/pull/22543) Drop `DenomMetadataByQueryString` rpc
* [#22543](https://github.com/cosmos/cosmos-sdk/pull/22543) Remove `DenomMetadataByQueryString` RPC as its functionality is now supported by the enhanced `DenomMetadata` RPC. Users should migrate to using `DenomMetadata` RPC which now properly handles denom values containing slashes.

Copy link
Member

@julienrbrt julienrbrt left a comment

Choose a reason for hiding this comment

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

Hey! We should strive to not do client breaking changes, please bring back the query.

@@ -77,15 +77,9 @@ service Query {
// DenomMetadata queries the client metadata of a given coin denomination.
rpc DenomMetadata(QueryDenomMetadataRequest) returns (QueryDenomMetadataResponse) {
option (cosmos.query.v1.module_query_safe) = true;
option (google.api.http).get = "/cosmos/bank/v1beta1/denoms_metadata/{denom}";
option (google.api.http).get = "/cosmos/bank/v1beta1/denoms_metadata/{denom=**}";
Copy link
Member

Choose a reason for hiding this comment

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

TIL, that's pretty cool, could you do that for all applicable queries?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I looked into it, and it seems that except for the endpoint, there is no case where a slash comes in the path parameter.

Copy link
Member

Choose a reason for hiding this comment

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

Cool, thanks!

@julienrbrt julienrbrt changed the title fix(x/bank): Allow value with slashes in DenomMetadata feat(x/bank): Allow value with slashes in DenomMetadata Nov 18, 2024
@JoowonYun
Copy link
Contributor Author

Hey! We should strive to not do client breaking changes, please bring back the query.

Hmm.. reducing breaking changes is important, but these two rpc's seem to do exactly the same thing. Do you still want to keep them both?

@julienrbrt
Copy link
Member

Hey! We should strive to not do client breaking changes, please bring back the query.

Hmm.. reducing breaking changes is important, but these two rpc's seem to do exactly the same thing. Do you still want to keep them both?

Yes please, it has no cost to keep them both.

@JoowonYun JoowonYun force-pushed the JoowonYun/22542-fix-rpc-denommetadata branch from b6ab249 to b2e0396 Compare November 19, 2024 01:06
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.

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (3)
CHANGELOG.md (3)

Line range hint 1-1: Add title to changelog file

The changelog file should start with a clear title like "# Changelog" to follow standard documentation practices.

+ # Changelog

Line range hint 14-20: Improve version header formatting consistency

The version headers should follow a consistent format. Some headers have dates in parentheses while others use hyphens. Standardize on one format.

- ## [v0.47.14](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.47.14) - 2024-09-20
+ ## [v0.47.14](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.47.14) (2024-09-20)

Line range hint 1-2000: Add table of contents

For better navigation in such a large changelog, consider adding a table of contents at the beginning that links to major versions.

📜 Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between b6ab249 and b2e0396.

📒 Files selected for processing (2)
  • CHANGELOG.md (1 hunks)
  • x/bank/CHANGELOG.md (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • x/bank/CHANGELOG.md
🧰 Additional context used
📓 Path-based instructions (1)
CHANGELOG.md (1)

Pattern **/*.md: "Assess the documentation for misspellings, grammatical errors, missing documentation and correctness"

🔇 Additional comments (1)
CHANGELOG.md (1)

Line range hint 1-2000: Verify future dates

The changelog contains entries dated in the future (e.g. November 2024). These should be marked as unreleased or have their dates adjusted.

@JoowonYun
Copy link
Contributor Author

JoowonYun commented Nov 19, 2024

Hey! We should strive to not do client breaking changes, please bring back the query.

Hmm.. reducing breaking changes is important, but these two rpc's seem to do exactly the same thing. Do you still want to keep them both?

Yes please, it has no cost to keep them both.

Okay, I removed that commit.

Copy link
Contributor

@akhilkumarpilli akhilkumarpilli left a comment

Choose a reason for hiding this comment

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

lgtm, please fix failing test-system CI check

@julienrbrt julienrbrt added the backport/v0.52.x PR scheduled for inclusion in the v0.52's next stable release label Nov 19, 2024
Copy link
Member

@julienrbrt julienrbrt left a comment

Choose a reason for hiding this comment

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

utACK, thanks! Just one more change and we'll merge and backport

CHANGELOG.md Outdated
@@ -52,9 +52,11 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i

* (sims) [#21906](https://github.com/cosmos/cosmos-sdk/pull/21906) Skip sims test when running dry on validators
* (cli) [#21919](https://github.com/cosmos/cosmos-sdk/pull/21919) Query address-by-acc-num by account_id instead of id.
* (bank) [#22543](https://github.com/cosmos/cosmos-sdk/pull/22543) Fix `DenomMetadata` rpc allow value with slashes
Copy link
Member

Choose a reason for hiding this comment

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

Could you delete this changelog entry?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@JoowonYun JoowonYun force-pushed the JoowonYun/22542-fix-rpc-denommetadata branch from b2e0396 to e97e236 Compare November 20, 2024 01:29
@JoowonYun JoowonYun force-pushed the JoowonYun/22542-fix-rpc-denommetadata branch from e97e236 to 90bd3e5 Compare November 20, 2024 01:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/v0.52.x PR scheduled for inclusion in the v0.52's next stable release C:x/bank
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: rpc DenomMetadata can't support slash
3 participants