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

Merged

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 new RPC method DenomsMetadata to query metadata for all registered coin denominations.
  • Improvements

    • Enhanced error handling in various coin transfer and delegation methods.
    • Updated balance queries to accurately reflect spendable balances.
  • Bug Fixes

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

    • Modified existing methods for better routing and removed redundant methods to streamline the API.

Copy link
Contributor

coderabbitai bot commented Nov 18, 2024

📝 Walkthrough

Walkthrough

The pull request includes updates to the Cosmos SDK's changelog and the query.proto file. It introduces a new message type MsgBurn for burning coins and enhances error handling in several methods related to coin transactions. Additionally, it modifies the API routing for querying coin metadata and removes redundant methods. The changes also address a bug related to querying denominations with slashes by updating the DenomMetadata method's routing.

Changes

File Path Change Summary
x/bank/CHANGELOG.md Updated to reflect new features, improvements, bug fixes, and breaking changes; added MsgBurn.
Enhanced error handling in multiple methods; updated signatures for several methods.
x/bank/proto/cosmos/bank/v1beta1/query.proto Added new RPC method DenomsMetadata; modified routing for DenomMetadata and DenomOwners.
Removed DenomMetadataByQueryString method; added resolve_denom field in QueryAllBalancesRequest.

Assessment against linked issues

