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

Problem: ibc channel upgrade related methods are not supported #1612

Merged
merged 3 commits into from
Sep 30, 2024

Conversation

mmsqe
Copy link
Collaborator

@mmsqe mmsqe commented Sep 30, 2024

👮🏻👮🏻👮🏻 !!!! REFERENCE THE PROBLEM YOUR ARE SOLVING IN THE PR TITLE AND DESCRIBE YOUR SOLUTION HERE !!!! DO NOT FORGET !!!! 👮🏻👮🏻👮🏻

PR Checklist:

  • Have you read the CONTRIBUTING.md?
  • Does your PR follow the C4 patch requirements?
  • Have you rebased your work on top of the latest master?
  • Have you checked your code compiles? (make)
  • Have you included tests for any non-trivial functionality?
  • Have you checked your code passes the unit tests? (make test)
  • Have you checked your code formatting is correct? (go fmt)
  • Have you checked your basic code style is fine? (golangci-lint run)
  • If you added any dependencies, have you checked they do not contain any known vulnerabilities? (go list -json -m all | nancy sleuth)
  • If your changes affect the client infrastructure, have you run the integration test?
  • If your changes affect public APIs, does your PR follow the C4 evolution of public contracts?
  • If your code changes public APIs, have you incremented the crate version numbers and documented your changes in the CHANGELOG.md?
  • If you are contributing for the first time, please read the agreement in CONTRIBUTING.md now and add a comment to this pull request stating that your PR is in accordance with the Developer's Certificate of Origin.

Thank you for your code, it's appreciated! :)

Summary by CodeRabbit

  • New Features

    • Introduced support for IBC (Inter-Blockchain Communication) channel upgrade methods, enhancing channel management capabilities.
    • Added new methods for querying and upgrading IBC channels, improving flexibility in operations.
  • Bug Fixes

    • Enhanced error handling for Inter-Chain Accounts (ICA) registration on active channels.
  • Tests

    • Expanded test functionalities to include processes for upgrading incentivized channels and improved error handling in ICA tests.

@mmsqe mmsqe requested a review from a team as a code owner September 30, 2024 01:06
@mmsqe mmsqe requested review from calvinaco and devashishdxt and removed request for a team September 30, 2024 01:06
Copy link
Contributor

coderabbitai bot commented Sep 30, 2024

Walkthrough

The changes introduce new functionality to support Inter-Blockchain Communication (IBC) channel upgrades across various modules and integration tests. Key updates include the addition of methods for upgrading IBC channels, modifications to existing functions for enhanced flexibility, and improvements in test cases to accommodate these new features. The updates are reflected in the changelog and involve changes to several files, enhancing the overall capability to manage IBC operations.

Changes

Files Change Summary
CHANGELOG.md Added a new feature for IBC channel upgrade methods, with references to pull request #1612.
integration_tests/cosmoscli.py Introduced new methods for IBC operations, updated module_address to accept a prefix, and added functionality for upgrading and querying IBC channels.
integration_tests/ibc_utils.py Added register_fee_payee function for fee registration logic, and modified register_acc to return port_id along with ica_address and channel_id.
integration_tests/test_ibc.py Enhanced test_ibc_incentivized_transfer to include a temporary file for proposals and added logic for upgrading incentivized channels.
integration_tests/test_ica.py Updated test_ica to handle IBC channel upgrades, including error handling and temporary file usage.
integration_tests/test_ica_incentivized.py Modified return values of register_acc in the test_incentivized function to capture additional data.
x/cronos/middleware/conversion_middleware.go Added methods to IBCConversionModule for handling various stages of IBC channel upgrades, including initialization and acknowledgment.

Possibly related PRs

Suggested reviewers

  • devashishdxt
  • yihuang
  • thomas-nguy

Poem

🐰 In the land of code where rabbits hop,
New IBC features make our hearts stop!
Channels upgrade with a flick of a paw,
Testing and tweaking, we’re in awe!
Hopping through changes, we dance with glee,
In the world of blockchain, we’re wild and free! 🌟


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

codecov bot commented Sep 30, 2024

Codecov Report

Attention: Patch coverage is 0% with 20 lines in your changes missing coverage. Please review.

