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

resolve issues with mappAccounts storage #1622

Merged
merged 3 commits into from
May 20, 2024
Merged

Conversation

joe-bowman
Copy link
Contributor

1. Summary

  • Correctly set the mappedAccount from memo as the local address when storing a mapped account pairing.
  • Ensure we use sdk.AccAddress instead of []byte
  • Add tests

Copy link

vercel bot commented May 20, 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 20, 2024 3:43pm

Copy link
Contributor

coderabbitai bot commented May 20, 2024

Walkthrough

The recent updates to the x/interchainstaking module primarily focus on enhancing type consistency by replacing []byte with sdk.AccAddress for address-related parameters. This change spans multiple files, including address_map.go, grpc_query.go, and receipt.go, among others. The goal is to improve code clarity and maintainability. Additionally, new tests have been added to ensure the robustness of the MintAndSendQAsset functionality.

Changes

File(s) Summary
x/interchainstaking/keeper/address_map.go, x/interchainstaking/types/keys.go Updated function signatures to use sdk.AccAddress instead of []byte for address parameters.
x/interchainstaking/keeper/address_map_test.go Replaced random byte generation with sdk.AccAddress for localAddress and remoteAddress in tests.
x/interchainstaking/keeper/grpc_query.go Changed remoteAddressBytes parameter from []byte to sdk.AccAddress in the MappedAccounts function.
x/interchainstaking/keeper/receipt.go Modified MintAndSendQAsset to use sdk.AccAddress for mappedAddress and adjusted argument order.
x/interchainstaking/keeper/receipt_test.go Added multiple test functions to cover various scenarios of MintAndSendQAsset.
x/interchainstaking/keeper/withdrawal_record.go Removed a logging statement in GetUserChainRequeuedWithdrawalRecord.

🐇

In the realm of interchain code,
Addresses now in new abode.
From bytes to Acc they now reside,
With tests and tweaks, the code's our guide.
A clearer path, a brighter day,
For interchain staking, hip-hip-hooray!

🌟


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.

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 a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @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 2540f31 and b480b4d.
Files selected for processing (7)
  • x/interchainstaking/keeper/address_map.go (4 hunks)
  • x/interchainstaking/keeper/address_map_test.go (3 hunks)
  • x/interchainstaking/keeper/grpc_query.go (1 hunks)
  • x/interchainstaking/keeper/receipt.go (2 hunks)
  • x/interchainstaking/keeper/receipt_test.go (1 hunks)
  • x/interchainstaking/keeper/withdrawal_record.go (1 hunks)
  • x/interchainstaking/types/keys.go (2 hunks)
Additional comments not posted (10)
x/interchainstaking/keeper/address_map_test.go (1)

13-14: Updated variable types to sdk.AccAddress align with PR objectives for type consistency.

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

10-10: Updated function signatures to use sdk.AccAddress enhance type safety and consistency across the module.

Also applies to: 19-19, 44-44, 51-51, 60-60, 67-67

x/interchainstaking/types/keys.go (1)

96-96: Updated key generation functions to use sdk.AccAddress for better type consistency and safety.

Also applies to: 101-101, 161-161

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

348-348: Updated IterateUserMappedAccounts to use sdk.AccAddress for consistent type usage across queries.

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

Line range hint 182-221: Refactor MintAndSendQAsset to handle sdk.AccAddress correctly.

The changes correctly implement the handling of sdk.AccAddress for mappedAddress, enhancing type safety and consistency with other parts of the system. The logic to handle different scenarios based on the presence of a mapped address and other conditions is well-implemented.

x/interchainstaking/keeper/receipt_test.go (5)

384-406: Add comprehensive tests for MintAndSendQAsset.

The test TestMintAndSendQAsset1RR correctly sets up the scenario with a redemption rate of 1.0 and checks the balance of the receiver after the operation, ensuring the function behaves as expected.


408-431: Ensure tests cover different redemption rates.

The test TestMintAndSendQAssetNon1RR effectively tests the function with a redemption rate of 1.1, verifying that the function correctly calculates and transfers the adjusted amount.


433-456: Validate handling of redemption rates below 1.0.

The test TestMintAndSendQAssetSub1RR is crucial as it checks the function's behavior when the redemption rate is 0.9, ensuring that the function increases the amount correctly.


458-493: Test the function with a mapped account and non-standard redemption rate.

The test TestMintAndSendQAssetNon1RRMappedAccount effectively verifies that the function handles scenarios with a mapped account and a non-1.0 redemption rate, ensuring that the assets are transferred to the correct account.


495-527: Ensure correct handling of the "return to sender" flag with non-standard redemption rates.

The test TestMintAndSendQAssetNon1RTS is well-designed to check the function's behavior when the "return to sender" flag is set along with a non-1.0 redemption rate, ensuring that the assets are handled correctly.

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 b480b4d and 6bdcc1b.
Files selected for processing (1)
  • x/interchainstaking/keeper/address_map_test.go (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • x/interchainstaking/keeper/address_map_test.go

Copy link

codecov bot commented May 20, 2024

Codecov Report

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

Project coverage is 63.58%. Comparing base (108cc47) to head (6a95f43).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1622      +/-   ##
==========================================
+ Coverage   63.52%   63.58%   +0.05%     
==========================================
  Files         194      194              
  Lines       13734    13733       -1     
==========================================
+ Hits         8725     8732       +7     
+ Misses       4160     4152       -8     
  Partials      849      849              
Flag Coverage Δ
unittests 63.58% <75.00%> (+0.05%) ⬆️

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

Files Coverage Δ
x/interchainstaking/keeper/address_map.go 89.18% <100.00%> (ø)
x/interchainstaking/keeper/grpc_query.go 88.07% <100.00%> (ø)
x/interchainstaking/keeper/receipt.go 82.08% <100.00%> (+3.33%) ⬆️
x/interchainstaking/keeper/withdrawal_record.go 83.33% <ø> (-0.10%) ⬇️
x/interchainstaking/types/keys.go 29.62% <0.00%> (ø)

@faddat faddat merged commit f53be8e into main May 20, 2024
22 checks passed
@joe-bowman joe-bowman deleted the fix-mapped-account-order branch November 18, 2024 18:49
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.

2 participants