Objective Addressed Explanation
Support querying denoms that contain slashes (#22542)

Possibly related PRs

Suggested labels

C:x/bank/v2

Suggested reviewers

  • kocubinski
  • sontrinh16
  • julienrbrt
  • akhilkumarpilli

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 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 (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 b6ab249f59b78f6bd3401fdc450059764bd14478 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
@julienrbrt
Copy link
Member

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 (1)
tests/systemtests/rest_cli.go (1)

URL handling needs improvement in GetRequestWithHeaders

Based on the test cases found, there are potential issues with the current URL handling implementation:

  1. The use of path.Join() in GetRequestWithHeaders is problematic as it:

    • Strips trailing slashes which could be significant for some APIs
    • Doesn't properly handle query parameters (everything after '?')
    • May incorrectly handle URL-encoded characters
  2. Test cases show various URL patterns including:

    • Query parameters (e.g., ?denom=foobar, ?pagination.limit=1)
    • Path parameters (e.g., /validators/%s/commission)
    • URL-encoded values that need preservation

Recommended changes:

  • Replace path.Join(url) with proper URL parsing and construction using url.Parse() and url.URL methods
  • Add test cases specifically for URL encoding and special characters
🔗 Analysis chain

Line range hint 1-89: Verify test coverage for URL handling scenarios

Since this is a test utility used across the codebase, we should ensure it properly handles various URL scenarios.


Let me gather more information about the URL handling in the test cases.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find test cases using this utility to ensure they handle URLs with special characters correctly

# Search for test cases using GetRequestWithHeaders or GetRequest
rg -l "GetRequest(With)?Headers?\(" --type go | while read -r file; do
    echo "=== $file ==="
    # Show the test cases with context
    rg -B 2 -A 2 "GetRequest(With)?Headers?\(" "$file"
done

Length of output: 2438


Script:

#!/bin/bash
# Search for actual URL patterns used in test cases
rg -B 2 -A 0 '\.url\s*=.*' --type go tests/systemtests/

# Also check if there are any test cases with special characters in URLs
rg -B 2 -A 0 '\.url\s*=.*[%?&=+]' --type go tests/systemtests/

Length of output: 122


Script:

#!/bin/bash
# Let's try a different approach to find test cases and their URL patterns
rg -A 10 'var\s+\w*[tT]est[cC]ases\s*=\s*\[\]' --type go tests/systemtests/ | grep -A 10 'url:'

# Also check the implementation for potential URL handling issues
ast-grep --pattern 'func GetRequestWithHeaders($$$) {
  $$$
  req, err := http.NewRequest("GET", path.Join(url), nil)
  $$$
}'

Length of output: 224


Script:

#!/bin/bash
# Search for test case definitions with more context
rg -B 2 -A 15 'RestTestCase\{' --type go tests/systemtests/

# Also check for any query parameter handling in URLs
rg -B 2 -A 2 'url\s*:.*\?' --type go tests/systemtests/

Length of output: 15377

📜 Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

📥 Commits

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

📒 Files selected for processing (1)
  • tests/systemtests/rest_cli.go (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
tests/systemtests/rest_cli.go (2)

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


Pattern tests/**/*: "Assess the integration and e2e test code assessing sufficient code coverage for the changes associated in the pull request"

tests/systemtests/rest_cli.go Outdated Show resolved Hide resolved
@JoowonYun JoowonYun force-pushed the JoowonYun/22542-fix-rpc-denommetadata branch from 23d8233 to 652f72f Compare November 25, 2024 06:57
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: 2

🧹 Outside diff range and nitpick comments (2)
tests/systemtests/rest_cli.go (2)

78-79: Consolidate and improve request logging

Multiple println statements make it harder to follow the test flow. Consider consolidating the logging and using proper test logger.

-println(`req : `, req.URL.String())
+t.Logf("Request details - URL: %s, Method: %s", req.URL.String(), req.Method)
🧰 Tools
🪛 golangci-lint (1.61.0)

78-78: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

(gci)


69-85: Consider adding test cases for redirect scenarios

While the code now handles and logs redirects, there are no test cases specifically verifying this behavior. Consider adding test cases that:

  1. Verify successful redirect handling
  2. Test maximum redirect limits
  3. Validate the behavior with various redirect status codes (301, 302, 307, 308)

Would you like assistance in generating these test cases?

🧰 Tools
🪛 golangci-lint (1.61.0)

69-69: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

(gci)


78-78: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

(gci)


83-83: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

(gci)

📜 Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 23d8233 and 652f72f.

📒 Files selected for processing (1)
  • tests/systemtests/rest_cli.go (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
tests/systemtests/rest_cli.go (2)

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


Pattern tests/**/*: "Assess the integration and e2e test code assessing sufficient code coverage for the changes associated in the pull request"

🪛 golangci-lint (1.61.0)
tests/systemtests/rest_cli.go

69-69: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

(gci)


78-78: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

(gci)


83-83: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

(gci)

tests/systemtests/rest_cli.go Outdated Show resolved Hide resolved
tests/systemtests/rest_cli.go Outdated Show resolved Hide resolved
@JoowonYun JoowonYun force-pushed the JoowonYun/22542-fix-rpc-denommetadata branch from 652f72f to fef7b7f Compare November 25, 2024 07:30
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 (2)
x/bank/proto/cosmos/bank/v1beta1/query.proto (1)

Line range hint 90-93: Remove redundant DenomMetadataByQueryString method.

Now that the DenomMetadata endpoint properly handles slashes in denoms, this method is redundant and should be removed along with its request/response message types as mentioned in the PR summary.

Apply this diff to remove the redundant method and its message types:

- // DenomMetadataByQueryString queries the client metadata of a given coin denomination.
- rpc DenomMetadataByQueryString(QueryDenomMetadataByQueryStringRequest)
-     returns (QueryDenomMetadataByQueryStringResponse) {
-   option (cosmos.query.v1.module_query_safe) = true;
-   option (google.api.http).get               = "/cosmos/bank/v1beta1/denoms_metadata_by_query_string";
- }

- // QueryDenomMetadataByQueryStringRequest is the request type for the Query/DenomMetadata RPC method.
- // Identical with QueryDenomMetadataRequest but receives denom as query string.
- message QueryDenomMetadataByQueryStringRequest {
-   // denom is the coin denom to query the metadata for.
-   string denom = 1;
- }
- 
- // QueryDenomMetadataByQueryStringResponse is the response type for the Query/DenomMetadata RPC
- // method. Identical with QueryDenomMetadataResponse but receives denom as query string in request.
- message QueryDenomMetadataByQueryStringResponse {
-   // metadata describes and provides all the client information for the requested token.
-   Metadata metadata = 1 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true];
- }

Also applies to: 269-281

api/cosmos/bank/v1beta1/query.pulsar.go (1)

14700-14721: Consider consolidating redundant endpoints.

The code introduces two endpoints (DenomMetadata and DenomMetadataByQueryString) that serve the same purpose. While maintaining both endpoints for backward compatibility is understandable, this creates unnecessary API surface area and potential maintenance overhead.

Consider:

  1. Deprecating one of the endpoints in future versions
  2. Adding API documentation to clarify the preferred endpoint
  3. Planning for eventual consolidation in a future major version

Also applies to: 14722-14735

📜 Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 652f72f and fef7b7f.

⛔ 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 (2)
  • api/cosmos/bank/v1beta1/query.pulsar.go (4 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
🧰 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 (5)
x/bank/proto/cosmos/bank/v1beta1/query.proto (3)

77-82: LGTM! Well-structured new RPC method.

The implementation follows the standard patterns with proper pagination support and safety options.


87-87: LGTM! Correct implementation for handling slashes in denom.

The {denom=**} pattern is the proper way to handle path parameters containing slashes in gRPC-gateway.


105-105: LGTM! Consistent update for DenomOwners endpoint.

Good catch on updating this endpoint as well to maintain consistency in handling denoms with slashes.

api/cosmos/bank/v1beta1/query.pulsar.go (2)

14718-14721: LGTM! Consistent pattern for handling denoms with slashes.

The implementation correctly uses the {denom=**} pattern in the endpoint paths to support denoms containing slashes. This is consistent across both metadata and owner endpoints.

Also applies to: 14746-14747


14742-14743: Verify SDK version compatibility.

The code contains references to different SDK versions (0.46, 0.50.3, 0.47). This inconsistency might indicate potential compatibility issues.

Also applies to: 14755-14756, 14767-14768

@JoowonYun
Copy link
Contributor Author

JoowonYun commented Nov 25, 2024

Looks like there's a regression: https://github.com/cosmos/cosmos-sdk/actions/runs/11925210497/job/33247052543?pr=22543

@julienrbrt Fix it!

@julienrbrt julienrbrt added this pull request to the merge queue Nov 25, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 25, 2024
@julienrbrt julienrbrt added this pull request to the merge queue Nov 25, 2024
Merged via the queue into cosmos:main with commit 6cbd15c Nov 25, 2024
71 of 74 checks passed
mergify bot pushed a commit that referenced this pull request Nov 25, 2024
(cherry picked from commit 6cbd15c)

# Conflicts:
#	api/cosmos/bank/v1beta1/query.pulsar.go
#	api/cosmos/bank/v1beta1/query_grpc.pb.go
julienrbrt added a commit that referenced this pull request Nov 25, 2024
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