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/dispatcher upgrade testing #81

Merged
merged 1 commit into from
May 7, 2024
Merged

Conversation

RnkSngh
Copy link
Collaborator

@RnkSngh RnkSngh commented Apr 10, 2024

PR to add upgrade testing to ensure that the v2.0.0-rc3 is compatible for an upgrade with the v2.0.0-pre-audit.

Seemed like proof generation might be a bit complex, so I'm settling for just mocking the calls to the proof verifier for now.

One thing I did discover through this testing was that the Channel struct was indeed incompatible since we were adding a portId to it to the beginning. Moving the portId to the end of the struct should solve this issue (the change is in the Ibc.sol file).

Summary by CodeRabbit

  • New Features

    • Enhanced channel and packet management in Dispatcher and UniversalChannelHandler contracts.
    • Added new functions for fraud proof and internal state management in OptimisticLightClient.
    • Introduced IbcUtils and IbcErrors libraries for improved IBC operations handling.
  • Documentation

    • Updated README with clearer project overview and middleware introduction.
    • Added comprehensive documentation comments across various contracts and interfaces.
  • Bug Fixes

    • Updated pragma solidity versions to ensure compatibility and security.
  • Tests

    • Expanded test suites to cover new functionalities and scenarios in Dispatcher, including channel handshake, packet timeout, and upgrade processes.
  • Refactor

    • Improved contract modularity and upgradeability in core contracts.
    • Refactored Proof Verifier to align with IProofVerifier interface standards.

@RnkSngh RnkSngh requested a review from nicopernas April 10, 2024 21:50
Copy link

coderabbitai bot commented Apr 10, 2024

Walkthrough

The update focuses on refining the vIBC protocol's smart contracts by restructuring, updating Solidity versions, and enhancing contract structures and interfaces. It includes optimizations and new features across core contracts, interfaces, and libraries to improve clarity, efficiency, and compliance with coding standards.

Changes

File Path Change Summary
.gitignore, README.md Updated .gitignore and restructured README.md for clarity.
contracts/base/GeneralMiddleware.sol Updated import statements and added comments in GeneralMiddleware.sol.
contracts/core/Dispatcher.sol, contracts/core/OptimisticLightClient.sol Refactored core contracts, updated interfaces, and Solidity versions.
contracts/core/UniversalChannelHandler.sol Introduced new functions, updated pragma version, and modified existing functions in UniversalChannelHandler.sol.
test/... Various modifications in test files including refactoring, adding new functionality, and modifying existing functions.

