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

Merged
merged 17 commits into from
Jan 16, 2025

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
  • Bug Fixes

    • Fixed accessibility of HTTP bindings for address conversions.

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/authz

Suggested reviewers

  • julienrbrt
  • aljo242
  • tac0turtle

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
Collaborator

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

@technicallyty
Copy link
Contributor Author

technicallyty commented Jan 15, 2025

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.

OTOH, this request did lead me to finding a bug, which prompted #23390. however after that is merged, i think that type of surface for bugs is incredibly minimized since custom HTTP handling code is 0 at this point.

@aljo242
Copy link
Collaborator

aljo242 commented Jan 15, 2025

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.

I disagree. We should be aggressive with our testing. System tests are already taking up to 20min in CI, so running more comprehensive tests that act as end to end acceptance tests seems perfectly fine to me.

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

I disagree. We should be aggressive with our testing. System tests are already taking up to 20min in CI, so running more comprehensive tests that act as end to end acceptance tests seems perfectly fine to me.

More test is indeed better, but we do not need to spin up a testnet with 4 nodes, just to query one endpoint.
It's good to give us confidence for some endpoints (we do have grpc gateway system tests), but we do not need to be exhaustive about it. System tests are the most expensive tests so they should be used wisely on critical path, the rest integration and unit testing of each specific component should give us enough confidence.
We are already close to of the acceptable if you want it to run at each commit, on each PRs.

Just my two cents, but I remember @alpe warned us about using system tests wisely.

@technicallyty
Copy link
Contributor Author

technicallyty commented Jan 15, 2025

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.

I disagree. We should be aggressive with our testing. System tests are already taking up to 20min in CI, so running more comprehensive tests that act as end to end acceptance tests seems perfectly fine to me.

More test is indeed better, but we do not need to spin up a testnet with 4 nodes, just to query one endpoint. It's good to give us confidence for some endpoints (we do have grpc gateway system tests), but we do not need to be exhaustive about it. System tests are the most expensive tests so they should be used wisely on critical path, the rest integration and unit testing of each specific component should give us enough confidence. We are already close to of the acceptable if you want it to run at each commit, on each PRs.

Just my two cents, but I remember @alpe warned us about using system tests wisely.

this makes sense to me. i think for testing that an endpoint works, we should using something lighter than systemtest.

@julienrbrt is there an example of creating an application with a server and everything in a test that's not in systemtest?

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed the panic handler that ignores duplicate mux registration here 3e52f9d

@julienrbrt
Copy link
Member

julienrbrt commented Jan 16, 2025

this makes sense to me. i think for testing that an endpoint works, we should using something lighter than systemtest.

@julienrbrt is there an example of creating an application with a server and everything in a test that's not in systemtest?

To test that an endpoint work you do not need even need an app: https://github.com/cosmos/cosmos-sdk/blob/main/x/bank/keeper/grpc_query_test.go#L199-L254. You definitely need some system tests to be sure that the gRPC wiring is correct, but we have those. An integration test doesn't have consensus nor server but is a real app, so you could start a small one (however this needs to be fixed first #22825 😅)

However if you really want to add this as a system tests, then i'd just add it in an existing test instead of creating a new one (like this one: https://github.com/cosmos/cosmos-sdk/blob/main/tests/systemtests/auth_test.go#L477-L496) The impact would then be minimal.

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

498-540: Document the test address values.

The test cases comprehensively cover the address conversion endpoints. Consider adding comments to explain the hardcoded test values:

  • What these addresses represent
  • Why these specific values were chosen
  • How the base64 encoded values were derived
 addr := "cosmos1q6cc9u0x5r3fkjcex0rgxee5qlu86w8rh2ypaj"
+// Test address representing a valid cosmos address
 addrBytesURLEncoded := "BrGC8eag4ptLGTPGg2c0B%2Fh9OOM%3D"
+// URL-encoded base64 representation of the address bytes
 addrBytes := "BrGC8eag4ptLGTPGg2c0B/h9OOM="
+// Base64 representation of the address bytes
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 9638418 and 163537b.

⛔ Files ignored due to path filters (2)
  • server/v2/cometbft/go.sum is excluded by !**/*.sum
  • server/v2/go.sum is excluded by !**/*.sum
