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

Chore: remove event emission on channel upgrade #6063

Merged
merged 20 commits into from
Apr 9, 2024

Conversation

hoangdv2429
Copy link
Contributor

@hoangdv2429 hoangdv2429 commented Mar 27, 2024

Description

closes: #5741

This PR will remove emitting the full upgrade on every handler.


Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Targeted PR against the correct branch (see CONTRIBUTING.md).
  • Linked to GitHub issue with discussion and accepted design, OR link to spec that describes this work.
  • Code follows the module structure standards and Go style guide.
  • Wrote unit and integration tests.
  • Updated relevant documentation (docs/).
  • Added relevant godoc comments.
  • Provide a conventional commit message to follow the repository standards.
  • Include a descriptive changelog entry when appropriate. This may be left to the discretion of the PR reviewers. (e.g. chores should be omitted from changelog)
  • Re-reviewed Files changed in the GitHub PR explorer.
  • Review SonarCloud Report in the comment section below once CI passes.

Summary by CodeRabbit

  • Refactor
    • Simplified event attributes for channel upgrade processes, enhancing clarity and efficiency.
    • Updated default Hermes tag in test configuration for improved test organization.

Copy link
Contributor

coderabbitai bot commented Mar 27, 2024

Walkthrough

The recent updates aim to optimize event emission during channel upgrades by selectively including essential attributes. This refinement involves removing specific fields from event emissions in certain functions and adjusting how other fields are handled. The goal is to emit only necessary upgrade fields at key points, aligning with the objectives outlined during an internal security audit regarding channel upgradability.

Changes

File(s) Change Summary
.../core/04-channel/keeper/events.go Removed ConnectionHops, Version, and Ordering attributes from EmitChannelUpgrade*Event functions; adjusted ConnectionHops and Version in related functions.
.../core/keeper/msg_server_test.go Eliminated references to upgrade fields like ConnectionHops, Version, and Ordering in channel upgrade test functions.

Assessment against linked issues

