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

Arham/auto register host zone #1784

Merged
merged 4 commits into from
Jan 6, 2025
Merged

Conversation

arhamchordia
Copy link
Contributor

@arhamchordia arhamchordia commented Jan 6, 2025

1. Summary

Fixes #1458

2.Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

3. Implementation details

4. How to test/use

5. Checklist

  • Does the Readme need to be updated?

6. Limitations (optional)

7. Future Work (optional)

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced protocol data management for interchain operations
    • Improved error handling for zone creation and channel management
  • Bug Fixes

    • Added robust validation for protocol data across different chains
    • Improved channel existence checks during zone creation
  • Tests

    • Expanded test coverage for interchain staking module
    • Added more comprehensive testing scenarios for protocol data handling
  • Chores

    • Introduced new utility functions for protocol data marshaling and storage
    • Updated test infrastructure to support more complex interchain scenarios

Copy link
Contributor

coderabbitai bot commented Jan 6, 2025

Warning

Rate limit exceeded

@arhamchordia has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 20 minutes and 4 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between bff71c6 and 77f08bf.

📒 Files selected for processing (2)
  • x/participationrewards/keeper/hooks.go (2 hunks)
  • x/participationrewards/keeper/keeper_test.go (5 hunks)

Walkthrough

The pull request introduces enhancements to the participation rewards module's zone creation and protocol data management. The changes focus on improving error handling and automatically registering IBC denominations for the host zone and Osmosis during zone registration. The modifications span multiple files in the x/participationrewards/keeper directory, adding new functions, updating test cases, and implementing more robust protocol data handling mechanisms.

Changes

File Change Summary
x/participationrewards/keeper/hooks.go Enhanced AfterZoneCreated method with improved error handling and protocol data management for host chain, Osmosis, and Umee
x/participationrewards/keeper/hooks_test.go Added test setup for channel initialization and protocol data verification
x/participationrewards/keeper/keeper_test.go Introduced new variables for Osmosis chain, added setupChannelForHookTest function
x/participationrewards/keeper/proposal_handler_test.go Updated protocol data proposal handling tests
x/participationrewards/keeper/protocol_data.go Added MarshalAndSetProtocolData function for protocol data marshaling and storage

Assessment against linked issues

Objective Addressed Explanation
Auto register IBC denoms for host zone and Osmosis

Possibly related PRs

Suggested labels

x/participationrewards

Suggested reviewers

  • faddat
  • minhngoc274
  • tuantran1702
  • joe-bowman

Poem

🐰 In the realm of chains and zones so bright,
Protocol data takes its flight,
Osmosis, Umee, and host zone's might,
Registered with error-handling's delight,
A rabbit's code dance, pure and right! 🌟


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.

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

🧹 Nitpick comments (5)
x/participationrewards/keeper/hooks.go (5)

5-6: Imports not GCI-compliant.
The pipeline indicates these lines are not ordered per the gci import rules. Please reorder them according to the specified format.

🧰 Tools
🪛 golangci-lint (1.62.2)

6-6: File is not gci-ed with --skip-generated -s standard -s default -s blank -s dot -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) -s prefix(github.com/cometbft/cometbft) -s prefix(github.com/cosmos/ibc-go) -s prefix(github.com/quicksilver-zone/quicksilver) --custom-order

(gci)


9-10: Imports not GCI-compliant.
These lines also violate the gci import ordering rules. Please reorder as indicated by the pipeline.

🧰 Tools
🪛 golangci-lint (1.62.2)

10-10: File is not gci-ed with --skip-generated -s standard -s default -s blank -s dot -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) -s prefix(github.com/cometbft/cometbft) -s prefix(github.com/cosmos/ibc-go) -s prefix(github.com/quicksilver-zone/quicksilver) --custom-order

(gci)


152-157: Consider encapsulating repeated "GetChannel" checks into a helper.
This logic of retrieving the channel and returning an error if not found appears multiple times (also in Osmosis and Umee sections). Factoring this out to a dedicated helper function can reduce duplication and improve readability.


