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: not payee set for relayer caller #1654

Merged
merged 11 commits into from
Oct 25, 2024

Conversation

mmsqe
Copy link
Collaborator

@mmsqe mmsqe commented Oct 22, 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

Release Notes for Version v1.4.0-rc2

  • New Features

    • Added support for incentivized packet functionality with relayer set as payee.
    • Enhanced transaction broadcasting and fee registration processes for improved error handling.
  • Bug Fixes

    • Resolved issues related to single validator benchmarks, node shutdown signals, and state overwrites in debug trace APIs.
    • Improved alignment of attributes for IBC timeout events.
  • Improvements

    • Parallel generation of test transactions and enhanced load generator with retry logic.
    • Optimized benchmarks and improved packet information emission for IBC relayer events.

Copy link

codecov bot commented Oct 22, 2024

Codecov Report

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

Project coverage is 34.99%. Comparing base (b17faf9) to head (864174c).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
x/cronos/keeper/precompiles/relayer.go 0.00% 8 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##             main    #1654       +/-   ##
===========================================
+ Coverage   16.71%   34.99%   +18.28%     
===========================================
  Files          72      123       +51     
  Lines        6187    11783     +5596     
===========================================
+ Hits         1034     4124     +3090     
- Misses       5030     7245     +2215     
- Partials      123      414      +291     
Files with missing lines Coverage Δ
x/cronos/keeper/precompiles/relayer.go 30.86% <0.00%> (+6.66%) ⬆️

... and 68 files with indirect coverage changes

Copy link
Contributor

coderabbitai bot commented Oct 24, 2024

Walkthrough

The changes in this pull request encompass updates to the CHANGELOG.md for version v1.4.0-rc2, highlighting bug fixes and improvements. Modifications include enhancements to transaction broadcasting and fee registration in the CosmosCLI class, the removal of a constant in the IBC testing file, and updates to method signatures in the RelayerContract to support context-aware operations. Overall, these changes aim to improve functionality, error handling, and performance across various components of the software.

Changes

File Change Summary
CHANGELOG.md Updated for version v1.4.0-rc2, added bug fix for relayer payee, and noted improvements including parallel transaction generation and load generator enhancements.
integration_tests/cosmoscli.py Updated broadcast_tx, register_payee, and pay_packet_fee methods for improved error handling and logic streamlining; removed default_kwargs, added response code checks.
integration_tests/test_ibc_rly.py Removed RELAYER_CALLER constant and updated test_ibc_incentivized_transfer function to distribute fees to src_relayer instead.
x/cronos/keeper/precompiles/relayer.go Enhanced RelayerContract methods with context parameters; updated Run method to wrap calls in anonymous functions that pass context, modifying error handling accordingly.

Possibly related PRs

Suggested reviewers

  • thomas-nguy
  • devashishdxt
  • yihuang

Poem

🐰 In the land of code, where changes bloom,
A relayer hops, dispelling gloom.
With fixes and tweaks, we dance with delight,
Bugs are now gone, everything feels right!
So let’s celebrate with a joyful cheer,
For a smoother path in the code we hold dear! 🎉


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.

nix/sources.json Outdated Show resolved Hide resolved
@mmsqe mmsqe marked this pull request as ready for review October 25, 2024 03:08
@mmsqe mmsqe requested a review from a team as a code owner October 25, 2024 03:08
@mmsqe mmsqe requested review from JayT106 and thomas-nguy and removed request for a team October 25, 2024 03:08
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 (1)
x/cronos/keeper/precompiles/relayer.go (1)

234-242: Consider a more generic approach for setting the signer

The current implementation duplicates the signer-setting logic in both handlers. Consider introducing a helper function or middleware that automatically sets the signer for all IBC messages that require it. This would:

  1. Reduce code duplication
  2. Ensure consistent signer handling
  3. Make it easier to add similar functionality to other handlers

Example approach:

func (bc *RelayerContract) withSigner(evm *vm.EVM, fn interface{}) interface{} {
    // Implementation that wraps handlers and sets signer from evm.TxContext.Origin
}

