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

Raunak/informal q3 fixes #192

Merged
merged 4 commits into from
Sep 16, 2024
Merged

Raunak/informal q3 fixes #192

merged 4 commits into from
Sep 16, 2024

Conversation

RnkSngh
Copy link
Collaborator

@RnkSngh RnkSngh commented Sep 9, 2024

PR to address findings in the informal audit:

  • Remove channelId to connection mapping in chanCloseInit & chanCloseConfirm to avoid cases where packets can be recieved even after a channel close has been initiated
  • add version != 0 check to revert in chanCloseInit instead of in peptide

Summary by CodeRabbit

  • New Features

    • Enhanced error handling for channel opening and closing processes.
    • Introduced a new error for invalid version input.
  • Bug Fixes

    • Improved validation checks to ensure valid version parameters during channel operations.
  • Tests

    • Added tests to validate error handling for channel opening with invalid versions.
  • Chores

    • Updated GitHub Actions workflow to use the latest version of the artifact upload action for improved reliability.

Copy link

coderabbitai bot commented Sep 9, 2024

Caution

Review failed

The pull request is closed.

Walkthrough

The pull request introduces updates to the GitHub Actions workflow and the Dispatcher contract. The workflow upgrades the upload-artifact action from version v2 to v4 for improved artifact handling. In the Dispatcher contract, input validation is enhanced by checking the version parameter in the ChannelOpenInit function, and the management of channel connections is refined by deleting the _channelIdToConnection mapping in the close functions. Additionally, a new invalidVersion error is added to improve error reporting.

Changes

Files Change Summary
.github/workflows/bindings.yml - Updated upload-artifact action from v2 to v4 for TypeScript and Go bindings uploads.
bindings/go/dispatcher/Dispatcher.go - Added invalidVersion error type to the ABI.
contracts/core/Dispatcher.sol - Added validation check for version in ChannelOpenInit.
- Updated validation for connectionHops to require exact length of 2.
- Deleted connection mapping in ChannelCloseInit and ChannelCloseConfirm.
contracts/libs/IbcErrors.sol - Added invalidVersion() error declaration for better error handling.
src/evm/contracts/factories/Dispatcher__factory.ts - Added invalidVersion error to the ABI definition for enhanced error handling.
src/evm/contracts/factories/Earth__factory.ts - Replaced existing bytecode string with a new bytecode string, indicating substantial changes.
src/evm/contracts/factories/IbcUtils__factory.ts - Updated the bytecode string, suggesting modifications to the contract's logic.
src/evm/contracts/factories/UniversalChannelHandler__factory.ts - Replaced existing bytecode string with a new bytecode string, indicating substantial changes.
test/Dispatcher/Dispatcher.t.sol - Added test_chanOpenInit_fail_invalidVersion to validate behavior when an invalid version is provided.

Possibly related PRs

  • Raunak/audit fixes 05 2024 #108: The changes in the Dispatcher.sol file regarding imports and modifications to the sendPacket function may relate to the updates in the main PR, as both involve the Dispatcher contract and its functionality.
  • Raunak/dispatcher agnostic fee implementation #114: The updates to the Dispatcher contract in this PR include changes to the sendPacket function, which aligns with the main PR's focus on improving the artifact upload process and may indicate related modifications in the contract's operational logic.
  • raunak/addNpmTesting #150: This PR modifies the .github/workflows/bindings.yml file, which is directly related to the main PR's changes in the same file, focusing on GitHub Actions workflows.
  • add fee vault threshold to prevent indexer spam #189: The introduction of a minimum fee threshold in the FeeVault contract relates to the main PR's focus on enhancing contract functionality, specifically in managing fees and preventing spam, which aligns with the overall goal of improving contract robustness.

Suggested labels

enhancement

Poem

🐰 In the meadow where channels flow,
A version check now starts to glow.
With mappings cleared, the path is bright,
Robust and clear, all feels just right!
Hops of joy for tests anew,
A dance of code, for me and you! 🌼


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 generate interesting stats about this repository and render them as a table.
    -- @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.

@RnkSngh RnkSngh force-pushed the raunak/informalQ3Fixes branch from d80e695 to f1ade7e Compare September 9, 2024 19:31
Copy link

@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 6e2f368 and d80e695.

Files selected for processing (4)
  • contracts/core/Dispatcher.sol (3 hunks)
  • contracts/libs/IbcErrors.sol (1 hunks)
  • test/Dispatcher/Dispatcher.closeChannel.t.sol (1 hunks)
  • test/Dispatcher/Dispatcher.t.sol (1 hunks)
Additional comments not posted (6)
contracts/libs/IbcErrors.sol (1)

33-33: LGTM!

The addition of the invalidVersion() error declaration to the IBCErrors library is approved. It enhances the error handling capabilities of the library by allowing it to signal an additional specific error condition related to version validation.

test/Dispatcher/Dispatcher.closeChannel.t.sol (1)

77-98: LGTM!

The addition of the test_recvPacket_afterChannelCloseInit() test function to the DispatcherCloseChannelTest contract is approved. This test is well-structured and enhances the test coverage for the dispatcher contract by validating the behavior when a channel close initialization occurs but is not relayed to the polymer.

