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

use bech32 addresses for mapped address queries; resolves #1719 #1766

Merged
merged 3 commits into from
Dec 3, 2024

Conversation

joe-bowman
Copy link
Contributor

@joe-bowman joe-bowman commented Dec 2, 2024

1. Summary

Fixes #1719

  • Add new query for lookup of local address from a remote address (inverse lookup)
  • Ensure output for all mapped_account queries is bech32 encoded
  • Add tests for new query

2.Type of change

  • New feature (non-breaking change which adds functionality)

Summary by CodeRabbit

  • New Features

    • Introduced several new API endpoints for enhanced functionality, including retrieval of mapped addresses and user withdrawal records.
    • Added a new method for querying inverse mapped accounts.
  • Modifications

    • Renamed and simplified existing endpoints for clarity and usability.
    • Updated response schemas and parameter definitions to improve data structure and clarity.
  • Bug Fixes

    • Enhanced error handling and validation in account mapping methods.
  • Tests

    • Added new tests for the inverse mapping functionality and improved existing tests for address validation.

Copy link
Contributor

coderabbitai bot commented Dec 2, 2024

Walkthrough

The pull request introduces extensive modifications to the API specifications and service definitions for the Quicksilver Chain. Key changes include the addition of several new endpoints, updates to existing endpoint paths and response schemas, and the introduction of new gRPC methods for querying mapped and inverse mapped accounts. The changes enhance the functionality and clarity of the API, aligning it with new requirements for address encoding and data handling.

Changes

File Path Change Summary
docs/swagger.yml Added new endpoints for mapped addresses and withdrawal records; modified existing endpoints and response schemas.
proto/quicksilver/interchainstaking/v1/query.proto Added new RPC method for inverse mapped accounts; updated existing method paths and message types.
x/interchainstaking/keeper/grpc_query.go Added method for inverse mapped accounts; updated variable types for mapped accounts.
x/interchainstaking/keeper/grpc_query_test.go Added tests for the new inverse mapped accounts method; modified existing tests for mapped accounts.

Assessment against linked issues