Possibly related issues

  • Clean up VIBC-Contracts (Misc. Pre-audit fixes/checks #46): This PR aligns with the issue by optimizing contract sizes, updating Solidity versions, and refining import statements, addressing the suggestions made in the issue.

Poem

🐇✨
In the realm of code and lore,
The rabbit danced on Solidity's floor.
Refactored lines with a magical sweep,
Optimizing the contracts deep.
Now they shine, clean and new,
In the blockchain meadow, under skies so blue.
🌟📜


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.

@RnkSngh RnkSngh linked an issue Apr 10, 2024 that may be closed by this pull request
@RnkSngh RnkSngh mentioned this pull request Apr 10, 2024
@RnkSngh RnkSngh force-pushed the raunak/upgrade-testing branch 3 times, most recently from 42f41bf to 6b7a30b Compare April 17, 2024 03:12
@RnkSngh RnkSngh changed the base branch from v2 to multi-client April 23, 2024 21:58
@RnkSngh RnkSngh force-pushed the raunak/upgrade-testing branch from 6b7a30b to fb75529 Compare April 24, 2024 12:24
@RnkSngh RnkSngh changed the base branch from multi-client to v2 April 24, 2024 12:45
@RnkSngh RnkSngh changed the base branch from v2 to main April 24, 2024 15:14
@RnkSngh RnkSngh force-pushed the raunak/upgrade-testing branch 2 times, most recently from 16eee0f to 76c46dd Compare April 24, 2024 16:15
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: 3

Out of diff range and nitpick comments (5)
contracts/base/GeneralMiddleware.sol (1)

16-21: The GeneralMiddleware class is well-documented and serves as a good starting point for middleware development. Consider adding more detailed comments for public methods to guide developers.

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

18-34: The DispatcherProofTestUtils class is well-implemented and provides necessary functionalities for loading and handling proofs in tests. Ensure that the test descriptions are clear and descriptive to help other developers understand the test scenarios.

contracts/libs/Ibc.sol (1)

258-308: > 📝 NOTE

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

The new utility functions for handling proofs and converting data types are well-implemented. Consider adding more detailed comments to these functions to improve their understandability and ease of use.

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

41-47: The upgradeDispatcher function is well-implemented and provides necessary functionalities for upgrading the Dispatcher contract. Ensure that the function description is clear and descriptive to help other developers understand its purpose and usage.

contracts/core/Dispatcher.sol (1)

22-28: The contract description is clear and informative. However, consider consolidating the multiple @notice tags into a single comprehensive description to enhance readability.

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
@RnkSngh RnkSngh changed the base branch from main to raunak/mainnet-rc1 April 25, 2024 15:29
@RnkSngh RnkSngh force-pushed the raunak/mainnet-rc1 branch 2 times, most recently from 679f504 to d3ca2db Compare April 25, 2024 15:37
@RnkSngh RnkSngh force-pushed the raunak/upgrade-testing branch 2 times, most recently from dee7968 to 7e2d744 Compare April 25, 2024 15:42
@RnkSngh RnkSngh changed the title Raunak/upgrade testing Raunak/dispatcherupgrade testing Apr 25, 2024
@RnkSngh RnkSngh changed the title Raunak/dispatcherupgrade testing Raunak/dispatcher upgrade testing Apr 25, 2024
@RnkSngh RnkSngh changed the base branch from raunak/mainnet-rc1 to v2 May 3, 2024 17:29
@RnkSngh RnkSngh force-pushed the v2 branch 4 times, most recently from 03642e2 to 596f2fd Compare May 6, 2024 14:50
@RnkSngh RnkSngh force-pushed the v2 branch 2 times, most recently from 02837cc to cff09c3 Compare May 6, 2024 15:15
@RnkSngh RnkSngh force-pushed the raunak/upgrade-testing branch 2 times, most recently from 91d32e4 to 6847751 Compare May 6, 2024 15:32
@RnkSngh RnkSngh changed the base branch from v2 to main May 6, 2024 15:48
@RnkSngh RnkSngh force-pushed the raunak/upgrade-testing branch from 6847751 to 3f57d4b Compare May 6, 2024 15:52
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 25e9a3d and 3f57d4b.
Files selected for processing (5)
  • test/Dispatcher/Dispatcher.proof.t.sol (1 hunks)
  • test/Dispatcher/Dispatcher.t.sol (2 hunks)
  • test/upgradeableProxy/Dispatcher.upgrade.t.sol (5 hunks)
  • test/upgradeableProxy/DispatcherRC4.upgrade.t.sol (1 hunks)
  • test/utils/Dispatcher.base.t.sol (1 hunks)
Files skipped from review due to trivial changes (1)
  • test/Dispatcher/Dispatcher.proof.t.sol
Additional comments not posted (7)
test/utils/Dispatcher.base.t.sol (1)

191-194: The genAckPacket function correctly generates an acknowledgment packet for a given packet sequence.

test/upgradeableProxy/Dispatcher.upgrade.t.sol (2)

40-40: The upgradeDispatcher function correctly handles the upgrade and initialization of the Dispatcher contract.


51-59: The deployDispatcherRC4ProxyAndImpl function correctly handles the deployment and initialization of the Dispatcher RC4 contract using an ERC1967 proxy.

test/upgradeableProxy/DispatcherRC4.upgrade.t.sol (2)

40-71: The setUp function correctly handles the setup of the testing environment, including the deployment of Dispatcher RC4 and setting initial state.


73-92: The test_SentPacketState_Conserved_RC4_Upgrade test case correctly checks if the packet state is conserved after upgrading Dispatcher RC4.

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

16-16: The test_openChannel_initiator_ok test case correctly checks the successful opening of a channel when the local end is the initiator.


16-16: The test_openChannel_receiver_ok test case correctly checks the successful opening of a channel when the remote end is the receiver.

@RnkSngh RnkSngh force-pushed the raunak/upgrade-testing branch 2 times, most recently from b774356 to 3161ac7 Compare May 6, 2024 18:21
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 25e9a3d and 3161ac7.
Files selected for processing (6)
  • test/Dispatcher/Dispatcher.multiclient.sol (1 hunks)
  • test/Dispatcher/Dispatcher.proof.t.sol (2 hunks)
  • test/Dispatcher/Dispatcher.t.sol (2 hunks)
  • test/upgradeableProxy/Dispatcher.upgrade.t.sol (5 hunks)
  • test/upgradeableProxy/DispatcherRC4.upgrade.t.sol (1 hunks)
  • test/utils/Dispatcher.base.t.sol (4 hunks)
Files not reviewed due to errors (1)
  • test/upgradeableProxy/Dispatcher.upgrade.t.sol (no review received)
Files skipped from review as they are similar to previous changes (5)
  • test/Dispatcher/Dispatcher.multiclient.sol
  • test/Dispatcher/Dispatcher.proof.t.sol
  • test/Dispatcher/Dispatcher.t.sol
  • test/upgradeableProxy/DispatcherRC4.upgrade.t.sol
  • test/utils/Dispatcher.base.t.sol

@RnkSngh RnkSngh force-pushed the raunak/upgrade-testing branch from 3161ac7 to ceddaa9 Compare May 7, 2024 14:16
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: 2

Out of diff range and nitpick comments (1)
test/upgradeableProxy/Dispatcher.upgrade.t.sol (1)

36-40: Consider documenting the purpose of connectionHops0 and connectionHops1 arrays.

These arrays are used in the upgrade process, and documenting their specific roles or the scenarios they represent could improve code readability and maintainability.

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 25e9a3d and ceddaa9.
Files selected for processing (6)
  • test/Dispatcher/Dispatcher.multiclient.sol (1 hunks)
  • test/Dispatcher/Dispatcher.proof.t.sol (2 hunks)
  • test/Dispatcher/Dispatcher.t.sol (2 hunks)
  • test/upgradeableProxy/Dispatcher.upgrade.t.sol (5 hunks)
  • test/upgradeableProxy/DispatcherRC4.upgrade.t.sol (1 hunks)
  • test/utils/Dispatcher.base.t.sol (4 hunks)
Files skipped from review as they are similar to previous changes (5)
  • test/Dispatcher/Dispatcher.multiclient.sol
  • test/Dispatcher/Dispatcher.proof.t.sol
  • test/Dispatcher/Dispatcher.t.sol
  • test/upgradeableProxy/DispatcherRC4.upgrade.t.sol
  • test/utils/Dispatcher.base.t.sol
Additional comments not posted (2)
test/upgradeableProxy/Dispatcher.upgrade.t.sol (2)

73-103: Ensure version compatibility during channel handshake.

Given the complexity of version handling in channel handshakes, it's crucial to verify that all versions used are compatible with both the local and remote ends to prevent potential issues during runtime.


188-220: Verify state conservation post-upgrade.

It's crucial to ensure that the state is conserved across upgrades, especially for critical components like sequence numbers and packet commitments. This script will help verify that appropriate tests are in place.

Copy link
Collaborator

@dshiell dshiell left a comment

Choose a reason for hiding this comment

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

lgtm, approving to unblock conditioned on the last couple requests

@RnkSngh RnkSngh force-pushed the raunak/upgrade-testing branch from ceddaa9 to 70df3c0 Compare May 7, 2024 16:26
@RnkSngh RnkSngh force-pushed the raunak/upgrade-testing branch from 70df3c0 to 1a4ecea Compare May 7, 2024 16:32
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 25e9a3d and 70df3c0.
Files selected for processing (6)
  • test/Dispatcher/Dispatcher.multiclient.sol (1 hunks)
  • test/Dispatcher/Dispatcher.proof.t.sol (2 hunks)
  • test/Dispatcher/Dispatcher.t.sol (2 hunks)
  • test/upgradeableProxy/Dispatcher.upgrade.t.sol (5 hunks)
  • test/upgradeableProxy/DispatcherRC4.upgrade.t.sol (1 hunks)
  • test/utils/Dispatcher.base.t.sol (4 hunks)
Files not reviewed due to errors (1)
  • test/upgradeableProxy/Dispatcher.upgrade.t.sol (no review received)
Files skipped from review as they are similar to previous changes (5)
  • test/Dispatcher/Dispatcher.multiclient.sol
  • test/Dispatcher/Dispatcher.proof.t.sol
  • test/Dispatcher/Dispatcher.t.sol
  • test/upgradeableProxy/DispatcherRC4.upgrade.t.sol
  • test/utils/Dispatcher.base.t.sol

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

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 25e9a3d and 1a4ecea.
Files selected for processing (6)
  • test/Dispatcher/Dispatcher.multiclient.sol (1 hunks)
  • test/Dispatcher/Dispatcher.proof.t.sol (2 hunks)
  • test/Dispatcher/Dispatcher.t.sol (2 hunks)
  • test/upgradeableProxy/Dispatcher.upgrade.t.sol (5 hunks)
  • test/upgradeableProxy/DispatcherRC4.upgrade.t.sol (1 hunks)
  • test/utils/Dispatcher.base.t.sol (4 hunks)
Files skipped from review as they are similar to previous changes (5)
  • test/Dispatcher/Dispatcher.multiclient.sol
  • test/Dispatcher/Dispatcher.proof.t.sol
  • test/Dispatcher/Dispatcher.t.sol
  • test/upgradeableProxy/DispatcherRC4.upgrade.t.sol
  • test/utils/Dispatcher.base.t.sol
Additional comments not posted (1)
test/upgradeableProxy/Dispatcher.upgrade.t.sol (1)

159-191: LGTM! The function correctly tests the conservation of packet state after an upgrade.

@RnkSngh RnkSngh merged commit fca85a4 into main May 7, 2024
2 checks passed
@RnkSngh RnkSngh deleted the raunak/upgrade-testing branch May 7, 2024 17:06
@RnkSngh RnkSngh restored the raunak/upgrade-testing branch May 7, 2024 17:06
@RnkSngh RnkSngh mentioned this pull request Jun 24, 2024
3 tasks
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.

Test Dispatcher contract Upgrades for Catalyst deploy
4 participants