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 UnsafeUpgrades library variations, add LegacyUpgrades.sol #50

Merged
merged 44 commits into from
May 14, 2024

Conversation

ericglau
Copy link
Member

@ericglau ericglau commented May 6, 2024

Fixes #2
Fixes #44
Fixes #34

Overview of changes:

  • Handle UPGRADE_INTERFACE_VERSION in upgrade functions.
  • Add LegacyUpgrades.sol to support upgrading existing deployments using OpenZeppelin Contracts v4.
  • Adds UnsafeUpgrades library variations in both Upgrades.sol and LegacyUpgrades.sol to work with forge coverage.
    Note that UnsafeUpgrades does not perform any upgrade safety validations, so is not recommended for use with Forge scripts.

Summary of how this was implemented:

  • Upgrades.sol imports proxies from OpenZeppelin Contracts v5 and its functions help to deploy those. Users who import this file must have OpenZeppelin Contracts v5, otherwise compilation would fail.
  • LegacyUpgrades.sol does not import proxy contracts, but only supports upgrading existing implementations or proxies which use OpenZeppelin Contracts v4. Users can import this file if they are using OpenZeppelin Contracts v4.
  • Upgrades and UnsafeUpgrades libraries exist in both Upgrades.sol and LegacyUpgrades.sol.
  • Testing for this project itself is separated into Foundry profiles (see foundry.toml), which allows us to use profile-specific remappings to test with different versions of OpenZeppelin Contracts for the proxies and/or for implementations, along with profile-specific test cases.

@ericglau ericglau changed the title Draft: Enable upgrading deployments using OpenZeppelin Contracts 4.x Add library variations to support forge coverage or upgrade deployments using OpenZeppelin Contracts 4.x May 8, 2024
@ericglau ericglau changed the title Add library variations to support forge coverage or upgrade deployments using OpenZeppelin Contracts 4.x Add UnsafeUpgrades library variations, add LegacyUpgrades.sol May 8, 2024
@ericglau ericglau marked this pull request as ready for review May 8, 2024 20:42
@ericglau ericglau requested a review from a team May 8, 2024 20:43
Copy link

@Amxx Amxx left a comment

Choose a reason for hiding this comment

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

LGTM

@ericglau ericglau merged commit 372170b into OpenZeppelin:main May 14, 2024
3 checks passed
@ericglau ericglau deleted the contracts4x branch May 14, 2024 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants