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

support mapped accounts in claims #1642

Merged
merged 1 commit into from
Jun 3, 2024
Merged

Conversation

joe-bowman
Copy link
Contributor

1. Summary

Add support for mapped accounts in claims validation.

Copy link

vercel bot commented May 31, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
quicksilver ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 31, 2024 3:10pm

Copy link
Contributor

coderabbitai bot commented May 31, 2024

Walkthrough

The recent updates focus on enhancing the ValidateClaim function across various submodules of the participationrewards/keeper package. The key changes include improved error handling, the introduction of address mapping, and validation logic refinements. These modifications ensure robust handling of user claims and address conversions, leveraging new utility functions and the errors package for better error management.

Changes

File Path Change Summary
x/participationrewards/keeper/submodule_liquid.go Added errors package for enhanced error handling in the ValidateClaim function.
x/participationrewards/keeper/submodule_osmosis.go Added imports for bytes, utils, and addressutils; removed banktypes; updated address validation.
x/participationrewards/keeper/submodule_osmosiscl.go Imported addressutils; updated address conversion and validation logic in ValidateClaim function.
x/participationrewards/keeper/submodule_umee.go Added errors and addressutils; replaced bech32.DecodeAndConvert with addressutils.AccAddressFromBech32; improved error handling.
x/participationrewards/types/expected_keepers.go Added GetLocalAddressMap method to InterchainStakingKeeper interface for retrieving local address mappings.

Poem

Amidst the code with lines so neat,
Error handling now complete.
Addresses mapped with utmost care,
Proofs and claims, we now compare.
In the realm where bytes align,
Our logic shines, refined, divine.
🐇✨


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 0d4322f and 2e4f5a4.

Files selected for processing (5)
  • x/participationrewards/keeper/submodule_liquid.go (2 hunks)
  • x/participationrewards/keeper/submodule_osmosis.go (4 hunks)
  • x/participationrewards/keeper/submodule_osmosiscl.go (4 hunks)
  • x/participationrewards/keeper/submodule_umee.go (3 hunks)
  • x/participationrewards/types/expected_keepers.go (1 hunks)
Additional comments not posted (9)
x/participationrewards/keeper/submodule_liquid.go (2)

5-5: The addition of the errors package is appropriate for the custom error handling introduced in the ValidateClaim function.


50-59: The updated error handling and address mapping in ValidateClaim are well-implemented. Ensure that the GetLocalAddressMap method correctly retrieves mapped addresses and that the error messages provide enough context for debugging.

Verification successful

The implementation of GetLocalAddressMap in x/interchainstaking/keeper/address_map.go appears to correctly retrieve the mapped address using the provided remote address and chain ID. The method accesses the key-value store, constructs the key using GetLocalAddressKey, retrieves the value, and returns it along with a boolean indicating whether the value was found.

The error handling in the ValidateClaim function, which uses this method, is appropriate and provides clear error messages when the mapped address is not found or when the proof is invalid.

  • x/interchainstaking/keeper/address_map.go:51-57: Implementation of GetLocalAddressMap.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the implementation of `GetLocalAddressMap` and its usage in error handling.

# Test: Search for the method implementation and usage. Expect: Correct retrieval and usage of mapped addresses.
rg --type go $'GetLocalAddressMap'

Length of output: 1773



Script:

#!/bin/bash
# Description: Review the implementation of `GetLocalAddressMap` in `x/interchainstaking/keeper/address_map.go`.

# Extract the implementation of `GetLocalAddressMap`.
ast-grep --lang go --pattern $'func (k *Keeper) GetLocalAddressMap(ctx sdk.Context, remoteAddress sdk.AccAddress, chainID string) (sdk.AccAddress, bool) {
  $$$
}' x/interchainstaking/keeper/address_map.go

Length of output: 792

x/participationrewards/keeper/submodule_osmosiscl.go (2)

Line range hint 4-17: The updated imports in submodule_osmosiscl.go are appropriate for the new address handling and validation logic in the ValidateClaim function.


Line range hint 78-99: The changes in the ValidateClaim function, including the use of addressutils.AccAddressFromBech32 and bytes.Equal, enhance address validation. Verify that these functions are used consistently across the codebase for similar operations.

x/participationrewards/types/expected_keepers.go (1)

79-79: The addition of the GetLocalAddressMap method to the InterchainStakingKeeper interface is crucial for supporting mapped accounts in claims validation. Ensure that all implementations of this interface are updated accordingly.

x/participationrewards/keeper/submodule_osmosis.go (2)

Line range hint 4-21: The updated imports in submodule_osmosis.go are appropriate for the new address handling and validation logic in the ValidateClaim function.


Line range hint 82-128: The changes in the ValidateClaim function, including the use of addressutils.AccAddressFromBechjson and bytes.Equal, enhance address validation. Verify that these functions are used consistently across the codebase for similar operations.

Verification successful

The rg command output shows multiple instances of bytes.Equal usage across different files, indicating its consistent use for address comparison. However, the AccAddressFromBechjson function is not found in the output, suggesting it might be a typo or an incorrect function name. The correct function might be AccAddressFromBech32.

Let's verify the correct function name and its usage across the codebase.


The search results confirm that the correct function name is AccAddressFromBech32, and it is used consistently across the codebase for address conversion. This aligns with the changes made in the ValidateClaim function.

  • The bytes.Equal function is used consistently for address comparison.
  • The AccAddressFromBech32 function is used correctly and consistently for address conversion.

No issues were found with the usage of these functions in the codebase.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify consistent use of `AccAddressFromBechjson` and `bytes.Equal` across the codebase.

# Test: Search for usage of these functions. Expect: Consistent and correct usage.
rg --type go $'AccAddressFromBechjson|bytes.Equal'

Length of output: 3641



Script:

#!/bin/bash
# Description: Verify the correct function name and its usage across the codebase.

# Test: Search for usage of `AccAddressFromBech32`. Expect: Consistent and correct usage.
rg --type go 'AccAddressFromBech32'

Length of output: 23765

x/participationrewards/keeper/submodule_umee.go (2)

5-18: The updated imports in submodule_umee.go are appropriate for the new error handling and address validation logic in the ValidateClaim function.


Line range hint 189-211: The changes in the ValidateClaim function, including the use of addressutils.AccAddressFromBechjson for address conversion and the handling of address mapping, enhance address validation. Verify that this function is used consistently across the codebase for similar operations.

Verification successful

The search results indicate that the function AccAddressFromBech32 is used consistently across the codebase, including in various files related to the participationrewards module and other modules. This confirms that the changes made in the ValidateClaim function are in line with the existing code practices.

  • x/participationrewards/keeper/distribution.go
  • x/participationrewards/keeper/submodule_osmosiscl.go
  • x/participationrewards/keeper/submodule_umee.go
  • x/participationrewards/keeper/submodule_osmosis.go
  • x/participationrewards/types/msgs.go
  • And many other files across different modules.

This consistent usage supports the robustness of the address validation changes introduced in the ValidateClaim function.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify consistent use of `AccAddressFromBechjson` across the codebase.

# Test: Search for usage of this function. Expect: Consistent and correct usage.
rg --type go $'AccAddressFromBechjson'

Length of output: 37



Script:

#!/bin/bash
# Description: Verify consistent use of `AccAddressFromBech32` across the codebase.

# Test: Search for usage of this function. Expect: Consistent and correct usage.
rg --type go $'AccAddressFromBech32'

Length of output: 23765

Copy link

codecov bot commented May 31, 2024

Codecov Report

Attention: Patch coverage is 15.38462% with 33 lines in your changes are missing coverage. Please review.

Project coverage is 63.60%. Comparing base (0d4322f) to head (2e4f5a4).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1642      +/-   ##
==========================================
- Coverage   63.72%   63.60%   -0.12%     
==========================================
  Files         194      194              
  Lines       13740    13770      +30     
==========================================
+ Hits         8756     8759       +3     
- Misses       4130     4154      +24     
- Partials      854      857       +3     
Flag Coverage Δ
unittests 63.60% <15.38%> (-0.12%) ⬇️

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

Files Coverage Δ
x/participationrewards/keeper/submodule_umee.go 72.10% <40.00%> (-2.72%) ⬇️
x/participationrewards/keeper/submodule_liquid.go 52.94% <0.00%> (-11.35%) ⬇️
...participationrewards/keeper/submodule_osmosiscl.go 40.98% <0.00%> (-3.66%) ⬇️
x/participationrewards/keeper/submodule_osmosis.go 55.69% <13.33%> (-7.54%) ⬇️

@joe-bowman joe-bowman merged commit 0b29640 into main Jun 3, 2024
19 of 21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants