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

fix(x/auth): update proto address conversion query to prevent duplicate HTTP binding #23357

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

Conversation

technicallyty
Copy link
Contributor

@technicallyty technicallyty commented Jan 13, 2025

Description

Closes: #23281

  • updates the AddressStringToBytes HTTP annotation so it is actually available, and updates the AddressBytesToString HTTP annotation with an additional binding to match the terminology change.

Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • 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

  • Dependency Updates

    • Updated cosmossdk.io/api dependency to version v0.8.2-0.20250114014050-e279d7cec391 across multiple modules
    • Updated module configurations in server/v2, simapp/v2, and tests go.mod files
  • API Modifications

    • Enhanced account query functionality with pagination support
    • Updated address conversion RPC methods with new HTTP bindings
    • Added new HTTP bindings for address conversions to improve functionality

Copy link
Contributor

coderabbitai bot commented Jan 13, 2025

📝 Walkthrough

Walkthrough

This pull request addresses HTTP binding issues for address conversion methods in the Cosmos SDK. The changes modify the AddressBytesToString and AddressStringToBytes RPC methods to have distinct HTTP endpoints, resolving a conflict where both methods previously mapped to the same URI. Additionally, the PR updates several go.mod files to upgrade the cosmossdk.io/api dependency to version v0.8.2-0.20250114014050-e279d7cec391 across multiple modules.

Changes

File Change Summary
CHANGELOG.md Added entry about fixing AddressStringToBytes HTTP binding and adding AddressBytesToString binding
api/cosmos/auth/v1beta1/query.pulsar.go Added pagination field to QueryAccountsRequest and QueryAccountsResponse
proto/cosmos/auth/v1beta1/query.proto Updated HTTP bindings for AddressBytesToString and AddressStringToBytes methods
server/v2/cometbft/go.mod, server/v2/go.mod, simapp/v2/go.mod, tests/go.mod Updated cosmossdk.io/api dependency to v0.8.2-0.20250114014050-e279d7cec391

Sequence Diagram

sequenceDiagram
    participant Client
    participant Server
    participant AddressConverter

    Client->>Server: Request AddressBytesToString
    Server->>AddressConverter: Convert bytes to string
    AddressConverter-->>Server: Return string representation
    Server-->>Client: Respond with converted address

    Client->>Server: Request AddressStringToBytes
    Server->>AddressConverter: Convert string to bytes
    AddressConverter-->>Server: Return byte representation
    Server-->>Client: Respond with converted address
Loading

Assessment against linked issues

Objective Addressed Explanation
Fix HTTP annotation mapping conflict
Ensure distinct endpoints for address conversion methods

Possibly related PRs

Suggested labels

C:x/tx, T:Docs

Suggested reviewers

  • julienrbrt
  • tac0turtle
  • sontrinh16

Finishing Touches

  • 📝 Generate Docstrings (Beta)

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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

@julienrbrt julienrbrt added the backport/v0.52.x PR scheduled for inclusion in the v0.52's next stable release label Jan 13, 2025
@github-actions github-actions bot added the C:server/v2 Issues related to server/v2 label Jan 14, 2025
@technicallyty technicallyty marked this pull request as ready for review January 14, 2025 22:32

This comment has been minimized.

@technicallyty
Copy link
Contributor Author

@julienrbrt i imagine this should be backported to v0.52 and thats where i should put the changelog entry? i imagine we may want to tag a minor bump for the api package and update deps for v0.52 as well?

@julienrbrt
Copy link
Member

julienrbrt commented Jan 14, 2025

@julienrbrt i imagine this should be backported to v0.52 and thats where i should put the changelog entry? i imagine we may want to tag a minor bump for the api package and update deps for v0.52 as well?

Correct it should be backported. x/auth isn't an extracted module from the SDK, so the changelog should only be in CHANGELOG.md.

Once merged you can do the following:

git checkout main
git pull
git tag api/v0.8.2 -m 'Release api v0.8.2' -s 
git push

Afterwards instead of using the pseudo version in the backport PR from mergify, just use v0.8.2

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

🧹 Nitpick comments (3)
api/cosmos/auth/v1beta1/query.pulsar.go (3)

Line range hint 52-53: Consider documenting the expected account types.

The accounts field uses google.protobuf.Any for flexibility, but it would be helpful to document which concrete account types can be expected here for better type safety and easier client implementation.


9530-9537: Document error handling for address conversion endpoints.