177-218: Duplicated code for Osmosis chain.
This block introduces almost identical logic as the host zone block. Consider extracting a shared utility function that handles chain-specific channel lookups and LiquidAllowedDenomProtocolData creation to maintain DRY principles.


220-262: Repeated pattern for Umee chain.
The same pattern of protocol data retrieval, channel verification, and LiquidAllowedDenomProtocolData creation is repeated. A shared helper for all chains would simplify future maintenance.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 14b566d and bff71c6.

📒 Files selected for processing (5)
  • x/participationrewards/keeper/hooks.go (2 hunks)
  • x/participationrewards/keeper/hooks_test.go (3 hunks)
  • x/participationrewards/keeper/keeper_test.go (5 hunks)
  • x/participationrewards/keeper/proposal_handler_test.go (1 hunks)
  • x/participationrewards/keeper/protocol_data.go (2 hunks)
🧰 Additional context used
🪛 golangci-lint (1.62.2)
x/participationrewards/keeper/hooks.go

6-6: File is not gci-ed with --skip-generated -s standard -s default -s blank -s dot -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) -s prefix(github.com/cometbft/cometbft) -s prefix(github.com/cosmos/ibc-go) -s prefix(github.com/quicksilver-zone/quicksilver) --custom-order

(gci)


8-8: File is not gci-ed with --skip-generated -s standard -s default -s blank -s dot -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) -s prefix(github.com/cometbft/cometbft) -s prefix(github.com/cosmos/ibc-go) -s prefix(github.com/quicksilver-zone/quicksilver) --custom-order

(gci)


10-10: File is not gci-ed with --skip-generated -s standard -s default -s blank -s dot -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) -s prefix(github.com/cometbft/cometbft) -s prefix(github.com/cosmos/ibc-go) -s prefix(github.com/quicksilver-zone/quicksilver) --custom-order

(gci)

x/participationrewards/keeper/keeper_test.go

39-39: var osmosisBaseDenom is unused

(unused)

🪛 GitHub Actions: golangci-lint
x/participationrewards/keeper/hooks.go

[warning] 6-11: File is not properly formatted with 'gci'. Imports need to be ordered according to the specified format: standard, default, blank, dot, and prefix-based ordering.

x/participationrewards/keeper/keeper_test.go

[error] 39-39: Unused variable 'osmosisBaseDenom'

🪛 GitHub Check: lint
x/participationrewards/keeper/keeper_test.go

[failure] 39-39:
var osmosisBaseDenom is unused (unused)

⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: test quicksilver (darwin, arm64)
  • GitHub Check: test quicksilver (amd64, windows)
  • GitHub Check: test quicksilver (amd64, linux)
  • GitHub Check: Analyze
🔇 Additional comments (19)
x/participationrewards/keeper/hooks.go (1)

158-176: Logic for host zone LiquidAllowedDenomProtocolData looks good.
The creation and validation of hostZoneDenom is correct and straightforward.

x/participationrewards/keeper/hooks_test.go (5)

4-4: Import addition approved.
Importing "github.com/quicksilver-zone/quicksilver/utils" is appropriate for the new test logic.


19-20: Improved testing setup.
Calling setupChannelForHookTest() and setupTestProtocolData() ensures the environment is fully initialized. This is a beneficial enhancement for test clarity.


36-47: Host chain IBC denom check is comprehensive.
Verifying the correct IBC denom for the host chain improves coverage and confidence in the new logic.


48-58: Osmosis IBC denom checks.
These checks mirror the host chain verification and maintain consistency for multi-chain scenarios.


59-68: Umee IBC denom checks.
Likewise, verifying the IBC denom for Umee ensures correctness across chains.

x/participationrewards/keeper/proposal_handler_test.go (6)

113-114: Context initialization is standard.
Creating a local reference to the context and keeper is typical for proposal tests. No issues found.


