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

Skip modified compilation for namespaces if solc < 0.8.20 #892

Merged
merged 3 commits into from
Oct 11, 2023

Conversation

ericglau
Copy link
Member

@ericglau ericglau commented Oct 10, 2023

To support namespaced storage validations, the Hardhat Upgrades plugin overrides the Hardhat compile phase to also make a modified copy and compilation of all contracts so that any namespaced structs' storage layouts can be extracted. This requires use of the AST to detect source locations and modify the source code accordingly.

In old versions of Solidity such as 0.5.x, the AST does not provide source locations for certain nodes, such as documentation nodes. This leads to an error such as #891.

To avoid this, we should skip the modified copy/compilation step for namespaced storage if the solc version is < 0.8.20.

Note that for versions of solc < 0.8.20, namespaced storage validation is not supported anyways because the Solidity compiler does not output struct documentation in the AST. We already throw an error if we detect namespaces being used with solc < 0.8.20, so the modified namespaced compilation is not needed for these cases.

Fixes #891

@ericglau ericglau requested a review from a team October 10, 2023 16:48
Copy link
Member

@ernestognw ernestognw left a comment

Choose a reason for hiding this comment

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

LGTM

packages/core/CHANGELOG.md Outdated Show resolved Hide resolved
@ericglau ericglau enabled auto-merge (squash) October 11, 2023 14:25
@ericglau ericglau merged commit 760e4be into OpenZeppelin:master Oct 11, 2023
7 checks passed
@ericglau ericglau deleted the 891 branch October 11, 2023 14:49
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