Objective Addressed Explanation
Update mapped address query to bech32 output (#1719)

Possibly related PRs

Suggested reviewers

  • faddat
  • ajansari95
  • minhngoc274

Poem

🐇 In the land of code where bunnies play,
New paths and queries brighten the day.
Mapped addresses now shine in Bech32,
With each hop and leap, we code with glee!
So let’s celebrate this API delight,
For every change makes our future bright! 🌟


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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

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 (4)
x/interchainstaking/keeper/grpc_query_test.go (1)

1182-1315: Update test case names to reflect the function under test

In the TestKeeper_InverseMappedAccounts function, the test case names start with "MappedAccounts_", which may cause confusion. Consider renaming them to start with "InverseMappedAccounts_" to accurately represent the function being tested.

proto/quicksilver/interchainstaking/v1/query.proto (2)

103-104: Be cautious with changing API endpoint paths to avoid breaking clients

Changing the HTTP GET path for the MappedAccounts RPC method may affect clients that rely on the existing endpoint. Consider maintaining backward compatibility by supporting the old path or incrementing the API version.


298-299: Changing field type in response message may break client compatibility

Updating remote_address_map from map<string, bytes> to map<string, string> changes the wire format and can break clients that depend on the previous message structure. Ensure that clients are ready to handle this change or consider versioning the API messages to maintain compatibility.

docs/swagger.yml (1)

2899-2938: Add summary and descriptions for the new API endpoint

The newly added endpoint /quicksilver/interchainstaking/v1/mapped_addresses/remote/{chain_id}/{remote_address} lacks a summary field and parameter descriptions. Including a summary, detailed description, and parameter descriptions will enhance the API documentation and improve clarity for users.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 1bd45ff and 2adebf8.

⛔ Files ignored due to path filters (2)
  • x/interchainstaking/types/query.pb.go is excluded by !**/*.pb.go
  • x/interchainstaking/types/query.pb.gw.go is excluded by !**/*.pb.gw.go
📒 Files selected for processing (4)
  • docs/swagger.yml (4 hunks)
  • proto/quicksilver/interchainstaking/v1/query.proto (2 hunks)
  • x/interchainstaking/keeper/grpc_query.go (1 hunks)
  • x/interchainstaking/keeper/grpc_query_test.go (2 hunks)
🔇 Additional comments (3)
x/interchainstaking/keeper/grpc_query.go (1)

360-383: The new InverseMappedAccounts method is well implemented

The InverseMappedAccounts method correctly handles input validation, retrieves the necessary zone information, and properly returns the local address corresponding to the given remote address and chain ID.

x/interchainstaking/keeper/grpc_query_test.go (1)

1433-1438: Good addition of validation for Bech32 address decoding

The added validation in TestKeeper_MappedAccounts ensures that the returned addresses are correctly encoded in Bech32 format and can be decoded using the appropriate account prefix.

proto/quicksilver/interchainstaking/v1/query.proto (1)

301-307: New RPC method and messages are appropriately defined

The InverseMappedAccounts RPC method and its request and response messages are well-defined and align with existing conventions.

x/interchainstaking/keeper/grpc_query.go Outdated Show resolved Hide resolved
Copy link

codecov bot commented Dec 2, 2024

Codecov Report

Attention: Patch coverage is 37.93103% with 18 lines in your changes missing coverage. Please review.

Project coverage is 61.41%. Comparing base (fe73f54) to head (66d0e36).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
x/interchainstaking/keeper/grpc_query.go 37.93% 12 Missing and 6 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1766      +/-   ##
==========================================
- Coverage   61.46%   61.41%   -0.05%     
==========================================
  Files         196      196              
  Lines       17079    17105      +26     
==========================================
+ Hits        10497    10505       +8     
- Misses       5735     5747      +12     
- Partials      847      853       +6     
Flag Coverage Δ
unittests 61.41% <37.93%> (-0.05%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
x/interchainstaking/keeper/grpc_query.go 82.87% <37.93%> (-4.51%) ⬇️

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/interchainstaking/keeper/grpc_query.go (2)

353-356: Consider logging errors during address encoding

When an error occurs while encoding the address with EncodeAddressToBech32, the error is currently ignored, and the iteration continues. For better observability and debugging, consider logging the error to help identify potential issues with specific addresses.


383-383: Enhance error message for clarity

The error message when no local address is found could be more informative. Currently, it only mentions the chain ID:

return nil, status.Error(codes.NotFound, fmt.Sprintf("no local address found matching %s", req.ChainId))

Consider including the remote address to provide clearer context:

return nil, status.Error(codes.NotFound, fmt.Sprintf("no local address found for remote address %s on chain %s", req.RemoteAddress, req.ChainId))
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 2adebf8 and 66d0e36.

📒 Files selected for processing (1)
  • x/interchainstaking/keeper/grpc_query.go (1 hunks)
🔇 Additional comments (2)
x/interchainstaking/keeper/grpc_query.go (2)

342-357: LGTM

The updates to the MappedAccounts method, including changing remoteAddressMap to map[string]string and handling errors from EncodeAddressToBech32, are implemented correctly.


364-387: LGTM

The new InverseMappedAccounts method is well-implemented with proper input validation and error handling. It effectively retrieves the local address mapped to a given remote address and chain ID.

Copy link
Contributor

@ajansari95 ajansari95 left a comment

Choose a reason for hiding this comment

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

Lgtm

@ajansari95 ajansari95 merged commit 2be465f into main Dec 3, 2024
15 of 17 checks passed
@joe-bowman joe-bowman deleted the 1719-bech32-mapped-accounts-queries branch December 3, 2024 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update mapped address query to bech32 output
2 participants