Project coverage is 36.88%. Comparing base (3d3cfed) to head (21e2278).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
x/cronos/middleware/conversion_middleware.go 0.00% 20 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1612      +/-   ##
==========================================
- Coverage   36.97%   36.88%   -0.10%     
==========================================
  Files         102      102              
  Lines        8035     8055      +20     
==========================================
  Hits         2971     2971              
- Misses       4686     4706      +20     
  Partials      378      378              
Files with missing lines Coverage Δ
x/cronos/middleware/conversion_middleware.go 3.57% <0.00%> (-0.78%) ⬇️

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: 9

🧹 Outside diff range and nitpick comments (6)
integration_tests/ibc_utils.py (1)

Line range hint 776-785: Approved: Good update to register_acc function.

The changes to the register_acc function are well-implemented:

  1. The function now returns port_id along with ica_address and channel_id, which provides more comprehensive information about the registered account.
  2. The port_id is correctly obtained from the assert_channel_open_init function.

These changes align with the AI-generated summary and improve the function's utility.

Consider updating the function's docstring (if it exists) to reflect the new return value. If there's no docstring, it would be beneficial to add one:

def register_acc(cli, connid, ordering=ChannelOrder.ORDERED.value, signer="signer2"):
    """
    Register an interchain account.

    :param cli: The client object
    :param connid: The connection ID
    :param ordering: The channel ordering (default: ORDERED)
    :param signer: The signer (default: "signer2")
    :return: A tuple containing (ica_address, port_id, channel_id)
    """
    # ... rest of the function ...
CHANGELOG.md (1)

Line range hint 1-1185: Well-structured and comprehensive changelog.

The CHANGELOG.md file provides a detailed history of changes for the Cronos project. It's well-organized, with clear version numbering and release dates. Each version includes categorized changes (e.g., State Machine Breaking, Bug Fixes, Improvements, Features), making it easy for users and developers to understand the evolution of the project.

Some suggestions for improvement:

  1. Consider adding links to relevant pull requests or issues for each change, which would allow readers to dive deeper into specific changes if needed.
  2. Maintain consistency in formatting across all versions (some older entries have slightly different formatting).
  3. Consider summarizing major changes or themes for each version at the top of its section, especially for releases with many changes.

Overall, this changelog serves as an excellent record of the project's development and will be valuable for users upgrading between versions.

integration_tests/test_ibc.py (1)

91-91: Add error handling for file operations

Consider adding error handling around the proposal file writing to catch potential exceptions, which can improve test robustness.

You might use a try-except block:

try:
    proposal.write_text(json.dumps(proposal_src))
except Exception as e:
    pytest.fail(f"Failed to write proposal file: {e}")
x/cronos/middleware/conversion_middleware.go (1)

268-268: Typo in comment: Extra space in 'implements'

There's a typo in the comment; the word "implements" has an extra space between "implement" and "s."

Apply this diff to correct the typo:

-// OnChanUpgradeTry implement s the IBCModule interface
+// OnChanUpgradeTry implements the IBCModule interface
integration_tests/cosmoscli.py (2)

1241-1261: Consider adding a docstring to the ibc_upgrade_channels method

Adding a docstring would improve understandability by explaining the method's purpose, parameters, and return value.

Apply this diff to add a docstring:

 def ibc_upgrade_channels(self, version, from_addr, **kwargs):
+    """
+    Upgrade IBC channels to a new version.
+
+    :param version: The new version information for the IBC channels.
+    :param from_addr: The address initiating the upgrade.
+    :param kwargs: Additional arguments for the transaction.
+    :return: JSON response of the upgrade transaction.
+    """
     kwargs.setdefault("gas_prices", DEFAULT_GAS_PRICE)

1452-1468: Consider adding a docstring to the ibc_query_channel method

Including a docstring would enhance code readability by providing documentation on the method's purpose and usage.

Apply this diff to add a docstring:

 def ibc_query_channel(self, port_id, channel_id, **kwargs):