The HTTP bindings for address conversion should document possible error cases and their corresponding HTTP status codes, especially for invalid addresses or encoding/decoding failures.


9551-9562: Consider adding pagination support for AccountInfo queries.

For consistency with other query endpoints and to handle large result sets efficiently, consider adding pagination support to the AccountInfo query endpoint.

📜 Review details

Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1c9159d and d73f87d.

⛔ Files ignored due to path filters (7)
  • client/grpc/reflection/reflection.pb.go is excluded by !**/*.pb.go
  • server/v2/cometbft/go.sum is excluded by !**/*.sum
  • server/v2/go.sum is excluded by !**/*.sum
  • simapp/v2/go.sum is excluded by !**/*.sum
  • tests/go.sum is excluded by !**/*.sum
  • x/auth/types/query.pb.go is excluded by !**/*.pb.go
  • x/auth/types/query.pb.gw.go is excluded by !**/*.pb.gw.go
📒 Files selected for processing (6)
  • api/cosmos/auth/v1beta1/query.pulsar.go (2 hunks)
  • proto/cosmos/auth/v1beta1/query.proto (1 hunks)
  • server/v2/cometbft/go.mod (1 hunks)
  • server/v2/go.mod (1 hunks)
  • simapp/v2/go.mod (1 hunks)
  • tests/go.mod (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
tests/go.mod (1)

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

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

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

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze
  • GitHub Check: Summary
🔇 Additional comments (6)
proto/cosmos/auth/v1beta1/query.proto (3)

66-71: LGTM! Good approach to maintain backward compatibility.

The additional binding for the decode endpoint provides better clarity while maintaining the original endpoint for backward compatibility.


73-77: Endpoint path now better reflects the operation.

The change from /bech32/{address_string} to /bech32/encode/{address_string} improves API clarity by explicitly indicating the operation type.


79-84: LGTM! No functional changes.

Only formatting changes were made to improve code readability.

server/v2/cometbft/go.mod (1)

17-17: LGTM! Consistent version update.

The version update is consistent with other modules.

tests/go.mod (1)

6-6: LGTM! Consistent version update.

The version update is consistent with other modules.

simapp/v2/go.mod (1)

6-6: LGTM! Consistent version update.

The version update is consistent with other modules.

server/v2/go.mod 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.

Actionable comments posted: 0

🧹 Nitpick comments (4)
CHANGELOG.md (4)

Line range hint 1-1: Add missing title to the CHANGELOG file

The file should start with a # title like "# Changelog" for better documentation.

+ # Changelog

60-60: Fix inconsistent bullet point style

The bullet point style is inconsistent with the rest of the file. Other entries use - while this one uses *.

- * (x/auth) [#23357](https://github.com/cosmos/cosmos-sdk/pull/23357) Fixes accessibility of the AddressStringToBytes HTTP binding and adds another binding to AddressBytesToString.
+ * (x/auth) [#23357](https://github.com/cosmos/cosmos-sdk/pull/23357) Fixes accessibility of the AddressStringToBytes HTTP binding and adds another binding to AddressBytesToString.

Line range hint 785-790: Fix broken link formatting

The link to previous versions contains raw markdown that should be properly formatted.

- [CHANGELOG of previous versions](https://github.com/cosmos/cosmos-sdk/blob/c17c3caab86a1426a1eef4541e8203f5f54a1a54/CHANGELOG.md#v0391---2020-08-11) (pre Stargate).
+ See [CHANGELOG of previous versions](https://github.com/cosmos/cosmos-sdk/blob/c17c3caab86a1426a1eef4541e8203f5f54a1a54/CHANGELOG.md#v0391---2020-08-11) for changes before Stargate.

Line range hint 791-793: Remove unnecessary code block

There's an empty code block at the end of the file that should be removed.

- ```
📜 Review details

Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1c9159d and 9638418.

⛔ Files ignored due to path filters (7)
  • client/grpc/reflection/reflection.pb.go is excluded by !**/*.pb.go
  • server/v2/cometbft/go.sum is excluded by !**/*.sum
  • server/v2/go.sum is excluded by !**/*.sum
  • simapp/v2/go.sum is excluded by !**/*.sum
  • tests/go.sum is excluded by !**/*.sum
  • x/auth/types/query.pb.go is excluded by !**/*.pb.go
  • x/auth/types/query.pb.gw.go is excluded by !**/*.pb.gw.go
