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

add storage slots for future proxy upgrades #75

Merged
merged 1 commit into from
Apr 4, 2024
Merged

Conversation

nicopernas
Copy link
Contributor

@nicopernas nicopernas commented Apr 4, 2024

This PR squashes these three commits from the v2 branch.

* 9a551a2 (HEAD, tag: v2.0.0-catalyst) add setting channelIdToConnection RnkSngh <[email protected]>, 19 hours ago
* e4c11d8 (origin/raunak/storage-gap-uc) add minor comment RnkSngh <[email protected]>, 2 days ago
* 6c365d3 add storage gap for dispatcher proxy to allwo for upgrades RnkSngh <[email protected]>, 2 days ago

They have been tested with the e2e.

Summary by CodeRabbit

  • New Features

    • Improved storage optimization with the addition of new data structures in smart contracts.
    • Enhanced mapping of channel IDs to connections for better data handling.
  • Bug Fixes

    • Adjusted nested mapping slot calculations for more accurate storage usage.
    • Updated values in contracts to ensure consistency and correct access control.
  • Refactor

    • Modified initialization and settings in smart contracts for improved performance and reliability.
    • Updated upgrade utility and access control in dispatcher implementations for enhanced security and functionality.

Copy link

coderabbitai bot commented Apr 4, 2024

Walkthrough

The recent updates primarily focus on storage optimization and mapping enhancements within the Dispatcher.sol contract, alongside adjustments in storage slot calculations for nested mappings and upgradeability tests in related contracts. These changes aim to streamline operations, improve contract interactions, and ensure smoother upgrade paths for the Dispatcher contract suite, reflecting a meticulous effort to enhance efficiency and functionality.

Changes

Files Summary
contracts/core/Dispatcher.sol, test/Dispatcher.proof.t.sol, test/Dispatcher.t.sol - Storage optimization with new private array.
- New mapping for channel ID to connection.
- Adjustments in _lightClient initialization and channel mapping in initChannel.
.../DispatcherIbcWithRealProofsSuite.sol, .../DappRevertTests.sol - Storage slot calculation for nested mapping updated.
test/upgradeableProxy/..., test/upgradeableProxy/upgrades/DispatcherV2.sol - Updated slot values in ChannelHandShakeUpgradeUtil.
- Adjustments in address loading for access control.
- Addition of __gap for upgrade compatibility.

🐰✨

In the realm of code, where smart contracts thrive,
A rabbit hopped through, making storage alive.
With a flick and a hop, updates were sown,
Optimizing the bytes, in the blockchain grown.
🚀🌌 To the future, we leap, with upgrades so sleek,
In the Dispatcher's land, efficiency we seek.
🐰💾

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/coderabbit-overrides.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.

@nicopernas nicopernas requested a review from RnkSngh April 4, 2024 14:11
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 Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between c7f7df2 and bb9d9e9.
Files selected for processing (6)
  • contracts/core/Dispatcher.sol (3 hunks)
  • test/Dispatcher.proof.t.sol (1 hunks)
  • test/Dispatcher.t.sol (1 hunks)
  • test/upgradeableProxy/Dispatcher.upgrade.t.sol (1 hunks)
  • test/upgradeableProxy/DispatcherUUPS.accessControl.t.sol (2 hunks)
  • test/upgradeableProxy/upgrades/DispatcherV2.sol (1 hunks)
Additional comments not posted (10)
test/upgradeableProxy/DispatcherUUPS.accessControl.t.sol (2)

35-35: Ensure the new byte32 value used in vm.load correctly points to the intended storage slot for the dispatcher proxy's upgrade mechanism.


47-47: Verify that the updated byte32 value used in vm.load accurately targets the correct storage slot for the light client address post-upgrade.

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

68-68: Ensure the updated nested mapping slot calculation aligns with the contract's storage layout and does not cause unintended overwrites or conflicts.

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

38-41: Verify that the updated slot values for packet handling align with the contract's new storage layout and do not cause conflicts or unintended overwrites.

test/upgradeableProxy/upgrades/DispatcherV2.sol (1)

34-34: Ensure the size of the __gap array is appropriately chosen based on the anticipated future needs of the contract to maintain storage layout compatibility with future upgrades.

contracts/core/Dispatcher.sol (4)

35-36: The addition of the __gap array is a good practice for upgradeable contracts to reserve space for future variables.


61-61: The addition of the _channelIdToConnection mapping is a good practice for efficiently linking channel IDs with their respective connections.


58-58: The modification in the initialization of _lightClient follows standard practices for upgradeable contracts.


594-594: Setting the channel to connection mapping in the _connectChannel method is correctly implemented.

test/Dispatcher.t.sol (1)

625-625: Ensure the correctness of the storage slot calculation change from uint32(107) to uint32(156) in the test_ack_packet_dapp_revert function. This is crucial for accurately testing the contract's behavior.

@RnkSngh
Copy link
Collaborator

RnkSngh commented Apr 4, 2024

LGTM

@nicopernas nicopernas merged commit bfa80cd into main Apr 4, 2024
2 checks passed
@nicopernas nicopernas deleted the nico/catalyst branch April 4, 2024 14:15
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