The test simulates a scenario where the Dapp on the local chain triggers a channel close, and subsequently, it checks that any attempt to receive a packet from a remote chain after this closure results in a revert with the expected channelIdNotFound error. This ensures that the dispatcher maintains a consistent view of the channel's status.

The test utilizes the vm.expectRevert function to assert the expected revert behavior when the recvPacket function is called under these conditions.

Overall, this test addition contributes to the robustness and reliability of the dispatcher contract.

test/Dispatcher/Dispatcher.t.sol (1)

180-191: LGTM!

The addition of the test_chanOpenInit_fail_invalidVersion() test function to the ChannelHandshakeTestSuite contract is approved. This test is well-structured and enhances the test coverage for the channel opening logic by validating the behavior when an invalid version is provided during the channel opening process.

The test sets up a scenario where the local end initiates a channel opening without a remote version being applied, which is expected to trigger a revert with the invalidVersion error. It iterates through a predefined set of channel handshake settings, ensuring that for each setting, the local end's version call is empty, and the expected revert behavior is correctly asserted using the vm.expectRevert function.

This test addition focuses on error handling related to version mismatches and contributes to the robustness and reliability of the channel opening process.

Overall, the test is well-designed and provides valuable coverage for an important failure scenario.

contracts/core/Dispatcher.sol (3)

181-183: LGTM!

The added check ensures that the version parameter is not empty when initializing a channel. This strengthens the input validation and aligns with the AI-generated summary.


399-402: LGTM!

Deleting the _channelIdToConnection mapping for the channelId in the ChannelCloseInit function is a good addition. It ensures that any proof-dependent calls related to the channel are effectively "bricked" after the channel close is initiated, maintaining consistency in the dispatcher's view of the channel across both local and proof-dependent logic. The change aligns with the AI-generated summary.


459-463: LGTM!

Deleting the _channelIdToConnection mapping for the channelId in the ChannelCloseConfirm function is a good addition, similar to the change in ChannelCloseInit. It ensures that any proof-dependent calls related to the channel are effectively "bricked" after the channel close is confirmed, maintaining consistency in the dispatcher's view of the channel across both local and proof-dependent logic. The change aligns with the AI-generated summary.

Copy link

@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 d80e695 and f1ade7e.

Files selected for processing (4)
  • contracts/core/Dispatcher.sol (3 hunks)
  • contracts/libs/IbcErrors.sol (1 hunks)
  • test/Dispatcher/Dispatcher.closeChannel.t.sol (1 hunks)
  • test/Dispatcher/Dispatcher.t.sol (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • contracts/libs/IbcErrors.sol
  • test/Dispatcher/Dispatcher.closeChannel.t.sol
Additional comments not posted (4)
test/Dispatcher/Dispatcher.t.sol (1)

180-191: LGTM!

The new test function test_chanOpenInit_fail_invalidVersion is a valuable addition to the test suite. It correctly tests the behavior of channelOpenInit when an invalid version is provided and expects the appropriate revert with the invalidVersion error.

The test iterates through a set of channel handshake settings to ensure comprehensive coverage.

Great work on enhancing the test coverage for the channel opening logic!

contracts/core/Dispatcher.sol (3)

181-183: LGTM!

The added validation check in the ChannelOpenInit function is a valuable improvement. It ensures that the version parameter is not empty and reverts with an invalidVersion error if it is.

This change strengthens the input validation for channel opening and enhances the robustness of the contract by enforcing that a valid version is always provided.

Well done on improving the contract's input validation!


399-402: LGTM!

The deletion of the _channelIdToConnection mapping for the channelId in the ChannelCloseInit function is a good practice. It ensures that any proof-dependent calls related to the channel are effectively "bricked" and maintains consistency in the dispatcher's view of the channel across both local and proof-dependent logic.

The accompanying comment provides a clear rationale for the deletion, emphasizing the importance of consistent behavior even in the absence of relayed events.

This change enhances the overall consistency and robustness of the contract by maintaining a coherent state across channel operations.

Great work on improving the contract's consistency and clarity!


459-462: LGTM!

The deletion of the _channelIdToConnection mapping for the channelId in the ChannelCloseConfirm function is a good practice, similar to the changes made in the ChannelCloseInit function. It ensures that any proof-dependent calls related to the channel are effectively "bricked" and maintains consistency in the dispatcher's view of the channel across both local and proof-dependent logic.

The accompanying comment provides a clear rationale for the deletion, emphasizing the importance of consistent behavior even in the absence of relayed events.

This change enhances the overall consistency and robustness of the contract by maintaining a coherent state across channel operations.

Excellent work on improving the contract's consistency and clarity!

@RnkSngh RnkSngh force-pushed the raunak/informalQ3Fixes branch 4 times, most recently from ce42ad3 to 515d592 Compare September 12, 2024 15:48
@RnkSngh RnkSngh force-pushed the raunak/informalQ3Fixes branch 3 times, most recently from d0c9fa2 to 227a716 Compare September 16, 2024 16:12
@RnkSngh RnkSngh force-pushed the raunak/informalQ3Fixes branch from 227a716 to dd01c21 Compare September 16, 2024 16:18
@RnkSngh RnkSngh merged commit b1f7d16 into main Sep 16, 2024
3 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Nov 26, 2024
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