📒 Files selected for processing (7)
  • CHANGELOG.md (1 hunks)
  • api/cosmos/auth/v1beta1/query.pulsar.go (2 hunks)
  • proto/cosmos/auth/v1beta1/query.proto (1 hunks)
  • server/v2/cometbft/go.mod (1 hunks)
  • server/v2/go.mod (1 hunks)
  • simapp/v2/go.mod (1 hunks)
  • tests/go.mod (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
tests/go.mod (1)

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

CHANGELOG.md (1)

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

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

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

⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Analyze
  • GitHub Check: test-system-v2
  • GitHub Check: Summary
🔇 Additional comments (12)
api/cosmos/auth/v1beta1/query.pulsar.go (4)

9530-9537: HTTP bindings for address conversion have been updated correctly

The HTTP bindings for address conversion methods have been properly updated with distinct endpoints:

  • /cosmos/auth/v1beta1/bech32/decode/{address_bytes} for bytes to string conversion
  • /cosmos/auth/v1beta1/bech32/{address_bytes} as an alternative endpoint

9538-9550: HTTP binding for address string to bytes conversion is properly defined

The endpoint /cosmos/auth/v1beta1/bech32/encode/{address_string} is correctly defined for string to bytes conversion, maintaining API consistency.


Line range hint 16-24: Message definitions follow protobuf best practices

The message definitions properly use the Any type for account interfaces and include appropriate pagination support. The code follows protobuf best practices for message definitions.


9562-9575: Package metadata is properly configured

The generated code includes complete package metadata with proper Go package path and protobuf options. The metadata ensures correct integration with the Cosmos SDK.

proto/cosmos/auth/v1beta1/query.proto (4)

66-71: Well-structured HTTP bindings for address decoding!

The addition of a more descriptive /decode/ endpoint while maintaining the original endpoint for backward compatibility is a good approach.


73-77: Consistent HTTP binding pattern for address encoding!

The endpoint now follows a consistent pattern with its decode counterpart, using /encode/ to clearly indicate its purpose.


79-84: LGTM - Well-documented RPC method!

The method includes all necessary annotations for versioning, safety, and HTTP binding.


66-84: Verify no remaining duplicate HTTP bindings.

Let's ensure there are no other duplicate HTTP bindings in the codebase.

✅ Verification successful

HTTP bindings verification successful

The changes have successfully eliminated duplicate HTTP bindings, and no other duplicates were found in the codebase. The new encode/decode path segments are properly organized.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for duplicate HTTP bindings in proto files
# Expected: No duplicate GET paths should be found

# Find all proto files and extract HTTP GET paths
rg -t proto 'option \(google\.api\.http\).*get:.*"([^"]+)"' -o | sort | uniq -d

# Also check additional_bindings
rg -t proto 'additional_bindings.*get:.*"([^"]+)"' -o | sort | uniq -d

Length of output: 214


Script:

#!/bin/bash
# Find all proto files first, then search within them
fd '\.proto$' | xargs rg 'get: "([^"]+)"' -o | sort | uniq -c | awk '$1 > 1 {print $0}'

Length of output: 89

server/v2/go.mod (1)

12-12: Verify the accessibility of the pseudo-version.

The dependency update to cosmossdk.io/api v0.8.2-0.20250114014050-e279d7cec391 uses a pseudo-version with a timestamp from 2025. This future date might cause issues with dependency resolution.

server/v2/cometbft/go.mod (1)

17-17: Consistent dependency update.

The update to cosmossdk.io/api v0.8.2-0.20250114014050-e279d7cec391 aligns with the version used in other modules, maintaining consistency across the codebase.

tests/go.mod (1)

6-6: Consistent dependency update.

The update to cosmossdk.io/api v0.8.2-0.20250114014050-e279d7cec391 aligns with the version used in other modules, maintaining consistency across the codebase.

simapp/v2/go.mod (1)

6-6: Consistent dependency update.

The update to cosmossdk.io/api v0.8.2-0.20250114014050-e279d7cec391 aligns with the version used in other modules, maintaining consistency across the codebase.

Copy link
Contributor

@aljo242 aljo242 left a comment

Choose a reason for hiding this comment

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

Can we add system tests for these end points?

@julienrbrt
Copy link
Member

Can we add system tests for these end points?

imho that isn't necessary, we have an unit test for it. system tests are expensive in CI time, and this isn't a critical flow and that would basically mean testing the grpc gateway implementation.

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:CLI C:server/v2 cometbft C:server/v2 Issues related to server/v2 C:x/auth
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: AddressBytesToString and AddressStringToBytes HTTP annotation maps to the same URI
4 participants