📒 Files selected for processing (6)
  • server/v2/api/grpcgateway/handler.go (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)
  • tests/systemtests/auth_test.go (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • tests/go.mod
  • server/v2/cometbft/go.mod
  • simapp/v2/go.mod
  • server/v2/go.mod
🧰 Additional context used
📓 Path-based instructions (2)
server/v2/api/grpcgateway/handler.go (1)

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

tests/systemtests/auth_test.go (3)

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"


Pattern **/*_test.go: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze
  • GitHub Check: Summary
🔇 Additional comments (3)
server/v2/api/grpcgateway/handler.go (1)

73-78: Verify the removal of panic handling for duplicate HTTP annotations.

The removal of panic handling could potentially expose the application to unhandled panics from duplicate HTTP annotations. While this aligns with the PR's objective to fix HTTP binding issues, we should verify this change doesn't impact error reporting.

✅ Verification successful

Removal of panic handling is safe and well-structured

The verification shows that duplicate HTTP annotations are prevented by design:

  • URIs are managed through a map structure that inherently prevents duplicates
  • Registration process is deterministic with sorted URI processing
  • Handler initialization is type-safe with proper struct field assignment
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any duplicate HTTP annotations that might cause panics
ast-grep --pattern 'google.api.http = {
  $$$
  get: "$_"
  $$$
}'

Length of output: 68


Script:

#!/bin/bash
# Find proto files and their HTTP annotations
fd -e proto -x rg -l "google\.api\.http"

# Check the context around handler registration for panic handling
rg -B 5 -A 5 "mux\.Handle.*protoHandler" server/

Length of output: 1961

tests/systemtests/auth_test.go (2)

Line range hint 478-497: LGTM! Test coverage improved.

The test now properly verifies memo preservation during transaction encoding and decoding.


Line range hint 542-600: LGTM! Comprehensive test coverage for fee payer functionality.

The test thoroughly covers:

  • Failure case when fee payer's signature is missing
  • Success case with proper signatures
  • Balance verification after fee deduction

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

500-540: Consider enhancing test coverage with additional edge cases.

The test cases are well-structured and cover the main scenarios. Consider adding:

  1. Tests for addresses with different prefixes (e.g., osmo1..., juno1...)
  2. Tests for addresses of different lengths
  3. Tests for malformed base64 encodings
 testCases := []systest.RestTestCase{
+    {
+        Name:    "should handle different address prefix",
+        Url:     fmt.Sprintf(stringToBytesPath, "osmo1q6cc9u0x5r3fkjcex0rgxee5qlu86w8rjd5225"),
+        ExpCode: http.StatusOK,
+        ExpOut:  `{"address_bytes":"..."}`, // Add expected bytes
+    },
+    {
+        Name:    "should fail with malformed base64",
+        Url:     fmt.Sprintf(bytesToStringPath, "!@#$"),
+        ExpCode: http.StatusBadRequest,
+        ExpOut:  `{"code":3,"message":"illegal base64 data","details":[]}`,
+    },
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 9638418 and 163537b.

⛔ Files ignored due to path filters (2)
  • server/v2/cometbft/go.sum is excluded by !**/*.sum
  • server/v2/go.sum is excluded by !**/*.sum
📒 Files selected for processing (6)
  • server/v2/api/grpcgateway/handler.go (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)
  • tests/systemtests/auth_test.go (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • tests/go.mod
  • server/v2/cometbft/go.mod
  • server/v2/go.mod
  • simapp/v2/go.mod
🧰 Additional context used
📓 Path-based instructions (2)
server/v2/api/grpcgateway/handler.go (1)

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

tests/systemtests/auth_test.go (3)

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"


Pattern **/*_test.go: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Summary
🔇 Additional comments (3)
server/v2/api/grpcgateway/handler.go (1)

73-78: LGTM! Verify route registration behavior.

The simplified route registration aligns with the PR's objective to support multiple HTTP bindings. However, let's verify there are no unintended side effects.

✅ Verification successful

Route registration change is safe and verified

The simplified route registration aligns with the codebase's HTTP routing patterns. All routes are properly namespaced by module and version, with no conflicting patterns that could cause routing issues. The removal of panic handling is safe in this context.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for potential duplicate HTTP routes that might conflict
# Look for routes with similar patterns but different HTTP methods

# Search for HTTP rule annotations in proto files
rg -A 5 "option \(google\.api\.http\)" 

Length of output: 68298

tests/systemtests/auth_test.go (2)

7-7: LGTM!

The addition of net/http import is appropriate for the new REST API test cases.


Line range hint 478-499: LGTM! Function name accurately reflects expanded scope.

The function rename better describes its expanded functionality, and the chain start is correctly positioned before the REST queries.

@technicallyty technicallyty added this pull request to the merge queue Jan 16, 2025
Merged via the queue into main with commit 9a27317 Jan 16, 2025
79 of 80 checks passed
@technicallyty technicallyty deleted the technicallyty/23281-duplicate-annotation branch January 16, 2025 17:38
mergify bot pushed a commit that referenced this pull request Jan 16, 2025
…te HTTP binding (#23357)

(cherry picked from commit 9a27317)

# Conflicts:
#	CHANGELOG.md
#	api/cosmos/auth/v1beta1/query.pulsar.go
#	server/v2/api/grpcgateway/handler.go
#	server/v2/cometbft/go.mod
#	server/v2/cometbft/go.sum
#	server/v2/go.mod
#	simapp/v2/go.mod
#	simapp/v2/go.sum
#	tests/go.mod
#	tests/go.sum
#	x/params/go.sum
julienrbrt pushed a commit that referenced this pull request Jan 17, 2025
…te HTTP binding (backport #23357) (#23422)

Co-authored-by: Tyler <48813565+technicallyty@users.noreply.github.com>
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 api 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