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

CLI: Support --referenceBuildInfoDirs option #1062

Merged
merged 30 commits into from
Aug 21, 2024

Conversation

ericglau
Copy link
Member

In some project setups, users of the Upgrades Core CLI may not want to change the names of upgradeable contracts for every new version that they deploy. Instead, they just change the source code and want to perform storage layout comparisons with a previous version of their repository (e.g. from a different branch).

This PR provides a --referenceBuildInfoDirs option that takes a comma-separated list of additional build info directories that can be referenced for storage layout comparisons. These build info directories can be built from previous versions of the project repository, containing the build artifacts (including storage layouts) of previously deployed versions of contracts.

When using this option, refer to one of these directories using prefix <dirName>: before the contract name or fully qualified name in the --reference option or @custom:oz-upgrades-from annotation, where <dirName> is the directory short name. Each directory short name must be unique.

Example usage:

  1. From an older branch containing previously deployed versions of contracts, compile the contracts with storage layouts and save a copy of the resulting build-info directory (defaults are artifacts/build-info for Hardhat projects or out/build-info for Foundry projects), renaming it to a unique name. For example, build-info-v1.
  2. From the current branch containing the new versions of contracts that you want to upgrade to, compile the contracts with storage layouts for the new versions.
  3. If you want to compare the storage layout of a contract called MyContract with its previous version, run the CLI command like:
npx @openzeppelin/upgrades-core validate --referenceBuildInfoDirs /old-builds/build-info-v1 --contract MyContract --reference build-info-v1:MyContract

Fixes #1034

@ericglau ericglau marked this pull request as ready for review August 16, 2024 21:07
@ericglau ericglau requested a review from a team August 16, 2024 21:08
Copy link
Contributor

@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.

Lot to look at, and difficult to keep track when you are not familiar with the CLI's code, but it looks good to me !

@ericglau ericglau enabled auto-merge (squash) August 21, 2024 20:19
@ericglau ericglau merged commit a79ccda into OpenZeppelin:master Aug 21, 2024
11 checks passed
@ericglau ericglau deleted the 1034 branch August 21, 2024 20:23
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.

CLI: Support validations with references to other build info dirs
2 participants