+    """
+    Query the status of an IBC channel given the port ID and channel ID.
+
+    :param port_id: The port identifier.
+    :param channel_id: The channel identifier.
+    :param kwargs: Additional arguments for the query.
+    :return: JSON response of the channel status.
+    """
     default_kwargs = {
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 3d3cfed and 21e2278.

📒 Files selected for processing (7)
  • CHANGELOG.md (1 hunks)
  • integration_tests/cosmoscli.py (4 hunks)
  • integration_tests/ibc_utils.py (4 hunks)
  • integration_tests/test_ibc.py (3 hunks)
  • integration_tests/test_ica.py (4 hunks)
  • integration_tests/test_ica_incentivized.py (1 hunks)
  • x/cronos/middleware/conversion_middleware.go (2 hunks)
🔇 Additional comments (14)
integration_tests/ibc_utils.py (1)

Line range hint 804-813: LGTM: assert_channel_open_init function updated correctly.

The changes to the assert_channel_open_init function are appropriate and consistent with the modifications in the register_acc function:

  1. The function now correctly returns both port_id and channel_id.
  2. The extraction of these values from the event attributes is implemented correctly.

This update ensures that the necessary information is available for the IBC channel initialization process.

CHANGELOG.md (2)

11-11: LGTM: Clear and concise bug fix description.

The bug fix for the inconsistent state during upgrade migration interruption is well-documented and important for maintaining system integrity during upgrades.


12-12: LGTM: Appropriate dependency update.

Updating IAVL to v0.19.4 is a good practice to ensure the system is using the latest stable version of its dependencies.

integration_tests/test_ica.py (3)

43-43: Addition of tmp_path fixture to the test_ica function

The inclusion of the tmp_path fixture in the test_ica function is appropriate. It allows for the creation of temporary files needed during the test execution.


150-150: Verify the correctness of the channel state 'STATE_FLUSHCOMPLETE'

Ensure that 'STATE_FLUSHCOMPLETE' is the correct state name when checking the channel status. An incorrect state name could cause the wait_for_check_channel_ready function to fail.


122-124: Reopening ICA account after channel closure

Reopening the Interchain Account after the channel closure correctly results in the same ica_address and a new channel_id. This behavior aligns with expected ICA functionality.

integration_tests/test_ibc.py (5)

1-2: Added import of json module

The json module is correctly imported to handle JSON serialization needed for proposal file operations.


Line range hint 5-17: Included necessary imports for upgraded channel logic

The additional imports of module_address, register_fee_payee, wait_for_check_channel_ready, and approve_proposal are appropriate and support the new functionality in the test.

Also applies to: 22-22


67-67: Updated test function signature to include tmp_path fixture

The tmp_path fixture is properly added to the test_ibc_incentivized_transfer function to handle temporary file creation for the proposal JSON.


68-99: Implemented channel upgrade logic for incentivized transfers

The code correctly adds logic to upgrade to an incentivized IBC channel when ibc.incentivized is False. This includes:

  • Constructing the proposal with the appropriate parameters.
  • Writing the proposal to a temporary JSON file.
  • Submitting and approving the proposal.
  • Waiting for the channel to reach the desired state.
  • Registering the fee payee.

99-99: Registered fee payee after channel upgrade

The call to register_fee_payee ensures that fee distribution is properly set up following the channel upgrade.

integration_tests/cosmoscli.py (3)

17-17: Import statements updated appropriately

The import of CRONOS_ADDRESS_PREFIX and get_sync_info is necessary and correctly implemented.


37-44: Enhancement of module_address function for custom prefixes

The addition of the prefix parameter with a default value CRONOS_ADDRESS_PREFIX to the module_address function increases its flexibility without affecting existing functionality.


1241-1261: Addition of ibc_upgrade_channels method

The new ibc_upgrade_channels method provides functionality to upgrade IBC channels, aligning with the PR objectives to support IBC channel upgrade methods.

integration_tests/test_ica_incentivized.py Show resolved Hide resolved
integration_tests/ibc_utils.py Show resolved Hide resolved
integration_tests/test_ica.py Show resolved Hide resolved
integration_tests/test_ica.py Show resolved Hide resolved
integration_tests/test_ibc.py Show resolved Hide resolved
integration_tests/test_ibc.py Show resolved Hide resolved
x/cronos/middleware/conversion_middleware.go Show resolved Hide resolved
x/cronos/middleware/conversion_middleware.go Show resolved Hide resolved
integration_tests/cosmoscli.py Show resolved Hide resolved
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