116-116: Preparing protocol data struct.
Defining a ConnectionProtocolData instance is clear and straightforward.


123-123: Utilizing MarshalAndSetProtocolData.
Good job using the new helper function. This improves consistency in storing protocol data.


126-126: Verifying protocol data existence.
Ensuring the data is actually stored before removal is a sensible check for the test scenario.


132-136: Proposal message for removal.
Constructing the removal proposal with a base64-encoded key is aligned with the updated approach.


144-144: Asserting protocol data removal.
Confirming that the data is no longer found after the removal proposal is processed completes the test coverage.

x/participationrewards/keeper/protocol_data.go (1)

111-123: New helper function improves consistency.
MarshalAndSetProtocolData centralizes the marshaling and storing of protocol data, reducing repeated boilerplate code. Great addition!

x/participationrewards/keeper/keeper_test.go (6)

45-49: Channel identifiers for multiple test chains.
Defining these constants clarifies the test environment configuration for ICS.


118-118: Updated expected protocol data count.
Changing from 14 to 15 aligns with the newly added data sets.


417-431: Channel setup function is beneficial.
Creating multiple channels in a single helper prepares the environment for testing complex multi-zone logic.


432-432: Extra blank line.
No functional changes.


Line range hint 434-452: Additional protocol data setup.
Extended protocol data for new test scenarios is consistent with the changes in the hooks logic.


492-492: New connection data for Osmosis chain.
Aligns with the added test coverage for chain-2.

@@ -35,10 +35,19 @@
umeeTestChain = "umee-types-1"
umeeBaseDenom = "uumee"

osmosisTestChain = "osmosis-1"
osmosisBaseDenom = "uosmo"
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Unused variable triggers pipeline error.
osmosisBaseDenom is reported as unused and fails the lint check. Consider removing it if it's not needed.

Apply this diff to remove the variable:

- osmosisBaseDenom = "uosmo"
🧰 Tools
🪛 golangci-lint (1.62.2)

39-39: var osmosisBaseDenom is unused

(unused)

🪛 GitHub Check: lint

[failure] 39-39:
var osmosisBaseDenom is unused (unused)

🪛 GitHub Actions: golangci-lint

[error] 39-39: Unused variable 'osmosisBaseDenom'

Copy link

codecov bot commented Jan 6, 2025

Codecov Report

Attention: Patch coverage is 54.05405% with 51 lines in your changes missing coverage. Please review.

Project coverage is 61.38%. Comparing base (53f92dd) to head (77f08bf).

Files with missing lines Patch % Lines
x/participationrewards/keeper/hooks.go 53.92% 32 Missing and 15 partials ⚠️
x/participationrewards/keeper/protocol_data.go 55.55% 3 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1784      +/-   ##
==========================================
- Coverage   61.43%   61.38%   -0.05%     
==========================================
  Files         196      196              
  Lines       17117    17228     +111     
==========================================
+ Hits        10515    10575      +60     
- Misses       5748     5783      +35     
- Partials      854      870      +16     
Flag Coverage Δ
unittests 61.38% <54.05%> (-0.05%) ⬇️

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

Files with missing lines Coverage Δ
x/participationrewards/keeper/protocol_data.go 75.30% <55.55%> (-2.47%) ⬇️
x/participationrewards/keeper/hooks.go 64.97% <53.92%> (-9.81%) ⬇️

@joe-bowman
Copy link
Contributor

@arhamchordia - can you run make lint-fix please? This will resolve formatting issues (although it won't fix the unused var)

Copy link
Contributor

@joe-bowman joe-bowman left a comment

Choose a reason for hiding this comment

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

lgtm

@joe-bowman joe-bowman merged commit 5bbfa28 into main Jan 6, 2025
15 of 17 checks passed
@joe-bowman joe-bowman deleted the arham/auto-register-host-zone branch January 6, 2025 19:43
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.

Auto register ibc denoms for host zone and osmosis on zone registration
2 participants