Would you like me to elaborate on this design pattern?

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 234-237: x/cronos/keeper/precompiles/relayer.go#L234-L237
Added lines #L234 - L237 were not covered by tests


[warning] 239-242: x/cronos/keeper/precompiles/relayer.go#L239-L242
Added lines #L239 - L242 were not covered by tests

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between b17faf9 and 864174c.

📒 Files selected for processing (4)
  • CHANGELOG.md (1 hunks)
  • integration_tests/cosmoscli.py (4 hunks)
  • integration_tests/test_ibc_rly.py (1 hunks)
  • x/cronos/keeper/precompiles/relayer.go (2 hunks)
🧰 Additional context used
🪛 GitHub Check: codecov/patch
x/cronos/keeper/precompiles/relayer.go

[warning] 234-237: x/cronos/keeper/precompiles/relayer.go#L234-L237
Added lines #L234 - L237 were not covered by tests


[warning] 239-242: x/cronos/keeper/precompiles/relayer.go#L239-L242
Added lines #L239 - L242 were not covered by tests

🔇 Additional comments (8)
x/cronos/keeper/precompiles/relayer.go (3)

4-4: LGTM: Context import addition

The context import is appropriately added to support the new context-aware handler implementations.


239-242: Implementation looks good but needs test coverage

The implementation correctly sets the signer for timeout messages, following the same pattern as the acknowledgement handler.

However, this critical IBC functionality lacks test coverage.

Let's verify the existing test coverage:

#!/bin/bash
# Search for existing tests related to relayer timeout
rg -l "TestRelayer.*Timeout" -g "**/*_test.go"

Would you like me to help create test cases that verify:

  1. The signer is correctly set from the EVM transaction origin
  2. The timeout handler is called with the correct context and message
🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 239-242: x/cronos/keeper/precompiles/relayer.go#L239-L242
Added lines #L239 - L242 were not covered by tests


234-237: Implementation looks good but needs test coverage

The implementation correctly sets the signer for acknowledgement messages by converting the EVM transaction origin to a Cosmos address. This addresses the missing payee issue.

However, this critical IBC functionality lacks test coverage.

Let's verify the existing test coverage:

Would you like me to help create test cases that verify:

  1. The signer is correctly set from the EVM transaction origin
  2. The acknowledgement handler is called with the correct context and message
🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 234-237: x/cronos/keeper/precompiles/relayer.go#L234-L237
Added lines #L234 - L237 were not covered by tests

integration_tests/test_ibc_rly.py (1)

295-296: ⚠️ Potential issue

Remove duplicate fee distribution assertions.

These lines appear to be duplicates of the previous fee distribution assertions. This duplication might be unintentional and could make the test assert incorrect behavior.

Apply this diff to remove the duplicate assertions:

-        distribute_fee(src_relayer, fee),
-        *send_coins(feeibc_addr, src_relayer, src_amount, fee_denom),

Let's verify if this is the intended behavior by checking the test implementation:

CHANGELOG.md (1)

12-12: LGTM! The changelog entry is well-formatted and descriptive.

The entry clearly describes the bug fix for setting the relayer as payee when incentivized packet functionality is enabled, and follows the consistent format with proper PR linking.

integration_tests/cosmoscli.py (3)

604-609: Improved error handling in broadcast_tx.

The changes enhance the transaction broadcasting flow by properly handling the response code and querying transaction events only for successful transactions.


Line range hint 1618-1634: Enhanced register_payee implementation.

The changes improve the register_payee method by:

  1. Simplifying the kwargs handling
  2. Adding consistent error handling with broadcast_tx
  3. Properly setting up the home directory parameter

These changes directly address the PR objective of fixing the payee setting for relayer caller.


1646-1647: Consistent implementation in pay_packet_fee.

The changes maintain consistency with the register_payee implementation by using the same pattern for home directory and kwargs handling.

@mmsqe mmsqe added this pull request to the merge queue Oct 25, 2024
@yihuang yihuang self-requested a review October 25, 2024 06:49
Merged via the queue into crypto-org-chain:main with commit 7dd3362 Oct 25, 2024
37 of 38 checks passed
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