Objective Addressed Explanation
Trim event emission on channel upgrades (#5741)

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.

@hoangdv2429 hoangdv2429 marked this pull request as draft March 27, 2024 07:53
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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 2555a7c and 26fc764.
Files selected for processing (1)
  • modules/core/04-channel/keeper/events.go (6 hunks)
Additional comments: 19
modules/core/04-channel/keeper/events.go (19)
  • 280-285: > 📝 NOTE

This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [14-19]

The emitChannelOpenInitEvent function emits a channel open init event with attributes including ConnectionHops and Version. Given the PR's objective to reduce unnecessary event emissions, consider if the inclusion of these attributes aligns with the optimization goals. If these attributes are not critical for the event's purpose, removing them could streamline the event emission process.

  • 280-285: > 📝 NOTE

This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [22-29]

The emitChannelOpenTryEvent function similarly includes ConnectionHops and Version attributes. As with the previous function, evaluate the necessity of these attributes in the context of the PR's optimization objectives. Removing non-critical attributes can contribute to the efficiency of event emissions during channel upgrades.

  • 280-285: > 📝 NOTE

This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [32-38]

In the emitChannelOpenAckEvent function, the ConnectionHops attribute is included. Given the PR's focus on optimizing event emissions, consider whether this attribute is essential for the event's purpose. If it is not critical, removing it could further align with the PR's objectives.

  • 280-285: > 📝 NOTE

This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [41-47]

The emitChannelOpenConfirmEvent function also emits an event with the ConnectionHops attribute. Review the necessity of this attribute in light of the PR's optimization goals. If the attribute is not required for the event's intended use, consider removing it to enhance event emission efficiency.

  • 280-285: > 📝 NOTE

This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [50-56]

The emitChannelCloseInitEvent function includes the ConnectionHops attribute in its event emission. Assess the importance of this attribute in the context of optimizing event emissions. If it is deemed non-essential, removing it could contribute to the PR's objectives.

  • 280-285: > 📝 NOTE

This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [59-65]

In the emitChannelCloseConfirmEvent function, the inclusion of the ConnectionHops attribute is observed. Evaluate its necessity considering the PR's aim to optimize event emissions. If removing it aligns with the optimization goals, consider doing so to streamline the event emission process.

  • 280-285: > 📝 NOTE

This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [68-83]

The emitSendPacketEvent and emitRecvPacketEvent functions include deprecated attributes related to packet data and connection information. Given the PR's focus on optimizing event emissions, review the continued inclusion of these deprecated attributes. Removing or updating them could enhance the efficiency and clarity of event emissions.

  • 280-285: > 📝 NOTE

This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [86-101]

In the emitWriteAcknowledgementEvent and emitAcknowledgePacketEvent functions, deprecated attributes are used. Consider the relevance of these attributes in the context of the PR's optimization objectives. If they are not essential or are outdated, removing or updating them could contribute to more efficient event emissions.

  • 280-285: > 📝 NOTE

This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [104-115]

The emitTimeoutPacketEvent function includes the ConnectionID attribute in its event emission. Assess the necessity of this attribute given the PR's aim to optimize event emissions. If it is not critical for the event's purpose, consider removing it to align with the optimization goals.

  • 280-285: > 📝 NOTE

This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [118-128]

In the emitChannelClosedEvent function, the ConnectionID attribute is included. Evaluate its importance in the context of optimizing event emissions. If removing it contributes to the PR's objectives, consider doing so to enhance the efficiency of event emissions.

  • 280-285: > 📝 NOTE

This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [131-142]

The EmitChannelUpgradeInitEvent function focuses on emitting a channel upgrade init event with the UpgradeSequence attribute. This change aligns with the PR's objective to streamline event emissions by focusing on essential attributes. Ensure that the removal of other attributes (e.g., ConnectionHops, Version) from this and similar functions is intentional and aligns with the optimization goals.

  • 280-285: > 📝 NOTE

This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [145-156]

The EmitChannelUpgradeTryEvent function emits a channel upgrade try event, similarly focusing on the UpgradeSequence attribute. This approach is consistent with the PR's objective to optimize event emissions. Confirm that the exclusion of non-essential attributes is deliberate and contributes to the efficiency of the upgrade process.

  • 280-285: > 📝 NOTE

This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [159-170]

In the EmitChannelUpgradeAckEvent function, the event emission is optimized by including only the UpgradeSequence attribute. This change is in line with the PR's goals. Verify that the removal of other attributes not directly related to the upgrade sequence is intentional and beneficial for the optimization of event emissions.

  • 280-285: > 📝 NOTE

This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [173-184]

The EmitChannelUpgradeConfirmEvent function emits an event with a focus on the UpgradeSequence attribute, aligning with the PR's optimization objectives. Ensure that the decision to exclude other attributes is intentional and contributes to streamlining the event emission process during channel upgrades.

  • 280-285: > 📝 NOTE

This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [187-198]

The EmitChannelUpgradeOpenEvent function emits an event centered on the UpgradeSequence attribute, consistent with the PR's aim to optimize event emissions. Confirm that the exclusion of additional attributes is deliberate and enhances the efficiency of the event emission process.

  • 280-285: > 📝 NOTE

This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [201-214]

The EmitChannelUpgradeTimeoutEvent function emits an upgrade timeout event with a focus on the UpgradeSequence and timeout-related attributes. This change appears to align with the PR's objectives by emphasizing essential attributes for the event's purpose. Ensure that the inclusion of timeout attributes is necessary and contributes to the optimization of event emissions.

  • 280-285: > 📝 NOTE

This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [217-229]

In the EmitErrorReceiptEvent function, the event emission includes the UpgradeSequence attribute and an error message. This approach aligns with the PR's optimization goals by focusing on essential information. Confirm that the inclusion of the error message is necessary and enhances the clarity and usefulness of the event emission.

  • 280-285: > 📝 NOTE

This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [232-243]

The EmitChannelUpgradeCancelEvent function emits an upgraded cancelled event with a focus on the UpgradeSequence attribute. This change is consistent with the PR's objective to optimize event emissions. Verify that the exclusion of other attributes is intentional and contributes to the efficiency of the event emission process.

  • 280-285: > 📝 NOTE

This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [246-257]

The emitChannelFlushCompleteEvent function emits a flushing event with a focus on the channel state. This function does not directly relate to the PR's objective of optimizing event emissions during channel upgrades but is included for completeness. Ensure that the inclusion of the channel state attribute aligns with the overall event emission strategy and contributes to the clarity of the event.

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.

Review Status

Actionable comments generated: 4

Configuration used: .coderabbit.yml

Commits Files that changed from the base of the PR and between 26fc764 and 8aa4e02.
Files selected for processing (1)
  • modules/core/04-channel/keeper/events.go (6 hunks)
Additional comments: 2
modules/core/04-channel/keeper/events.go (2)
  • 373-377: The changes in EmitChannelUpgradeTimeoutEvent correctly adjust the attributes being emitted to focus on essential details for the upgrade process. Ensure that the currentChannel variable is correctly defined and accessible within this function's scope.
  • 406-414: The changes in EmitChannelUpgradeCancelEvent correctly adjust the attributes being emitted to focus on essential details for the upgrade process. Ensure that the currentChannel variable is correctly defined and accessible within this function's scope.

modules/core/04-channel/keeper/events.go Outdated Show resolved Hide resolved
modules/core/04-channel/keeper/events.go Outdated Show resolved Hide resolved
modules/core/04-channel/keeper/events.go Outdated Show resolved Hide resolved
modules/core/04-channel/keeper/events.go Outdated Show resolved Hide resolved
@hoangdv2429 hoangdv2429 marked this pull request as ready for review March 27, 2024 11:25
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.

Review Status

Actionable comments generated: 0

Configuration used: .coderabbit.yml

Commits Files that changed from the base of the PR and between 8aa4e02 and ced7b32.
Files selected for processing (2)
  • modules/core/04-channel/keeper/events.go (6 hunks)
  • modules/core/keeper/msg_server_test.go (15 hunks)
Files skipped from review as they are similar to previous changes (1)
  • modules/core/04-channel/keeper/events.go
Additional comments: 1
modules/core/keeper/msg_server_test.go (1)
  • 932-937: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [1-1065]

The tests cover a wide range of scenarios for packet handling, client recovery, packet acknowledgment, packet timeout, and channel upgrade processes. The use of path setup and teardown for each test case ensures isolation and repeatability. The assertions are well-placed to check both the success and failure conditions appropriately.

@hoangdv2429 hoangdv2429 changed the title Chore: remove event emission Chore: remove event emission on channel upgrade Mar 29, 2024
@crodriguezvega
Copy link
Contributor

Looks like some channel upgrades e2e tests are consistently failing, so could be that we have removed too much. 😅 I will take a look.

@hoangdv2429
Copy link
Contributor Author

Looks like some channel upgrades e2e tests are consistently failing, so could be that we have removed too much. 😅 I will take a look.

no problem sir, I'll run it locally and fix it 🙏

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 Status

Configuration used: .coderabbit.yml

Commits Files that changed from the base of the PR and between ced7b32 and 2dbfd46.
Files selected for processing (1)
  • e2e/testsuite/testconfig.go (1 hunks)
Additional Context Used
Path-based Instructions (1)
e2e/testsuite/testconfig.go (2)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.


Pattern e2e/**/*: "Assess the integration and e2e test code assessing sufficient code coverage for the changes associated in the pull request"

Additional comments not posted (1)
e2e/testsuite/testconfig.go (1)

65-65: Ensure the new Hermes tag "sean-channel-upgradability" is compatible with the current test suite and update any relevant documentation to reflect this change.

Verification successful

The verification process confirms that the new Hermes tag "sean-channel-upgradability" is only referenced in e2e/testsuite/testconfig.go and does not appear in any other configuration or documentation files within the codebase. This suggests that the change is isolated. It remains important to ensure that this tag is compatible with the current test suite and to update any relevant documentation accordingly. No further issues were found through this verification process.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify if the new Hermes tag is used in any other configuration or documentation files.
rg "sean-channel-upgradability" --files-with-matches

Length of output: 80

@crodriguezvega
Copy link
Contributor

A new hermes tag fixed the e2e tests. Thank you, @ljoss17!

Copy link
Contributor

@crodriguezvega crodriguezvega left a comment

Choose a reason for hiding this comment

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

Thank you, @hoangdv2429!

@@ -62,7 +62,7 @@ const (
// TODO: https://github.com/cosmos/ibc-go/issues/4965
defaultHyperspaceTag = "20231122v39"
// defaultHermesTag is the tag that will be used if no relayer tag is specified for hermes.
defaultHermesTag = "luca_joss-channel-upgrade-authority"
defaultHermesTag = "sean-channel-upgradability"
Copy link
Member

Choose a reason for hiding this comment

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

have we been using this tag for the last few months?

Copy link
Contributor

Choose a reason for hiding this comment

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

We were using luca_joss-..., but when these attributes were removed, Luca discovered while debugging that there was a bug in hermes and fixed it in this new tag.

Copy link

Choose a reason for hiding this comment

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

For more context, the branch sean-channel-upgradability was the branch for the channel upgrade beta implementation and the luca_joss-channel-upgrade-authority was the branch adding the changes that came after the beta (e.g. initiating an upgrade only with authority). Between the release of channel upgrade and now the branch luca_joss-channel-upgrade-authority has been merged in sean-channel-upgradability so that we only have one open PR related to channel upgrade. New Hermes Docker images for channel upgrade, until it is merged, will be in the tag sean-channel-upgradability.

@crodriguezvega crodriguezvega merged commit 8cf607e into cosmos:main Apr 9, 2024
77 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.

Trim event emission on channel upgrades
5 participants